Skip to content

Commit

Permalink
Jokers 2-16
Browse files Browse the repository at this point in the history
  • Loading branch information
imisaacwu committed Aug 13, 2024
1 parent 928e0bf commit 9fcb8a5
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 29 deletions.
93 changes: 92 additions & 1 deletion src/GameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const initialGameState: GameState = {
},

blind: {
curr: 'boss',
curr: 'small',
boss: boss_roll(1),
base: ante_base(1)
},
Expand Down Expand Up @@ -501,6 +501,30 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>

state.jokers.filter(j => j.joker.activation.includes(Activation.OnScored) && !j.debuffed).forEach(j => {
switch(j.joker.name) {
case 'Greedy Joker':
if(c.suit === Suit.Diamonds) {
mult += 3
next.scoreLog.push({name: 'Greedy Joker', mult: 3, mult_type: '+'})
}
break
case 'Lusty Joker':
if(c.suit === Suit.Hearts) {
mult += 3
next.scoreLog.push({name: 'Lusty Joker', mult: 3, mult_type: '+'})
}
break
case 'Wrathful Joker':
if(c.suit === Suit.Spades) {
mult += 3
next.scoreLog.push({name: 'Wrathful Joker', mult: 3, mult_type: '+'})
}
break
case 'Gluttonous Joker':
if(c.suit === Suit.Clubs) {
mult += 3
next.scoreLog.push({name: 'Gluttonous Joker', mult: 3, mult_type: '+'})
}
break
case 'Triboulet':
if([Rank.King, Rank.Queen].includes(c.rank)) {
mult *= 2
Expand Down Expand Up @@ -573,12 +597,79 @@ export const gameReducer = (state: GameState, action: GameAction): GameState =>
}
})

ranks = ranks.sort((a, b) => b - a)
state.jokers.filter(j => j.joker.activation.includes(Activation.Independent) && !j.debuffed).forEach(j => {
switch(j.joker.name) {
case 'Joker':
mult += 4;
next.scoreLog.push({name: 'Joker', mult: 4, mult_type: '+'})
break
case 'Jolly Joker':
if(ranks[0] >= 2) {
mult += 8;
next.scoreLog.push({name: 'Jolly Joker', mult: 8, mult_type: '+'})
}
break
case 'Zany Joker':
if(ranks[0] >= 3) {
mult += 12;
next.scoreLog.push({name: 'Zany Joker', mult: 12, mult_type: '+'})
}
break
case 'Mad Joker':
if(ranks[0] >= 2 && ranks[1] >= 2) {
mult += 10;
next.scoreLog.push({name: 'Mad Joker', mult: 10, mult_type: '+'})
}
break
case 'Crazy Joker':
if(hand.match(/.*STRAIGHT.*/)) {
mult += 12;
next.scoreLog.push({name: 'Crazy Joker', mult: 12, mult_type: '+'})
}
break
case 'Droll Joker':
if(hand.match(/.*FLUSH.*/)) {
mult += 10;
next.scoreLog.push({name: 'Droll Joker', mult: 10, mult_type: '+'})
}
break
case 'Sly Joker':
if(ranks[0] >= 2) {
chips += 50;
next.scoreLog.push({name: 'Sly Joker', chips: 50})
}
break
case 'Wily Joker':
if(ranks[0] >= 3) {
chips += 100;
next.scoreLog.push({name: 'Wily Joker', chips: 100})
}
break
case 'Clever Joker':
if(ranks[0] >= 2 && ranks[1] >= 2) {
chips += 80;
next.scoreLog.push({name: 'Clever Joker', chips: 80})
}
break
case 'Devious Joker':
if(hand.match(/.*STRAIGHT.*/)) {
chips += 100;
next.scoreLog.push({name: 'Devious Joker', chips: 100})
}
break
case 'Crafty Joker':
if(hand.match(/.*FLUSH.*/)) {
chips += 80;
next.scoreLog.push({name: 'Crafty Joker', chips: 80})
}
break
case 'Half Joker':
if(state.cards.selected.length <= 3) {
mult += 20;
next.scoreLog.push({name: 'Half Joker', mult: 20, mult_type: '+'})
}
break
}
if(baseball && j.joker.rarity === 'Uncommon') {
mult *= 1.5
Expand Down
14 changes: 6 additions & 8 deletions src/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,22 @@ const getPokerHand = (cards: CardInfo[]): keyof typeof HandType => {
// xxSAKQJT 98765432
const straights = [0x100F, 0x1F, 0x3E, 0x7C, 0xF8, 0x1F0, 0x3E0, 0x7C0, 0xF80, 0x1F00]
const hand = cards.reduce((total, c) => total | (1 << c.rank), 0)
let min_rank: keyof typeof HandType = 'NONE'

// [2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A, Stone]
let ranks: number[] = new Array(14).fill(0), suits: number[] = new Array(4).fill(0)
// [2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A]
let ranks: number[] = new Array(13).fill(0), suits: number[] = new Array(4).fill(0)
cards.forEach(c => {
if(c.enhancement !== undefined && c.enhancement === Enhancement.Stone) {
ranks[13]++;
min_rank = 'HIGH_CARD'
} else {
ranks[c.rank]++
suits[c.suit]++
}
})

ranks = ranks.filter(r => r !== 0).sort((a, b) => b - a)
suits = suits.filter(s => s !== 0).sort((a, b) => b - a)

if(ranks.length === 1 && hand === 0x3000) {
return 'HIGH_CARD'
}

if(suits[0] === 5) {
if(ranks[0] === 5) return 'FLUSH_FIVE'
if(straights.includes(hand)) return 'STRAIGHT_FLUSH'
Expand All @@ -77,7 +75,7 @@ const getPokerHand = (cards: CardInfo[]): keyof typeof HandType => {
case 1: return straights.includes(hand) ? 'STRAIGHT' : 'HIGH_CARD'
}

return 'NONE'
return min_rank
}

export const shuffle = (cards: any[]) => {
Expand Down
Binary file added src/assets/jokers/Common/Clever_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/Crafty_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/Crazy_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/Devious_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/Droll_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/Gluttonous_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/Greedy_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/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/Jolly_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/Lusty_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/Mad_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/Sly_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/Wily_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/Wrathful_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/Zany_Joker.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: 0 additions & 6 deletions src/components/Card.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,4 @@

.tag-description div div {
width: max-content;
}

#playing-card-scored-popup {
position: absolute;
top: -48px;
background-color: var(--blue);
}
5 changes: 0 additions & 5 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,6 @@ export const Card = ({
</div>
</div>
</div>}
{submitted && scored && !debuffed &&
<div id='playing-card-scored-popup'>
{`+${rankChips[Rank[rank] as keyof typeof rankChips]}`}
</div>
}
</div>
)
}
5 changes: 2 additions & 3 deletions src/components/Consumable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,14 @@ export const Consumable = ({ selected = false, consumable: cons, ...props }: Con
`${selected ? ' selected' : ''}` +
`${props.shopMode ? ' shopping' : ''}`
}

>
<img src={image} onClick={() => {
if(props.shopMode) {
dispatch({type: 'shop-select', payload: {card: game.shop.offers.find(c => c.id === props.id)}})
} else {
dispatch({type: 'select', payload: {card: game.cards.consumables.find(c => c.id === props.id)}})
}
}} onMouseDown={mouseDown} />
}} onMouseDown={props.shopMode ? () => {} : mouseDown} />
{props.shopMode &&
<div id='consumable-price-tab'>
<div id='consumable-price' className='yellow'>
Expand Down Expand Up @@ -193,7 +192,7 @@ export const Consumable = ({ selected = false, consumable: cons, ...props }: Con
if(game.stats.money >= price) {
dispatch({type: 'stat', payload: {stat: 'money', amount: -price}})
dispatch({type: 'shop-remove', payload: {card: {selected, consumable: cons, ...props}}})
useConsumable(game, dispatch, cons)
useConsumable(game, dispatch, cons, true)
}
}}>
<div id='consumable-buy-and-use-buy'>BUY</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Joker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const Joker = ({id, joker, edition, selected = false, ...props}: JokerIns
} else {
dispatch({type: 'select', payload: {card: self}})
}
}} onMouseDown={mouseDown} />
}} onMouseDown={props.shopMode ? () => {} : mouseDown} />
{props.debuffed && <img className='debuff' src={debuff} />}
{!props.flipped && <div id='joker-description-outline'>
<div id='joker-description'>
Expand Down
99 changes: 97 additions & 2 deletions src/components/JokerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,103 @@ export const Jokers: JokerType[] = [
cost: 2,
rarity: 'Common',
activation: [Activation.Independent]
},
{
}, {
name: 'Greedy Joker',
description: 'Played cards with \n{orange}Diamond/ suit give \n{red}+3/ Mult when scored',
cost: 5,
rarity: 'Common',
activation: [Activation.OnScored]
}, {
name: 'Lusty Joker',
description: 'Played cards with \n{red}Heart/ suit give \n{red}+3/ Mult when scored',
cost: 5,
rarity: 'Common',
activation: [Activation.OnScored]
}, {
name: 'Wrathful Joker',
description: 'Played cards with \n{dark-purple}Spade/ suit give \n{red}+3/ Mult when scored',
cost: 5,
rarity: 'Common',
activation: [Activation.OnScored]
}, {
name: 'Gluttonous Joker',
description: 'Played cards with \n{blue}Club/ suit give \n{red}+3/ Mult when scored',
cost: 5,
rarity: 'Common',
activation: [Activation.OnScored]
}, {
name: 'Jolly Joker',
description: '{red}+8/ Mult if played hand\n contains a /{orange}Pair',
cost: 3,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Zany Joker',
description: '{red}+12/ Mult if played\n hand contains a\n {orange}Three of a Kind',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Mad Joker',
description: '{red}+10/ Mult if played\nhand contains a\n {orange}Two Pair',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Crazy Joker',
description: '{red}+12/ Mult if played\nhand contains a\n {orange}Straight',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Droll Joker',
description: '{red}+10/ Mult if played\nhand contains a\n {orange}Flush',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Sly Joker',
description: '{blue}+50/ Chips if played\n hand contains a\n{orange}Pair',
cost: 3,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Wily Joker',
description: '{blue}+100/ Chips if played\n hand contains a\n{orange}Three of a Kind',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Clever Joker',
description: '{blue}+80/ Chips if played\n hand contains a\n{orange}Two Pair',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Devious Joker',
description: '{blue}+100/ Chips if played\n hand contains a\n{orange}Straight',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Crafty Joker',
description: '{blue}+80/ Chips if played\n hand contains a\n{orange}Flush',
cost: 4,
rarity: 'Common',
activation: [Activation.Independent]
}, {
name: 'Half Joker',
description: '{red}+20/ Mult if played\n hand contains /{orange}3\n or fewer cards',
cost: 5,
rarity: 'Common',
activation: [Activation.Independent]
}





,{
name: 'Baseball Card',
description: '{green}Uncommon/Jokers each\ngive/{red-invert}X1.5/Mult',
cost: 8,
Expand Down
8 changes: 5 additions & 3 deletions src/components/UseConsumable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const suits = Object.keys(Suit).filter(k => isNaN(Number(k))).map(s => s as keyo
const ranks = Object.keys(Rank).filter(r => isNaN(Number(r))).map(r => r as keyof typeof Rank)
const enhancements = Object.keys(Enhancement).filter(e => isNaN(Number(e))).map(e => e as keyof typeof Enhancement)

export const useConsumable = (game: GameState, dispatch: React.Dispatch<GameAction>, consumable: ConsumableType) => {
export const useConsumable = (game: GameState, dispatch: React.Dispatch<GameAction>, consumable: ConsumableType, instant?: boolean) => {
if(game.cards.submitted.length === 0) {
if(consumable.type === 'Planet') {
levelHand({hand: consumable.hand!})
Expand Down Expand Up @@ -191,7 +191,9 @@ export const useConsumable = (game: GameState, dispatch: React.Dispatch<GameActi
if(validTarots.length === 0) { validTarots.push(Consumables[40])}

let tarot: Omit<ConsumableType, 'id'>
for(let i = 0; i < Math.min(2, game.stats.consumableSize - game.cards.consumables.length + 1); i++) {
let n = Math.min(2, game.stats.consumableSize - game.cards.consumables.length)
if(game.cards.consumables.find(c => c.consumable.name === 'The Emperor')) { n++ }
for(let i = 0; i < n; i++) {
tarot = validTarots[Math.floor(Random.next() * validTarots.length)]
dispatch({type: 'addCard', payload: {card: tarot}})
validTarots = validTarots.filter(c => c.name !== tarot.name)
Expand Down Expand Up @@ -290,6 +292,6 @@ export const useConsumable = (game: GameState, dispatch: React.Dispatch<GameActi
debuffCards(game.blind.boss, game.cards.hand, game.cards.played)
}
dispatch({type: 'setLastUsedConsumable', payload: {card: consumable}})
dispatch({type: 'discard'})
if(!instant) { dispatch({type: 'discard'}) }
}
}

0 comments on commit 9fcb8a5

Please sign in to comment.