mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-26 00:36:25 +00:00
hotfix creating berry with undefined type (#1260)
This commit is contained in:
parent
6c824d8894
commit
a601d4d39e
@ -2273,16 +2273,17 @@ export class PostTurnLootAbAttr extends PostTurnAbAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const randomIdx = Utils.randSeedInt(berriesEaten.length);
|
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
|
berriesEaten.splice(randomIdx) // Remove berry from memory
|
||||||
|
|
||||||
const berryModifier = pokemon.scene.findModifier(
|
const berryModifier = pokemon.scene.findModifier(
|
||||||
(m) => m instanceof BerryModifier && m.berryType === berriesEaten[randomIdx],
|
(m) => m instanceof BerryModifier && m.berryType === chosenBerryType,
|
||||||
pokemon.isPlayer()
|
pokemon.isPlayer()
|
||||||
) as BerryModifier | undefined;
|
) as BerryModifier | undefined;
|
||||||
|
|
||||||
if (!berryModifier) {
|
if (!berryModifier) {
|
||||||
pokemon.scene.addModifier(new BerryModifier(chosenBerry, pokemon.id, berriesEaten[randomIdx], 1));
|
pokemon.scene.addModifier(new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1));
|
||||||
} else {
|
} else {
|
||||||
berryModifier.stackCount++;
|
berryModifier.stackCount++;
|
||||||
}
|
}
|
||||||
|
@ -2076,7 +2076,6 @@ export class TurnStartPhase extends FieldPhase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scene.pushPhase(new BerryPhase(this.scene));
|
|
||||||
|
|
||||||
if (this.scene.arena.weather)
|
if (this.scene.arena.weather)
|
||||||
this.scene.pushPhase(new WeatherEffectPhase(this.scene, 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 PostTurnStatusEffectPhase(this.scene, o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.scene.pushPhase(new BerryPhase(this.scene));
|
||||||
this.scene.pushPhase(new TurnEndPhase(this.scene));
|
this.scene.pushPhase(new TurnEndPhase(this.scene));
|
||||||
|
|
||||||
this.end();
|
this.end();
|
||||||
@ -2098,7 +2098,9 @@ export class BerryPhase extends FieldPhase {
|
|||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
this.executeForAll((pokemon) => {
|
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) {
|
if (hasUsableBerry) {
|
||||||
const cancelled = new Utils.BooleanHolder(false);
|
const cancelled = new Utils.BooleanHolder(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user