Skip to content

Commit

Permalink
Hover fixes, joker repeat fixes, Jokers 66-72
Browse files Browse the repository at this point in the history
imisaacwu committed Aug 30, 2024
1 parent 419aa6b commit 8768273
Showing 13 changed files with 391 additions and 258 deletions.
2 changes: 1 addition & 1 deletion src/App.css
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ img#shop-logo {
line-height: 80px;
margin: 16px 0;
}
#cash-out {
#cash-out:hover {
cursor: pointer;
filter: brightness(.75);
}
83 changes: 76 additions & 7 deletions src/GameState.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { createContext, Dispatch } from "react"
import { BlindType, ConsumableInstance, Consumables, ConsumableType, DeckType, Edition, Enhancement, handLevels, HandType, handUpgrade, Rank, rankChips, Seal, Suit } from "./Constants"
import { ante_base, AnteBlinds, bestHand, boss_roll, cardSnap, debuffCards, getNextBlind, newOffers, shuffle } from "./Utilities"
import { CardInfo } from "./components/CardInfo"
import { Activation, JokerInstance, JokerType } from "./components/JokerInfo"
import { Activation, JokerInstance, Jokers, JokerType } from "./components/JokerInfo"
import Rand from "rand-seed"

export let Random: Rand = new Rand()
@@ -298,6 +298,24 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>
}
}
break
case 'Riff-Raff':
if(state.jokers.length < state.stats.jokerSize) {
let validJokers = Jokers.filter(j => state.jokers.every(joker => joker.joker.name === j.name))
let joker: JokerType
let nToAdd = Math.min(2, state.stats.jokerSize - state.jokers.length)
for(let i = 0; i < nToAdd; i++) {
if(validJokers.length === 0) { validJokers.push(Jokers[0]) }
joker = validJokers[Math.floor(Random.next() * validJokers.length)]
next = {...next,
jokers: [...next.jokers, {
id: next.cards.nextId + i,
joker: joker
}]
}
validJokers.filter(j => j.name !== joker.name)
}
next.cards.nextId + nToAdd
}
}
})
break
@@ -313,6 +331,10 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>
case 'Egg':
j.joker.counter! += 3
break
case 'Cloud 9':
// TODO: add to post log
next.stats.money += deck.reduce((nines, c) => nines += (c.rank === Rank.Nine ? 1 : 0), 0)
break
}
})
next.jokers.forEach(j => {j.debuffed = false; j.flipped = false})
@@ -536,6 +558,34 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>
if(selected.length === 4) {
j.joker.counter! += 4
}
break
case 'Seance':
if(hand === 'STRAIGHT_FLUSH' && state.cards.consumables.length < state.stats.consumableSize) {
let validSpectrals = Consumables.slice(12, 28)
validSpectrals.filter(c => state.cards.consumables.every(con => con.consumable.name !== c.name))
if(validSpectrals.length === 0) { validSpectrals.push(Consumables[29]) }
next = {...next, cards: {...next.cards,
consumables: [...next.cards.consumables, {
id: next.cards.nextId,
consumable: validSpectrals[Math.floor(Random.next() * validSpectrals.length)]
}],
nextId: next.cards.nextId + 1
}}
}
break
case 'Vagabond':
if(state.stats.money <= 4 && state.cards.consumables.length < state.stats.consumableSize) {
let validTarots = Consumables.slice(30, 52)
validTarots.filter(c => state.cards.consumables.every(con => con.consumable.name !== c.name))
if(validTarots.length === 0) { validTarots.push(Consumables[41]) }
next = {...next, cards: {...next.cards,
consumables: [...next.cards.consumables, {
id: next.cards.nextId,
consumable: validTarots[Math.floor(Random.next() * validTarots.length)]
}],
nextId: next.cards.nextId + 1
}}
}
}
if(baseball && j.joker.rarity === 'Uncommon') {
mult *= 1.5
@@ -699,6 +749,12 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>
case 'Hiker':
c.chips += 5
break
case 'Vampire':
if(c.enhancement) {
j.joker.counter! += 0.1
c.enhancement = undefined
}
break
case 'Triboulet':
if([Rank.King, Rank.Queen].includes(c.rank)) {
mult *= 2
@@ -734,10 +790,12 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>

state.cards.hand.filter(c => !c.selected && !c.submitted).forEach(c => {
if(!c.debuffed) {
let will_trigger = c.enhancement === Enhancement?.Steel || c.enhancement === Enhancement?.Gold
let will_trigger = c.enhancement === Enhancement?.Steel
state.jokers.filter(j => j.joker.activation.includes(Activation.OnHeld) && !j.debuffed).forEach(j => {
switch(j.joker.name) {

case 'Baron':
will_trigger ||= c.rank === Rank.King
break
}
})

@@ -751,11 +809,16 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>
if(c.enhancement === Enhancement?.Steel) {
mult *= 1.5
next.scoreLog.push({name: 'Steel Card', mult: 1.5, mult_type: 'x'})
} else if(c.enhancement === Enhancement?.Gold) {
next.stats.money += 3
next.scoreLog.push({name: 'Gold Card', notes: '+$3'})
next.moneyTotalLog += 3
}

state.jokers.filter(j => j.joker.activation.includes(Activation.OnHeld) && !j.debuffed).forEach(j => {
switch(j.joker.name) {
case 'Baron':
mult *= 1.5
next.scoreLog.push({name: 'Baron', mult: 1.5, mult_type: 'x'})
break
}
})
}

heldInHand()
@@ -963,6 +1026,12 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>
chips += j.joker.counter!
next.scoreLog.push({name: 'Square Joker', chips: j.joker.counter!})
break
case 'Vampire':
if(j.joker.counter! > 1) {
mult *= j.joker.counter!
next.scoreLog.push({name: 'Vampire', mult: j.joker.counter!, mult_type: 'x'})
}
break
}
if(baseball && j.joker.rarity === 'Uncommon') {
mult *= 1.5
16 changes: 13 additions & 3 deletions src/Utilities.ts
Original file line number Diff line number Diff line change
@@ -42,12 +42,21 @@ export const bestHand = (cards: CardInfo[], jokers: JokerInstance[]): keyof type

const getPokerHand = (cards: CardInfo[], jokers: JokerInstance[]): keyof typeof HandType => {
const fourFingers = jokers.find(j => j.joker.name === 'Four Fingers') !== undefined
const shortcut = jokers.find(j => j.joker.name === 'Shortcut') !== undefined

// xxSA KQJT 9876 5432
const straights = [0x100F, 0x1F, 0x3E, 0x7C, 0xF8, 0x1F0, 0x3E0, 0x7C0, 0xF80, 0x1F00]
if(fourFingers) {
straights.push(...[0x1007, 0xF, 0x1E, 0x3C, 0x78, 0xF0, 0x1E0, 0x3C0, 0x780, 0xF00, 0x1E00])
}
// Not extensively tested
if(shortcut) {
straights.push(...[0x2F, 0x5E, 0xBC, 0x178, 0x2F0, 0x5E0, 0xBC0, 0x1780, 0x37, 0x6E, 0xDC, 0x1B8, 0x370, 0x6E0, 0xDC0, 0x1B80, 0x3B, 0x76, 0xEC, 0x1D8, 0x3B0, 0x760, 0xEC0, 0x1D80, 0x3D, 0x7A, 0xF4, 0x1E8, 0x3D0, 0x7A0, 0xF40, 0x1E80, 0x57, 0xAE, 0x15C, 0x2B8, 0x570, 0xAE0, 0x15C0, 0x5B, 0xB6, 0x16C, 0x2D8, 0x5B0, 0xB60, 0x16C0, 0x5D, 0xBA, 0x174, 0x2E8, 0x5D0, 0xBA0, 0x1740, 0x6B, 0xD6, 0x1AC, 0x358, 0x6B0, 0xD60, 0x1AC0, 0x6D, 0xDA, 0x1B4, 0x368, 0x6D0, 0xDA0, 0x1B40, 0x75, 0xEA, 0x1D4, 0x3A8, 0x750, 0xEA0, 0x1D40, 0xAB, 0x156, 0x2AC, 0x558, 0xAB0, 0x1560, 0xAD, 0x15A, 0x2B4, 0x568, 0xAD0, 0x15A0, 0xB5, 0x16A, 0x2D4, 0x5A8, 0xB50, 0x16A0, 0xD5, 0x1AA, 0x354, 0x6A8, 0xD50, 0x1AA0, 0x155, 0x2AA, 0x554, 0xAA8, 0x1550])
}
if(fourFingers && shortcut) {
straights.push(...[0x17, 0x2E, 0x5C, 0xB8, 0x170, 0x2E0, 0x5C0, 0xB80, 0x1700, 0x1B, 0x36, 0x6C, 0xD8, 0x1B0, 0x360, 0x6C0, 0xD80, 0x1B00, 0x1D, 0x3A, 0x74, 0xE8, 0x1D0, 0x3A0, 0x740, 0xE80, 0x1D00, 0x2B, 0x56, 0xAC, 0x158, 0x2B0, 0x560, 0xAC0, 0x1580, 0x2D, 0x5A, 0xB4, 0x168, 0x2D0, 0x5A0, 0xB40, 0x1680, 0x35, 0x6A, 0xD4, 0x1A8, 0x350, 0x6A0, 0xD40, 0x1A80, 0x55, 0xAA, 0x154, 0x2A8, 0x550, 0xAA0, 0x1540, 0x155, 0x2AA, 0x554, 0xAA8, 0x1550])
}

const hand = cards.reduce((total, c) => total | (1 << c.rank), 0)
let min_rank: keyof typeof HandType = 'NONE'

@@ -179,14 +188,15 @@ export const newOffers = (slots: number, weights: {
Card: number;
Spectral: number;
}, game: GameState) => {
const offers = []
const offers: (JokerInstance | ConsumableInstance)[] = []
const total = Object.values(weights).reduce((n, w) => n += w)
for(let i = 1; i <= slots; i++) {
const roll = Random.next()
if(roll < weights.Joker / total) {
const rare_roll = Random.next()
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))
const rarity = rare_roll < .7 ? 'Common' : rare_roll < .95 ? 'Uncommon' : 'Rare'
const validJokers = Jokers.filter(j => j.rarity === rarity && !game.jokers.find(joker => joker.joker.name === j.name) && !offers.filter(o => (o as JokerInstance).joker).find(o => (o as JokerInstance).joker.name === j.name))

if(validJokers.length === 0) { validJokers.push(Jokers[0])}
offers.push({
id: -i,
Binary file added src/assets/jokers/Common/Riff-Raff.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/Baron.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/Vagabond.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/Cloud_9.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/Seance.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/Shortcut.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/Vampire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/components/Joker.css
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ div[id^='joker_'].shopping {

div[id^='joker_']:hover {
cursor: pointer;
filter: brightness(.75);
scale: 1.1;
}

16 changes: 13 additions & 3 deletions src/components/Joker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext, useRef } from "react"
import { DeckType, Edition, editionInfo } from "../Constants"
import { DeckType, Edition, editionInfo, Rank } from "../Constants"
import { calcPrice, cardSnap, debuffCards, getImage } from "../Utilities"
import debuff from '../assets/cards/modifiers/debuffed.webp'
import { GameStateContext } from "../GameState"
@@ -16,6 +16,7 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
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}
let { price, sell } = calcPrice(self)
let displayName = joker.name

let description = joker.description
switch(joker.name) {
@@ -30,17 +31,26 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
case 'Green Joker':
case 'Madness':
case 'Square Joker':
case 'Vampire':
description = description.replace('_', joker.counter! + '')
break
case 'Abstract Joker':
description = description.replace('_',(3 * game.jokers.length) + '')
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
case 'Seance':
displayName = 'Séance'
break
case 'Cloud 9':
let fullDeck = [...game.cards.deck, ...game.cards.hand, ...game.cards.submitted, ...game.cards.hidden]
let nines = fullDeck.reduce((nines, c) => nines += (c.rank === Rank.Nine ? 1 : 0), 0)
description = description.replace('_', nines + '')
break
}

const descriptionElement = description.split('\n').map((line, i) =>
@@ -154,7 +164,7 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
{!props.flipped && <div id='joker-description-outline'>
<div id='joker-description'>
<div id='joker-name'>
{joker.name}
{displayName}
</div>
<div id='joker-info'>
{props.debuffed ?
531 changes: 288 additions & 243 deletions src/components/JokerInfo.ts

Large diffs are not rendered by default.

0 comments on commit 8768273

Please sign in to comment.