[Test] Add test for final boss fight phase switch (#3847)
* implement test for final boss encounter phase switch * Update Eternatus tests & helper function * fix endless_boss test following GameManager update --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
14e0c66ed9
commit
dcb03f4ee9
|
@ -32,7 +32,7 @@ describe("Endless Boss", () => {
|
||||||
|
|
||||||
it(`should spawn a minor boss every ${EndlessBossWave.Minor} waves in END biome in Endless`, async () => {
|
it(`should spawn a minor boss every ${EndlessBossWave.Minor} waves in END biome in Endless`, async () => {
|
||||||
game.override.startingWave(EndlessBossWave.Minor);
|
game.override.startingWave(EndlessBossWave.Minor);
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.ENDLESS);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.ENDLESS);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Minor);
|
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Minor);
|
||||||
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
||||||
|
@ -44,7 +44,7 @@ describe("Endless Boss", () => {
|
||||||
|
|
||||||
it(`should spawn a major boss every ${EndlessBossWave.Major} waves in END biome in Endless`, async () => {
|
it(`should spawn a major boss every ${EndlessBossWave.Major} waves in END biome in Endless`, async () => {
|
||||||
game.override.startingWave(EndlessBossWave.Major);
|
game.override.startingWave(EndlessBossWave.Major);
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.ENDLESS);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.ENDLESS);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Major);
|
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Major);
|
||||||
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
||||||
|
@ -56,7 +56,7 @@ describe("Endless Boss", () => {
|
||||||
|
|
||||||
it(`should spawn a minor boss every ${EndlessBossWave.Minor} waves in END biome in Spliced Endless`, async () => {
|
it(`should spawn a minor boss every ${EndlessBossWave.Minor} waves in END biome in Spliced Endless`, async () => {
|
||||||
game.override.startingWave(EndlessBossWave.Minor);
|
game.override.startingWave(EndlessBossWave.Minor);
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.SPLICED_ENDLESS);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.SPLICED_ENDLESS);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Minor);
|
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Minor);
|
||||||
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
||||||
|
@ -68,7 +68,7 @@ describe("Endless Boss", () => {
|
||||||
|
|
||||||
it(`should spawn a major boss every ${EndlessBossWave.Major} waves in END biome in Spliced Endless`, async () => {
|
it(`should spawn a major boss every ${EndlessBossWave.Major} waves in END biome in Spliced Endless`, async () => {
|
||||||
game.override.startingWave(EndlessBossWave.Major);
|
game.override.startingWave(EndlessBossWave.Major);
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.SPLICED_ENDLESS);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.SPLICED_ENDLESS);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Major);
|
expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Major);
|
||||||
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
||||||
|
@ -80,7 +80,7 @@ describe("Endless Boss", () => {
|
||||||
|
|
||||||
it(`should NOT spawn major or minor boss outside wave ${EndlessBossWave.Minor}s in END biome`, async () => {
|
it(`should NOT spawn major or minor boss outside wave ${EndlessBossWave.Minor}s in END biome`, async () => {
|
||||||
game.override.startingWave(EndlessBossWave.Minor - 1);
|
game.override.startingWave(EndlessBossWave.Minor - 1);
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.ENDLESS);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.ENDLESS);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).not.toBe(EndlessBossWave.Minor);
|
expect(game.scene.currentBattle.waveIndex).not.toBe(EndlessBossWave.Minor);
|
||||||
expect(game.scene.getEnemyPokemon()!.species.speciesId).not.toBe(Species.ETERNATUS);
|
expect(game.scene.getEnemyPokemon()!.species.speciesId).not.toBe(Species.ETERNATUS);
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
|
import { StatusEffect } from "#app/data/status-effect";
|
||||||
|
import { Abilities } from "#app/enums/abilities";
|
||||||
import { Biome } from "#app/enums/biome";
|
import { Biome } from "#app/enums/biome";
|
||||||
|
import { Moves } from "#app/enums/moves";
|
||||||
import { Species } from "#app/enums/species";
|
import { Species } from "#app/enums/species";
|
||||||
import { GameModes } from "#app/game-mode";
|
import { GameModes } from "#app/game-mode";
|
||||||
|
import { TurnHeldItemTransferModifier } from "#app/modifier/modifier";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
import GameManager from "./utils/gameManager";
|
import GameManager from "./utils/gameManager";
|
||||||
|
import { SPLASH_ONLY } from "./utils/testUtils";
|
||||||
|
|
||||||
const FinalWave = {
|
const FinalWave = {
|
||||||
Classic: 200,
|
Classic: 200,
|
||||||
|
@ -20,7 +25,13 @@ describe("Final Boss", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.override.startingWave(FinalWave.Classic).startingBiome(Biome.END).disableCrits();
|
game.override
|
||||||
|
.startingWave(FinalWave.Classic)
|
||||||
|
.startingBiome(Biome.END)
|
||||||
|
.disableCrits()
|
||||||
|
.enemyMoveset(SPLASH_ONLY)
|
||||||
|
.moveset([ Moves.SPLASH, Moves.WILL_O_WISP, Moves.DRAGON_PULSE ])
|
||||||
|
.startingLevel(10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -28,7 +39,7 @@ describe("Final Boss", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should spawn Eternatus on wave 200 in END biome", async () => {
|
it("should spawn Eternatus on wave 200 in END biome", async () => {
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.CLASSIC);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).toBe(FinalWave.Classic);
|
expect(game.scene.currentBattle.waveIndex).toBe(FinalWave.Classic);
|
||||||
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
||||||
|
@ -37,7 +48,7 @@ describe("Final Boss", () => {
|
||||||
|
|
||||||
it("should NOT spawn Eternatus before wave 200 in END biome", async () => {
|
it("should NOT spawn Eternatus before wave 200 in END biome", async () => {
|
||||||
game.override.startingWave(FinalWave.Classic - 1);
|
game.override.startingWave(FinalWave.Classic - 1);
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.CLASSIC);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).not.toBe(FinalWave.Classic);
|
expect(game.scene.currentBattle.waveIndex).not.toBe(FinalWave.Classic);
|
||||||
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
expect(game.scene.arena.biomeType).toBe(Biome.END);
|
||||||
|
@ -46,7 +57,7 @@ describe("Final Boss", () => {
|
||||||
|
|
||||||
it("should NOT spawn Eternatus outside of END biome", async () => {
|
it("should NOT spawn Eternatus outside of END biome", async () => {
|
||||||
game.override.startingBiome(Biome.FOREST);
|
game.override.startingBiome(Biome.FOREST);
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.CLASSIC);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC);
|
||||||
|
|
||||||
expect(game.scene.currentBattle.waveIndex).toBe(FinalWave.Classic);
|
expect(game.scene.currentBattle.waveIndex).toBe(FinalWave.Classic);
|
||||||
expect(game.scene.arena.biomeType).not.toBe(Biome.END);
|
expect(game.scene.arena.biomeType).not.toBe(Biome.END);
|
||||||
|
@ -54,12 +65,81 @@ describe("Final Boss", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not have passive enabled on Eternatus", async () => {
|
it("should not have passive enabled on Eternatus", async () => {
|
||||||
await game.runToFinalBossEncounter(game, [Species.BIDOOF], GameModes.CLASSIC);
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC);
|
||||||
|
|
||||||
const eternatus = game.scene.getEnemyPokemon();
|
const eternatus = game.scene.getEnemyPokemon()!;
|
||||||
expect(eternatus?.species.speciesId).toBe(Species.ETERNATUS);
|
expect(eternatus.species.speciesId).toBe(Species.ETERNATUS);
|
||||||
expect(eternatus?.hasPassive()).toBe(false);
|
expect(eternatus.hasPassive()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should change form on direct hit down to last boss fragment", async () => {
|
||||||
|
await game.runToFinalBossEncounter([Species.KYUREM], GameModes.CLASSIC);
|
||||||
|
await game.phaseInterceptor.to("CommandPhase");
|
||||||
|
|
||||||
|
// Eternatus phase 1
|
||||||
|
const eternatus = game.scene.getEnemyPokemon()!;
|
||||||
|
const phase1Hp = eternatus.getMaxHp();
|
||||||
|
expect(eternatus.species.speciesId).toBe(Species.ETERNATUS);
|
||||||
|
expect(eternatus.formIndex).toBe(0);
|
||||||
|
expect(eternatus.bossSegments).toBe(4);
|
||||||
|
expect(eternatus.bossSegmentIndex).toBe(3);
|
||||||
|
|
||||||
|
game.move.select(Moves.DRAGON_PULSE);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
// Eternatus phase 2: changed form, healed and restored its shields
|
||||||
|
expect(eternatus.species.speciesId).toBe(Species.ETERNATUS);
|
||||||
|
expect(eternatus.hp).toBeGreaterThan(phase1Hp);
|
||||||
|
expect(eternatus.hp).toBe(eternatus.getMaxHp());
|
||||||
|
expect(eternatus.formIndex).toBe(1);
|
||||||
|
expect(eternatus.bossSegments).toBe(5);
|
||||||
|
expect(eternatus.bossSegmentIndex).toBe(4);
|
||||||
|
const miniBlackHole = eternatus.getHeldItems().find(m => m instanceof TurnHeldItemTransferModifier);
|
||||||
|
expect(miniBlackHole).toBeDefined();
|
||||||
|
expect(miniBlackHole?.stackCount).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should change form on status damage down to last boss fragment", async () => {
|
||||||
|
game.override.ability(Abilities.NO_GUARD);
|
||||||
|
|
||||||
|
await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC);
|
||||||
|
await game.phaseInterceptor.to("CommandPhase");
|
||||||
|
|
||||||
|
// Eternatus phase 1
|
||||||
|
const eternatus = game.scene.getEnemyPokemon()!;
|
||||||
|
const phase1Hp = eternatus.getMaxHp();
|
||||||
|
expect(eternatus.species.speciesId).toBe(Species.ETERNATUS);
|
||||||
|
expect(eternatus.formIndex).toBe(0);
|
||||||
|
expect(eternatus.bossSegments).toBe(4);
|
||||||
|
expect(eternatus.bossSegmentIndex).toBe(3);
|
||||||
|
|
||||||
|
game.move.select(Moves.WILL_O_WISP);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(eternatus.status?.effect).toBe(StatusEffect.BURN);
|
||||||
|
|
||||||
|
const tickDamage = phase1Hp - eternatus.hp;
|
||||||
|
const lastShieldHp = Math.ceil(phase1Hp / eternatus.bossSegments);
|
||||||
|
// Stall until the burn is one hit away from breaking the last shield
|
||||||
|
while (eternatus.hp - tickDamage > lastShieldHp) {
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(eternatus.bossSegmentIndex).toBe(1);
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
// Eternatus phase 2: changed form, healed and restored its shields
|
||||||
|
expect(eternatus.hp).toBeGreaterThan(phase1Hp);
|
||||||
|
expect(eternatus.hp).toBe(eternatus.getMaxHp());
|
||||||
|
expect(eternatus.status).toBeFalsy();
|
||||||
|
expect(eternatus.formIndex).toBe(1);
|
||||||
|
expect(eternatus.bossSegments).toBe(5);
|
||||||
|
expect(eternatus.bossSegmentIndex).toBe(4);
|
||||||
|
const miniBlackHole = eternatus.getHeldItems().find(m => m instanceof TurnHeldItemTransferModifier);
|
||||||
|
expect(miniBlackHole).toBeDefined();
|
||||||
|
expect(miniBlackHole?.stackCount).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.todo("should change form on direct hit down to last boss fragment", () => {});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
|
||||||
import Trainer from "#app/field/trainer";
|
import Trainer from "#app/field/trainer";
|
||||||
import { GameModes, getGameMode } from "#app/game-mode";
|
import { GameModes, getGameMode } from "#app/game-mode";
|
||||||
import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type";
|
import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type";
|
||||||
|
import overrides from "#app/overrides";
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
import { CommandPhase } from "#app/phases/command-phase";
|
||||||
import { EncounterPhase } from "#app/phases/encounter-phase";
|
import { EncounterPhase } from "#app/phases/encounter-phase";
|
||||||
import { FaintPhase } from "#app/phases/faint-phase";
|
import { FaintPhase } from "#app/phases/faint-phase";
|
||||||
|
@ -148,28 +149,26 @@ export default class GameManager {
|
||||||
* @param species
|
* @param species
|
||||||
* @param mode
|
* @param mode
|
||||||
*/
|
*/
|
||||||
async runToFinalBossEncounter(game: GameManager, species: Species[], mode: GameModes) {
|
async runToFinalBossEncounter(species: Species[], mode: GameModes) {
|
||||||
console.log("===to final boss encounter===");
|
console.log("===to final boss encounter===");
|
||||||
await game.runToTitle();
|
await this.runToTitle();
|
||||||
|
|
||||||
game.onNextPrompt("TitlePhase", Mode.TITLE, () => {
|
this.onNextPrompt("TitlePhase", Mode.TITLE, () => {
|
||||||
game.scene.gameMode = getGameMode(mode);
|
this.scene.gameMode = getGameMode(mode);
|
||||||
const starters = generateStarter(game.scene, species);
|
const starters = generateStarter(this.scene, species);
|
||||||
const selectStarterPhase = new SelectStarterPhase(game.scene);
|
const selectStarterPhase = new SelectStarterPhase(this.scene);
|
||||||
game.scene.pushPhase(new EncounterPhase(game.scene, false));
|
this.scene.pushPhase(new EncounterPhase(this.scene, false));
|
||||||
selectStarterPhase.initBattle(starters);
|
selectStarterPhase.initBattle(starters);
|
||||||
});
|
});
|
||||||
|
|
||||||
game.onNextPrompt("EncounterPhase", Mode.MESSAGE, async () => {
|
// This will consider all battle entry dialog as seens and skip them
|
||||||
// This will skip all entry dialogue (I can't figure out a way to sequentially handle the 8 chained messages via 1 prompt handler)
|
vi.spyOn(this.scene.ui, "shouldSkipDialogue").mockReturnValue(true);
|
||||||
game.setMode(Mode.MESSAGE);
|
|
||||||
const encounterPhase = game.scene.getCurrentPhase() as EncounterPhase;
|
|
||||||
|
|
||||||
// No need to end phase, this will do it for you
|
if (overrides.OPP_HELD_ITEMS_OVERRIDE.length === 0) {
|
||||||
encounterPhase.doEncounterCommon(false);
|
this.removeEnemyHeldItems();
|
||||||
});
|
}
|
||||||
|
|
||||||
await game.phaseInterceptor.to(EncounterPhase, true);
|
await this.phaseInterceptor.to(EncounterPhase);
|
||||||
console.log("===finished run to final boss encounter===");
|
console.log("===finished run to final boss encounter===");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,10 +317,11 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||||
if (i18next.exists(keyOrText) ) {
|
if (i18next.exists(keyOrText) ) {
|
||||||
const i18nKey = keyOrText;
|
const i18nKey = keyOrText;
|
||||||
hasi18n = true;
|
hasi18n = true;
|
||||||
|
|
||||||
text = i18next.t(i18nKey, { context: genderStr }); // override text with translation
|
text = i18next.t(i18nKey, { context: genderStr }); // override text with translation
|
||||||
|
|
||||||
// Skip dialogue if the player has enabled the option and the dialogue has been already seen
|
// Skip dialogue if the player has enabled the option and the dialogue has been already seen
|
||||||
if (battleScene.skipSeenDialogues && battleScene.gameData.getSeenDialogues()[i18nKey] === true) {
|
if (this.shouldSkipDialogue(i18nKey)) {
|
||||||
console.log(`Dialogue ${i18nKey} skipped`);
|
console.log(`Dialogue ${i18nKey} skipped`);
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue