From 377aafa85c00477b79b7703efe7065c612349e03 Mon Sep 17 00:00:00 2001 From: Lylian Date: Mon, 31 Mar 2025 15:04:37 +0200 Subject: [PATCH] review corrections --- src/data/ability.ts | 16 +++++++--------- src/field/pokemon.ts | 7 +++++++ src/messages.ts | 1 + test/abilities/illusion.test.ts | 12 ++++++------ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index e6afa4bc083..dd6d522ac5b 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -5245,14 +5245,13 @@ export class IllusionBreakAbAttr extends PostDefendAbAttr { * @param args - unused * @returns - Whether the illusion was destroyed. */ - applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: 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 ]; - if (!breakIllusion.includes(hitResult)) { - return false; - } + override applyPostDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): void { pokemon.breakIllusion(); - return true; + } + + override canApplyPostDefend(pokemon: Pokemon, passive: boolean, simulated: 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 ]; + return breakIllusion.includes(hitResult) && pokemon.battleData.illusion.active } } @@ -5265,10 +5264,9 @@ export class IllusionPostBattleAbAttr extends PostBattleAbAttr { * @param {...any} args - N/A * @returns {boolean} - Whether the illusion was applied. */ - applyPostBattle(pokemon: Pokemon, passive: boolean, simulated:boolean, args: any[]): boolean { + override applyPostBattle(pokemon: Pokemon, passive: boolean, simulated:boolean, args: any[]): void { pokemon.breakIllusion(); pokemon.battleData.illusion.available = true; - return true; } } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index d19b5541fa7..25bd3d84ec7 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -735,10 +735,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } else { let availables: Species[] = []; let randomIllusion: PokemonSpecies = globalScene.arena.randomSpecies(globalScene.currentBattle.waveIndex, this.level); + /* if (this.isBoss()) { availables = [ Species.ENTEI, Species.RAIKOU, Species.SUICUNE ]; randomIllusion = getPokemonSpecies(availables[this.randSeedInt(availables.length)]); } + */ this.battleData.illusion = { active: true, @@ -1857,6 +1859,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } + /** + * + * @param fakeShininess - Whether we want the fake or real shininess (illusion ability). + * @returns `true` if the {@linkcode Pokemon} is shiny and the fusion is shiny as well, `false` otherwise + */ isDoubleShiny(fakeShininess: boolean = false): boolean { if (!fakeShininess && this.battleData?.illusion.active) { return this.isFusion(false) && this.battleData?.illusion.basePokemon!.shiny && this.battleData?.illusion.basePokemon.fusionShiny; diff --git a/src/messages.ts b/src/messages.ts index 3cf49709b0d..c29151a98b3 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -6,6 +6,7 @@ import i18next from "i18next"; /** * Retrieves the Pokemon's name, potentially with an affix indicating its role (wild or foe) in the current battle context, translated * @param pokemon {@linkcode Pokemon} name and battle context will be retrieved from this instance + * @param {boolean} useIllusion - Whether we want the name of the illusion or not. Default value : true * @returns {string} ex: "Wild Gengar", "Ectoplasma sauvage" */ export function getPokemonNameWithAffix(pokemon: Pokemon | undefined, useIllusion = true): string { diff --git a/test/abilities/illusion.test.ts b/test/abilities/illusion.test.ts index c3d702621fc..46a1f0a018e 100644 --- a/test/abilities/illusion.test.ts +++ b/test/abilities/illusion.test.ts @@ -28,10 +28,10 @@ describe("Abilities - Illusion", () => { 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.enemyMoveset(Moves.TACKLE); game.override.enemyHeldItems([{ name: "WIDE_LENS", count: 3 }]); - game.override.moveset([Moves.WORRY_SEED, Moves.SOAK, Moves.TACKLE, Moves.TACKLE]); + game.override.moveset([Moves.WORRY_SEED, Moves.SOAK, Moves.TACKLE]); game.override.startingHeldItems([{ name: "WIDE_LENS", count: 3 }]); }); @@ -108,7 +108,7 @@ describe("Abilities - Illusion", () => { it("does not break from indirect damage", 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.enemyMoveset(Moves.WILL_O_WISP); game.override.moveset([Moves.FLARE_BLITZ]); await game.classicMode.startBattle([Species.ZOROARK, Species.AZUMARILL]); @@ -122,9 +122,9 @@ describe("Abilities - Illusion", () => { expect(zoroark.battleData.illusion.active).equals(true); }); - it("copy the the name, the nickname, the gender, the shininess and the pokeball of the pokemon", async () => { - await game.classicMode.startBattle([Species.ABRA, Species.ZOROARK, Species.AXEW]).enemyMoveset([Moves.SPLASH]); - + it("copies the the name, nickname, gender, shininess, and pokeball from the illusion source", async () => { + game.override.enemyMoveset(Moves.SPLASH); + await game.classicMode.startBattle([Species.ABRA, Species.ZOROARK, Species.AXEW]); const axew = game.scene.getPlayerParty().at(2)!; axew.shiny = true; axew.nickname = btoa(unescape(encodeURIComponent("axew nickname")));