From 15fbd9a54f2c2ba2fafbbc349ad495cbf2835a37 Mon Sep 17 00:00:00 2001 From: Lylian Date: Mon, 10 Mar 2025 12:42:35 +0100 Subject: [PATCH] merge --- src/battle-scene.ts | 2 +- src/messages.ts | 10 +++--- src/phases/summon-phase.ts | 14 +++++--- src/phases/switch-summon-phase.ts | 8 ++++- src/ui/battle-info.ts | 2 +- src/ui/party-ui-handler.ts | 4 ++- src/ui/summary-ui-handler.ts | 14 ++++++-- test/abilities/illusion.test.ts | 53 ++++++++++++++++++++----------- 8 files changed, 72 insertions(+), 35 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 8bb4081e812..aad3e035d81 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -884,7 +884,7 @@ export default class BattleScene extends SceneBase { return true; } - public getPlayerParty(fakeShininess: boolean = true): PlayerPokemon[] { + public getPlayerParty(fakeShininess = true): PlayerPokemon[] { const party = this.party; if (!fakeShininess) { party.map(pokemon => { diff --git a/src/messages.ts b/src/messages.ts index ee352037df1..3cf49709b0d 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -8,7 +8,7 @@ import i18next from "i18next"; * @param pokemon {@linkcode Pokemon} name and battle context will be retrieved from this instance * @returns {string} ex: "Wild Gengar", "Ectoplasma sauvage" */ -export function getPokemonNameWithAffix(pokemon: Pokemon | undefined, useIllusion: boolean = true): string { +export function getPokemonNameWithAffix(pokemon: Pokemon | undefined, useIllusion = true): string { if (!pokemon) { return "Missigno"; } @@ -18,11 +18,11 @@ export function getPokemonNameWithAffix(pokemon: Pokemon | undefined, useIllusio return !pokemon.isPlayer() ? pokemon.hasTrainer() ? i18next.t("battle:foePokemonWithAffix", { - pokemonName: pokemon.getNameToRender(useIllusion), - }) + pokemonName: pokemon.getNameToRender(useIllusion), + }) : i18next.t("battle:wildPokemonWithAffix", { - pokemonName: pokemon.getNameToRender(useIllusion), - }) + pokemonName: pokemon.getNameToRender(useIllusion), + }) : pokemon.getNameToRender(useIllusion); case BattleSpec.FINAL_BOSS: return !pokemon.isPlayer() diff --git a/src/phases/summon-phase.ts b/src/phases/summon-phase.ts index a55a569a43e..ae179c26248 100644 --- a/src/phases/summon-phase.ts +++ b/src/phases/summon-phase.ts @@ -125,10 +125,10 @@ export class SummonPhase extends PartyMemberPokemonPhase { const pokemon = this.getPokemon(); const pokeball = globalScene.addFieldSprite( - this.player ? 36 : 248, - this.player ? 80 : 44, - "pb", - getPokeballAtlasKey(pokemon.battleData.illusion.pokeball ?? pokemon.pokeball) + this.player ? 36 : 248, + this.player ? 80 : 44, + "pb", + getPokeballAtlasKey(pokemon.battleData.illusion.pokeball ?? pokemon.pokeball), ); pokeball.setVisible(false); pokeball.setOrigin(0.5, 0.625); @@ -177,7 +177,11 @@ export class SummonPhase extends PartyMemberPokemonPhase { } globalScene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id); } - addPokeballOpenParticles(pokemon.x, pokemon.y - 16, pokemon.battleData.illusion.pokeball ?? pokemon.pokeball); + addPokeballOpenParticles( + pokemon.x, + pokemon.y - 16, + pokemon.battleData.illusion.pokeball ?? pokemon.pokeball, + ); globalScene.updateModifiers(this.player); globalScene.updateFieldScale(); pokemon.showInfo(); diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index 5aa8d909d02..8edbeb63e4d 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -1,5 +1,11 @@ import { globalScene } from "#app/global-scene"; -import { applyPreSummonAbAttrs, applyPreSwitchOutAbAttrs, PostDamageForceSwitchAbAttr, PreSummonAbAttr, PreSwitchOutAbAttr } from "#app/data/ability"; +import { + applyPreSummonAbAttrs, + applyPreSwitchOutAbAttrs, + PostDamageForceSwitchAbAttr, + PreSummonAbAttr, + PreSwitchOutAbAttr, +} from "#app/data/ability"; import { allMoves, ForceSwitchOutAttr } from "#app/data/moves/move"; import { getPokeballTintColor } from "#app/data/pokeball"; import { SpeciesFormChangeActiveTrigger } from "#app/data/pokemon-forms"; diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 7e70e15c40b..fd916dd5947 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -798,7 +798,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { while ( nameTextWidth > (this.player || !this.boss ? 60 : 98) - - ((pokemon.gender !== Gender.GENDERLESS ? 6 : 0) + + ((gender !== Gender.GENDERLESS ? 6 : 0) + (pokemon.fusionSpecies ? 8 : 0) + (pokemon.isShiny() ? 8 : 0) + (Math.min(pokemon.level.toString().length, 3) - 3) * 8) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 0ae1b9a7437..d16bea57131 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1582,7 +1582,9 @@ class PartySlot extends Phaser.GameObjects.Container { const fusionShinyStar = globalScene.add.image(0, 0, "shiny_star_small_2"); fusionShinyStar.setOrigin(0, 0); fusionShinyStar.setPosition(shinyStar.x, shinyStar.y); - fusionShinyStar.setTint(getVariantTint(this.pokemon.battleData.illusion.basePokemon?.fusionVariant ?? this.pokemon.fusionVariant)); + fusionShinyStar.setTint( + getVariantTint(this.pokemon.battleData.illusion.basePokemon?.fusionVariant ?? this.pokemon.fusionVariant), + ); slotInfoContainer.add(fusionShinyStar); } diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index abd49e0f3e3..f2294e38157 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -348,8 +348,14 @@ export default class SummaryUiHandler extends UiHandler { this.pokemonSprite.setPipelineData("isTerastallized", this.pokemon.isTerastallized); this.pokemonSprite.setPipelineData("ignoreTimeTint", true); this.pokemonSprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey()); - this.pokemonSprite.setPipelineData("shiny", this.pokemon.battleData.illusion.basePokemon?.shiny ?? this.pokemon.shiny); - this.pokemonSprite.setPipelineData("variant", this.pokemon.battleData.illusion.basePokemon?.variant ?? this.pokemon.variant); + this.pokemonSprite.setPipelineData( + "shiny", + this.pokemon.battleData.illusion.basePokemon?.shiny ?? this.pokemon.shiny, + ); + this.pokemonSprite.setPipelineData( + "variant", + this.pokemon.battleData.illusion.basePokemon?.variant ?? this.pokemon.variant, + ); ["spriteColors", "fusionSpriteColors"].map(k => { delete this.pokemonSprite.pipelineData[`${k}Base`]; if (this.pokemon?.summonData?.speciesForm) { @@ -446,7 +452,9 @@ export default class SummaryUiHandler extends UiHandler { this.fusionShinyIcon.setPosition(this.shinyIcon.x, this.shinyIcon.y); this.fusionShinyIcon.setVisible(doubleShiny); if (isFusion) { - this.fusionShinyIcon.setTint(getVariantTint(this.pokemon.battleData.illusion.basePokemon?.fusionVariant ?? this.pokemon.fusionVariant)); + this.fusionShinyIcon.setTint( + getVariantTint(this.pokemon.battleData.illusion.basePokemon?.fusionVariant ?? this.pokemon.fusionVariant), + ); } this.pokeball.setFrame(getPokeballAtlasKey(this.pokemon.pokeball)); diff --git a/test/abilities/illusion.test.ts b/test/abilities/illusion.test.ts index 4bc00fd7b62..aff8b642f89 100644 --- a/test/abilities/illusion.test.ts +++ b/test/abilities/illusion.test.ts @@ -3,9 +3,7 @@ import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import overrides from "#app/overrides"; import { Species } from "#enums/species"; -import { - TurnEndPhase, -} from "#app/phases/turn-end-phase"; +import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Moves } from "#enums/moves"; import { Abilities } from "#enums/abilities"; import { PokeballType } from "#app/enums/pokeball"; @@ -30,15 +28,15 @@ 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, Moves.TACKLE, Moves.TACKLE, 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, Moves.TACKLE]); game.override.startingHeldItems([{ name: "WIDE_LENS", count: 3 }]); }); it("creates illusion at the start", async () => { - await game.classicMode.startBattle([ Species.ZOROARK, Species.AXEW ]); + await game.classicMode.startBattle([Species.ZOROARK, Species.AXEW]); const zoroark = game.scene.getPlayerPokemon()!; const zorua = game.scene.getEnemyPokemon()!; @@ -47,7 +45,7 @@ describe("Abilities - Illusion", () => { }); it("break after receiving damaging move", async () => { - await game.classicMode.startBattle([ Species.AXEW ]); + await game.classicMode.startBattle([Species.AXEW]); game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(TurnEndPhase); @@ -60,7 +58,7 @@ describe("Abilities - Illusion", () => { }); it("break after getting ability changed", async () => { - await game.classicMode.startBattle([ Species.AXEW ]); + await game.classicMode.startBattle([Species.AXEW]); game.move.select(Moves.WORRY_SEED); await game.phaseInterceptor.to(TurnEndPhase); @@ -72,7 +70,7 @@ describe("Abilities - Illusion", () => { it("break if the ability is suppressed", async () => { game.override.enemyAbility(Abilities.NEUTRALIZING_GAS); - await game.classicMode.startBattle([ Species.KOFFING ]); + await game.classicMode.startBattle([Species.KOFFING]); const zorua = game.scene.getEnemyPokemon()!; @@ -80,26 +78,40 @@ describe("Abilities - Illusion", () => { }); 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.classicMode.startBattle([ Species.ZOROARK, Species.AXEW ]); + game.override.enemyMoveset([Moves.FLAMETHROWER, Moves.PSYCHIC, Moves.TACKLE, Moves.TACKLE]); + await game.classicMode.startBattle([Species.ZOROARK, Species.AXEW]); const enemy = game.scene.getEnemyPokemon()!; const zoroark = game.scene.getPlayerPokemon()!; const flameThrower = enemy.getMoveset()[0]!.getMove(); const psychic = enemy.getMoveset()[1]!.getMove(); - const flameThrowerEffectiveness = zoroark.getAttackTypeEffectiveness(flameThrower.type, enemy, undefined, undefined, flameThrower, true); - const psychicEffectiveness = zoroark.getAttackTypeEffectiveness(psychic.type, enemy, undefined, undefined, psychic, true); + const flameThrowerEffectiveness = zoroark.getAttackTypeEffectiveness( + flameThrower.type, + enemy, + undefined, + undefined, + flameThrower, + true, + ); + const psychicEffectiveness = zoroark.getAttackTypeEffectiveness( + psychic.type, + enemy, + undefined, + undefined, + psychic, + true, + ); expect(psychicEffectiveness).above(flameThrowerEffectiveness); }); 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 ]); + 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.classicMode.startBattle([ Species.ZOROARK, Species.AZUMARILL ]); + await game.classicMode.startBattle([Species.ZOROARK, Species.AZUMARILL]); game.move.select(Moves.FLARE_BLITZ); @@ -111,9 +123,14 @@ describe("Abilities - Illusion", () => { }); it("copy the the name, the nickname, the gender, the shininess and the pokeball of the pokemon", async () => { - vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.SCARY_FACE, Moves.SCARY_FACE, Moves.SCARY_FACE, Moves.SCARY_FACE ]); + vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([ + Moves.SCARY_FACE, + Moves.SCARY_FACE, + Moves.SCARY_FACE, + Moves.SCARY_FACE, + ]); - await game.classicMode.startBattle([ Species.ABRA, Species.ZOROARK, Species.AXEW ]); + await game.classicMode.startBattle([Species.ABRA, Species.ZOROARK, Species.AXEW]); const axew = game.scene.getPlayerParty().at(2)!; axew.shiny = true;