Rename isXPhase to is

This commit is contained in:
Sirz Benjie 2025-05-28 18:09:12 -05:00
parent 97e19be8d2
commit ecf18e1cdf
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
22 changed files with 49 additions and 52 deletions

View File

@ -900,7 +900,7 @@ export default class BattleScene extends SceneBase {
do {
targetingMovePhase = this.findPhase(
mp =>
mp.isXPhase("MovePhase") &&
mp.is("MovePhase") &&
mp.targets.length === 1 &&
mp.targets[0] === removedPokemon.getBattlerIndex() &&
mp.pokemon.isPlayer() !== allyPokemon.isPlayer(),
@ -1449,7 +1449,7 @@ export default class BattleScene extends SceneBase {
}
if (lastBattle?.double && !newDouble) {
this.tryRemovePhase((p: Phase) => p.isXPhase("SwitchPhase"));
this.tryRemovePhase((p: Phase) => p.is("SwitchPhase"));
for (const p of this.getPlayerField()) {
p.lapseTag(BattlerTagType.COMMANDED);
}

View File

@ -2828,7 +2828,7 @@ export class CommanderAbAttr extends AbAttr {
// Apply boosts from this effect to the ally Dondozo
pokemon.getAlly()?.addTag(BattlerTagType.COMMANDED, 0, MoveId.NONE, pokemon.id);
// Cancel the source Pokemon's next move (if a move is queued)
globalScene.tryRemovePhase((phase) => phase.isXPhase("MovePhase") && phase.pokemon === pokemon);
globalScene.tryRemovePhase((phase) => phase.is("MovePhase") && phase.pokemon === pokemon);
}
}
}
@ -6897,7 +6897,7 @@ export function initAbilities() {
.ignorable(),
new Ability(AbilityId.ANALYTIC, 5)
.attr(MovePowerBoostAbAttr, (user, target, move) => {
const movePhase = globalScene.findPhase((phase) => phase.isXPhase("MovePhase") && phase.pokemon.id !== user?.id);
const movePhase = globalScene.findPhase((phase) => phase.is("MovePhase") && phase.pokemon.id !== user?.id);
return isNullOrUndefined(movePhase);
}, 1.3),
new Ability(AbilityId.ILLUSION, 5)

View File

@ -383,7 +383,7 @@ const QuickGuardConditionFunc: ProtectConditionFunc = (_arena, moveId) => {
const move = allMoves[moveId];
const effectPhase = globalScene.getCurrentPhase();
if (effectPhase?.isXPhase("MoveEffectPhase")) {
if (effectPhase?.is("MoveEffectPhase")) {
const attacker = effectPhase.getUserPokemon();
if (attacker) {
return move.getPriority(attacker) > 0;

View File

@ -553,9 +553,9 @@ export class ShellTrapTag extends BattlerTag {
// Trap should only be triggered by opponent's Physical moves
if (phaseData?.move.category === MoveCategory.PHYSICAL && pokemon.isOpponent(phaseData.attacker)) {
const shellTrapPhaseIndex = globalScene.phaseQueue.findIndex(
phase => phase.isXPhase("MovePhase") && phase.pokemon === pokemon,
phase => phase.is("MovePhase") && phase.pokemon === pokemon,
);
const firstMovePhaseIndex = globalScene.phaseQueue.findIndex(phase => phase.isXPhase("MovePhase"));
const firstMovePhaseIndex = globalScene.phaseQueue.findIndex(phase => phase.is("MovePhase"));
// Only shift MovePhase timing if it's not already next up
if (shellTrapPhaseIndex !== -1 && shellTrapPhaseIndex !== firstMovePhaseIndex) {
@ -1027,7 +1027,7 @@ export class PowderTag extends BattlerTag {
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
const movePhase = globalScene.getCurrentPhase();
if (movePhase?.isXPhase("MovePhase")) {
if (movePhase?.is("MovePhase")) {
const move = movePhase.move.getMove();
const weather = globalScene.arena.weather;
if (
@ -1183,13 +1183,13 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
}),
);
const movePhase = globalScene.findPhase(m => m.isXPhase("MovePhase") && m.pokemon === pokemon);
const movePhase = globalScene.findPhase(m => m.is("MovePhase") && m.pokemon === pokemon);
if (movePhase) {
const movesetMove = pokemon.getMoveset().find(m => m.moveId === this.moveId);
if (movesetMove) {
const lastMove = pokemon.getLastXMoves(1)[0];
globalScene.tryReplacePhase(
m => m.isXPhase("MovePhase") && m.pokemon === pokemon,
m => m.is("MovePhase") && m.pokemon === pokemon,
new MovePhase(pokemon, lastMove.targets ?? [], movesetMove),
);
}
@ -1624,7 +1624,7 @@ export class ProtectedTag extends BattlerTag {
// Stop multi-hit moves early
const effectPhase = globalScene.getCurrentPhase();
if (effectPhase?.isXPhase("MoveEffectPhase")) {
if (effectPhase?.is("MoveEffectPhase")) {
effectPhase.stopMultiHit(pokemon);
}
return true;
@ -2646,7 +2646,7 @@ export class GulpMissileTag extends BattlerTag {
}
const moveEffectPhase = globalScene.getCurrentPhase();
if (moveEffectPhase?.isXPhase("MoveEffectPhase")) {
if (moveEffectPhase?.is("MoveEffectPhase")) {
const attacker = moveEffectPhase.getUserPokemon();
if (!attacker) {
@ -3004,7 +3004,7 @@ export class SubstituteTag extends BattlerTag {
/** If the Substitute redirects damage, queue a message to indicate it. */
onHit(pokemon: Pokemon): void {
const moveEffectPhase = globalScene.getCurrentPhase();
if (moveEffectPhase?.isXPhase("MoveEffectPhase")) {
if (moveEffectPhase?.is("MoveEffectPhase")) {
const attacker = moveEffectPhase.getUserPokemon();
if (!attacker) {
return;
@ -3693,7 +3693,7 @@ export function loadBattlerTag(source: BattlerTag | any): BattlerTag {
*/
function getMoveEffectPhaseData(_pokemon: Pokemon): { phase: MoveEffectPhase; attacker: Pokemon; move: Move } | null {
const phase = globalScene.getCurrentPhase();
if (phase?.isXPhase("MoveEffectPhase")) {
if (phase?.is("MoveEffectPhase")) {
return {
phase: phase,
attacker: phase.getPokemon(),

View File

@ -3109,7 +3109,7 @@ export class AwaitCombinedPledgeAttr extends OverrideMoveEffectAttr {
const overridden = args[0] as BooleanHolder;
const allyMovePhase = globalScene.findPhase<MovePhase>((phase) => phase.isXPhase("MovePhase") && phase.pokemon.isPlayer() === user.isPlayer());
const allyMovePhase = globalScene.findPhase<MovePhase>((phase) => phase.is("MovePhase") && phase.pokemon.isPlayer() === user.isPlayer());
if (allyMovePhase) {
const allyMove = allyMovePhase.move.getMove();
if (allyMove !== move && allyMove.hasAttr(AwaitCombinedPledgeAttr)) {
@ -3123,7 +3123,7 @@ export class AwaitCombinedPledgeAttr extends OverrideMoveEffectAttr {
// Move the ally's MovePhase (if needed) so that the ally moves next
const allyMovePhaseIndex = globalScene.phaseQueue.indexOf(allyMovePhase);
const firstMovePhaseIndex = globalScene.phaseQueue.findIndex((phase) => phase.isXPhase("MovePhase"));
const firstMovePhaseIndex = globalScene.phaseQueue.findIndex((phase) => phase.is("MovePhase"));
if (allyMovePhaseIndex !== firstMovePhaseIndex) {
globalScene.prependToPhase(globalScene.phaseQueue.splice(allyMovePhaseIndex, 1)[0], MovePhase);
}
@ -4477,7 +4477,7 @@ export class CueNextRoundAttr extends MoveEffectAttr {
override apply(user: Pokemon, target: Pokemon, move: Move, args?: any[]): boolean {
const nextRoundPhase = globalScene.findPhase<MovePhase>(phase =>
phase.isXPhase("MovePhase") && phase.move.moveId === MoveId.ROUND
phase.is("MovePhase") && phase.move.moveId === MoveId.ROUND
);
if (!nextRoundPhase) {
@ -4486,7 +4486,7 @@ export class CueNextRoundAttr extends MoveEffectAttr {
// Update the phase queue so that the next Pokemon using Round moves next
const nextRoundIndex = globalScene.phaseQueue.indexOf(nextRoundPhase);
const nextMoveIndex = globalScene.phaseQueue.findIndex(phase => phase.isXPhase("MovePhase"));
const nextMoveIndex = globalScene.phaseQueue.findIndex(phase => phase.is("MovePhase"));
if (nextRoundIndex !== nextMoveIndex) {
globalScene.prependToPhase(globalScene.phaseQueue.splice(nextRoundIndex, 1)[0], MovePhase);
}
@ -6177,7 +6177,7 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
// Handle cases where revived pokemon needs to get switched in on same turn
if (allyPokemon.isFainted() || allyPokemon === pokemon) {
// Enemy switch phase should be removed and replaced with the revived pkmn switching in
globalScene.tryRemovePhase((phase: SwitchSummonPhase) => phase.isXPhase("SwitchSummonPhase") && phase.getPokemon() === pokemon);
globalScene.tryRemovePhase((phase: SwitchSummonPhase) => phase.is("SwitchSummonPhase") && phase.getPokemon() === pokemon);
// If the pokemon being revived was alive earlier in the turn, cancel its move
// (revived pokemon can't move in the turn they're brought back)
globalScene.findPhase((phase: MovePhase) => phase.pokemon === pokemon)?.cancel();
@ -7896,7 +7896,7 @@ export class ForceLastAttr extends MoveEffectAttr {
// Either the end of the turn or in front of another, slower move which has also been forced last
const prependPhase = globalScene.findPhase((phase) =>
[ MovePhase, MoveEndPhase ].every(cls => !(phase instanceof cls))
|| (phase.isXPhase("MovePhase")) && phaseForcedSlower(phase, target, !!globalScene.arena.getTag(ArenaTagType.TRICK_ROOM))
|| (phase.is("MovePhase")) && phaseForcedSlower(phase, target, !!globalScene.arena.getTag(ArenaTagType.TRICK_ROOM))
);
if (prependPhase) {
globalScene.phaseQueue.splice(
@ -7942,7 +7942,7 @@ const userSleptOrComatoseCondition: MoveConditionFunc = (user: Pokemon, target:
const targetSleptOrComatoseCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => target.status?.effect === StatusEffect.SLEEP || target.hasAbility(AbilityId.COMATOSE);
const failIfLastCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => globalScene.phaseQueue.find(phase => phase.isXPhase("MovePhase")) !== undefined;
const failIfLastCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => globalScene.phaseQueue.find(phase => phase.is("MovePhase")) !== undefined;
const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => {
const party: Pokemon[] = user.isPlayer() ? globalScene.getPlayerParty() : globalScene.getEnemyParty();

View File

@ -769,7 +769,7 @@ export function setEncounterRewards(
if (customShopRewards) {
globalScene.unshiftPhase(new SelectModifierPhase(0, undefined, customShopRewards));
} else {
globalScene.tryRemovePhase(p => p.isXPhase("MysteryEncounterRewardsPhase"));
globalScene.tryRemovePhase(p => p.is("MysteryEncounterRewardsPhase"));
}
if (eggRewards) {

View File

@ -232,7 +232,6 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { FaintPhase } from "#app/phases/faint-phase";
import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase";
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
@ -1300,7 +1299,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
// During the Pokemon's MoveEffect phase, the offset is removed to put the Pokemon "in focus"
const currentPhase = globalScene.getCurrentPhase();
if (currentPhase?.isXPhase("MoveEffectPhase") && currentPhase.getPokemon() === this) {
if (currentPhase?.is("MoveEffectPhase") && currentPhase.getPokemon() === this) {
return false;
}
return true;
@ -4775,7 +4774,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
*/
if (effect === StatusEffect.SLEEP || effect === StatusEffect.FREEZE) {
const currentPhase = globalScene.getCurrentPhase();
if (currentPhase?.isXPhase("MoveEffectPhase") && currentPhase.getUserPokemon() === this) {
if (currentPhase?.is("MoveEffectPhase") && currentPhase.getUserPokemon() === this) {
this.turnData.hitCount = 1;
this.turnData.hitsLeft = 1;
}

View File

@ -9,7 +9,7 @@ export abstract class Phase {
}
/**
* The string name of the phase, used to identify the phase type for {@linkcode isXPhase}
* The string name of the phase, used to identify the phase type for {@linkcode is}
*
* @privateremarks
*
@ -27,7 +27,7 @@ export abstract class Phase {
* This does not check for subclasses! It only checks if the phase is *exactly* the given type.
* This method exists to avoid circular import issues, as using `instanceof` would require importing each phase.
*/
isXPhase<K extends keyof PhaseMap>(phase: K): this is PhaseMap[K] {
is<K extends keyof PhaseMap>(phase: K): this is PhaseMap[K] {
return this.phaseName === phase;
}
}

View File

@ -20,7 +20,7 @@ export class BattleEndPhase extends BattlePhase {
// cull any extra `BattleEnd` phases from the queue.
globalScene.phaseQueue = globalScene.phaseQueue.filter(phase => {
if (phase.isXPhase("BattleEndPhase")) {
if (phase.is("BattleEndPhase")) {
this.isVictory ||= phase.isVictory;
return false;
}
@ -29,7 +29,7 @@ export class BattleEndPhase extends BattlePhase {
// `phaseQueuePrepend` is private, so we have to use this inefficient loop.
while (
globalScene.tryRemoveUnshiftedPhase(phase => {
if (phase.isXPhase("BattleEndPhase")) {
if (phase.is("BattleEndPhase")) {
this.isVictory ||= phase.isVictory;
return true;
}

View File

@ -225,7 +225,7 @@ export class EggHatchPhase extends Phase {
}
end() {
if (globalScene.findPhase(p => p.isXPhase("EggHatchPhase"))) {
if (globalScene.findPhase(p => p.is("EggHatchPhase"))) {
this.eggHatchHandler.clear();
} else {
globalScene.time.delayedCall(250, () => globalScene.setModifiersVisible(true));

View File

@ -195,7 +195,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
pokemon.usedTMs = [];
}
pokemon.usedTMs.push(this.moveId);
globalScene.tryRemovePhase(phase => phase.isXPhase("SelectModifierPhase"));
globalScene.tryRemovePhase(phase => phase.is("SelectModifierPhase"));
} else if (this.learnMoveType === LearnMoveType.MEMORY) {
if (this.cost !== -1) {
if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) {
@ -205,7 +205,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
}
globalScene.playSound("se/buy");
} else {
globalScene.tryRemovePhase(phase => phase.isXPhase("SelectModifierPhase"));
globalScene.tryRemovePhase(phase => phase.is("SelectModifierPhase"));
}
}
pokemon.setMove(index, this.moveId);

View File

@ -62,7 +62,7 @@ export class MoveChargePhase extends PokemonPhase {
if (instantCharge.value) {
// this MoveEndPhase will be duplicated by the queued MovePhase if not removed
globalScene.tryRemovePhase(phase => phase.isXPhase("MoveEndPhase") && phase.getPokemon() === user);
globalScene.tryRemovePhase(phase => phase.is("MoveEndPhase") && phase.getPokemon() === user);
// queue a new MovePhase for this move's attack phase
globalScene.unshiftPhase(new MovePhase(user, [this.targetIndex], this.move, false));
} else {

View File

@ -247,8 +247,8 @@ export class MysteryEncounterBattleStartCleanupPhase extends Phase {
});
// Remove any status tick phases
while (globalScene.findPhase(p => p.isXPhase("PostTurnStatusEffectPhase"))) {
globalScene.tryRemovePhase(p => p.isXPhase("PostTurnStatusEffectPhase"));
while (globalScene.findPhase(p => p.is("PostTurnStatusEffectPhase"))) {
globalScene.tryRemovePhase(p => p.is("PostTurnStatusEffectPhase"));
}
// The total number of Pokemon in the player's party that can legally fight
@ -562,7 +562,7 @@ export class MysteryEncounterRewardsPhase extends Phase {
if (encounter.doEncounterRewards) {
encounter.doEncounterRewards();
} else if (this.addHealPhase) {
globalScene.tryRemovePhase(p => p.isXPhase("SelectModifierPhase"));
globalScene.tryRemovePhase(p => p.is("SelectModifierPhase"));
globalScene.unshiftPhase(
new SelectModifierPhase(0, undefined, {
fillRemaining: false,

View File

@ -7,9 +7,9 @@ export class NewBattlePhase extends BattlePhase {
super.start();
// cull any extra `NewBattle` phases from the queue.
globalScene.phaseQueue = globalScene.phaseQueue.filter(phase => !phase.isXPhase("NewBattlePhase"));
globalScene.phaseQueue = globalScene.phaseQueue.filter(phase => !phase.is("NewBattlePhase"));
// `phaseQueuePrepend` is private, so we have to use this inefficient loop.
while (globalScene.tryRemoveUnshiftedPhase(phase => phase.isXPhase("NewBattlePhase"))) {}
while (globalScene.tryRemoveUnshiftedPhase(phase => phase.is("NewBattlePhase"))) {}
globalScene.newBattle();

View File

@ -169,7 +169,7 @@ export class QuietFormChangePhase extends BattlePhase {
this.pokemon.initBattleInfo();
this.pokemon.cry();
const movePhase = globalScene.findPhase(p => p.isXPhase("MovePhase") && p.pokemon === this.pokemon) as MovePhase;
const movePhase = globalScene.findPhase(p => p.is("MovePhase") && p.pokemon === this.pokemon) as MovePhase;
if (movePhase) {
movePhase.cancel();
}

View File

@ -236,9 +236,9 @@ export class StatStageChangePhase extends PokemonPhase {
// Look for any other stat change phases; if this is the last one, do White Herb check
const existingPhase = globalScene.findPhase(
p => p.isXPhase("StatStageChangePhase") && p.battlerIndex === this.battlerIndex,
p => p.is("StatStageChangePhase") && p.battlerIndex === this.battlerIndex,
);
if (!existingPhase?.isXPhase("StatStageChangePhase")) {
if (!existingPhase?.is("StatStageChangePhase")) {
// Apply White Herb if needed
const whiteHerb = globalScene.applyModifier(
ResetNegativeStatStageModifier,
@ -317,7 +317,7 @@ export class StatStageChangePhase extends PokemonPhase {
while (
(existingPhase = globalScene.findPhase(
p =>
p.isXPhase("StatStageChangePhase") &&
p.is("StatStageChangePhase") &&
p.battlerIndex === this.battlerIndex &&
p.stats.length === 1 &&
p.stats[0] === this.stats[0] &&
@ -336,7 +336,7 @@ export class StatStageChangePhase extends PokemonPhase {
while (
(existingPhase = globalScene.findPhase(
p =>
p.isXPhase("StatStageChangePhase") &&
p.is("StatStageChangePhase") &&
p.battlerIndex === this.battlerIndex &&
p.selfTarget === this.selfTarget &&
accEva.some(s => p.stats.includes(s)) === isAccEva &&

View File

@ -76,9 +76,7 @@ export class SwitchPhase extends BattlePhase {
if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) {
// Remove any pre-existing PostSummonPhase under the same field index.
// Pre-existing PostSummonPhases may occur when this phase is invoked during a prompt to switch at the start of a wave.
globalScene.tryRemovePhase(
p => p.isXPhase("PostSummonPhase") && p.player && p.fieldIndex === this.fieldIndex,
);
globalScene.tryRemovePhase(p => p.is("PostSummonPhase") && p.player && p.fieldIndex === this.fieldIndex);
const switchType = option === PartyOption.PASS_BATON ? SwitchType.BATON_PASS : this.switchType;
globalScene.unshiftPhase(new SwitchSummonPhase(switchType, fieldIndex, slotIndex, this.doReturn));
}

View File

@ -75,7 +75,7 @@ export default class CommandUiHandler extends UiHandler {
let commandPhase: CommandPhase;
const currentPhase = globalScene.getCurrentPhase();
if (currentPhase?.isXPhase("CommandPhase")) {
if (currentPhase?.is("CommandPhase")) {
commandPhase = currentPhase;
} else {
commandPhase = globalScene.getStandbyPhase() as CommandPhase;

View File

@ -45,7 +45,7 @@ export default class EggHatchSceneHandler extends UiHandler {
processInput(button: Button): boolean {
if (button === Button.ACTION || button === Button.CANCEL) {
const phase = globalScene.getCurrentPhase();
if (phase?.isXPhase("EggHatchPhase") && phase.trySkip()) {
if (phase?.is("EggHatchPhase") && phase.trySkip()) {
return true;
}
}

View File

@ -222,7 +222,7 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
if (button === Button.CANCEL) {
if (!this.blockExit) {
const phase = globalScene.getCurrentPhase();
if (phase?.isXPhase("EggSummaryPhase")) {
if (phase?.is("EggSummaryPhase")) {
phase.end();
}
success = true;

View File

@ -125,7 +125,7 @@ export default class MenuUiHandler extends MessageUiHandler {
const ui = this.getUi();
this.excludedMenus = () => [
{
condition: !!globalScene.getCurrentPhase()?.isXPhase("SelectModifierPhase"),
condition: !!globalScene.getCurrentPhase()?.is("SelectModifierPhase"),
options: [MenuOptions.EGG_GACHA],
},
{ condition: bypassLogin, options: [MenuOptions.LOG_OUT] },

View File

@ -750,7 +750,7 @@ export default class PartyUiHandler extends MessageUiHandler {
// TODO: This risks hitting the other options (.MOVE_i and ALL) so does it? Do we need an extra check?
if (
option >= PartyOption.FORM_CHANGE_ITEM &&
globalScene.getCurrentPhase()?.isXPhase("SelectModifierPhase") &&
globalScene.getCurrentPhase()?.is("SelectModifierPhase") &&
this.partyUiMode === PartyUiMode.CHECK
) {
const formChangeItemModifiers = this.getFormChangeItemsModifiers(pokemon);
@ -1337,7 +1337,7 @@ export default class PartyUiHandler extends MessageUiHandler {
this.addCommonOptions(pokemon);
break;
case PartyUiMode.CHECK:
if (globalScene.getCurrentPhase()?.isXPhase("SelectModifierPhase")) {
if (globalScene.getCurrentPhase()?.is("SelectModifierPhase")) {
const formChangeItemModifiers = this.getFormChangeItemsModifiers(pokemon);
for (let i = 0; i < formChangeItemModifiers.length; i++) {
this.options.push(PartyOption.FORM_CHANGE_ITEM + i);