From bba6418bd52170b147f2e4c2e400ca9d5287a3d4 Mon Sep 17 00:00:00 2001 From: cadi Date: Fri, 13 Sep 2024 16:28:41 +0900 Subject: [PATCH] tag must not removed & changed test --- src/data/battler-tags.ts | 11 ++++------- src/test/moves/power_trick.test.ts | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index a6d50987cee..f185c1b5d87 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2210,6 +2210,7 @@ export class TarShotTag extends BattlerTag { pokemon.scene.queueMessage(i18next.t("battlerTags:tarShotOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); } } + /** * Tag that swaps the user's base ATK stat with its base DEF stat. * @extends BattlerTag @@ -2224,17 +2225,13 @@ export class PowerTrickTag extends BattlerTag { pokemon.scene.queueMessage(i18next.t("battlerTags:powerTrickActive", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); } - onRemove(pokemon: Pokemon): void { - this.swapStat(pokemon); - pokemon.scene.queueMessage(i18next.t("battlerTags:powerTrickActive", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); - } - /** - * Removes the Power Trick tag and reverts any stat changes if the tag is already applied. + * Active stat swap again if the tag overlaps. tag will be remain. * @param {Pokemon} pokemon The {@linkcode Pokemon} that already has the Power Trick tag. */ onOverlap(pokemon: Pokemon): void { - pokemon.removeTag(this.tagType); + this.swapStat(pokemon); + pokemon.scene.queueMessage(i18next.t("battlerTags:powerTrickActive", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); } /** diff --git a/src/test/moves/power_trick.test.ts b/src/test/moves/power_trick.test.ts index 601c23f8b0b..6444e09624c 100644 --- a/src/test/moves/power_trick.test.ts +++ b/src/test/moves/power_trick.test.ts @@ -68,28 +68,27 @@ describe("Moves - Power Trick", () => { expect(player.getStat(Stat.ATK, false)).toBe(baseATK); expect(player.getStat(Stat.DEF, false)).toBe(baseDEF); - expect(player.getTag(BattlerTagType.POWER_TRICK)).toBeUndefined(); + expect(player.getTag(BattlerTagType.POWER_TRICK)).toBeDefined(); }, 20000); - it("should pass effect when using BATON_PASS", async () => { + it("effect should be passed with the tag when using BATON_PASS", async () => { await game.classicMode.startBattle([Species.SHUCKLE, Species.SHUCKLE]); - await game.override.moveset([Moves.POWER_TRICK, Moves.BATON_PASS]); + await game.override.moveset([Moves.BATON_PASS]); - game.move.select(Moves.POWER_TRICK); - - await game.phaseInterceptor.to(TurnEndPhase); + const player = game.scene.getPlayerPokemon()!; + player.addTag(BattlerTagType.POWER_TRICK); game.move.select(Moves.BATON_PASS); game.doSelectPartyPokemon(1); await game.phaseInterceptor.to(TurnEndPhase); - const player = game.scene.getPlayerPokemon()!; - const baseATK = player.getStat(Stat.ATK); - const baseDEF = player.getStat(Stat.DEF); + const switchedPlayer = game.scene.getPlayerPokemon()!; + const baseATK = switchedPlayer.getStat(Stat.ATK); + const baseDEF = switchedPlayer.getStat(Stat.DEF); - expect(player.getStat(Stat.ATK, false)).toBe(baseDEF); - expect(player.getStat(Stat.DEF, false)).toBe(baseATK); - expect(player.getTag(BattlerTagType.POWER_TRICK)).toBeDefined(); + expect(switchedPlayer.getStat(Stat.ATK, false)).toBe(baseDEF); + expect(switchedPlayer.getStat(Stat.DEF, false)).toBe(baseATK); + expect(switchedPlayer.getTag(BattlerTagType.POWER_TRICK)).toBeDefined(); }, 20000); });