Make onField default to true

This commit is contained in:
Sirz Benjie 2025-04-17 12:38:56 -05:00
parent a564413cc5
commit 50d4e6e180
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
5 changed files with 11 additions and 6 deletions

View File

@ -8183,7 +8183,7 @@ export type MoveTargetSet = {
export function getMoveTargets(user: Pokemon, move: Moves, replaceTarget?: MoveTarget): MoveTargetSet {
const variableTarget = new NumberHolder(0);
user.getOpponents().forEach(p => applyMoveAttrs(VariableTargetAttr, user, p, allMoves[move], variableTarget));
user.getOpponents(false).forEach(p => applyMoveAttrs(VariableTargetAttr, user, p, allMoves[move], variableTarget));
let moveTarget: MoveTarget | undefined;
if (allMoves[move].hasAttr(VariableTargetAttr)) {
@ -8195,7 +8195,7 @@ export function getMoveTargets(user: Pokemon, move: Moves, replaceTarget?: MoveT
} else if (move === undefined) {
moveTarget = MoveTarget.NEAR_ENEMY;
}
const opponents = user.getOpponents();
const opponents = user.getOpponents(false);
let set: Pokemon[] = [];
let multiple = false;

View File

@ -59,7 +59,7 @@ export class Terrain {
// Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain
return (
move.getPriority(user) > 0 &&
user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded())
user.getOpponents(true).some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded())
);
}
}

View File

@ -3852,7 +3852,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return null;
}
getOpponents(onField = false): Pokemon[] {
/**
* Returns the pokemon that oppose this one and are active
*
* @param onField - whether to also check if the pokemon is currently on the field (defaults to true)
*/
getOpponents(onField = true): Pokemon[] {
return (
(this.isPlayer()
? globalScene.getEnemyField()

View File

@ -654,7 +654,7 @@ export class MovePhase extends BattlePhase {
}),
500,
);
applyMoveAttrs(PreMoveMessageAttr, this.pokemon, this.pokemon.getOpponents()[0], this.move.getMove());
applyMoveAttrs(PreMoveMessageAttr, this.pokemon, this.pokemon.getOpponents(false)[0], this.move.getMove());
}
public showFailedText(failedText: string = i18next.t("battle:attackFailed")): void {

View File

@ -346,7 +346,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle {
return undefined;
}
const opponents = pokemon.getOpponents(true);
const opponents = pokemon.getOpponents();
if (opponents.length <= 0) {
return undefined;
}