Updated tests to use new functions introduced. Less intuitive, but faster.

This commit is contained in:
Frutescens 2024-08-15 11:24:48 -07:00
parent f683a69a11
commit 2f0e765a3d
2 changed files with 41 additions and 57 deletions

View File

@ -1,4 +1,4 @@
import { MovePhase, TurnEndPhase } from "#app/phases"; import { EnemyCommandPhase, TurnStartPhase, TurnEndPhase } from "#app/phases";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
@ -43,63 +43,55 @@ describe("Abilities - Mycelium Might", () => {
it("If a Pokemon with Mycelium Might uses a status move, it will always move last but the status move will ignore protective abilities", async() => { it("If a Pokemon with Mycelium Might uses a status move, it will always move last but the status move will ignore protective abilities", async() => {
await game.startBattle([ Species.REGIELEKI ]); await game.startBattle([ Species.REGIELEKI ]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyPokemon = game.scene.getEnemyPokemon(); const enemyPokemon = game.scene.getEnemyPokemon();
const enemyIndex = enemyPokemon?.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES));
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.run(EnemyCommandPhase);
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const speedOrder = phase.getSpeedOrder();
const commandOrder = phase.getCommandOrder();
// The opponent Pokemon (without Mycelium Might) goes first despite having lower speed than the player Pokemon. // The opponent Pokemon (without Mycelium Might) goes first despite having lower speed than the player Pokemon.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex);
await game.phaseInterceptor.run(MovePhase);
await game.phaseInterceptor.to(MovePhase, false);
// The player Pokemon (with Mycelium Might) goes last despite having higher speed than the opponent. // The player Pokemon (with Mycelium Might) goes last despite having higher speed than the opponent.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex); // This means that the commandOrder is equivalent to the speed Order reversed
expect(speedOrder.reverse().every((val, index) => val === commandOrder[index])).toBe(true);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
// Despite the opponent's ability (Clear Body), its attack stat is still reduced.
expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1); expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1);
}, 20000); }, 20000);
it("Pokemon with Mycelium Might will go first if a status move that is in a higher priority bracket than the opponent's move is used", async() => { it("Pokemon with Mycelium Might will go first if a status move that is in a higher priority bracket than the opponent's move is used", async() => {
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle([ Species.REGIELEKI ]); await game.startBattle([ Species.REGIELEKI ]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyPokemon = game.scene.getEnemyPokemon(); const enemyPokemon = game.scene.getEnemyPokemon();
const enemyIndex = enemyPokemon?.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES));
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.run(EnemyCommandPhase);
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const speedOrder = phase.getSpeedOrder();
const commandOrder = phase.getCommandOrder();
// The player Pokemon (with M.M.) goes first because its move is still within a higher priority bracket than its opponent. // The player Pokemon (with M.M.) goes first because its move is still within a higher priority bracket than its opponent.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex);
await game.phaseInterceptor.run(MovePhase);
await game.phaseInterceptor.to(MovePhase, false);
// The enemy Pokemon goes second because its move is in a lower priority bracket. // The enemy Pokemon goes second because its move is in a lower priority bracket.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex); // This means that the commandOrder should be identical to the speedOrder
expect(speedOrder.every((val, index) => val === commandOrder[index])).toBe(true);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
// Despite the opponent's ability (Clear Body), its attack stat is still reduced.
expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1); expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1);
}, 20000); }, 20000);
it("Order is established normally if the Pokemon uses a non-status move", async() => { it("Order is established normally if the Pokemon uses a non-status move", async() => {
await game.startBattle([ Species.REGIELEKI ]); await game.startBattle([ Species.REGIELEKI ]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.run(EnemyCommandPhase);
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const speedOrder = phase.getSpeedOrder();
const commandOrder = phase.getCommandOrder();
// The player Pokemon (with M.M.) goes first because it has a higher speed and did not use a status move. // The player Pokemon (with M.M.) goes first because it has a higher speed and did not use a status move.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex);
await game.phaseInterceptor.run(MovePhase);
await game.phaseInterceptor.to(MovePhase, false);
// The enemy Pokemon (without M.M.) goes second because its speed is lower. // The enemy Pokemon (without M.M.) goes second because its speed is lower.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex); // This means that the commandOrder should be identical to the speedOrder
expect(speedOrder.every((val, index) => val === commandOrder[index])).toBe(true);
}, 20000); }, 20000);
}); });

View File

@ -1,4 +1,4 @@
import { MovePhase } from "#app/phases"; import { EnemyCommandPhase, TurnStartPhase } from "#app/phases";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
@ -41,55 +41,47 @@ describe("Abilities - Stall", () => {
it("Pokemon with Stall should move last in its priority bracket regardless of speed", async() => { it("Pokemon with Stall should move last in its priority bracket regardless of speed", async() => {
await game.startBattle([ Species.SHUCKLE ]); await game.startBattle([ Species.SHUCKLE ]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.run(EnemyCommandPhase);
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const speedOrder = phase.getSpeedOrder();
const commandOrder = phase.getCommandOrder();
// The player Pokemon (without Stall) goes first despite having lower speed than the opponent. // The player Pokemon (without Stall) goes first despite having lower speed than the opponent.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex);
await game.phaseInterceptor.run(MovePhase);
await game.phaseInterceptor.to(MovePhase, false);
// The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon. // The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex); // This means that the commandOrder is equivalent to the speed Order reversed
expect(speedOrder.reverse().every((val, index) => val === commandOrder[index])).toBe(true);
}, 20000); }, 20000);
it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async() => { it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async() => {
await game.startBattle([ Species.SHUCKLE ]); await game.startBattle([ Species.SHUCKLE ]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.run(EnemyCommandPhase);
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const speedOrder = phase.getSpeedOrder();
const commandOrder = phase.getCommandOrder();
// The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent. // The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex);
await game.phaseInterceptor.run(MovePhase);
await game.phaseInterceptor.to(MovePhase, false);
// The player Pokemon goes second because its move is in a lower priority bracket. // The player Pokemon goes second because its move is in a lower priority bracket.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex); // This means that the commandOrder should be identical to the speedOrder
expect(speedOrder.every((val, index) => val === commandOrder[index])).toBe(true);
}, 20000); }, 20000);
it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async() => { it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async() => {
game.override.ability(Abilities.STALL); game.override.ability(Abilities.STALL);
await game.startBattle([ Species.SHUCKLE ]); await game.startBattle([ Species.SHUCKLE ]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.run(EnemyCommandPhase);
// The opponent Pokemon (with Stall) goes first because it has a higher speed. const phase = game.scene.getCurrentPhase() as TurnStartPhase;
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex); const speedOrder = phase.getSpeedOrder();
const commandOrder = phase.getCommandOrder();
await game.phaseInterceptor.run(MovePhase); // The opponent Pokemon (with Stall) goes first because it has a higher speed.
await game.phaseInterceptor.to(MovePhase, false);
// The player Pokemon (with Stall) goes second because its speed is lower. // The player Pokemon (with Stall) goes second because its speed is lower.
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex); // This means that the commandOrder should be identical to the speedOrder
expect(speedOrder.every((val, index) => val === commandOrder[index])).toBe(true);
}, 20000); }, 20000);
}); });