Rename `DamagePhase` to `DamageAnimPhase`

This commit is contained in:
NightKev 2024-11-15 18:19:23 -08:00
parent 360a897ed2
commit be908f8394
17 changed files with 76 additions and 76 deletions

View File

@ -51,7 +51,7 @@ import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { FaintPhase } from "#app/phases/faint-phase"; import { FaintPhase } from "#app/phases/faint-phase";
import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
@ -2996,7 +2996,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @returns integer of damage done * @returns integer of damage done
*/ */
damageAndUpdate(damage: integer, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): integer { damageAndUpdate(damage: integer, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): integer {
const damagePhase = new DamagePhase(this.scene, this.getBattlerIndex(), damage, result as DamageResult, critical); const damagePhase = new DamageAnimPhase(this.scene, this.getBattlerIndex(), damage, result as DamageResult, critical);
this.scene.unshiftPhase(damagePhase); this.scene.unshiftPhase(damagePhase);
damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase); damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase);
// Damage amount may have changed, but needed to be queued before calling damage function // Damage amount may have changed, but needed to be queued before calling damage function

View File

@ -1,11 +1,11 @@
import BattleScene from "#app/battle-scene"; import type BattleScene from "#app/battle-scene";
import { BattlerIndex } from "#app/battle"; import { type BattlerIndex } from "#app/battle";
import { BattleSpec } from "#app/enums/battle-spec"; import { BattleSpec } from "#enums/battle-spec";
import { DamageResult, HitResult } from "#app/field/pokemon"; import { type DamageResult, HitResult } from "#app/field/pokemon";
import * as Utils from "#app/utils"; import { fixedInt } from "#app/utils";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "#app/phases/pokemon-phase";
export class DamagePhase extends PokemonPhase { export class DamageAnimPhase extends PokemonPhase {
private amount: integer; private amount: integer;
private damageResult: DamageResult; private damageResult: DamageResult;
private critical: boolean; private critical: boolean;
@ -25,7 +25,7 @@ export class DamagePhase extends PokemonPhase {
if (this.scene.moveAnimations) { if (this.scene.moveAnimations) {
this.scene.toggleInvert(true); this.scene.toggleInvert(true);
} }
this.scene.time.delayedCall(Utils.fixedInt(1000), () => { this.scene.time.delayedCall(fixedInt(1000), () => {
this.scene.toggleInvert(false); this.scene.toggleInvert(false);
this.applyDamage(); this.applyDamage();
}); });

View File

@ -12,7 +12,7 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { PokemonInstantReviveModifier } from "#app/modifier/modifier"; import { PokemonInstantReviveModifier } from "#app/modifier/modifier";
import { SwitchType } from "#enums/switch-type"; import { SwitchType } from "#enums/switch-type";
import i18next from "i18next"; import i18next from "i18next";
import { DamagePhase } from "./damage-phase"; import { DamageAnimPhase } from "./damage-anim-phase";
import { GameOverPhase } from "./game-over-phase"; import { GameOverPhase } from "./game-over-phase";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
import { SwitchPhase } from "./switch-phase"; import { SwitchPhase } from "./switch-phase";
@ -206,7 +206,7 @@ export class FaintPhase extends PokemonPhase {
} else { } else {
// Final boss' HP threshold has been bypassed; cancel faint and force check for 2nd phase // Final boss' HP threshold has been bypassed; cancel faint and force check for 2nd phase
enemy.hp++; enemy.hp++;
this.scene.unshiftPhase(new DamagePhase(this.scene, enemy.getBattlerIndex(), 0, HitResult.OTHER)); this.scene.unshiftPhase(new DamageAnimPhase(this.scene, enemy.getBattlerIndex(), 0, HitResult.OTHER));
this.end(); this.end();
} }
return true; return true;

View File

@ -2,7 +2,7 @@ import { BattlerIndex } from "#app/battle";
import { allAbilities } from "#app/data/ability"; import { allAbilities } from "#app/data/ability";
import { Abilities } from "#app/enums/abilities"; import { Abilities } from "#app/enums/abilities";
import { WeatherType } from "#app/enums/weather-type"; import { WeatherType } from "#app/enums/weather-type";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { MovePhase } from "#app/phases/move-phase"; import { MovePhase } from "#app/phases/move-phase";
import { PostSummonPhase } from "#app/phases/post-summon-phase"; import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
@ -273,7 +273,7 @@ describe("Abilities - Forecast", () => {
const castform = game.scene.getPlayerPokemon()!; const castform = game.scene.getPlayerPokemon()!;
// Damage phase should come first // Damage phase should come first
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamageAnimPhase);
expect(castform.hp).toBeLessThan(castform.getMaxHp()); expect(castform.hp).toBeLessThan(castform.getMaxHp());
// Then change form // Then change form

View File

@ -42,7 +42,7 @@ describe("Abilities - Hustle", () => {
game.move.select(Moves.TACKLE); game.move.select(Moves.TACKLE);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(pikachu.getEffectiveStat).toHaveReturnedWith(Math.floor(atk * 1.5)); expect(pikachu.getEffectiveStat).toHaveReturnedWith(Math.floor(atk * 1.5));
}); });
@ -68,7 +68,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(pikachu, "getAccuracyMultiplier"); vi.spyOn(pikachu, "getAccuracyMultiplier");
game.move.select(Moves.GIGA_DRAIN); game.move.select(Moves.GIGA_DRAIN);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(pikachu.getEffectiveStat).toHaveReturnedWith(spatk); expect(pikachu.getEffectiveStat).toHaveReturnedWith(spatk);
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1); expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1);
@ -86,7 +86,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(allMoves[Moves.FISSURE], "calculateBattleAccuracy"); vi.spyOn(allMoves[Moves.FISSURE], "calculateBattleAccuracy");
game.move.select(Moves.FISSURE); game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(enemyPokemon.turnData.damageTaken).toBe(enemyPokemon.getMaxHp()); expect(enemyPokemon.turnData.damageTaken).toBe(enemyPokemon.getMaxHp());
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1); expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1);

