Skip to content

Commit

Permalink
fix(core): triggering Seltzer and Sock and Buskin on held hands
Browse files Browse the repository at this point in the history
Fixes #17.
  • Loading branch information
kleinfreund committed Jan 21, 2025
1 parent 2c91e82 commit bd881c7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/lib/calculateScore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('calculateScore', async () => {
(await import('./test-files/033.ts')).default('Run from 2024-04-10 16:52 UTC'),
(await import('./test-files/034.ts')).default('Run from 2024-04-09 19:20 UTC'),
(await import('./test-files/035.ts')).default('https://www.youtube.com/watch?v=hcZF7NJGuPE'),
(await import('./test-files/036.ts')).default('Regression test for #17'),
])('$message', ({ initialState, expected }) => {
const score = calculateScore(getState(initialState))

Expand Down
11 changes: 2 additions & 9 deletions src/lib/calculateScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ function getScore (state: State, playedHand: HandName, scoringCards: Card[], luc
case 'steel': {
score.push({
multiplier: ['*', 1.5],
phase: 'held-cards', card,
phase: 'held-cards',
card,
type: 'enhancement',
trigger,
})
Expand Down Expand Up @@ -327,14 +328,6 @@ function getHeldCardTriggers ({ state, card }: { state: State, card: Card }): st
triggers.push(name)
break
}
case 'Seltzer': {
triggers.push(name)
break
}
case 'Sock and Buskin': {
if (isFaceCard(card, state.jokerSet.has('Pareidolia'))) triggers.push(name)
break
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ export const PLAYED_CARD_RETRIGGER_JOKER_NAMES: JokerName[] = [
'Hack',
]
export const HELD_CARD_RETRIGGER_JOKER_NAMES: JokerName[] = [
'Seltzer',
'Sock and Buskin',
'Mime',
]

Expand Down
28 changes: 28 additions & 0 deletions src/lib/test-files/036.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { TestCase } from '#lib/calculateScore.test.ts'

export default (message: string): TestCase => {
return {
message,
initialState: {
cards: [
{ played: true, rank: 'Queen', suit: 'Diamonds' },
{ rank: 'Queen', suit: 'Hearts', enhancement: 'steel' },
],
jokers: [
{ name: 'Sock and Buskin' },
{ name: 'Seltzer' },
],
},
expected: {
hand: 'High Card',
scoringCards: [
{ rank: 'Queen', suit: 'Diamonds' },
],
scores: [
{ score: '52.5', formattedScore: '53', luck: 'none' },
{ score: '52.5', formattedScore: '53', luck: 'average' },
{ score: '52.5', formattedScore: '53', luck: 'all' },
],
},
}
}

0 comments on commit bd881c7

Please sign in to comment.