diff --git a/test/abilities/ability-duplication.test.ts b/test/abilities/ability-duplication.test.ts index da572d94466..443a3275e07 100644 --- a/test/abilities/ability-duplication.test.ts +++ b/test/abilities/ability-duplication.test.ts @@ -30,12 +30,13 @@ describe("Ability Duplication", () => { .enemyMoveset(MoveId.SPLASH); }); + // todo: this doesn't really work it("huge power should only be applied once if both normal and passive", async () => { game.override.passiveAbility(AbilityId.HUGE_POWER); await game.classicMode.startBattle([SpeciesId.MAGIKARP]); - const [magikarp] = game.scene.getPlayerField(); + const magikarp = game.field.getPlayerPokemon(); const magikarpAttack = magikarp.getEffectiveStat(Stat.ATK); magikarp.summonData.abilitySuppressed = true; @@ -48,7 +49,7 @@ describe("Ability Duplication", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP]); - const [magikarp] = game.scene.getPlayerField(); + const magikarp = game.field.getPlayerPokemon(); const magikarpAttack = magikarp.getEffectiveStat(Stat.ATK); magikarp.summonData.abilitySuppressed = true; diff --git a/test/abilities/analytic.test.ts b/test/abilities/analytic.test.ts index cf5a501bbc5..aa9eb3135db 100644 --- a/test/abilities/analytic.test.ts +++ b/test/abilities/analytic.test.ts @@ -56,7 +56,7 @@ describe("Abilities - Analytic", () => { game.override.battleStyle("double"); await game.classicMode.startBattle([SpeciesId.GENGAR, SpeciesId.SHUCKLE]); - const [enemy] = game.scene.getEnemyField(); + const enemy = game.field.getEnemyPokemon(); game.move.select(MoveId.TACKLE, 0, BattlerIndex.ENEMY); game.move.select(MoveId.SPLASH, 1); diff --git a/test/abilities/commander.test.ts b/test/abilities/commander.test.ts index d485cab83a2..daf81bdf9f2 100644 --- a/test/abilities/commander.test.ts +++ b/test/abilities/commander.test.ts @@ -5,8 +5,7 @@ import { MoveId } from "#enums/move-id"; import { MoveResult } from "#enums/move-result"; import { PokemonAnimType } from "#enums/pokemon-anim-type"; import { SpeciesId } from "#enums/species-id"; -import type { EffectiveStat } from "#enums/stat"; -import { Stat } from "#enums/stat"; +import { EFFECTIVE_STATS } from "#enums/stat"; import { StatusEffect } from "#enums/status-effect"; import { WeatherType } from "#enums/weather-type"; import { GameManager } from "#test/test-utils/game-manager"; @@ -48,23 +47,24 @@ describe("Abilities - Commander", () => { const [tatsugiri, dondozo] = game.scene.getPlayerField(); - const affectedStats: EffectiveStat[] = [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]; - expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); - expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); - affectedStats.forEach(stat => expect(dondozo.getStatStage(stat)).toBe(2)); - - game.move.select(MoveId.SPLASH, 1); + expect(dondozo).toHaveBattlerTag(BattlerTagType.COMMANDED); + EFFECTIVE_STATS.forEach(stat => { + expect(dondozo).toHaveStatStage(stat, 2); + }); + game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2); expect(game.scene.currentBattle.turnCommands[0]?.skip).toBeTruthy(); // Force both enemies to target the Tatsugiri - await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER); - await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER); + await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER); + await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER); - await game.phaseInterceptor.to("BerryPhase", false); - game.scene.getEnemyField().forEach(enemy => expect(enemy.getLastXMoves(1)[0].result).toBe(MoveResult.MISS)); - expect(tatsugiri.isFullHp()).toBeTruthy(); + await game.toEndOfTurn(); + const [enemy1, enemy2] = game.scene.getEnemyField(); + expect(enemy1).toHaveUsedMove({ move: MoveId.TACKLE, result: MoveResult.MISS }); + expect(enemy2).toHaveUsedMove({ move: MoveId.TACKLE, result: MoveResult.MISS }); + expect(tatsugiri).toHaveFullHp(); }); it("should activate when a Dondozo switches in and cancel the source's move", async () => { @@ -72,7 +72,7 @@ describe("Abilities - Commander", () => { await game.classicMode.startBattle([SpeciesId.TATSUGIRI, SpeciesId.MAGIKARP, SpeciesId.DONDOZO]); - const tatsugiri = game.scene.getPlayerField()[0]; + const [tatsugiri, dondozo] = game.scene.getPlayerField(); game.move.select(MoveId.LIQUIDATION, 0, BattlerIndex.ENEMY); game.doSwitchPokemon(2); @@ -80,12 +80,11 @@ describe("Abilities - Commander", () => { await game.phaseInterceptor.to("MovePhase", false); expect(game.scene.triggerPokemonBattleAnim).toHaveBeenCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); - const dondozo = game.scene.getPlayerField()[1]; expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); await game.phaseInterceptor.to("BerryPhase", false); expect(tatsugiri.getMoveHistory()).toHaveLength(0); - expect(game.scene.getEnemyField()[0].isFullHp()).toBeTruthy(); + expect(game.field.getEnemyPokemon()).toHaveFullHp(); }); it("source should reenter the field when Dondozo faints", async () => { @@ -192,26 +191,24 @@ describe("Abilities - Commander", () => { }); it("should interrupt the source's semi-invulnerability", async () => { - game.override.moveset([MoveId.SPLASH, MoveId.DIVE]).enemyMoveset(MoveId.SPLASH); - await game.classicMode.startBattle([SpeciesId.TATSUGIRI, SpeciesId.MAGIKARP, SpeciesId.DONDOZO]); - const tatsugiri = game.scene.getPlayerField()[0]; + const [tatsugiri, , dondozo] = game.scene.getPlayerParty(); - game.move.select(MoveId.DIVE, 0, BattlerIndex.ENEMY); - game.move.select(MoveId.SPLASH, 1); + game.move.use(MoveId.DIVE, BattlerIndex.PLAYER, BattlerIndex.ENEMY); + game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2); await game.toNextTurn(); - expect(tatsugiri.getTag(BattlerTagType.UNDERWATER)).toBeDefined(); + expect(tatsugiri).toHaveBattlerTag(BattlerTagType.UNDERWATER); + game.doSwitchPokemon(2); - await game.phaseInterceptor.to("MovePhase", false); - const dondozo = game.scene.getPlayerField()[1]; - expect(tatsugiri.getTag(BattlerTagType.UNDERWATER)).toBeUndefined(); - expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); - await game.toNextTurn(); - const enemy = game.scene.getEnemyField()[0]; - expect(enemy.isFullHp()).toBeTruthy(); + expect(tatsugiri).not.toHaveBattlerTag(BattlerTagType.UNDERWATER); + expect(dondozo).toHaveBattlerTag(BattlerTagType.COMMANDED); + + await game.toEndOfTurn(); + + expect(game.field.getEnemyPokemon()).toHaveFullHp(); }); }); diff --git a/test/abilities/dancer.test.ts b/test/abilities/dancer.test.ts index c651a341c42..e640e326d58 100644 --- a/test/abilities/dancer.test.ts +++ b/test/abilities/dancer.test.ts @@ -74,8 +74,8 @@ describe("Abilities - Dancer", () => { .enemyLevel(10); await game.classicMode.startBattle([SpeciesId.ORICORIO, SpeciesId.FEEBAS]); - const [oricorio] = game.scene.getPlayerField(); - const [, shuckle2] = game.scene.getEnemyField(); + const oricorio = game.field.getPlayerPokemon(); + const shuckle2 = game.scene.getEnemyField()[1]; game.move.select(MoveId.REVELATION_DANCE, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2); game.move.select(MoveId.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2); diff --git a/test/abilities/flower-gift.test.ts b/test/abilities/flower-gift.test.ts index 01459cd4e1e..11a6ab92eaa 100644 --- a/test/abilities/flower-gift.test.ts +++ b/test/abilities/flower-gift.test.ts @@ -58,12 +58,12 @@ describe("Abilities - Flower Gift", () => { const ally_target = allyAttacker ? BattlerIndex.ENEMY : null; await game.classicMode.startBattle([SpeciesId.CHERRIM, SpeciesId.MAGIKARP]); - const target = allyAttacker ? game.scene.getEnemyField()[0] : game.scene.getPlayerField()[1]; + const target = allyAttacker ? game.field.getEnemyPokemon() : game.scene.getPlayerField()[1]; const initialHp = target.getMaxHp(); // Override the ability for the target and attacker only vi.spyOn(game.scene.getPlayerField()[1], "getAbility").mockReturnValue(allAbilities[allyAbility]); - vi.spyOn(game.scene.getEnemyField()[0], "getAbility").mockReturnValue(allAbilities[enemyAbility]); + vi.spyOn(game.field.getEnemyPokemon(), "getAbility").mockReturnValue(allAbilities[enemyAbility]); // turn 1 game.move.select(MoveId.SUNNY_DAY, 0); diff --git a/test/abilities/flower-veil.test.ts b/test/abilities/flower-veil.test.ts index 44274d86a1b..ec34f696bc9 100644 --- a/test/abilities/flower-veil.test.ts +++ b/test/abilities/flower-veil.test.ts @@ -66,7 +66,7 @@ describe("Abilities - Flower Veil", () => { await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.BULBASAUR]); // Clear the ability of the ally to isolate the test - const ally = game.scene.getPlayerField()[1]!; + const ally = game.scene.getPlayerField()[1]; vi.spyOn(ally, "getAbility").mockReturnValue(allAbilities[AbilityId.BALL_FETCH]); game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH); diff --git a/test/abilities/forecast.test.ts b/test/abilities/forecast.test.ts index 87d1d20acdb..9bd40709a94 100644 --- a/test/abilities/forecast.test.ts +++ b/test/abilities/forecast.test.ts @@ -76,7 +76,7 @@ describe("Abilities - Forecast", () => { vi.spyOn(game.scene.getPlayerParty()[5], "getAbility").mockReturnValue(allAbilities[AbilityId.CLOUD_NINE]); - const castform = game.scene.getPlayerField()[0]; + const castform = game.field.getPlayerPokemon(); expect(castform.formIndex).toBe(NORMAL_FORM); game.move.select(MoveId.RAIN_DANCE); diff --git a/test/abilities/friend-guard.test.ts b/test/abilities/friend-guard.test.ts index 32f4fe06df4..bc230db7e44 100644 --- a/test/abilities/friend-guard.test.ts +++ b/test/abilities/friend-guard.test.ts @@ -38,7 +38,7 @@ describe("Moves - Friend Guard", () => { const [player1, player2] = game.scene.getPlayerField(); const spy = vi.spyOn(player1, "getAttackDamage"); - const enemy1 = game.scene.getEnemyField()[0]; + const enemy1 = game.field.getEnemyPokemon(); game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH, 1); diff --git a/test/abilities/magic-bounce.test.ts b/test/abilities/magic-bounce.test.ts index c15690c3f5d..6b7bc7453ed 100644 --- a/test/abilities/magic-bounce.test.ts +++ b/test/abilities/magic-bounce.test.ts @@ -64,7 +64,7 @@ describe("Abilities - Magic Bounce", () => { game.move.use(MoveId.SPLASH, 1); await game.phaseInterceptor.to("BerryPhase"); - const user = game.scene.getPlayerField()[0]; + const user = game.field.getPlayerPokemon(); expect(user.getStatStage(Stat.ATK)).toBe(-2); }); diff --git a/test/abilities/mirror-armor.test.ts b/test/abilities/mirror-armor.test.ts index b2bd9be4755..85d821d0683 100644 --- a/test/abilities/mirror-armor.test.ts +++ b/test/abilities/mirror-armor.test.ts @@ -92,8 +92,7 @@ describe("Ability - Mirror Armor", () => { game.override.battleStyle("double").enemyAbility(AbilityId.MIRROR_ARMOR).ability(AbilityId.INTIMIDATE); await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER]); - const [enemy1, enemy2] = game.scene.getEnemyField(); - const [player1, player2] = game.scene.getPlayerField(); + const [player1, player2, enemy1, enemy2] = game.scene.getField(); // Enemy has intimidate, enemy should lose -1 atk game.move.select(MoveId.SPLASH); diff --git a/test/abilities/no-guard.test.ts b/test/abilities/no-guard.test.ts index 9ce12e710e5..9fc308ab9e3 100644 --- a/test/abilities/no-guard.test.ts +++ b/test/abilities/no-guard.test.ts @@ -58,6 +58,6 @@ describe("Abilities - No Guard", () => { await game.classicMode.startBattle(); - expect(game.scene.getEnemyField().length).toBe(2); + expect(game.scene.getEnemyField()).toHaveLength(2); }); }); diff --git a/test/abilities/storm-drain.test.ts b/test/abilities/storm-drain.test.ts index bc4d4f15cfa..5439459b1dd 100644 --- a/test/abilities/storm-drain.test.ts +++ b/test/abilities/storm-drain.test.ts @@ -37,9 +37,7 @@ describe("Abilities - Storm Drain", () => { it("should redirect water type moves", async () => { await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.MAGIKARP]); - const enemy1 = game.scene.getEnemyField()[0]; - const enemy2 = game.scene.getEnemyField()[1]; - + const [enemy1, enemy2] = game.scene.getEnemyField(); game.field.mockAbility(enemy2, AbilityId.STORM_DRAIN); game.move.select(MoveId.WATER_GUN, BattlerIndex.PLAYER, BattlerIndex.ENEMY); @@ -53,8 +51,7 @@ describe("Abilities - Storm Drain", () => { game.override.moveset([MoveId.SPLASH, MoveId.AERIAL_ACE]); await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.MAGIKARP]); - const enemy1 = game.scene.getEnemyField()[0]; - const enemy2 = game.scene.getEnemyField()[1]; + const [enemy1, enemy2] = game.scene.getEnemyField(); game.field.mockAbility(enemy2, AbilityId.STORM_DRAIN); @@ -83,8 +80,7 @@ describe("Abilities - Storm Drain", () => { game.override.ability(AbilityId.NORMALIZE); await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.MAGIKARP]); - const enemy1 = game.scene.getEnemyField()[0]; - const enemy2 = game.scene.getEnemyField()[1]; + const [enemy1, enemy2] = game.scene.getEnemyField(); game.field.mockAbility(enemy2, AbilityId.STORM_DRAIN); game.move.select(MoveId.WATER_GUN, BattlerIndex.PLAYER, BattlerIndex.ENEMY); @@ -98,8 +94,7 @@ describe("Abilities - Storm Drain", () => { game.override.ability(AbilityId.LIQUID_VOICE); await game.classicMode.startBattle([SpeciesId.FEEBAS]); - const enemy1 = game.scene.getEnemyField()[0]; - const enemy2 = game.scene.getEnemyField()[1]; + const [enemy1, enemy2] = game.scene.getEnemyField(); game.field.mockAbility(enemy2, AbilityId.STORM_DRAIN); diff --git a/test/abilities/unburden.test.ts b/test/abilities/unburden.test.ts index c10dd404ab9..285ea8af32c 100644 --- a/test/abilities/unburden.test.ts +++ b/test/abilities/unburden.test.ts @@ -362,7 +362,7 @@ describe("Abilities - Unburden", () => { .startingHeldItems([{ name: "WIDE_LENS" }]); await game.classicMode.startBattle([SpeciesId.TREECKO, SpeciesId.FEEBAS, SpeciesId.MILOTIC]); - const treecko = game.scene.getPlayerField()[0]; + const treecko = game.field.getPlayerPokemon(); const treeckoInitialHeldItems = getHeldItemCount(treecko); const initialSpeed = treecko.getStat(Stat.SPD); @@ -374,7 +374,7 @@ describe("Abilities - Unburden", () => { game.doSelectPartyPokemon(0, "RevivalBlessingPhase"); await game.toNextTurn(); - expect(game.scene.getPlayerField()[0]).toBe(treecko); + expect(game.field.getPlayerPokemon()).toBe(treecko); expect(getHeldItemCount(treecko)).toBeLessThan(treeckoInitialHeldItems); expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialSpeed); }); diff --git a/test/escape-calculations.test.ts b/test/escape-calculations.test.ts index f1bb955582a..6ff83fb613c 100644 --- a/test/escape-calculations.test.ts +++ b/test/escape-calculations.test.ts @@ -7,6 +7,7 @@ import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +// TODO: These tests are stupid and need to be redone describe("Escape chance calculations", () => { let phaserGame: Phaser.Game; let game: GameManager; diff --git a/test/items/double-battle-chance-booster.test.ts b/test/items/double-battle-chance-booster.test.ts index 9985d4b3a55..01bf6d30227 100644 --- a/test/items/double-battle-chance-booster.test.ts +++ b/test/items/double-battle-chance-booster.test.ts @@ -31,7 +31,7 @@ describe("Items - Double Battle Chance Boosters", () => { await game.classicMode.startBattle(); - expect(game.scene.getEnemyField().length).toBe(2); + expect(game.scene.getEnemyField()).toHaveLength(2); }); it("should guarantee double boss battle with 3 unique tiers", async () => { @@ -41,7 +41,7 @@ describe("Items - Double Battle Chance Boosters", () => { const enemyField = game.scene.getEnemyField(); - expect(enemyField.length).toBe(2); + expect(enemyField).toHaveLength(2); expect(enemyField[0].isBoss()).toBe(true); expect(enemyField[1].isBoss()).toBe(true); }); diff --git a/test/items/grip-claw.test.ts b/test/items/grip-claw.test.ts index 5ffebd76946..54a40942beb 100644 --- a/test/items/grip-claw.test.ts +++ b/test/items/grip-claw.test.ts @@ -44,7 +44,7 @@ describe("Items - Grip Claw", () => { it("should steal items on contact and only from the attack target", async () => { await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.MILOTIC]); - const [playerPokemon] = game.scene.getPlayerField(); + const playerPokemon = game.field.getPlayerPokemon(); const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier; vi.spyOn(gripClaw, "chance", "get").mockReturnValue(100); @@ -73,7 +73,7 @@ describe("Items - Grip Claw", () => { it("should not steal items when using a targetted, non attack move", async () => { await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.MILOTIC]); - const [playerPokemon] = game.scene.getPlayerField(); + const playerPokemon = game.field.getPlayerPokemon(); const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier; vi.spyOn(gripClaw, "chance", "get").mockReturnValue(100); diff --git a/test/items/multi-lens.test.ts b/test/items/multi-lens.test.ts index b69a07033c9..3686aff0fcf 100644 --- a/test/items/multi-lens.test.ts +++ b/test/items/multi-lens.test.ts @@ -103,7 +103,7 @@ describe("Items - Multi Lens", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]); - const [magikarp] = game.scene.getPlayerField(); + const magikarp = game.field.getPlayerPokemon(); game.move.select(MoveId.SWIFT, 0); game.move.select(MoveId.SPLASH, 1); diff --git a/test/moves/ability-ignore-moves.test.ts b/test/moves/ability-ignore-moves.test.ts index e3a7c7db12f..089af242f87 100644 --- a/test/moves/ability-ignore-moves.test.ts +++ b/test/moves/ability-ignore-moves.test.ts @@ -102,7 +102,7 @@ describe("Moves - Ability-Ignoring Moves", () => { // Both the initial and redirected instruct use ignored sturdy const [enemy1, enemy2] = game.scene.getEnemyField(); - expect(enemy1.isFainted()).toBe(true); - expect(enemy2.isFainted()).toBe(true); + expect(enemy1).toHaveFainted(); + expect(enemy2).toHaveFainted(); }); }); diff --git a/test/moves/defog.test.ts b/test/moves/defog.test.ts index 820dfaa6bcb..4ddb397ee71 100644 --- a/test/moves/defog.test.ts +++ b/test/moves/defog.test.ts @@ -1,4 +1,5 @@ import { AbilityId } from "#enums/ability-id"; +import { ArenaTagType } from "#enums/arena-tag-type"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; @@ -32,26 +33,21 @@ describe("Moves - Defog", () => { .enemyMoveset([MoveId.DEFOG, MoveId.GROWL]); }); + // TODO: Refactor these tests they suck ass it("should not allow Safeguard to be active", async () => { await game.classicMode.startBattle([SpeciesId.REGIELEKI]); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + game.scene.arena.addTag(ArenaTagType.SAFEGUARD, 0, 0, 0); - game.move.select(MoveId.SAFEGUARD); - await game.move.selectEnemyMove(MoveId.DEFOG); - await game.phaseInterceptor.to("BerryPhase"); + game.move.use(MoveId.DEFOG); + await game.toEndOfTurn(); - expect(playerPokemon[0].isSafeguarded(enemyPokemon[0])).toBe(false); - - expect(true).toBe(true); + expect(game).not.toHaveArenaTag(ArenaTagType.SAFEGUARD); }); it("should not allow Mist to be active", async () => { await game.classicMode.startBattle([SpeciesId.REGIELEKI]); - const playerPokemon = game.scene.getPlayerField(); - game.move.select(MoveId.MIST); await game.move.selectEnemyMove(MoveId.DEFOG); @@ -62,8 +58,6 @@ describe("Moves - Defog", () => { await game.phaseInterceptor.to("BerryPhase"); - expect(playerPokemon[0].getStatStage(Stat.ATK)).toBe(-1); - - expect(true).toBe(true); + expect(game.field.getPlayerPokemon()).toHaveStatStage(Stat.ATK, -1); }); }); diff --git a/test/moves/destiny-bond.test.ts b/test/moves/destiny-bond.test.ts index 118a45e7682..510ad489156 100644 --- a/test/moves/destiny-bond.test.ts +++ b/test/moves/destiny-bond.test.ts @@ -160,11 +160,7 @@ describe("Moves - Destiny Bond", () => { game.override.moveset([MoveId.DESTINY_BOND, MoveId.CRUNCH]).battleStyle("double"); await game.classicMode.startBattle([SpeciesId.SHEDINJA, SpeciesId.BULBASAUR, SpeciesId.SQUIRTLE]); - const enemyPokemon0 = game.scene.getEnemyField()[0]; - const enemyPokemon1 = game.scene.getEnemyField()[1]; - const playerPokemon0 = game.scene.getPlayerField()[0]; - const playerPokemon1 = game.scene.getPlayerField()[1]; - + const [enemyPokemon0, enemyPokemon1, playerPokemon0, playerPokemon1] = game.scene.getField(); // Shedinja uses Destiny Bond, then ally Bulbasaur KO's Shedinja with Crunch game.move.select(MoveId.DESTINY_BOND, 0); game.move.select(MoveId.CRUNCH, 1, BattlerIndex.PLAYER); diff --git a/test/moves/dragon-tail.test.ts b/test/moves/dragon-tail.test.ts index e3a5bf459e8..28266465523 100644 --- a/test/moves/dragon-tail.test.ts +++ b/test/moves/dragon-tail.test.ts @@ -171,7 +171,7 @@ describe("Moves - Dragon Tail", () => { const enemy = game.field.getEnemyPokemon(); expect(enemy).toBeDefined(); expect(enemy.hp).toBe(Math.floor(enemy.getMaxHp() / 2)); - expect(game.scene.getEnemyField().length).toBe(1); + expect(game.scene.getEnemyField()).toHaveLength(1); }); it("should not cause a softlock when activating a player's reviver seed", async () => { diff --git a/test/moves/fell-stinger.test.ts b/test/moves/fell-stinger.test.ts index ede70b7af9b..4550cdffa12 100644 --- a/test/moves/fell-stinger.test.ts +++ b/test/moves/fell-stinger.test.ts @@ -107,7 +107,7 @@ describe("Moves - Fell Stinger", () => { await game.classicMode.startBattle([SpeciesId.LEAVANNY]); const leadPokemon = game.field.getPlayerPokemon(); - const leftEnemy = game.scene.getEnemyField()[0]!; + const leftEnemy = game.field.getEnemyPokemon(); // Turn 1: set Salt Cure, enemy splashes and does nothing game.move.select(MoveId.SALT_CURE, 0, leftEnemy.getBattlerIndex()); diff --git a/test/moves/instruct.test.ts b/test/moves/instruct.test.ts index 27318105783..eb3eccff400 100644 --- a/test/moves/instruct.test.ts +++ b/test/moves/instruct.test.ts @@ -498,7 +498,7 @@ describe("Moves - Instruct", () => { .enemyLevel(1); await game.classicMode.startBattle([SpeciesId.KORAIDON, SpeciesId.KLEFKI]); - const koraidon = game.scene.getPlayerField()[0]!; + const koraidon = game.field.getPlayerPokemon(); game.move.select(MoveId.BREAKING_SWIPE); await game.phaseInterceptor.to("TurnEndPhase", false); @@ -527,7 +527,7 @@ describe("Moves - Instruct", () => { .enemyLevel(1); await game.classicMode.startBattle([SpeciesId.KORAIDON, SpeciesId.KLEFKI]); - const koraidon = game.scene.getPlayerField()[0]!; + const koraidon = game.field.getPlayerPokemon(); game.move.select(MoveId.BRUTAL_SWING); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); @@ -587,7 +587,7 @@ describe("Moves - Instruct", () => { .enemyLevel(5); await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.IVYSAUR]); - const [, ivysaur] = game.scene.getPlayerField(); + const ivysaur = game.scene.getPlayerField()[1]; game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER); game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2); diff --git a/test/moves/jaw-lock.test.ts b/test/moves/jaw-lock.test.ts index 441c74c7356..0ea2c0bd8bf 100644 --- a/test/moves/jaw-lock.test.ts +++ b/test/moves/jaw-lock.test.ts @@ -111,7 +111,8 @@ describe("Moves - Jaw Lock", () => { await game.classicMode.startBattle([SpeciesId.CHARMANDER, SpeciesId.BULBASAUR]); - const playerPokemon = game.scene.getPlayerField(); + const playerPokemon = game.field.getPlayerPokemon(); + const enemyPokemon = game.scene.getEnemyField(); game.move.select(MoveId.JAW_LOCK, 0, BattlerIndex.ENEMY); @@ -120,7 +121,7 @@ describe("Moves - Jaw Lock", () => { await game.phaseInterceptor.to(MoveEffectPhase); - expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(playerPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); expect(enemyPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); await game.toNextTurn(); @@ -131,8 +132,8 @@ describe("Moves - Jaw Lock", () => { await game.phaseInterceptor.to(MoveEffectPhase); expect(enemyPokemon[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); - expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)?.sourceId).toBe(enemyPokemon[0].id); + expect(playerPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(playerPokemon.getTag(BattlerTagType.TRAPPED)?.sourceId).toBe(enemyPokemon[0].id); }); it("should not trap either pokemon if the target is protected", async () => { diff --git a/test/moves/tailwind.test.ts b/test/moves/tailwind.test.ts index 5c91a37f786..d9a0bdeb5f1 100644 --- a/test/moves/tailwind.test.ts +++ b/test/moves/tailwind.test.ts @@ -34,8 +34,7 @@ describe("Moves - Tailwind", () => { it("doubles the Speed stat of the Pokemons on its side", async () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MEOWTH]); - const magikarp = game.scene.getPlayerField()[0]; - const meowth = game.scene.getPlayerField()[1]; + const [magikarp, meowth] = game.scene.getPlayerField(); const magikarpSpd = magikarp.getStat(Stat.SPD); const meowthSpd = meowth.getStat(Stat.SPD);