Fix existing stacks of lures only applying once

This commit is contained in:
EmberCM 2024-06-23 18:40:49 -05:00
parent c8a6a963f9
commit c954a56b41
1 changed files with 11 additions and 1 deletions

View File

@ -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;
}