View File

@ -51,7 +51,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.TACKLE); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
const firstStrikeDamage = enemyStartingHp - enemyPokemon.hp; const firstStrikeDamage = enemyStartingHp - enemyPokemon.hp;
enemyStartingHp = enemyPokemon.hp; enemyStartingHp = enemyPokemon.hp;
@ -129,7 +129,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.SELF_DESTRUCT); game.move.select(Moves.SELF_DESTRUCT);
await game.phaseInterceptor.to("DamagePhase", false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(leadPokemon.turnData.hitCount).toBe(1); expect(leadPokemon.turnData.hitCount).toBe(1);
} }
@ -147,7 +147,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.ROLLOUT); game.move.select(Moves.ROLLOUT);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase", false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(leadPokemon.turnData.hitCount).toBe(1); expect(leadPokemon.turnData.hitCount).toBe(1);
} }
@ -181,7 +181,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.COUNTER); game.move.select(Moves.COUNTER);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
const playerDamage = leadPokemon.getMaxHp() - leadPokemon.hp; const playerDamage = leadPokemon.getMaxHp() - leadPokemon.hp;
@ -221,7 +221,7 @@ describe("Abilities - Parental Bond", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.EARTHQUAKE); game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to("DamagePhase", false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
} }
@ -238,7 +238,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.MIND_BLOWN); game.move.select(Moves.MIND_BLOWN);
await game.phaseInterceptor.to("DamagePhase", false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
@ -285,7 +285,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.TACKLE); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(leadPokemon.turnData.hitCount).toBe(3); expect(leadPokemon.turnData.hitCount).toBe(3);
} }
@ -307,7 +307,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.SEISMIC_TOSS); game.move.select(Moves.SEISMIC_TOSS);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(leadPokemon.turnData.hitCount).toBe(3); expect(leadPokemon.turnData.hitCount).toBe(3);
@ -329,7 +329,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.HYPER_BEAM); game.move.select(Moves.HYPER_BEAM);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined(); expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined();
@ -353,7 +353,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.ANCHOR_SHOT); game.move.select(Moves.ANCHOR_SHOT);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined();
@ -380,7 +380,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.SMACK_DOWN); game.move.select(Moves.SMACK_DOWN);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined();
@ -424,7 +424,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.WAKE_UP_SLAP); game.move.select(Moves.WAKE_UP_SLAP);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP); expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP);

View File

