From 2ca86dd90146c8ccbfa9de7c1512850c0f400790 Mon Sep 17 00:00:00 2001 From: EmberCM Date: Mon, 24 Jun 2024 11:55:42 -0500 Subject: [PATCH] [Bug] Prevent lures from stacking different tiers (#2550) * Prevent lures from stacking different tiers * Fix existing stacks of lures only applying once * Revert "Fix existing stacks of lures only applying once" This reverts commit c954a56b4101eb988c871d004981d87f585f4e47. * Document lure modifier code --- src/modifier/modifier.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index b28d4e3b5b3..d47ede6d4ca 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -328,7 +328,8 @@ export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier match(modifier: Modifier): boolean { if (modifier instanceof DoubleBattleChanceBoosterModifier) { - return (modifier as DoubleBattleChanceBoosterModifier).battlesLeft === this.battlesLeft; + // Check type id to not match different tiers of lures + return modifier.type.id === this.type.id && modifier.battlesLeft === this.battlesLeft; } return false; } @@ -340,9 +341,15 @@ export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier getArgs(): any[] { 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 { const doubleBattleChance = args[0] as Utils.NumberHolder; + // 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 / 2); return true;