From 48f2e2e5180aedd24890386cecce0eda34eebc3b Mon Sep 17 00:00:00 2001 From: Zach Day Date: Thu, 8 Aug 2024 18:48:09 -0400 Subject: [PATCH] All disable tests passing --- src/phases.ts | 5 +++-- src/test/moves/disable.test.ts | 31 ++++++++++++++----------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 4c8764789c7..781735fcacd 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2683,8 +2683,9 @@ export class MovePhase extends BattlePhase { if (!this.canMove()) { if (this.move.moveId && this.pokemon.isMoveDisabled(this.move.moveId)) { this.scene.queueMessage(`${this.move.getName()} is disabled!`); - } - if (this.pokemon.isActive(true) && this.move.ppUsed >= this.move.getMovePp()) { // if the move PP was reduced from Spite or otherwise, the move fails + this.pokemon.pushMoveHistory({ move: this.move.moveId, result: MoveResult.FAIL, virtual: false }); + this.fail(); + } else if (this.pokemon.isActive(true) && this.move.ppUsed >= this.move.getMovePp()) { // if the move PP was reduced from Spite or otherwise, the move fails this.fail(); this.showMoveText(); this.showFailedText(); diff --git a/src/test/moves/disable.test.ts b/src/test/moves/disable.test.ts index 58e5d476287..c15917331af 100644 --- a/src/test/moves/disable.test.ts +++ b/src/test/moves/disable.test.ts @@ -46,14 +46,13 @@ describe("Moves - Disable", () => { game.override.enemyAbility(Abilities.NONE); game.override.moveset([Moves.DISABLE, Moves.SPLASH, Moves.NONE, Moves.NONE]); game.override.enemyMoveset([Moves.SPLASH,Moves.NONE,Moves.NONE,Moves.NONE]); + game.override.starterSpecies(Species.PIKACHU); + game.override.enemySpecies(Species.SHUCKLE); }); it("DISABLE fails if enemy has no move history", async() => { // Player goes first - await game.startBattle([ - Species.PIKACHU, - Species.SHUCKLE, - ]); + await game.startBattle(); expect(game.scene.getParty()[0].stats[Stat.SPD]).toBeGreaterThan(game.scene.getEnemyParty()[0].stats[Stat.SPD]); _useMove(); @@ -63,14 +62,14 @@ describe("Moves - Disable", () => { }, 20000); it("DISABLE works when user moves after enemy", async() => { - await game.startBattle([ - Species.SHUCKLE, - Species.PIKACHU, - ]); + game.override.starterSpecies(Species.SHUCKLE); + game.override.enemySpecies(Species.PIKACHU); + + await game.startBattle(); expect(game.scene.getParty()[0].stats[Stat.SPD]).toBeLessThan(game.scene.getEnemyParty()[0].stats[Stat.SPD]); _useMove(); - await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); expect(game.scene.getParty()[0].getMoveHistory().at(0)!.move).toBe(Moves.DISABLE); expect(game.scene.getParty()[0].getMoveHistory().at(0)!.result).toBe(MoveResult.SUCCESS); @@ -87,10 +86,7 @@ describe("Moves - Disable", () => { it("DISABLE interrupts target's move when user moves first", async() => { // Player goes first - await game.startBattle([ - Species.PIKACHU, - Species.SHUCKLE, - ]); + await game.startBattle(); _useMove(Moves.SPLASH); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(CommandPhase); @@ -102,11 +98,12 @@ describe("Moves - Disable", () => { _useMove(Moves.DISABLE); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(CommandPhase); - expect(game.scene.getPlayerPokemon()!.getMoveHistory().length === 2); + expect(game.scene.getPlayerPokemon()!.getMoveHistory().length).toBe(2); + expect(game.scene.getEnemyParty()[0].isMoveDisabled(Moves.SPLASH)); - expect(game.scene.getEnemyParty()[0].getMoveHistory().length === 2); - expect(game.scene.getEnemyParty()[0].getLastXMoves().at(0)!.result).toBe(MoveResult.FAIL); - expect(game.scene.getEnemyParty()[0].getLastXMoves().at(1)!.result).toBe(MoveResult.SUCCESS); + expect(game.scene.getEnemyParty()[0].getMoveHistory().length).toBe(2); + expect(game.scene.getEnemyParty()[0].getLastXMoves(2).at(0)!.result).toBe(MoveResult.FAIL); + expect(game.scene.getEnemyParty()[0].getLastXMoves(2).at(1)!.result).toBe(MoveResult.SUCCESS); }, 20000); });