mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +02:00
Updating battle-order.test.ts
This commit is contained in:
parent
63a503e47f
commit
285ad9043a
@ -10,7 +10,7 @@ import { Moves } from "#enums/moves";
|
|||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
import { CommandPhase } from "#app/phases/command-phase.js";
|
import { CommandPhase } from "#app/phases/command-phase";
|
||||||
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
|
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
|
||||||
import { SelectTargetPhase } from "#app/phases/select-target-phase";
|
import { SelectTargetPhase } from "#app/phases/select-target-phase";
|
||||||
import { TurnStartPhase } from "#app/phases/turn-start-phase";
|
import { TurnStartPhase } from "#app/phases/turn-start-phase";
|
||||||
@ -43,6 +43,7 @@ describe("Battle order", () => {
|
|||||||
await game.startBattle([
|
await game.startBattle([
|
||||||
Species.BULBASAUR,
|
Species.BULBASAUR,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
game.scene.getParty()[0].stats[Stat.SPD] = 50;
|
game.scene.getParty()[0].stats[Stat.SPD] = 50;
|
||||||
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150;
|
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150;
|
||||||
|
|
||||||
@ -54,10 +55,13 @@ describe("Battle order", () => {
|
|||||||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||||
});
|
});
|
||||||
await game.phaseInterceptor.run(EnemyCommandPhase);
|
await game.phaseInterceptor.run(EnemyCommandPhase);
|
||||||
|
|
||||||
|
const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex();
|
||||||
|
const enemyPokemonIndex = game.scene.getEnemyPokemon()?.getBattlerIndex();
|
||||||
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
||||||
const order = phase.getCommandOrder();
|
const order = phase.getCommandOrder();
|
||||||
expect(order[0]).toBe(2);
|
expect(order[0]).toBe(enemyPokemonIndex);
|
||||||
expect(order[1]).toBe(0);
|
expect(order[1]).toBe(playerPokemonIndex);
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
it("Player faster than opponent 150 vs 50", async() => {
|
it("Player faster than opponent 150 vs 50", async() => {
|
||||||
@ -75,10 +79,13 @@ describe("Battle order", () => {
|
|||||||
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
||||||
});
|
});
|
||||||
await game.phaseInterceptor.run(EnemyCommandPhase);
|
await game.phaseInterceptor.run(EnemyCommandPhase);
|
||||||
|
|
||||||
|
const playerPokemonIndex = game.scene.getPlayerPokemon()?.getBattlerIndex();
|
||||||
|
const enemyPokemonIndex = game.scene.getEnemyPokemon()?.getBattlerIndex();
|
||||||
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
||||||
const order = phase.getCommandOrder();
|
const order = phase.getCommandOrder();
|
||||||
expect(order[0]).toBe(0);
|
expect(order[0]).toBe(playerPokemonIndex);
|
||||||
expect(order[1]).toBe(2);
|
expect(order[1]).toBe(enemyPokemonIndex);
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
it("double - both opponents faster than player 50/50 vs 150/150", async() => {
|
it("double - both opponents faster than player 50/50 vs 150/150", async() => {
|
||||||
@ -87,10 +94,16 @@ describe("Battle order", () => {
|
|||||||
Species.BULBASAUR,
|
Species.BULBASAUR,
|
||||||
Species.BLASTOISE,
|
Species.BLASTOISE,
|
||||||
]);
|
]);
|
||||||
game.scene.getParty()[0].stats[Stat.SPD] = 50;
|
|
||||||
game.scene.getParty()[1].stats[Stat.SPD] = 50;
|
const playerParty = game.scene.getParty();
|
||||||
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150;
|
const playerPokemon1 = playerParty[0];
|
||||||
game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150;
|
const playerPokemon2 = playerParty[1];
|
||||||
|
const enemyPokemon1 = game.scene.currentBattle.enemyParty[0];
|
||||||
|
const enemyPokemon2 = game.scene.currentBattle.enemyParty[1];
|
||||||
|
playerPokemon1.stats[Stat.SPD] = 50;
|
||||||
|
playerPokemon2.stats[Stat.SPD] = 50;
|
||||||
|
enemyPokemon1.stats[Stat.SPD] = 150;
|
||||||
|
enemyPokemon2.stats[Stat.SPD] = 150;
|
||||||
|
|
||||||
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
||||||
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
||||||
@ -115,12 +128,17 @@ describe("Battle order", () => {
|
|||||||
handler.processInput(Button.ACTION);
|
handler.processInput(Button.ACTION);
|
||||||
});
|
});
|
||||||
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
|
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
|
||||||
|
|
||||||
|
const pp1Index = playerPokemon1?.getBattlerIndex();
|
||||||
|
const pp2Index = playerPokemon2?.getBattlerIndex();
|
||||||
|
const ep1Index = enemyPokemon1?.getBattlerIndex();
|
||||||
|
const ep2Index = enemyPokemon2?.getBattlerIndex();
|
||||||
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
||||||
const order = phase.getCommandOrder();
|
const order = phase.getCommandOrder();
|
||||||
expect(order.indexOf(0)).toBeGreaterThan(order.indexOf(2));
|
expect(order.slice(0,2).includes(ep1Index)).toBe(true);
|
||||||
expect(order.indexOf(0)).toBeGreaterThan(order.indexOf(3));
|
expect(order.slice(0,2).includes(ep2Index)).toBe(true);
|
||||||
expect(order.indexOf(1)).toBeGreaterThan(order.indexOf(2));
|
expect(order.slice(2,4).includes(pp1Index)).toBe(true);
|
||||||
expect(order.indexOf(1)).toBeGreaterThan(order.indexOf(3));
|
expect(order.slice(2,4).includes(pp2Index)).toBe(true);
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
it("double - speed tie except 1 - 100/100 vs 100/150", async() => {
|
it("double - speed tie except 1 - 100/100 vs 100/150", async() => {
|
||||||
@ -129,10 +147,15 @@ describe("Battle order", () => {
|
|||||||
Species.BULBASAUR,
|
Species.BULBASAUR,
|
||||||
Species.BLASTOISE,
|
Species.BLASTOISE,
|
||||||
]);
|
]);
|
||||||
game.scene.getParty()[0].stats[Stat.SPD] = 100;
|
const playerParty = game.scene.getParty();
|
||||||
game.scene.getParty()[1].stats[Stat.SPD] = 100;
|
const playerPokemon1 = playerParty[0];
|
||||||
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 100;
|
const playerPokemon2 = playerParty[1];
|
||||||
game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150;
|
const enemyPokemon1 = game.scene.currentBattle.enemyParty[0];
|
||||||
|
const enemyPokemon2 = game.scene.currentBattle.enemyParty[1];
|
||||||
|
playerPokemon1.stats[Stat.SPD] = 100;
|
||||||
|
playerPokemon2.stats[Stat.SPD] = 100;
|
||||||
|
enemyPokemon1.stats[Stat.SPD] = 100;
|
||||||
|
enemyPokemon2.stats[Stat.SPD] = 150;
|
||||||
|
|
||||||
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
||||||
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
||||||
@ -157,11 +180,17 @@ describe("Battle order", () => {
|
|||||||
handler.processInput(Button.ACTION);
|
handler.processInput(Button.ACTION);
|
||||||
});
|
});
|
||||||
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
|
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
|
||||||
|
|
||||||
|
const pp1Index = playerPokemon1?.getBattlerIndex();
|
||||||
|
const pp2Index = playerPokemon2?.getBattlerIndex();
|
||||||
|
const ep1Index = enemyPokemon1?.getBattlerIndex();
|
||||||
|
const ep2Index = enemyPokemon2?.getBattlerIndex();
|
||||||
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
||||||
const order = phase.getCommandOrder();
|
const order = phase.getCommandOrder();
|
||||||
expect(order.indexOf(3)).toBeLessThan(order.indexOf(0));
|
expect(order[0]).toBe(ep2Index);
|
||||||
expect(order.indexOf(3)).toBeLessThan(order.indexOf(1));
|
expect(order.slice(1,4).includes(ep1Index)).toBe(true);
|
||||||
expect(order.indexOf(3)).toBeLessThan(order.indexOf(2));
|
expect(order.slice(1,4).includes(pp2Index)).toBe(true);
|
||||||
|
expect(order.slice(1,4).includes(pp1Index)).toBe(true);
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
it("double - speed tie 100/150 vs 100/150", async() => {
|
it("double - speed tie 100/150 vs 100/150", async() => {
|
||||||
@ -170,10 +199,15 @@ describe("Battle order", () => {
|
|||||||
Species.BULBASAUR,
|
Species.BULBASAUR,
|
||||||
Species.BLASTOISE,
|
Species.BLASTOISE,
|
||||||
]);
|
]);
|
||||||
game.scene.getParty()[0].stats[Stat.SPD] = 100;
|
const playerParty = game.scene.getParty();
|
||||||
game.scene.getParty()[1].stats[Stat.SPD] = 150;
|
const playerPokemon1 = playerParty[0];
|
||||||
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 100;
|
const playerPokemon2 = playerParty[1];
|
||||||
game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150;
|
const enemyPokemon1 = game.scene.currentBattle.enemyParty[0];
|
||||||
|
const enemyPokemon2 = game.scene.currentBattle.enemyParty[1];
|
||||||
|
playerPokemon1.stats[Stat.SPD] = 100;
|
||||||
|
playerPokemon2.stats[Stat.SPD] = 150;
|
||||||
|
enemyPokemon1.stats[Stat.SPD] = 100;
|
||||||
|
enemyPokemon2.stats[Stat.SPD] = 150;
|
||||||
|
|
||||||
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
||||||
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
||||||
@ -198,11 +232,16 @@ describe("Battle order", () => {
|
|||||||
handler.processInput(Button.ACTION);
|
handler.processInput(Button.ACTION);
|
||||||
});
|
});
|
||||||
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
|
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
|
||||||
|
|
||||||
|
const pp1Index = playerPokemon1?.getBattlerIndex();
|
||||||
|
const pp2Index = playerPokemon2?.getBattlerIndex();
|
||||||
|
const ep1Index = enemyPokemon1?.getBattlerIndex();
|
||||||
|
const ep2Index = enemyPokemon2?.getBattlerIndex();
|
||||||
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
|
||||||
const order = phase.getCommandOrder();
|
const order = phase.getCommandOrder();
|
||||||
expect(order.indexOf(1)).toBeLessThan(order.indexOf(0));
|
expect(order.slice(0,2).includes(pp2Index)).toBe(true);
|
||||||
expect(order.indexOf(1)).toBeLessThan(order.indexOf(2));
|
expect(order.slice(0,2).includes(ep2Index)).toBe(true);
|
||||||
expect(order.indexOf(3)).toBeLessThan(order.indexOf(0));
|
expect(order.slice(2,4).includes(ep1Index)).toBe(true);
|
||||||
expect(order.indexOf(3)).toBeLessThan(order.indexOf(2));
|
expect(order.slice(2,4).includes(pp1Index)).toBe(true);
|
||||||
}, 20000);
|
}, 20000);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user