From a601d4d39e89c724e705c1fe4c2dd9225b70639b Mon Sep 17 00:00:00 2001 From: Dmitriy K Date: Wed, 22 May 2024 19:34:49 -0400 Subject: [PATCH] hotfix creating berry with undefined type (#1260) --- src/data/ability.ts | 7 ++++--- src/phases.ts | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 0f87e7167d1..459bd4bcbf7 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2273,16 +2273,17 @@ export class PostTurnLootAbAttr extends PostTurnAbAttr { } const randomIdx = Utils.randSeedInt(berriesEaten.length); - const chosenBerry = new BerryModifierType(berriesEaten[randomIdx]); + const chosenBerryType = berriesEaten[randomIdx] + const chosenBerry = new BerryModifierType(chosenBerryType); berriesEaten.splice(randomIdx) // Remove berry from memory const berryModifier = pokemon.scene.findModifier( - (m) => m instanceof BerryModifier && m.berryType === berriesEaten[randomIdx], + (m) => m instanceof BerryModifier && m.berryType === chosenBerryType, pokemon.isPlayer() ) as BerryModifier | undefined; if (!berryModifier) { - pokemon.scene.addModifier(new BerryModifier(chosenBerry, pokemon.id, berriesEaten[randomIdx], 1)); + pokemon.scene.addModifier(new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1)); } else { berryModifier.stackCount++; } diff --git a/src/phases.ts b/src/phases.ts index d1dacee6f24..bec02390c72 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2076,7 +2076,6 @@ export class TurnStartPhase extends FieldPhase { } } - this.scene.pushPhase(new BerryPhase(this.scene)); if (this.scene.arena.weather) this.scene.pushPhase(new WeatherEffectPhase(this.scene, this.scene.arena.weather)); @@ -2086,6 +2085,7 @@ export class TurnStartPhase extends FieldPhase { this.scene.pushPhase(new PostTurnStatusEffectPhase(this.scene, o)); } + this.scene.pushPhase(new BerryPhase(this.scene)); this.scene.pushPhase(new TurnEndPhase(this.scene)); this.end(); @@ -2098,7 +2098,9 @@ export class BerryPhase extends FieldPhase { super.start(); this.executeForAll((pokemon) => { - const hasUsableBerry = !!this.scene.findModifier((m) => m instanceof BerryModifier && m.shouldApply([pokemon]), pokemon.isPlayer()); + const hasUsableBerry = !!this.scene.findModifier((m) => { + return m instanceof BerryModifier && m.shouldApply([pokemon]); + }, pokemon.isPlayer()); if (hasUsableBerry) { const cancelled = new Utils.BooleanHolder(false);