Skip to content

Commit

Permalink
tag must not removed & changed test
Browse files Browse the repository at this point in the history
  • Loading branch information
ysh4296 committed Sep 13, 2024
1 parent efbcbb1 commit bba6418
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
11 changes: 4 additions & 7 deletions src/data/battler-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) }));
}

/**
Expand Down
23 changes: 11 additions & 12 deletions src/test/moves/power_trick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

game.move.select(Moves.POWER_TRICK);
await game.override.moveset([Moves.BATON_PASS]);

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);
});

0 comments on commit bba6418

Please sign in to comment.