From 17e5ef789dce525e79fac48fa0fcb06657d41eba Mon Sep 17 00:00:00 2001 From: Temps Ray Date: Tue, 17 Sep 2024 23:40:03 -0400 Subject: [PATCH] Fix unit tests --- src/data/battler-tags.ts | 4 ++-- src/field/pokemon.ts | 2 +- src/test/moves/autotomize.test.ts | 30 +++++++++++++++++++++++------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index f5b80a06c18..9e910430c09 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2207,12 +2207,12 @@ export class TarShotTag extends BattlerTag { */ export class AutotomizedTag extends BattlerTag { public autotomizeCount: number = 0; - constructor(sourceMove: Moves = Moves.NONE) { + constructor(sourceMove: Moves = Moves.AUTOTOMIZE) { super(BattlerTagType.AUTOTOMIZED, BattlerTagLapseType.CUSTOM, 1, sourceMove); } /** - * Adds an autotmize count to the Pokemon. Each stack reduces weight by 100kg + * Adds an autotomize count to the Pokemon. Each stack reduces weight by 100kg * If the Pokemon is over 0.1kg it also displays a message. * @param pokemon The Pokemon that is being autotomized */ diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 4eeab536bc5..9a9156e327d 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1401,7 +1401,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getWeight(): number { const autotomizedTag = this.getTag(AutotomizedTag); let weightRemoved = 0; - if (autotomizedTag !== null && autotomizedTag !== undefined) { + if (!Utils.isNullOrUndefined(autotomizedTag)) { weightRemoved = 100 * autotomizedTag.autotomizeCount; } const minWeight = 0.1; diff --git a/src/test/moves/autotomize.test.ts b/src/test/moves/autotomize.test.ts index 36f90216a0a..4da246736f9 100644 --- a/src/test/moves/autotomize.test.ts +++ b/src/test/moves/autotomize.test.ts @@ -39,17 +39,16 @@ describe("Moves - Autotomize", () => { const playerPokemon = game.scene.getPlayerPokemon()!; expect(playerPokemon.getWeight()).toBe(baseDracozoltWeight); game.move.select(Moves.AUTOTOMIZE); - // expect a queued message here + await game.toNextTurn(); expect(playerPokemon.getWeight()).toBe(oneAutotomizeDracozoltWeight); - await game.toNextTurn(); game.move.select(Moves.AUTOTOMIZE); - //expect a queued message here + await game.toNextTurn(); expect(playerPokemon.getWeight()).toBe(twoAutotomizeDracozoltWeight); - await game.toNextTurn(); + game.move.select(Moves.AUTOTOMIZE); - // expect no queued message here + await game.toNextTurn(); expect(playerPokemon.getWeight()).toBe(threeAutotomizeDracozoltWeight); }, TIMEOUT); @@ -62,21 +61,38 @@ describe("Moves - Autotomize", () => { expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); + game.move.select(Moves.FALSE_SWIPE); await game.toNextTurn(); game.move.select(Moves.KINGS_SHIELD); - expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); game.move.select(Moves.FALSE_SWIPE); - expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); }, TIMEOUT); + + it("Autotomize should interact with light metal correctly", async () => { + const baseLightGroudonWeight = 475; + const autotomizeLightGroudonWeight = 425; + game.override.ability(Abilities.LIGHT_METAL); + await game.classicMode.startBattle([Species.GROUDON]); + const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getWeight()).toBe(baseLightGroudonWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(autotomizeLightGroudonWeight); + }, TIMEOUT); });