From 41ca2cd9efcb337440d4413dcf19afe8a89d5f38 Mon Sep 17 00:00:00 2001 From: Lylian Date: Mon, 5 Aug 2024 01:17:25 +0200 Subject: [PATCH] nit corrections --- src/data/ability.ts | 22 ++++++++---- src/locales/pt_BR/config.ts | 1 - src/test/abilities/illusion.test.ts | 56 ++++++++++++++++------------- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index f3e8270f17b..3f25c99fd2d 100755 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1896,11 +1896,14 @@ export class PostSummonMessageAbAttr extends PostSummonAbAttr { applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { pokemon.scene.queueMessage(this.messageFunc(pokemon)); + return true; + } +} +export class PostSummonRemoveIllusionAbAttr extends PostSummonAbAttr { + applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { pokemon.scene.getField(true).map(pokemon => { - if (pokemon.breakIllusion()) { - pokemon.scene.queueMessage(i18next.t("abilityTriggers:illusionBreak", { pokemonName: getPokemonNameWithAffix(pokemon) })); - } + pokemon.breakIllusion(); }); return true; } @@ -4049,6 +4052,11 @@ export class IceFaceBlockPhysicalAbAttr extends ReceivedMoveDamageMultiplierAbAt } } +/** + * Base class for defining {@linkcode Ability} attributes before summon + * (should use {@linkcode PostSummonAbAttr} for most ability) + * @see {@linkcode applyPreSummon()} + */ export class PreSummonAbAttr extends AbAttr { applyPreSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { return false; @@ -4097,17 +4105,16 @@ export class IllusionBreakAbAttr extends PostDefendAbAttr { */ applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { - const breakIllusion: HitResult[] = [HitResult.EFFECTIVE, HitResult.SUPER_EFFECTIVE, HitResult.NOT_VERY_EFFECTIVE, HitResult.ONE_HIT_KO]; + const breakIllusion: HitResult[] = [ HitResult.EFFECTIVE, HitResult.SUPER_EFFECTIVE, HitResult.NOT_VERY_EFFECTIVE, HitResult.ONE_HIT_KO ]; if (!breakIllusion.includes(hitResult)) { return false; } pokemon.breakIllusion(); - pokemon.scene.queueMessage(i18next.t("abilityTriggers:illusionBreak", { pokemonName: getPokemonNameWithAffix(pokemon) })); return true; } } -export class IllusionAfterBattle extends PostBattleAbAttr { +export class IllusionPostBattleAbAttr extends PostBattleAbAttr { /** * Illusion will be available again after a battle and apply the illusion of the pokemon is already on field * @@ -4868,7 +4875,7 @@ export function initAbilities() { //The pokemon loses his illusion when he is damaged by a move .conditionalAttr((pokemon) => pokemon.illusion.active, IllusionBreakAbAttr, true) //Illusion is available again after a battle - .conditionalAttr((pokemon) => pokemon.isAllowedInBattle(), IllusionAfterBattle, false) + .conditionalAttr((pokemon) => pokemon.isAllowedInBattle(), IllusionPostBattleAbAttr, false) //Illusion is not available after summon .attr(IllusionDisableAbAttr, false) .bypassFaint(), @@ -5246,6 +5253,7 @@ export function initAbilities() { .attr(UnswappableAbilityAbAttr) .attr(NoTransformAbilityAbAttr) .attr(PostSummonMessageAbAttr, (pokemon: Pokemon) => i18next.t("abilityTriggers:postSummonNeutralizingGas", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })) + .attr(PostSummonRemoveIllusionAbAttr) .partial(), new Ability(Abilities.PASTEL_VEIL, 8) .attr(PostSummonUserFieldRemoveStatusEffectAbAttr, StatusEffect.POISON, StatusEffect.TOXIC) diff --git a/src/locales/pt_BR/config.ts b/src/locales/pt_BR/config.ts index 1b0b20d532b..5f7582dca63 100644 --- a/src/locales/pt_BR/config.ts +++ b/src/locales/pt_BR/config.ts @@ -1,6 +1,5 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; -import { arenaFlyout } from "./arena-flyout"; import { PGFachv, PGMachv } from "./achv"; import { arenaFlyout } from "./arena-flyout"; import { arenaTag } from "./arena-tag"; diff --git a/src/test/abilities/illusion.test.ts b/src/test/abilities/illusion.test.ts index 39683b956ec..1fe2f740e1f 100644 --- a/src/test/abilities/illusion.test.ts +++ b/src/test/abilities/illusion.test.ts @@ -28,17 +28,17 @@ describe("Abilities - Illusion", () => { beforeEach(() => { game = new GameManager(phaserGame); - vi.spyOn(overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("single"); - vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.ZORUA); - vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.ILLUSION); - vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); - vi.spyOn(overrides, "OPP_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "WIDE_LENS", count: 3}]); + game.override.battleType("single"); + game.override.enemySpecies(Species.ZORUA); + game.override.enemyAbility(Abilities.ILLUSION); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); + game.override.enemyHeldItems([{name: "WIDE_LENS", count: 3}]); - vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.WORRY_SEED, Moves.SOAK, Moves.TACKLE, Moves.TACKLE]); - vi.spyOn(overrides, "STARTING_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "WIDE_LENS", count: 3}]); + game.override.moveset([Moves.WORRY_SEED, Moves.SOAK, Moves.TACKLE, Moves.TACKLE]); + game.override.startingHeldItems([{name: "WIDE_LENS", count: 3}]); }); - it("create illusion at the start", async () => { + it("creates illusion at the start", async () => { await game.startBattle([Species.ZOROARK, Species.AXEW]); const zoroark = game.scene.getPlayerPokemon(); @@ -47,24 +47,30 @@ describe("Abilities - Illusion", () => { expect(zoroark.illusion.active).equals(true); expect(zorua.illusion.active).equals(true); expect(zoroark.illusion.available).equals(false); - }); - it("disappear after receiving damaging move and changing ability move", async () => { - await game.startBattle([Species.ZOROARK, Species.AXEW]); - game.doAttack(getMovePosition(game.scene, 0, Moves.WORRY_SEED)); + it("break after receiving damaging move", async () => { + await game.startBattle([Species.AXEW]); + game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); await game.phaseInterceptor.to(TurnEndPhase); - const zoroark = game.scene.getPlayerPokemon(); const zorua = game.scene.getEnemyPokemon(); expect(zorua.illusion.active).equals(false); - expect(zoroark.illusion.active).equals(false); }); - it("disappear if the ability is suppressed", async () => { - vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.NEUTRALIZING_GAS); + it("break after getting ability changed", async () => { + await game.startBattle([Species.AXEW]); + game.doAttack(getMovePosition(game.scene, 0, Moves.WORRY_SEED)); + + const zorua = game.scene.getEnemyPokemon(); + + expect(zorua.illusion.active).equals(false); + }); + + it("break if the ability is suppressed", async () => { + game.override.enemyAbility(Abilities.NEUTRALIZING_GAS); await game.startBattle([Species.KOFFING]); const zorua = game.scene.getEnemyPokemon(); @@ -72,24 +78,24 @@ describe("Abilities - Illusion", () => { expect(zorua.illusion.active).equals(false); }); - it("trick the enemy AI", async () => { - vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.FLAMETHROWER, Moves.PSYCHIC, Moves.TACKLE, Moves.TACKLE]); + it("trick the enemy AI for moves effectiveness using ILLUSION type instead of actual type", async () => { + game.override.enemyMoveset([Moves.FLAMETHROWER, Moves.PSYCHIC, Moves.TACKLE, Moves.TACKLE]); await game.startBattle([Species.ZOROARK, Species.AXEW]); const enemy = game.scene.getEnemyPokemon(); const zoroark = game.scene.getPlayerPokemon(); - const flameThwowerEffectiveness = zoroark.getAttackMoveEffectiveness(enemy, enemy.getMoveset()[0], false, true); + const flameThrowerEffectiveness = zoroark.getAttackMoveEffectiveness(enemy, enemy.getMoveset()[0], false, true); const psychicEffectiveness = zoroark.getAttackMoveEffectiveness(enemy, enemy.getMoveset()[1], false, true); - expect(psychicEffectiveness).above(flameThwowerEffectiveness); + expect(psychicEffectiveness).above(flameThrowerEffectiveness); }); - it("do not disappear if the pokemon takes indirect damages", async () => { - vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.GIGALITH); - vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.SAND_STREAM); - vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP]); - vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.FLARE_BLITZ]); + it("do not breaks if the pokemon takes indirect damages", async () => { + game.override.enemySpecies(Species.GIGALITH); + game.override.enemyAbility(Abilities.SAND_STREAM); + game.override.enemyMoveset([Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP]); + game.override.moveset([Moves.FLARE_BLITZ]); await game.startBattle([Species.ZOROARK, Species.AZUMARILL]);