Tweaked battle scene test to not be jank

This commit is contained in:
Bertie690 2025-04-30 13:42:17 -04:00 committed by Bertie690
parent dabc61ace2
commit 0d06fc11fd
3 changed files with 48 additions and 76 deletions

View File

@ -33,16 +33,16 @@ describe("Abilities - Illusion", () => {
.startingHeldItems([{ name: "WIDE_LENS", count: 3 }]);
});
it("creates illusion at the start", async () => {
await game.classicMode.startBattle([Species.ZOROARK, Species.FEEBAS]);
it("creates illusion at battle start", async () => {
await game.classicMode.startBattle([Species.ZOROARK, Species.AXEW]);
const zoroark = game.scene.getPlayerPokemon()!;
const zorua = game.scene.getEnemyPokemon()!;
expect(!!zoroark.summonData.illusion).equals(true);
expect(!!zorua.summonData.illusion).equals(true);
expect(zoroark.summonData.illusion).toBeTruthy();
expect(zorua.summonData.illusion).toBeTruthy();
});
it("break after receiving damaging move", async () => {
it("breaks after receiving damaging move", async () => {
await game.classicMode.startBattle([Species.FEEBAS]);
game.move.select(Moves.TACKLE);
@ -50,11 +50,11 @@ describe("Abilities - Illusion", () => {
const zorua = game.scene.getEnemyPokemon()!;
expect(!!zorua.summonData.illusion).equals(false);
expect(zorua.name).equals("Zorua");
expect(zorua.summonData.illusion).toBeFalsy();
expect(zorua.name).toBe("Zorua");
});
it("break after getting ability changed", async () => {
it("breaks after getting ability changed", async () => {
await game.classicMode.startBattle([Species.FEEBAS]);
game.move.select(Moves.WORRY_SEED);
@ -62,7 +62,7 @@ describe("Abilities - Illusion", () => {
const zorua = game.scene.getEnemyPokemon()!;
expect(!!zorua.summonData.illusion).equals(false);
expect(zorua.summonData.illusion).toBeFalsy();
});
it("breaks with neutralizing gas", async () => {
@ -70,8 +70,7 @@ describe("Abilities - Illusion", () => {
await game.classicMode.startBattle([Species.KOFFING]);
const zorua = game.scene.getEnemyPokemon()!;
expect(!!zorua.summonData.illusion).equals(false);
expect(zorua.summonData.illusion).toBeFalsy();
});
it("does not activate if neutralizing gas is active", async () => {
@ -113,14 +112,15 @@ describe("Abilities - Illusion", () => {
psychic,
true,
);
expect(psychicEffectiveness).above(flameThrowerEffectiveness);
expect(psychicEffectiveness).toBeGreaterThan(flameThrowerEffectiveness);
});
it("does not break from indirect damage", async () => {
game.override.enemySpecies(Species.GIGALITH);
game.override.enemyAbility(Abilities.SAND_STREAM);
game.override.enemyMoveset(Moves.WILL_O_WISP);
game.override.moveset([Moves.FLARE_BLITZ]);
game.override
.enemySpecies(Species.GIGALITH)
.enemyAbility(Abilities.SAND_STREAM)
.enemyMoveset(Moves.WILL_O_WISP)
.moveset(Moves.FLARE_BLITZ);
await game.classicMode.startBattle([Species.ZOROARK, Species.AZUMARILL]);
@ -130,7 +130,7 @@ describe("Abilities - Illusion", () => {
const zoroark = game.scene.getPlayerPokemon()!;
expect(!!zoroark.summonData.illusion).equals(true);
expect(zoroark.summonData.illusion).toBeTruthy();
});
it("copies the the name, nickname, gender, shininess, and pokeball from the illusion source", async () => {
@ -148,11 +148,11 @@ describe("Abilities - Illusion", () => {
const zoroark = game.scene.getPlayerPokemon()!;
expect(zoroark.name).equals("Axew");
expect(zoroark.getNameToRender()).equals("axew nickname");
expect(zoroark.getGender(false, true)).equals(Gender.FEMALE);
expect(zoroark.isShiny(true)).equals(true);
expect(zoroark.getPokeball(true)).equals(PokeballType.GREAT_BALL);
expect(zoroark.name).toBe("Axew");
expect(zoroark.getNameToRender()).toBe("axew nickname");
expect(zoroark.getGender(false, true)).toBe(Gender.FEMALE);
expect(zoroark.isShiny(true)).toBe(true);
expect(zoroark.getPokeball(true)).toBe(PokeballType.GREAT_BALL);
});
it("breaks when suppressed", async () => {
@ -160,12 +160,12 @@ describe("Abilities - Illusion", () => {
await game.classicMode.startBattle([Species.MAGIKARP]);
const zorua = game.scene.getEnemyPokemon()!;
expect(!!zorua.summonData?.illusion).toBe(true);
expect(zorua.summonData.illusion).toBeTruthy();
game.move.select(Moves.GASTRO_ACID);
await game.phaseInterceptor.to("BerryPhase");
expect(zorua.isFullHp()).toBe(true);
expect(!!zorua.summonData?.illusion).toBe(false);
expect(zorua.summonData.illusion).toBeFalsy();
});
});

View File

@ -87,11 +87,9 @@ describe("Battle order", () => {
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getCommandOrder();
expect(order.slice(0, 2).includes(enemyIndices[0])).toBe(true);
expect(order.slice(0, 2).includes(enemyIndices[1])).toBe(true);
expect(order.slice(2, 4).includes(playerIndices[0])).toBe(true);
expect(order.slice(2, 4).includes(playerIndices[1])).toBe(true);
}, 20000);
expect(order.slice(0, 2)).toStrictEqual(expect.arrayContaining(enemyIndices));
expect(order.slice(2, 4)).toStrictEqual(expect.arrayContaining(playerIndices));
});
it("double - speed tie except 1 - 100/100 vs 100/150", async () => {
game.override.battleStyle("double");
@ -111,10 +109,9 @@ describe("Battle order", () => {
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getCommandOrder();
// fastest pokemon goes first, followed by a random slower mon
expect(order[0]).toBe(enemyIndices[1]);
expect(order.slice(1, 4).includes(enemyIndices[0])).toBe(true);
expect(order.slice(1, 4).includes(playerIndices[0])).toBe(true);
expect(order.slice(1, 4).includes(playerIndices[1])).toBe(true);
expect(order.slice(1, 4)).toStrictEqual(expect.arrayContaining([enemyIndices[0], ...playerIndices]));
}, 20000);
it("double - speed tie 100/150 vs 100/150", async () => {
@ -136,9 +133,7 @@ describe("Battle order", () => {
const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getCommandOrder();
expect(order.slice(0, 2).includes(playerIndices[1])).toBe(true);
expect(order.slice(0, 2).includes(enemyIndices[1])).toBe(true);
expect(order.slice(2, 4).includes(playerIndices[0])).toBe(true);
expect(order.slice(2, 4).includes(enemyIndices[0])).toBe(true);
expect(order.slice(0, 2)).toStrictEqual(expect.arrayContaining([playerIndices[1], enemyIndices[1]]));
expect(order.slice(2, 4)).toStrictEqual(expect.arrayContaining([playerIndices[0], enemyIndices[0]]));
}, 20000);
});

View File

@ -202,47 +202,25 @@ describe("Test Battle Phase", () => {
await game.phaseInterceptor.runFrom(SelectGenderPhase).to(SummonPhase);
}, 20000);
it("2vs1", async () => {
game.override.battleStyle("single");
game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.HYDRATION);
await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000);
it.each([
{ name: "1v1", double: false, qty: 1 },
{ name: "2v1", double: false, qty: 2 },
{ name: "2v2", double: true, qty: 2 },
{ name: "4v2", double: true, qty: 4 },
])("should not crash when starting $1 battle", async ({ double, qty }) => {
game.override
.battleStyle(double ? "double" : "single")
.enemySpecies(Species.MIGHTYENA)
.enemyAbility(Abilities.HYDRATION)
.ability(Abilities.HYDRATION);
it("1vs1", async () => {
game.override.battleStyle("single");
game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.HYDRATION);
await game.classicMode.startBattle([Species.BLASTOISE]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000);
await game.classicMode.startBattle(
[Species.BLASTOISE, Species.CHARIZARD, Species.DARKRAI, Species.GABITE].slice(qty),
);
it("2vs2", async () => {
game.override.battleStyle("double");
game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.HYDRATION);
game.override.startingWave(3);
await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000);
it("4vs2", async () => {
game.override.battleStyle("double");
game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.HYDRATION);
game.override.startingWave(3);
await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD, Species.DARKRAI, Species.GABITE]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000);
expect(game.scene.getCurrentPhase()).toBeInstanceOf(CommandPhase.name);
});
it("kill opponent pokemon", async () => {
const moveToUse = Moves.SPLASH;
@ -310,7 +288,6 @@ describe("Test Battle Phase", () => {
const moveToUse = Moves.TAKE_DOWN;
game.override
.battleStyle("single")
.starterSpecies(Species.SAWK)
.enemySpecies(Species.RATTATA)
.startingWave(1)
.startingLevel(100)
@ -318,7 +295,7 @@ describe("Test Battle Phase", () => {
.enemyMoveset(Moves.SPLASH)
.startingHeldItems([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }]);
await game.classicMode.startBattle();
await game.classicMode.startBattle([Species.SAWK]);
game.scene.getPlayerPokemon()!.hp = 1;
game.move.select(moveToUse);