@ -1,5 +1,5 @@
import { EnemyPokemon } from "#app/field/pokemon"; import { EnemyPokemon } from "#app/field/pokemon";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase"; import { MoveEndPhase } from "#app/phases/move-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -55,7 +55,7 @@ describe("Abilities - Sturdy", () => {
enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; enemyPokemon.hp = enemyPokemon.getMaxHp() - 1;
game.move.select(Moves.CLOSE_COMBAT); game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamageAnimPhase);
expect(enemyPokemon.hp).toBe(0); expect(enemyPokemon.hp).toBe(0);
expect(enemyPokemon.isFainted()).toBe(true); expect(enemyPokemon.isFainted()).toBe(true);
@ -81,7 +81,7 @@ describe("Abilities - Sturdy", () => {
await game.startBattle(); await game.startBattle();
game.move.select(Moves.CLOSE_COMBAT); game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamageAnimPhase);
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
expect(enemyPokemon.hp).toBe(0); expect(enemyPokemon.hp).toBe(0);

View File

@ -3,7 +3,7 @@ import { Stat } from "#enums/stat";
import { GameModes, getGameMode } from "#app/game-mode"; import { GameModes, getGameMode } from "#app/game-mode";
import { BattleEndPhase } from "#app/phases/battle-end-phase"; import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { CommandPhase } from "#app/phases/command-phase"; import { CommandPhase } from "#app/phases/command-phase";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { EncounterPhase } from "#app/phases/encounter-phase"; import { EncounterPhase } from "#app/phases/encounter-phase";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { LoginPhase } from "#app/phases/login-phase"; import { LoginPhase } from "#app/phases/login-phase";
@ -267,7 +267,7 @@ describe("Test Battle Phase", () => {
]); ]);
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
await game.killPokemon(game.scene.currentBattle.enemyParty[0]); await game.killPokemon(game.scene.currentBattle.enemyParty[0]);
expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true); expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true);
await game.phaseInterceptor.to(VictoryPhase, false); await game.phaseInterceptor.to(VictoryPhase, false);

View File

@ -102,7 +102,7 @@ describe("Battle Mechanics - Damage Calculation", () => {
game.move.select(Moves.JUMP_KICK); game.move.select(Moves.JUMP_KICK);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(shedinja.hp).toBe(shedinja.getMaxHp() - 1); expect(shedinja.hp).toBe(shedinja.getMaxHp() - 1);
}); });

View File

@ -1,4 +1,4 @@
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -48,7 +48,7 @@ describe("Items - Leftovers", () => {
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
// We should have less hp after the attack // We should have less hp after the attack
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
const leadHpAfterDamage = leadPokemon.hp; const leadHpAfterDamage = leadPokemon.hp;

View File

@ -1,6 +1,6 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
@ -51,7 +51,7 @@ describe("Moves - Dynamax Cannon", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 20000); }, 20000);
@ -65,7 +65,7 @@ describe("Moves - Dynamax Cannon", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 20000); }, 20000);
@ -82,7 +82,7 @@ describe("Moves - Dynamax Cannon", () => {
expect(phase.move.moveId).toBe(dynamaxCannon.id); expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100 // Force level cap to be 100
vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100); vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120);
}, 20000); }, 20000);
@ -99,7 +99,7 @@ describe("Moves - Dynamax Cannon", () => {
expect(phase.move.moveId).toBe(dynamaxCannon.id); expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100 // Force level cap to be 100
vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100); vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140);
}, 20000); }, 20000);
@ -116,7 +116,7 @@ describe("Moves - Dynamax Cannon", () => {
expect(phase.move.moveId).toBe(dynamaxCannon.id); expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100 // Force level cap to be 100
vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100); vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160);
}, 20000); }, 20000);
@ -133,7 +133,7 @@ describe("Moves - Dynamax Cannon", () => {
expect(phase.move.moveId).toBe(dynamaxCannon.id); expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100 // Force level cap to be 100
vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100); vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180);
}, 20000); }, 20000);
@ -150,7 +150,7 @@ describe("Moves - Dynamax Cannon", () => {
expect(phase.move.moveId).toBe(dynamaxCannon.id); expect(phase.move.moveId).toBe(dynamaxCannon.id);
// Force level cap to be 100 // Force level cap to be 100
vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100); vi.spyOn(phase.getFirstTarget()!.scene, "getMaxExpLevel").mockReturnValue(100);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
@ -165,7 +165,7 @@ describe("Moves - Dynamax Cannon", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
}); });

View File

@ -1,7 +1,7 @@
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { Species } from "#app/enums/species"; import { Species } from "#app/enums/species";
import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -56,7 +56,7 @@ describe("Moves - Fissure", () => {
game.override.enemyAbility(Abilities.FUR_COAT); game.override.enemyAbility(Abilities.FUR_COAT);
game.move.select(Moves.FISSURE); game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to(DamagePhase, true); await game.phaseInterceptor.to(DamageAnimPhase, true);
expect(enemyPokemon.isFainted()).toBe(true); expect(enemyPokemon.isFainted()).toBe(true);
}); });

View File

