This commit is contained in:
Lylian 2025-03-10 12:42:35 +01:00
parent b3ccf8d9b6
commit 15fbd9a54f
8 changed files with 72 additions and 35 deletions

View File

@ -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 => {

View File

@ -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()

View File

@ -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();

View File

@ -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";

View File

@ -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)

View File

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

View File

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

View File

@ -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;