Skip to content

Commit

Permalink
fix(core): loyalty card joker setting mult to 0 when inactive
Browse files Browse the repository at this point in the history
Turns out multiplying a number by 0 results in 0. 🤡

Fixes #18.
  • Loading branch information
kleinfreund committed Jan 25, 2025
1 parent bd881c7 commit bbf3600
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 @@ -50,6 +50,7 @@ describe('calculateScore', async () => {
(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'),
(await import('./test-files/037.ts')).default('Regression test for #18'),
])('$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 @@ -354,7 +354,7 @@ export const JOKER_DEFINITIONS: Record<JokerName, JokerDefinition> = {
hasIsActiveInput: true,
effect ({ score, trigger }) {
score.push({
multiplier: ['*', this.active ? 4 : 0],
multiplier: ['*', this.active ? 4 : 1],
phase: 'jokers',
joker: this,
trigger,
Expand Down
26 changes: 26 additions & 0 deletions src/lib/test-files/037.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: 'Queen', suit: 'Diamonds' },
],
jokers: [
{ name: 'Loyalty Card', active: false },
],
},
expected: {
hand: 'High Card',
scoringCards: [
{ rank: 'Queen', suit: 'Diamonds' },
],
scores: [
{ score: '15', formattedScore: '15', luck: 'none' },
{ score: '15', formattedScore: '15', luck: 'average' },
{ score: '15', formattedScore: '15', luck: 'all' },
],
},
}
}

0 comments on commit bbf3600

Please sign in to comment.