@ -1,7 +1,7 @@
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase"; import { MoveEndPhase } from "#app/phases/move-end-phase";
import { MovePhase } from "#app/phases/move-phase"; import { MovePhase } from "#app/phases/move-phase";
@ -58,12 +58,12 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
@ -81,12 +81,12 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
@ -104,7 +104,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -114,7 +114,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
@ -133,7 +133,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -142,7 +142,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
}, 20000); }, 20000);
@ -160,12 +160,12 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
@ -209,22 +209,22 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
@ -268,22 +268,22 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
}); });

View File

@ -41,11 +41,11 @@ describe("Moves - Glaive Rush", () => {
enemy.hp = 1000; enemy.hp = 1000;
game.move.select(Moves.SHADOW_SNEAK); game.move.select(Moves.SHADOW_SNEAK);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
const damageDealt = 1000 - enemy.hp; const damageDealt = 1000 - enemy.hp;
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(Moves.SHADOW_SNEAK); game.move.select(Moves.SHADOW_SNEAK);
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamageAnimPhase");
expect(enemy.hp).toBeLessThanOrEqual(1001 - (damageDealt * 3)); expect(enemy.hp).toBeLessThanOrEqual(1001 - (damageDealt * 3));
}); });

View File

@ -1,6 +1,6 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase"; import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
@ -48,7 +48,7 @@ describe("Moves - Scale Shot", () => {
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamageAnimPhase);
//check that stats haven't changed after one or two hits have occurred //check that stats haven't changed after one or two hits have occurred
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);

View File

@ -33,7 +33,7 @@ export async function runMysteryEncounterToEnd(game: GameManager, optionNo: numb
}, () => game.isCurrentPhase(MysteryEncounterBattlePhase) || game.isCurrentPhase(MysteryEncounterRewardsPhase)); }, () => game.isCurrentPhase(MysteryEncounterBattlePhase) || game.isCurrentPhase(MysteryEncounterRewardsPhase));
if (isBattle) { if (isBattle) {
game.onNextPrompt("DamagePhase", Mode.MESSAGE, () => { game.onNextPrompt("DamageAnimPhase", Mode.MESSAGE, () => {
game.setMode(Mode.MESSAGE); game.setMode(Mode.MESSAGE);
game.endPhase(); game.endPhase();
}, () => game.isCurrentPhase(CommandPhase)); }, () => game.isCurrentPhase(CommandPhase));

View File

@ -5,7 +5,7 @@ import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { BerryPhase } from "#app/phases/berry-phase"; import { BerryPhase } from "#app/phases/berry-phase";
import { CheckSwitchPhase } from "#app/phases/check-switch-phase"; import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
import { CommandPhase } from "#app/phases/command-phase"; import { CommandPhase } from "#app/phases/command-phase";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { EggLapsePhase } from "#app/phases/egg-lapse-phase"; import { EggLapsePhase } from "#app/phases/egg-lapse-phase";
import { EncounterPhase } from "#app/phases/encounter-phase"; import { EncounterPhase } from "#app/phases/encounter-phase";
import { EndEvolutionPhase } from "#app/phases/end-evolution-phase"; import { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
@ -87,7 +87,7 @@ type PhaseClass =
| typeof TurnStartPhase | typeof TurnStartPhase
| typeof MovePhase | typeof MovePhase
| typeof MoveEffectPhase | typeof MoveEffectPhase
| typeof DamagePhase | typeof DamageAnimPhase
| typeof FaintPhase | typeof FaintPhase
| typeof BerryPhase | typeof BerryPhase
| typeof TurnEndPhase | typeof TurnEndPhase
@ -146,7 +146,7 @@ type PhaseString =
| "TurnStartPhase" | "TurnStartPhase"
| "MovePhase" | "MovePhase"
| "MoveEffectPhase" | "MoveEffectPhase"
| "DamagePhase" | "DamageAnimPhase"
| "FaintPhase" | "FaintPhase"
| "BerryPhase" | "BerryPhase"
| "TurnEndPhase" | "TurnEndPhase"
@ -229,7 +229,7 @@ export default class PhaseInterceptor {
[ TurnStartPhase, this.startPhase ], [ TurnStartPhase, this.startPhase ],
[ MovePhase, this.startPhase ], [ MovePhase, this.startPhase ],
[ MoveEffectPhase, this.startPhase ], [ MoveEffectPhase, this.startPhase ],
[ DamagePhase, this.startPhase ], [ DamageAnimPhase, this.startPhase ],
[ FaintPhase, this.startPhase ], [ FaintPhase, this.startPhase ],
[ BerryPhase, this.startPhase ], [ BerryPhase, this.startPhase ],
[ TurnEndPhase, this.startPhase ], [ TurnEndPhase, this.startPhase ],