From 7d2df53c51fdc12d26c755f0f931754470a40111 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sun, 29 Sep 2024 23:45:44 -0700 Subject: [PATCH] Add `waveTurnCount` to `PokemonBattleData` (#4168) Swap `FirstMoveCondition` to use the new `waveTurnCount` field --- src/data/move.ts | 2 +- src/field/pokemon.ts | 2 ++ src/phases/battle-end-phase.ts | 6 ++++++ src/phases/switch-summon-phase.ts | 1 + src/phases/turn-end-phase.ts | 1 + src/test/moves/fake_out.test.ts | 36 +++++++++++++++++++++++-------- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 9b1fa44071a..e163e89a272 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -6591,7 +6591,7 @@ export class MoveCondition { export class FirstMoveCondition extends MoveCondition { constructor() { - super((user, target, move) => user.battleSummonData?.turnCount === 1); + super((user, target, move) => user.battleSummonData?.waveTurnCount === 1); } getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index a318d3ffdeb..c66da0572ad 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -5000,6 +5000,8 @@ export class PokemonBattleData { export class PokemonBattleSummonData { /** The number of turns the pokemon has passed since entering the battle */ public turnCount: number = 1; + /** The number of turns the pokemon has passed since the start of the wave */ + public waveTurnCount: number = 1; /** The list of moves the pokemon has used since entering the battle */ public moveHistory: TurnMove[] = []; } diff --git a/src/phases/battle-end-phase.ts b/src/phases/battle-end-phase.ts index 902a85325ad..eaa458af904 100644 --- a/src/phases/battle-end-phase.ts +++ b/src/phases/battle-end-phase.ts @@ -35,6 +35,12 @@ export class BattleEndPhase extends BattlePhase { this.scene.unshiftPhase(new GameOverPhase(this.scene, true)); } + for (const pokemon of this.scene.getField()) { + if (pokemon && pokemon.battleSummonData) { + pokemon.battleSummonData.waveTurnCount = 1; + } + } + for (const pokemon of this.scene.getParty().filter(p => p.isAllowedInBattle())) { applyPostBattleAbAttrs(PostBattleAbAttr, pokemon); } diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index eb1e089543b..07761b10d6e 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -173,6 +173,7 @@ export class SwitchSummonPhase extends SummonPhase { // Or compensate for force switch move if switched out pokemon is not fainted if (currentCommand === Command.POKEMON || lastPokemonIsForceSwitchedAndNotFainted) { pokemon.battleSummonData.turnCount--; + pokemon.battleSummonData.waveTurnCount--; } if (this.switchType === SwitchType.BATON_PASS && pokemon) { diff --git a/src/phases/turn-end-phase.ts b/src/phases/turn-end-phase.ts index 724a5206d74..60a2e6600db 100644 --- a/src/phases/turn-end-phase.ts +++ b/src/phases/turn-end-phase.ts @@ -44,6 +44,7 @@ export class TurnEndPhase extends FieldPhase { this.scene.applyModifiers(TurnHeldItemTransferModifier, pokemon.isPlayer(), pokemon); pokemon.battleSummonData.turnCount++; + pokemon.battleSummonData.waveTurnCount++; }; this.executeForAll(handlePokemon); diff --git a/src/test/moves/fake_out.test.ts b/src/test/moves/fake_out.test.ts index 04d6216b952..e306ab12a3f 100644 --- a/src/test/moves/fake_out.test.ts +++ b/src/test/moves/fake_out.test.ts @@ -23,14 +23,15 @@ describe("Moves - Fake Out", () => { game.override .battleType("single") .enemySpecies(Species.CORVIKNIGHT) - .starterSpecies(Species.FEEBAS) .moveset([Moves.FAKE_OUT, Moves.SPLASH]) .enemyMoveset(Moves.SPLASH) + .enemyLevel(10) + .startingLevel(10) // prevent LevelUpPhase from happening .disableCrits(); }); - it("can only be used on the first turn a pokemon is sent out", async() => { - await game.classicMode.startBattle(); + it("can only be used on the first turn a pokemon is sent out in a battle", async() => { + await game.classicMode.startBattle([Species.FEEBAS]); const enemy = game.scene.getEnemyPokemon()!; @@ -44,22 +45,27 @@ describe("Moves - Fake Out", () => { await game.toNextTurn(); expect(enemy.hp).toBe(postTurnOneHp); + }, 20000); - game.move.select(Moves.SPLASH); - await game.doKillOpponents(); + // This is a PokeRogue buff to Fake Out + it("can be used at the start of every wave even if the pokemon wasn't recalled", async() => { + await game.classicMode.startBattle([Species.FEEBAS]); + + const enemy = game.scene.getEnemyPokemon()!; + enemy.damageAndUpdate(enemy.getMaxHp() - 1); + + game.move.select(Moves.FAKE_OUT); await game.toNextWave(); - const newEnemy = game.scene.getEnemyPokemon()!; - game.move.select(Moves.FAKE_OUT); await game.toNextTurn(); - expect(newEnemy.hp).toBe(newEnemy.getMaxHp()); + expect(game.scene.getEnemyPokemon()!.isFullHp()).toBe(false); }, 20000); it("can be used again if recalled and sent back out", async() => { game.override.startingWave(4); - await game.classicMode.startBattle(); + await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]); const enemy1 = game.scene.getEnemyPokemon()!; @@ -76,6 +82,18 @@ describe("Moves - Fake Out", () => { const enemy2 = game.scene.getEnemyPokemon()!; + expect(enemy2.hp).toBeLessThan(enemy2.getMaxHp()); + enemy2.hp = enemy2.getMaxHp(); + + game.doSwitchPokemon(1); + await game.toNextTurn(); + + game.doSwitchPokemon(1); + await game.toNextTurn(); + + game.move.select(Moves.FAKE_OUT); + await game.toNextTurn(); + expect(enemy2.hp).toBeLessThan(enemy2.getMaxHp()); }, 20000); });