From c954a56b4101eb988c871d004981d87f585f4e47 Mon Sep 17 00:00:00 2001 From: EmberCM Date: Sun, 23 Jun 2024 18:40:49 -0500 Subject: [PATCH] Fix existing stacks of lures only applying once --- src/modifier/modifier.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index a55c4edcf4e..56e81746be1 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -342,9 +342,19 @@ export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier return [ this.battlesLeft ]; } + /** + * Modifies the chance of a double battle occurring + * @param args A single element array containing the double battle chance as a NumberHolder + * @returns {boolean} Returns true if the modifier was applied + */ apply(args: any[]): boolean { + // Use Math.max to ensure no dividing by 0 + const chanceMultiplier = 2 * Math.max(1, this.getStackCount()); + const doubleBattleChance = args[0] as Utils.NumberHolder; - doubleBattleChance.value = Math.ceil(doubleBattleChance.value / 2); + // This is divided because the chance is generated as a number from 0 to doubleBattleChance.value using Utils.randSeedInt + // A double battle will initiate if the generated number is 0 + doubleBattleChance.value = Math.ceil(doubleBattleChance.value / chanceMultiplier); return true; }