Skip to content

Commit

Permalink
Jokers 45-65
Browse files Browse the repository at this point in the history
imisaacwu committed Aug 26, 2024
1 parent 0ba75e1 commit aa1d265
Showing 29 changed files with 443 additions and 148 deletions.
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import { InfoPanel } from './components/InfoPanel'
import { Joker } from './components/Joker'
import { Round } from './components/Round'
import { Shop } from './components/Shop'
import { Blinds, DeckType } from './Constants'
import { Blinds, Consumables, DeckType } from './Constants'
import { gameReducer, GameStateContext, initialGameState } from './GameState'
import { cardSnap } from './Utilities'

@@ -22,6 +22,7 @@ export default function App() {

useEffect(() => {
dispatch({type: 'init', payload: {deck: DeckType.Red }})
dispatch({type: 'addCard', payload: {cardLocation: 'consumables', card: Consumables[41]}})
}, [])

useEffect(() => {
185 changes: 163 additions & 22 deletions src/GameState.ts

Large diffs are not rendered by default.

53 changes: 28 additions & 25 deletions src/Utilities.ts
Original file line number Diff line number Diff line change
@@ -137,30 +137,33 @@ export const cardSnap = ({cards, idPrefix, r = 6000, log = false}: {cards: any[]
}

export const debuffCards = (blind: BlindType, cards: CardInfo[], past?: (keyof typeof HandType | CardInfo)[], sold?: boolean) => {
switch(blind.name) {
case 'The Goad':
cards.forEach(c => c.debuffed = (c.suit === Suit.Spades || c.enhancement === Enhancement?.Wild))
break
case 'The Head':
cards.forEach(c => c.debuffed = (c.suit === Suit.Hearts || c.enhancement === Enhancement?.Wild))
break
case 'The Club':
cards.forEach(c => c.debuffed = (c.suit === Suit.Clubs || c.enhancement === Enhancement?.Wild))
break
case 'The Window':
cards.forEach(c => c.debuffed = (c.suit === Suit.Diamonds || c.enhancement === Enhancement?.Wild))
break
case 'The Plant':
cards.forEach(c => c.debuffed = ([Rank.King, Rank.Queen, Rank.Jack].includes(c.rank)))
break
case 'The Pillar':
cards.forEach(c => c.debuffed = (past!.includes(c)))
break
case 'Verdant Leaf':
cards.forEach(c => c.debuffed = !sold)
break
default:
}
cards.forEach(c => {
switch(blind.name) {
case 'The Goad':
c.debuffed = (c.suit === Suit.Spades || c.enhancement === Enhancement?.Wild)
break
case 'The Head':
c.debuffed = (c.suit === Suit.Hearts || c.enhancement === Enhancement?.Wild)
break
case 'The Club':
c.debuffed = (c.suit === Suit.Clubs || c.enhancement === Enhancement?.Wild)
break
case 'The Window':
c.debuffed = (c.suit === Suit.Diamonds || c.enhancement === Enhancement?.Wild)
break
case 'The Plant':
c.debuffed = ([Rank.King, Rank.Queen, Rank.Jack].includes(c.rank))
break
case 'The Pillar':
c.debuffed = (past!.includes(c))
break
case 'Verdant Leaf':
c.debuffed = !sold
break

}
if(c.enhancement === Enhancement?.Stone) { c.debuffed = false }
})
}

export const getImage = (url: string, images: Record<string, { default: string }>) => {
@@ -182,7 +185,7 @@ export const newOffers = (slots: number, weights: {
const roll = Random.next()
if(roll < weights.Joker / total) {
const rare_roll = Random.next()
const rarity = rare_roll < .7 ? 'Common' : rare_roll < .95 ? 'Uncommon' : 'Rare'
const rarity = rare_roll < .1 ? 'Common' : rare_roll < .95 ? 'Uncommon' : 'Rare'
const validJokers = Jokers.filter(j => j.rarity === rarity && !game.jokers.find(joker => joker.joker.name === j.name))
if(validJokers.length === 0) { validJokers.push(Jokers[0])}
offers.push({
Binary file added src/assets/jokers/Common/Blue_Joker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Cavendish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Egg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Faceless_Joker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/jokers/Common/Half_Joker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Ice_Cream.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Runner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Square_Joker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Common/Superposition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Rare/DNA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Uncommon/Blackboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Uncommon/Burglar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Uncommon/Constellation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Uncommon/Hiker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Uncommon/Madness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/jokers/Uncommon/Sixth_Sense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext, useRef } from 'react'
import debuff from '../assets/cards/modifiers/debuffed.webp'
import { DeckType, Edition, editionInfo, Enhancement, enhancementInfo, Rank, rankChips, Seal, sealInfo, Suit } from '../Constants'
import { DeckType, Edition, editionInfo, Enhancement, enhancementInfo, Rank, Seal, sealInfo, Suit } from '../Constants'
import { cardSnap } from '../Utilities'
import './Card.css'
import { CardInfo } from './CardInfo'
@@ -18,7 +18,7 @@ const getImage = (url: string) => {
}

export const Card = ({
id, suit, rank, deck,
id, suit, rank, chips, deck,
mode = 'standard',
edition, enhancement = Enhancement.Base, seal,
draggable = true,
@@ -43,7 +43,7 @@ export const Card = ({
{(enhancement === undefined || enhancement !== Enhancement.Stone) &&
<div id='playing-card-chips'>
<div className='blue'>
{`+${rankChips[Rank[rank] as keyof typeof rankChips]}`}
{`+${chips}`}
</div>&nbsp;{'chips'}
</div>
}
1 change: 1 addition & 0 deletions src/components/CardInfo.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ export type CardInfo = {
id: number
suit: Suit
rank: Rank
chips: number
deck: DeckType

mode?: 'standard' | 'deck-view'
4 changes: 2 additions & 2 deletions src/components/Consumable.tsx
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ export const Consumable = ({ selected = false, consumable: cons, ...props }: Con
dragElem = (e.target as HTMLElement).parentElement!
origX = dragElem.offsetLeft
origY = dragElem.offsetTop
origI = [...dragElem.parentElement!.children].indexOf(dragElem)
origI = gameRef.current.cards.consumables.findIndex(c => c.id === dragElem!.id.replace(/consumable /, '') as unknown as number)
startX = e.clientX - origX
startY = e.clientY - origY

@@ -153,7 +153,7 @@ export const Consumable = ({ selected = false, consumable: cons, ...props }: Con
if(now - lastReorder < renderDelay) { return }

const container = dragElem.parentElement!
const w = container.clientWidth, l = container.childElementCount - 1
const w = container.clientWidth, l = container.childElementCount - 2
const lStep = w / (l + 1), extra = (lStep - dragElem.clientWidth) / l
let i = Math.min(l, Math.max(0, Math.round(dragElem.offsetLeft / (lStep + extra))))
if(Math.abs(dragElem.offsetLeft - i * (lStep + extra)) < tolerance && origI !== i) {
10 changes: 10 additions & 0 deletions src/components/Hand.tsx
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ export default function Hand() {
<div id='hand-buttons'>
<div id='ship' className={`button ${game.cards.selected.length > 0}`} onClick={() => {
if(gameRef.current.cards.selected.length > 0) {
let selected = gameRef.current.cards.selected
let len = Math.max(gameRef.current.stats.handSize - (gameRef.current.cards.hand.length - gameRef.current.cards.selected.length), 0)
dispatch({type: 'submit'})
if(game.blind.curr === 'boss' && game.blind.boss.name === 'The Hook') {
@@ -33,6 +34,15 @@ export default function Hand() {
dispatch({type: 'updateCards', payload: {cardLocation: 'hidden', update: [...game.cards.hidden, ...discard]}})
len += discard.length
}
if(game.jokers.find(j => j.joker.name === 'DNA') !== undefined && gameRef.current.cards.hidden.length === 0 && selected.length === 1) {
dispatch({type: 'addCard', payload: {cardLocation: 'hand', card: {
...selected[0],
selected: false,
submitted: false
}}})
len--
}

setTimeout(() => {
const lastHand = game.active.name
dispatch({type: 'discard'})
2 changes: 1 addition & 1 deletion src/components/Joker.css
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ div[id^='joker_']:hover #joker-description-outline { display: initial; }
text-align: center;
border-radius: 8px;
margin: 2px 0;
padding: 0 4px;
padding: 0 16px;
color: aliceblue;
}

18 changes: 15 additions & 3 deletions src/components/Joker.tsx
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
const image = getImage(`../assets/jokers/${joker.rarity}/${joker.name.replace(/\s/g, '_')}.png`, images)
const back = getImage(`../assets/decks/${DeckType[game.stats.deck]}.png`, import.meta.glob('../assets/decks/*.png', { eager: true }))
const self: JokerInstance = {id, joker, edition, selected, ...props}
const { price, sell } = calcPrice(self)
let { price, sell } = calcPrice(self)

let description = joker.description
switch(joker.name) {
@@ -24,11 +24,23 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
break
case 'Loyalty Card':
case 'Ride the Bus':
case 'Runner':
case 'Ice Cream':
case 'Constellation':
case 'Green Joker':
case 'Madness':
case 'Square Joker':
description = description.replace('_', joker.counter! + '')
break
case 'Abstract Joker':
description = description.replace('_',(3 * game.jokers.length) + '')
break
case 'Egg':
sell += joker.counter!
break
case 'Blue Joker':
description = description.replace('_', (2 * game.cards.deck.length) + '')
break
}

const descriptionElement = description.split('\n').map((line, i) =>
@@ -77,7 +89,7 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
dragElem = (e.target as HTMLElement).parentElement!
origX = dragElem.offsetLeft
origY = dragElem.offsetTop
origI = [...dragElem.parentElement!.children].indexOf(dragElem)
origI = gameRef.current.cards.consumables.findIndex(c => c.id === dragElem!.id.replace(/joker /, '') as unknown as number)
startX = e.clientX - origX
startY = e.clientY - origY

@@ -100,7 +112,7 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
if(now - lastReorder < renderDelay) { return }

const container = dragElem.parentElement!
const w = container.clientWidth, l = container.childElementCount - 1
const w = container.clientWidth, l = container.childElementCount - 2
const lStep = w / (l + 1), extra = (lStep - dragElem.clientWidth) / l
let i = Math.min(l, Math.max(0, Math.round(dragElem.offsetLeft / (lStep + extra))))
if(Math.abs(dragElem.offsetLeft - i * (lStep + extra)) < tolerance && origI !== i) {
Loading

0 comments on commit aa1d265

Please sign in to comment.