Fix comeback bonus
This commit is contained in:
parent
d38aeb2f44
commit
99977bc8e6
4 changed files with 44 additions and 3 deletions
|
|
@ -231,6 +231,7 @@ describe('calculatePointsWithBreakdown', () => {
|
|||
const result = calculatePointsWithBreakdown({
|
||||
...baseParams,
|
||||
playerRank: 5,
|
||||
currentQuestionIndex: 1,
|
||||
config: { ...DEFAULT_GAME_CONFIG, comebackBonusEnabled: false },
|
||||
});
|
||||
|
||||
|
|
@ -242,6 +243,7 @@ describe('calculatePointsWithBreakdown', () => {
|
|||
const result = calculatePointsWithBreakdown({
|
||||
...baseParams,
|
||||
playerRank: rank,
|
||||
currentQuestionIndex: 1,
|
||||
config: { ...DEFAULT_GAME_CONFIG, comebackBonusEnabled: true, comebackBonusPoints: 100 },
|
||||
});
|
||||
|
||||
|
|
@ -253,6 +255,7 @@ describe('calculatePointsWithBreakdown', () => {
|
|||
const result = calculatePointsWithBreakdown({
|
||||
...baseParams,
|
||||
playerRank: 4,
|
||||
currentQuestionIndex: 1,
|
||||
config: { ...DEFAULT_GAME_CONFIG, comebackBonusEnabled: true, comebackBonusPoints: 100 },
|
||||
});
|
||||
|
||||
|
|
@ -264,11 +267,33 @@ describe('calculatePointsWithBreakdown', () => {
|
|||
const result = calculatePointsWithBreakdown({
|
||||
...baseParams,
|
||||
playerRank: 10,
|
||||
currentQuestionIndex: 2,
|
||||
config: { ...DEFAULT_GAME_CONFIG, comebackBonusEnabled: true, comebackBonusPoints: 150 },
|
||||
});
|
||||
|
||||
expect(result.comebackBonus).toBe(150);
|
||||
});
|
||||
|
||||
it('applies no comeback bonus on first question (index 0)', () => {
|
||||
const result = calculatePointsWithBreakdown({
|
||||
...baseParams,
|
||||
playerRank: 5,
|
||||
currentQuestionIndex: 0,
|
||||
config: { ...DEFAULT_GAME_CONFIG, comebackBonusEnabled: true, comebackBonusPoints: 100 },
|
||||
});
|
||||
|
||||
expect(result.comebackBonus).toBe(0);
|
||||
});
|
||||
|
||||
it('applies no comeback bonus when currentQuestionIndex is undefined', () => {
|
||||
const result = calculatePointsWithBreakdown({
|
||||
...baseParams,
|
||||
playerRank: 5,
|
||||
config: { ...DEFAULT_GAME_CONFIG, comebackBonusEnabled: true, comebackBonusPoints: 100 },
|
||||
});
|
||||
|
||||
expect(result.comebackBonus).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('first correct bonus', () => {
|
||||
|
|
@ -319,9 +344,10 @@ describe('calculatePointsWithBreakdown', () => {
|
|||
|
||||
const result = calculatePointsWithBreakdown({
|
||||
...baseParams,
|
||||
streak: 4, // Above threshold
|
||||
playerRank: 5, // Qualifies for comeback
|
||||
streak: 4,
|
||||
playerRank: 5,
|
||||
isFirstCorrect: true,
|
||||
currentQuestionIndex: 2,
|
||||
config,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue