From 6bc469dec41ae0c8977479bab8124a12f9c0f4ca Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Tue, 26 Aug 2025 22:33:16 +0200 Subject: [PATCH 1/4] Some tests for weakening and catching bosses --- test/field/catching.test.ts | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/test/field/catching.test.ts b/test/field/catching.test.ts index 5e732dafe93..69ca58a5dda 100644 --- a/test/field/catching.test.ts +++ b/test/field/catching.test.ts @@ -1,4 +1,5 @@ import { pokerogueApi } from "#api/pokerogue-api"; +import { AbilityId } from "#enums/ability-id"; import { BattleType } from "#enums/battle-type"; import { BiomeId } from "#enums/biome-id"; import { Challenges } from "#enums/challenges"; @@ -297,3 +298,74 @@ describe("Throwing balls at trainers", () => { await runPokeballTest(game, PokeballType.MASTER_BALL, "battle:noPokeballTrainer"); }); }); + +describe("Throwing balls at bosses after weakening them", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .battleType(BattleType.WILD) + .moveset([MoveId.SLASH]) + .enemyMoveset([MoveId.SPLASH]) + .enemyHeldItems([]) + .enemySpecies(SpeciesId.CATERPIE) + .startingLevel(99999) + .startingWave(170); + }); + + it("weakening and catching a single boss", async () => { + game.override.battleStyle("single").enemyAbility(AbilityId.STURDY); + + await game.classicMode.startBattle([SpeciesId.KARTANA]); + + const partyLength = game.scene.getPlayerParty().length; + + const ball = PokeballType.ROGUE_BALL; + game.scene.pokeballCounts[ball] = 1; + + game.move.select(MoveId.SLASH); + await game.toNextTurn(); + + game.doThrowPokeball(ball); + await game.toEndOfTurn(); + + expect(game.scene.getPlayerParty()).toHaveLength(partyLength + 1); + }); + + it("weakening and catching a boss in a double battle", async () => { + game.override.battleStyle("double").enemyAbility(AbilityId.STURDY); + + await game.classicMode.startBattle([SpeciesId.KARTANA]); + + const partyLength = game.scene.getPlayerParty().length; + + const ball = PokeballType.ROGUE_BALL; + game.scene.pokeballCounts[ball] = 1; + + game.move.select(MoveId.SLASH); + await game.toNextTurn(); + + game.move.select(MoveId.SLASH); + await game.toNextTurn(); + + game.move.select(MoveId.SLASH); + await game.toNextTurn(); + + game.doThrowPokeball(ball); + await game.toEndOfTurn(); + + expect(game.scene.getPlayerParty()).toHaveLength(partyLength + 1); + }); +}); From d674aee395f1a3065ea5d2f7b28f6a4c75d48666 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Fri, 5 Sep 2025 22:30:42 -0500 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> --- test/field/catching.test.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/field/catching.test.ts b/test/field/catching.test.ts index 69ca58a5dda..ed8a8f943ba 100644 --- a/test/field/catching.test.ts +++ b/test/field/catching.test.ts @@ -317,17 +317,13 @@ describe("Throwing balls at bosses after weakening them", () => { game = new GameManager(phaserGame); game.override .battleType(BattleType.WILD) - .moveset([MoveId.SLASH]) - .enemyMoveset([MoveId.SPLASH]) - .enemyHeldItems([]) + .enemyMoveset(MoveId.SPLASH) .enemySpecies(SpeciesId.CATERPIE) .startingLevel(99999) .startingWave(170); }); it("weakening and catching a single boss", async () => { - game.override.battleStyle("single").enemyAbility(AbilityId.STURDY); - await game.classicMode.startBattle([SpeciesId.KARTANA]); const partyLength = game.scene.getPlayerParty().length; @@ -335,9 +331,12 @@ describe("Throwing balls at bosses after weakening them", () => { const ball = PokeballType.ROGUE_BALL; game.scene.pokeballCounts[ball] = 1; - game.move.select(MoveId.SLASH); + game.move.use(MoveId.FALSE_SWIPE); await game.toNextTurn(); + const enemy = game.field.getEnemyPokemon(); + expect(enemy.bossSegmentIndex).toBe(0); // last bar + game.doThrowPokeball(ball); await game.toEndOfTurn(); From 75c7e982126413882c193d5c36df998dd2a7e148 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Fri, 5 Sep 2025 22:31:12 -0500 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> --- test/field/catching.test.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/test/field/catching.test.ts b/test/field/catching.test.ts index ed8a8f943ba..c0db556b082 100644 --- a/test/field/catching.test.ts +++ b/test/field/catching.test.ts @@ -319,6 +319,7 @@ describe("Throwing balls at bosses after weakening them", () => { .battleType(BattleType.WILD) .enemyMoveset(MoveId.SPLASH) .enemySpecies(SpeciesId.CATERPIE) + .battleStyle("single") .startingLevel(99999) .startingWave(170); }); @@ -344,8 +345,7 @@ describe("Throwing balls at bosses after weakening them", () => { }); it("weakening and catching a boss in a double battle", async () => { - game.override.battleStyle("double").enemyAbility(AbilityId.STURDY); - + game.override.battleStyle("double"); await game.classicMode.startBattle([SpeciesId.KARTANA]); const partyLength = game.scene.getPlayerParty().length; @@ -353,15 +353,9 @@ describe("Throwing balls at bosses after weakening them", () => { const ball = PokeballType.ROGUE_BALL; game.scene.pokeballCounts[ball] = 1; - game.move.select(MoveId.SLASH); - await game.toNextTurn(); - - game.move.select(MoveId.SLASH); - await game.toNextTurn(); - - game.move.select(MoveId.SLASH); - await game.toNextTurn(); - + // Kill 1 boss, knock other down to critical hp + game.move.use(MoveId.FALSE_SWIPE); + await game.doKillPokemon(game.field.getEnemyField()[1) game.doThrowPokeball(ball); await game.toEndOfTurn(); From bceec50089405f60252eb6b73da01db28baf9d89 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 6 Sep 2025 08:57:32 +0200 Subject: [PATCH 4/4] Fixed test broken by suggestions --- test/field/catching.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/field/catching.test.ts b/test/field/catching.test.ts index c0db556b082..92972f69549 100644 --- a/test/field/catching.test.ts +++ b/test/field/catching.test.ts @@ -1,5 +1,4 @@ import { pokerogueApi } from "#api/pokerogue-api"; -import { AbilityId } from "#enums/ability-id"; import { BattleType } from "#enums/battle-type"; import { BiomeId } from "#enums/biome-id"; import { Challenges } from "#enums/challenges"; @@ -355,7 +354,7 @@ describe("Throwing balls at bosses after weakening them", () => { // Kill 1 boss, knock other down to critical hp game.move.use(MoveId.FALSE_SWIPE); - await game.doKillPokemon(game.field.getEnemyField()[1) + await game.killPokemon(game.scene.getEnemyField()[1]); game.doThrowPokeball(ball); await game.toEndOfTurn();