hotfix creating berry with undefined type (#1260)

This commit is contained in:
Dmitriy K 2024-05-22 19:34:49 -04:00 committed by GitHub
parent 6c824d8894
commit a601d4d39e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

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

View File

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