mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-17 15:25:22 +01:00
[Misc] fix error throwing in forewarn
This commit is contained in:
parent
a4b27eb05e
commit
07c1491649
@ -4342,6 +4342,10 @@ export class ForewarnAbAttr extends PostSummonAbAttr {
|
|||||||
super(true);
|
super(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override canApply({ pokemon }: AbAttrBaseParams): boolean {
|
||||||
|
return pokemon.getOpponents().some(opp => opp.getMoveset().length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
override apply({ simulated, pokemon }: AbAttrBaseParams): void {
|
override apply({ simulated, pokemon }: AbAttrBaseParams): void {
|
||||||
if (simulated) {
|
if (simulated) {
|
||||||
return;
|
return;
|
||||||
@ -4374,8 +4378,7 @@ export class ForewarnAbAttr extends PostSummonAbAttr {
|
|||||||
|
|
||||||
// Pick a random move in our list.
|
// Pick a random move in our list.
|
||||||
if (movesAtMaxPower.length === 0) {
|
if (movesAtMaxPower.length === 0) {
|
||||||
// NB: The ONLY way this can happen is if both opponents have 0 moves in their moveset
|
return;
|
||||||
throw new Error("Forewarn ability found 0 valid moves!");
|
|
||||||
}
|
}
|
||||||
const chosenMove = movesAtMaxPower[pokemon.randBattleSeedInt(movesAtMaxPower.length)];
|
const chosenMove = movesAtMaxPower[pokemon.randBattleSeedInt(movesAtMaxPower.length)];
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user