From 182397411ec6706f3945911d0b6cb05c5874e0a7 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:23:16 -0500 Subject: [PATCH] [Bug] Fix infinite memory mushrooms (#5993) * Set cost to -1 for modifiers chosen as rewards * Ensure apply modifier conditional retains original behavior --- src/phases/select-modifier-phase.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index 34a905f64c6..53e1f5bc282 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -134,7 +134,7 @@ export class SelectModifierPhase extends BattlePhase { return true; } const modifierType = this.typeOptions[cursor].type; - return this.applyChosenModifier(modifierType, 0, modifierSelectCallback); + return this.applyChosenModifier(modifierType, -1, modifierSelectCallback); } // Pick a modifier from the shop and apply it @@ -260,8 +260,13 @@ export class SelectModifierPhase extends BattlePhase { return false; } - // Applies the effects of the chosen modifier - private applyModifier(modifier: Modifier, cost = 0, playSound = false): void { + /** + * Apply the effects of the chosen modifier + * @param modifier - The modifier to apply + * @param cost - The cost of the modifier if it was purchased, or -1 if selected as the modifier reward + * @param playSound - Whether the 'obtain modifier' sound should be played when adding the modifier. + */ + private applyModifier(modifier: Modifier, cost = -1, playSound = false): void { const result = globalScene.addModifier(modifier, false, playSound, undefined, undefined, cost); // Queue a copy of this phase when applying a TM or Memory Mushroom. // If the player selects either of these, then escapes out of consuming them, @@ -270,7 +275,7 @@ export class SelectModifierPhase extends BattlePhase { globalScene.phaseManager.unshiftPhase(this.copy()); } - if (cost && !(modifier.type instanceof RememberMoveModifierType)) { + if (cost !== -1 && !(modifier.type instanceof RememberMoveModifierType)) { if (result) { if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) { globalScene.money -= cost;