[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 c954a56b41.

* Document lure modifier code
This commit is contained in:
EmberCM 2024-06-24 11:55:42 -05:00 committed by GitHub
parent 9e3fe2d53a
commit 2ca86dd901
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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