From 06926a4b2dbe05b2ae69e17dde6e9f0bf0b406a6 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Sat, 28 Dec 2024 22:54:37 -0500 Subject: [PATCH] Update Instruct code + tests to work on spread moves + added more tests ~~Ignore the fact that the tests aren't working lol~~ --- src/battle-scene.ts | 6 + src/data/move.ts | 29 ++-- src/data/status-effect.ts | 2 +- src/field/pokemon.ts | 3 + src/test/abilities/dancer.test.ts | 37 +++++ src/test/moves/instruct.test.ts | 231 ++++++++++++++++++++++----- src/test/utils/helpers/moveHelper.ts | 4 +- 7 files changed, 261 insertions(+), 51 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index c430a12ae3e..e0023ce596a 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -853,6 +853,12 @@ export default class BattleScene extends SceneBase { return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1)); } + /** + * Returns an array of Pokemon on both sides of the battle - player first, then enemy. + * Does not actually check if the pokemon are on the field or not, and always has length 4 regardless of battle type. + * @param activeOnly Whether to consider only active pokemon + * @returns array of {@linkcode Pokemon} + */ public getField(activeOnly: boolean = false): Pokemon[] { const ret = new Array(4).fill(null); const playerField = this.getPlayerField(); diff --git a/src/data/move.ts b/src/data/move.ts index 7a6f08a5372..670f881b85c 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1410,12 +1410,10 @@ export class TargetHalfHpDamageAttr extends FixedDamageAttr { // multi lens added hit; use initialHp tracker to ensure correct damage (args[0] as Utils.NumberHolder).value = Utils.toDmgValue(this.initialHp / 2); return true; - break; case lensCount + 1: // parental bond added hit; calc damage as normal (args[0] as Utils.NumberHolder).value = Utils.toDmgValue(target.hp / 2); return true; - break; } } @@ -6768,7 +6766,11 @@ export class RepeatMoveAttr extends MoveEffectAttr { // get the last move used (excluding status based failures) as well as the corresponding moveset slot const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE)!; const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move)!; - const moveTargets = lastMove.targets ?? []; + // If the last move used can hit more than one target, + // re-compute the targets for the attack + // (mainly for alternating double/single battle shenanigans) + // Rampaging moves (e.g. Outrage) are not included due to being incompatible with Instruct + const moveTargets = movesetMove.getMove().isMultiTarget() ? getMoveTargets(target, lastMove.move).targets : lastMove.targets!; user.scene.queueMessage(i18next.t("moveTriggers:instructingMove", { userPokemonName: getPokemonNameWithAffix(user), @@ -6785,9 +6787,8 @@ export class RepeatMoveAttr extends MoveEffectAttr { // TODO: Confirm behavior of instructing move known by target but called by another move const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE); const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove?.move); - const moveTargets = lastMove?.targets ?? []; // TODO: Add a way of adding moves to list procedurally rather than a pre-defined blacklist - const unrepeatablemoves = [ + const uninstructableMoves = [ // Locking/Continually Executed moves Moves.OUTRAGE, Moves.RAGING_FURY, @@ -6842,11 +6843,11 @@ export class RepeatMoveAttr extends MoveEffectAttr { // TODO: Add Max/G-Move blockage if or when they are implemented ]; - if (!movesetMove // called move not in target's moveset (dancer, forgetting the move, etc.) + if (!lastMove?.move // no move to instruct + || !movesetMove // called move not in target's moveset (dancer, forgetting the move, etc.) || movesetMove.ppUsed === movesetMove.getMovePp() // move out of pp - || allMoves[lastMove?.move ?? Moves.NONE].isChargingMove() // called move is a charging/recharging move - || !moveTargets.length // called move has no targets - || unrepeatablemoves.includes(lastMove?.move ?? Moves.NONE)) { // called move is explicitly in the banlist + || allMoves[lastMove.move].isChargingMove() // called move is a charging/recharging move + || uninstructableMoves.includes(lastMove.move)) { // called move is in the banlist return false; } return true; @@ -6854,7 +6855,7 @@ export class RepeatMoveAttr extends MoveEffectAttr { } getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { - // TODO: Make the AI acutally use instruct + // TODO: Make the AI actually use instruct /* Ideally, the AI would score instruct based on the scorings of the on-field pokemons' * last used moves at the time of using Instruct (by the time the instructor gets to act) * with respect to the user's side. @@ -7895,6 +7896,12 @@ export type MoveTargetSet = { multiple: boolean; }; +/** + * Returns a list of potential targets for a move + * @param user The {@linkcode Pokemon} using the move + * @param move The {@linkcode Moves} being used + * @returns MoveTargetSet containing the applicable targets and whether the move will hit multiple targets + */ export function getMoveTargets(user: Pokemon, move: Moves): MoveTargetSet { const variableTarget = new Utils.NumberHolder(0); user.getOpponents().forEach(p => applyMoveAttrs(VariableTargetAttr, user, p, allMoves[move], variableTarget)); @@ -10030,6 +10037,8 @@ export function initMoves() { .ignoresSubstitute() .attr(RepeatMoveAttr) .edgeCase(), // incorrect interactions with Gigaton Hammer, Blood Moon & Torment + // Also has incorrect interactions with move-calling moves (Mirror Move, Copycat/Mimic, Metronome) + // and Dancer that will need to be cleaned up separately new AttackMove(Moves.BEAK_BLAST, Type.FLYING, MoveCategory.PHYSICAL, 100, 100, 15, -1, -3, 7) .attr(BeakBlastHeaderAttr) .ballBombMove() diff --git a/src/data/status-effect.ts b/src/data/status-effect.ts index 6b4e1d546df..f5ab7def039 100644 --- a/src/data/status-effect.ts +++ b/src/data/status-effect.ts @@ -161,7 +161,7 @@ export function getNonVolatileStatusEffects():Array { } /** - * Returns whether a statuss effect is non volatile. + * Returns whether a status effect is non volatile. * Non-volatile status condition is a status that remains after being switched out. * @param status The status to check */ diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index fcfc2ff7536..fca32934364 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1094,6 +1094,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.getStat(Stat.HP); } + /** + Returns the amount of hp currently missing from this {@linkcode Pokemon} (max - current) + */ getInverseHp(): integer { return this.getMaxHp() - this.hp; } diff --git a/src/test/abilities/dancer.test.ts b/src/test/abilities/dancer.test.ts index 8fa3d444f37..d65202ccc69 100644 --- a/src/test/abilities/dancer.test.ts +++ b/src/test/abilities/dancer.test.ts @@ -60,4 +60,41 @@ describe("Abilities - Dancer", () => { // doesn't use PP if copied move is also in moveset expect(oricorio.moveset[0]?.ppUsed).toBe(0); }); + + // TODO: Enable after move-calling move rework + it.todo("should not count as the last move used for mirror move/instruct", async () => { + game.override + .moveset([ Moves.FIERY_DANCE, Moves.REVELATION_DANCE ]) + .enemyMoveset([ Moves.INSTRUCT, Moves.MIRROR_MOVE, Moves.SPLASH ]) + .enemySpecies(Species.DIALGA) + .enemyLevel(100); + await game.classicMode.startBattle([ Species.ORICORIO, Species.FEEBAS ]); + + const [ oricorio ] = game.scene.getPlayerField(); + const [ , dialga2 ] = game.scene.getEnemyField(); + + game.move.select(Moves.REVELATION_DANCE, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2); + game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2); + await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.MIRROR_MOVE, BattlerIndex.PLAYER); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY ]); + await game.phaseInterceptor.to("MovePhase"); // Oricorio rev dance + await game.phaseInterceptor.to("MovePhase"); // Feebas fiery dance + await game.phaseInterceptor.to("MovePhase"); // Oricorio fiery dance + await game.phaseInterceptor.to("MoveEndPhase", false); + expect(oricorio.getLastXMoves(-1)[0].move).toBe(Moves.REVELATION_DANCE); // dancer copied move doesn't appear in move history + + await game.phaseInterceptor.to("MovePhase"); // dialga 2 mirror moves oricorio + await game.phaseInterceptor.to("MovePhase"); // calls instructed rev dance + let currentPhase = game.scene.getCurrentPhase() as MovePhase; + expect(currentPhase.pokemon).toBe(dialga2); + expect(currentPhase.move.moveId).toBe(Moves.REVELATION_DANCE); + + await game.phaseInterceptor.to("MovePhase"); // dialga 1 instructs oricorio + await game.phaseInterceptor.to("MovePhase"); + currentPhase = game.scene.getCurrentPhase() as MovePhase; + expect(currentPhase.pokemon).toBe(oricorio); + expect(currentPhase.move.moveId).toBe(Moves.REVELATION_DANCE); + + }); }); diff --git a/src/test/moves/instruct.test.ts b/src/test/moves/instruct.test.ts index 0e227ef6a3f..beca1c7484b 100644 --- a/src/test/moves/instruct.test.ts +++ b/src/test/moves/instruct.test.ts @@ -1,6 +1,8 @@ import { BattlerIndex } from "#app/battle"; +import { Button } from "#app/enums/buttons"; import type Pokemon from "#app/field/pokemon"; import { MoveResult } from "#app/field/pokemon"; +import type { MovePhase } from "#app/phases/move-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; @@ -12,10 +14,10 @@ describe("Moves - Instruct", () => { let phaserGame: Phaser.Game; let game: GameManager; - function instructSuccess(pokemon: Pokemon, move: Moves): void { - expect(pokemon.getLastXMoves(-1)[0].move).toBe(move); - expect(pokemon.getLastXMoves(-1)[1].move).toBe(pokemon.getLastXMoves()[0].move); - expect(pokemon.getMoveset().find(m => m?.moveId === move)?.ppUsed).toBe(2); + function instructSuccess(target: Pokemon, move: Moves): void { + expect(target.getLastXMoves(-1)[0].move).toBe(move); + expect(target.getLastXMoves(-1)[1].move).toBe(target.getLastXMoves()[0].move); + expect(target.getMoveset().find(m => m?.moveId === move)?.ppUsed).toBe(2); } beforeAll(() => { @@ -41,7 +43,7 @@ describe("Moves - Instruct", () => { .disableCrits(); }); - it("should repeat enemy's attack move when moving last", async () => { + it("should repeat target's last used move", async () => { await game.classicMode.startBattle([ Species.AMOONGUSS ]); const enemy = game.scene.getEnemyPokemon()!; @@ -50,6 +52,17 @@ describe("Moves - Instruct", () => { game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + + await game.phaseInterceptor.to("MovePhase"); // enemy attacks us + await game.phaseInterceptor.to("MovePhase", false); // instruct + let currentPhase = game.scene.getCurrentPhase() as MovePhase; + expect(currentPhase.pokemon).toBe(game.scene.getPlayerPokemon()); + await game.phaseInterceptor.to("MoveEndPhase"); + + await game.phaseInterceptor.to("MovePhase", false); // enemy repeats move + currentPhase = game.scene.getCurrentPhase() as MovePhase; + expect(currentPhase.pokemon).toBe(enemy); + expect(currentPhase.move.moveId).toBe(Moves.SONIC_BOOM); await game.phaseInterceptor.to("TurnEndPhase", false); expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40); @@ -97,10 +110,9 @@ describe("Moves - Instruct", () => { instructSuccess(shuckle, Moves.SONIC_BOOM); }); - // TODO: Enable test case once gigaton hammer (and blood moon) is fixed + // TODO: Enable test case once gigaton hammer (and blood moon) are reworked it.todo("should repeat enemy's Gigaton Hammer", async () => { - game.override - .enemyLevel(5); + game.override.enemyLevel(5); await game.classicMode.startBattle([ Species.AMOONGUSS ]); const enemy = game.scene.getEnemyPokemon()!; @@ -115,28 +127,42 @@ describe("Moves - Instruct", () => { it("should respect enemy's status condition", async () => { game.override - .moveset([ Moves.THUNDER_WAVE, Moves.INSTRUCT ]) - .enemyMoveset([ Moves.SPLASH, Moves.SONIC_BOOM ]); + .moveset([ Moves.INSTRUCT, Moves.THUNDER_WAVE ]) + .enemyMoveset(Moves.SONIC_BOOM); await game.classicMode.startBattle([ Species.AMOONGUSS ]); game.move.select(Moves.THUNDER_WAVE); - await game.forceEnemyMove(Moves.SONIC_BOOM); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.toNextTurn(); game.move.select(Moves.INSTRUCT); - await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.move.forceStatusActivation(true); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.phaseInterceptor.to("MovePhase"); + await game.move.forceStatusActivation(true); // force enemy's instructed move to bork and then immediately thaw out await game.move.forceStatusActivation(false); await game.phaseInterceptor.to("TurnEndPhase", false); - const moveHistory = game.scene.getEnemyPokemon()!.getMoveHistory(); - expect(moveHistory.length).toBe(3); - expect(moveHistory[0].move).toBe(Moves.SONIC_BOOM); - expect(moveHistory[1].move).toBe(Moves.NONE); - expect(moveHistory[2].move).toBe(Moves.SONIC_BOOM); + const moveHistory = game.scene.getEnemyPokemon()?.getLastXMoves(-1)!; + expect(moveHistory.map(m => m.move)).toEqual([ Moves.SONIC_BOOM, Moves.NONE, Moves.SONIC_BOOM ]); + expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40); + }); + + it("should repeat move with no targets, but move should immediately fail", async () => { + game.override.battleType("double"); + await game.classicMode.startBattle([ Species.BRUTE_BONNET, Species.VOLCARONA ]); + + const [ , volcarona ] = game.scene.getPlayerField(); + game.move.changeMoveset(volcarona, [ Moves.INSTRUCT, Moves.SPLASH, Moves.BUG_BITE ]); + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); + game.move.select(Moves.BUG_BITE, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER_2); + await game.forceEnemyMove(Moves.SPLASH); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.toNextTurn(); + + // attack #2 failed due to brute bonnet having already fainted + instructSuccess(volcarona, Moves.BUG_BITE); + expect(volcarona.getLastXMoves(-1)[0].result).toBe(MoveResult.FAIL); }); it("should not repeat enemy's out of pp move", async () => { @@ -191,7 +217,23 @@ describe("Moves - Instruct", () => { const enemyMove = game.scene.getEnemyPokemon()!.getLastXMoves()[0]; expect(enemyMove.result).toBe(MoveResult.FAIL); expect(game.scene.getEnemyPokemon()!.getMoveset().find(m => m?.moveId === Moves.SONIC_BOOM)?.ppUsed).toBe(1); + }); + it("should allow for dancer copying of instructed dance move", async () => { + game.override.battleType("double"); + await game.classicMode.startBattle([ Species.ORICORIO, Species.VOLCARONA ]); + + const [ , volcarona ] = game.scene.getPlayerField(); + game.move.changeMoveset(volcarona, Moves.FIERY_DANCE); + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); + game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); + await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.SPLASH); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.phaseInterceptor.to("TurnEndPhase", false); + + instructSuccess(volcarona, Moves.FIERY_DANCE); + expect(game.scene.getEnemyPokemon()?.turnData.attacksReceived).toBe(4); }); it("should not repeat enemy's move through protect", async () => { @@ -234,22 +276,135 @@ describe("Moves - Instruct", () => { expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL); }); - it("should not repeat dance move not known by target", async () => { + it("should not repeat move since forgotten by target", async () => { game.override .battleType("double") - .moveset([ Moves.INSTRUCT, Moves.FIERY_DANCE ]) - .enemyMoveset(Moves.SPLASH) - .enemyAbility(Abilities.DANCER); - await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]); + .startingWave(199) // disables level cap + .enemyLevel(50) + .startingLevel(62) + .enemySpecies(Species.WURMPLE); // 1 level before learning hydro pump + await game.classicMode.startBattle([ Species.LUGIA ]); + const lugia = game.scene.getPlayerPokemon()!; + lugia.addExp(14647); - game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); - game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); + game.move.changeMoveset(lugia, [ Moves.BRAVE_BIRD, Moves.SPLASH, Moves.AEROBLAST, Moves.FURY_CUTTER ]); + + game.move.select(Moves.BRAVE_BIRD, BattlerIndex.PLAYER, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.SPLASH); - await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER); + await game.phaseInterceptor.to("LearnMovePhase", false); + while (game.isCurrentPhase("LearnMovePhase")) { + game.scene.ui.getHandler().processInput(Button.ACTION); // mash enter to learn level up move + } await game.phaseInterceptor.to("TurnEndPhase", false); - expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(lugia.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(game.scene.getEnemyField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); + + it("should disregard priority of instructed move on use", async () => { + game.override + .enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ]) + .disableTrainerWaves(); + await game.classicMode.startBattle([ Species.LUCARIO, Species.BANETTE ]); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.WHIRLWIND, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }]; + + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2); + await game.forceEnemyMove(Moves.SPLASH); + await game.phaseInterceptor.to("TurnEndPhase", false); + + // lucario instructed enemy whirlwind at 0 priority to switch itself out + const instructedMove = enemyPokemon.getLastXMoves(-1)[1]; + expect(instructedMove.result).toBe(MoveResult.SUCCESS); + expect(instructedMove.move).toBe(Moves.WHIRLWIND); + expect(game.scene.getPlayerPokemon()?.species.speciesId).toBe(Species.BANETTE); + }); + + it("should respect moves' original priority in psychic terrain", async () => { + game.override. + battleType("double") + .moveset([ Moves.QUICK_ATTACK, Moves.SPLASH, Moves.INSTRUCT ]) + .enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]); + await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]); + + const banette = game.scene.getPlayerPokemon(); + game.move.select(Moves.QUICK_ATTACK, BattlerIndex.PLAYER, BattlerIndex.ENEMY); // succeeds due to terrain no + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2); + await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.PSYCHIC_TERRAIN); + await game.toNextTurn(); + + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); + await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.phaseInterceptor.to("TurnEndPhase", false); + // quick attack failed when instructed + expect(banette?.getLastXMoves(-1)[1].move).toBe(Moves.QUICK_ATTACK); + expect(banette?.getLastXMoves(-1)[1].result).toBe(MoveResult.FAIL); + }); + + it("should cause spread moves to correctly hit targets in doubles after singles", async () => { + game.override + .battleType("even-doubles") + .moveset([ Moves.BREAKING_SWIPE, Moves.INSTRUCT, Moves.SPLASH ]) + .enemySpecies(Species.AXEW) + .startingLevel(500); + await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]); + + const koraidon = game.scene.getPlayerField()[0]!; + + game.move.select(Moves.BREAKING_SWIPE); + await game.forceEnemyMove(Moves.SONIC_BOOM); + await game.phaseInterceptor.to("TurnEndPhase", false); + expect (koraidon.getInverseHp()).toBe(0); + expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]); + await game.toNextWave(); + + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); + await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.phaseInterceptor.to("TurnEndPhase", false); + // did not take damage since enemies died beforehand; + // last move used hit both enemies + expect(koraidon.getInverseHp()).toBe(0); + expect(koraidon.getLastXMoves(-1)[1].targets).toMatchObject([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + }); + + it("should cause AoE moves to correctly hit everyone in doubles after singles", async () => { + game.override + .battleType("even-doubles") + .moveset([ Moves.BRUTAL_SWING, Moves.INSTRUCT, Moves.SPLASH ]) + .enemySpecies(Species.AXEW) + .startingLevel(500); + await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]); + + const koraidon = game.scene.getPlayerField()[0]!; + + game.move.select(Moves.BRUTAL_SWING); + await game.forceEnemyMove(Moves.SONIC_BOOM); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.phaseInterceptor.to("TurnEndPhase", false); + expect(koraidon.getInverseHp()).toBe(0); + expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]); + await game.toNextWave(); + + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); + await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.phaseInterceptor.to("TurnEndPhase", false); + // did not take damage since enemies died beforehand; + // last move used hit everything around it + expect(koraidon.getInverseHp()).toBe(0); + expect(koraidon.getLastXMoves(-1)[1].targets).toEqual([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]); + expect(game.scene.getPlayerField()[1].getInverseHp()).toBeGreaterThan(0); + expect(game.scene.getEnemyField()[0].getInverseHp()).toBeGreaterThan(0); + expect(game.scene.getEnemyField()[1].getInverseHp()).toBeGreaterThan(0); }); it("should cause multi-hit moves to hit the appropriate number of times in singles", async () => { @@ -258,7 +413,7 @@ describe("Moves - Instruct", () => { .enemyMoveset(Moves.BULLET_SEED); await game.classicMode.startBattle([ Species.BULBASAUR ]); - const player = game.scene.getPlayerPokemon()!; + const bulbasaur = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); await game.toNextTurn(); @@ -267,14 +422,14 @@ describe("Moves - Instruct", () => { await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.phaseInterceptor.to("BerryPhase"); - expect(player.turnData.attacksReceived.length).toBe(10); + expect(bulbasaur.turnData.attacksReceived.length).toBe(10); await game.toNextTurn(); game.move.select(Moves.INSTRUCT); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.phaseInterceptor.to("BerryPhase"); - expect(player.turnData.attacksReceived.length).toBe(10); + expect(bulbasaur.turnData.attacksReceived.length).toBe(10); }); it("should cause multi-hit moves to hit the appropriate number of times in doubles", async () => { @@ -287,14 +442,14 @@ describe("Moves - Instruct", () => { const [ , ivysaur ] = game.scene.getPlayerField(); - game.move.select(Moves.SPLASH); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); + game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.SPLASH); await game.toNextTurn(); - game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY); - game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY); + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.SPLASH); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); @@ -303,8 +458,8 @@ describe("Moves - Instruct", () => { expect(ivysaur.turnData.attacksReceived.length).toBe(15); await game.toNextTurn(); - game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY); - game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY); + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); + game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.SPLASH); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); diff --git a/src/test/utils/helpers/moveHelper.ts b/src/test/utils/helpers/moveHelper.ts index 68d3b3d51d7..4b6ccbab737 100644 --- a/src/test/utils/helpers/moveHelper.ts +++ b/src/test/utils/helpers/moveHelper.ts @@ -76,8 +76,8 @@ export class MoveHelper extends GameManagerHelper { /** * Used when the normal moveset override can't be used (such as when it's necessary to check updated properties of the moveset). - * @param pokemon - The pokemon being modified - * @param moveset - The moveset to use + * @param pokemon - The {@linkcode Pokemon} being modified + * @param moveset - The {@linkcode Moves} (single or array) to set the Pokemon's moveset to */ public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void { if (!Array.isArray(moveset)) {