From 5457e8efbf2586742560e604cee5040802a2eea4 Mon Sep 17 00:00:00 2001 From: kleinfreund <5774638+kleinfreund@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:58:52 +0100 Subject: [PATCH] fix(core): not counting Abstract Joker correctly Fixes #20. --- src/lib/calculateScore.test.ts | 1 + src/lib/data.ts | 2 +- src/lib/test-files/038.ts | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/lib/test-files/038.ts diff --git a/src/lib/calculateScore.test.ts b/src/lib/calculateScore.test.ts index 6f1b58b..d0021e8 100644 --- a/src/lib/calculateScore.test.ts +++ b/src/lib/calculateScore.test.ts @@ -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)) diff --git a/src/lib/data.ts b/src/lib/data.ts index ed23c03..2c80796 100644 --- a/src/lib/data.ts +++ b/src/lib/data.ts @@ -437,7 +437,7 @@ export const JOKER_DEFINITIONS: Record = { rarity: 'common', effect ({ score, state, trigger }) { score.push({ - multiplier: ['+', state.jokers.length], + multiplier: ['+', 3 * state.jokers.length], phase: 'jokers', joker: this, trigger, diff --git a/src/lib/test-files/038.ts b/src/lib/test-files/038.ts new file mode 100644 index 0000000..cc3dad3 --- /dev/null +++ b/src/lib/test-files/038.ts @@ -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' }, + ], + }, + } +}