Skip to content

Commit

Permalink
fix(core): not counting Abstract Joker correctly
Browse files Browse the repository at this point in the history
Fixes #20.
  • Loading branch information
kleinfreund committed Jan 30, 2025
1 parent 6d05185 commit 5457e8e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/calculateScore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('calculateScore', async () => {
(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'),
(await import('./test-files/037.ts')).default('Regression test for #18'),
(await import('./test-files/038.ts')).default('Regression test for #20'),
])('$message', ({ initialState, expected }) => {
const score = calculateScore(getState(initialState))

Expand Down
2 changes: 1 addition & 1 deletion src/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export const JOKER_DEFINITIONS: Record<JokerName, JokerDefinition> = {
rarity: 'common',
effect ({ score, state, trigger }) {
score.push({
multiplier: ['+', state.jokers.length],
multiplier: ['+', 3 * state.jokers.length],
phase: 'jokers',
joker: this,
trigger,
Expand Down
26 changes: 26 additions & 0 deletions src/lib/test-files/038.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { TestCase } from '#lib/calculateScore.test.ts'

export default (message: string): TestCase => {
return {
message,
initialState: {
cards: [
{ played: true, rank: 'Jack', suit: 'Spades' },
],
jokers: [
{ name: 'Abstract Joker' },
],
},
expected: {
hand: 'High Card',
scoringCards: [
{ rank: 'Jack', suit: 'Spades' },
],
scores: [
{ score: '60', formattedScore: '60', luck: 'none' },
{ score: '60', formattedScore: '60', luck: 'average' },
{ score: '60', formattedScore: '60', luck: 'all' },
],
},
}
}

0 comments on commit 5457e8e

Please sign in to comment.