From 446849636de50ef40a991fa0c2006caee1e0413c Mon Sep 17 00:00:00 2001 From: AJ Fontaine Date: Mon, 28 Apr 2025 16:36:14 -0400 Subject: [PATCH] Fix Shedinja --- src/data/balance/pokemon-evolutions.ts | 64 ++++++++++++++++---------- src/field/pokemon.ts | 9 ++-- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/data/balance/pokemon-evolutions.ts b/src/data/balance/pokemon-evolutions.ts index 3fedede7402..1e73cbdfa1e 100644 --- a/src/data/balance/pokemon-evolutions.ts +++ b/src/data/balance/pokemon-evolutions.ts @@ -154,29 +154,41 @@ export class SpeciesEvolutionCondition { switch(cond) { case EvoCondKey.FRIENDSHIP: str.push(i18next.t("pokemonEvolutions:friendship")); + break; case EvoCondKey.TIME: str.push(i18next.t(`pokemonEvolutions:timeOfDay.${TimeOfDay[this.data.time![0]]}`)); + break; case EvoCondKey.MOVE_TYPE: str.push(i18next.t("pokemonEvolutions:moveType", {type: i18next.t(`pokemonInfo:Type.${this.data.moveType!}`)})); + break; case EvoCondKey.PARTY_TYPE: str.push(i18next.t("pokemonEvolutions:partyType", {type: i18next.t(`pokemonInfo:Type.${this.data.partyType!}`)})); + break; case EvoCondKey.GENDER: str.push(i18next.t(`pokemonEvolutions:gender.${Gender[this.data.gender!]}`)); + break; case EvoCondKey.MOVE: case EvoCondKey.TYROGUE: str.push(i18next.t("pokemonEvolutions:move", {move: allMoves[this.data.move!].name})); + break; case EvoCondKey.BIOME: str.push(i18next.t("pokemonEvolutions:biome")); + break; case EvoCondKey.NATURE: str.push(i18next.t("pokemonEvolutions:nature")); + break; case EvoCondKey.WEATHER: str.push(i18next.t("pokemonEvolutions:weather")); + break; case EvoCondKey.SHEDINJA: str.push(i18next.t("pokemonEvolutions:shedinja")); + break; case EvoCondKey.EVO_COUNTER: str.push(i18next.t("pokemonEvolutions:treasure")); + break; case EvoCondKey.SPECIES_CAUGHT: str.push(i18next.t("pokemonEvolutions:caught", {species: getPokemonSpecies(this.data.speciesCaught!).name})); + break; } }); return str.join(i18next.t("pokemonEvolutions:connector")); @@ -207,8 +219,8 @@ export class SpeciesEvolutionCondition { ).length >= this.data.evoCount!; case EvoCondKey.GENDER: return pokemon.gender === this.data.gender; - case EvoCondKey.SHEDINJA: - return globalScene.getPlayerParty().length < 6 && globalScene.pokeballCounts[PokeballType.POKEBALL] > 0; + case EvoCondKey.SHEDINJA: // Shedinja cannot be evolved into directly + return false; case EvoCondKey.BIOME: return this.data.biome?.includes(globalScene.arena.biomeType); case EvoCondKey.WEATHER: @@ -230,6 +242,10 @@ export class SpeciesEvolutionCondition { } } +export function validateShedinjaEvo(): boolean { + return globalScene.getPlayerParty().length < 6 && globalScene.pokeballCounts[PokeballType.POKEBALL] > 0; +} + export class SpeciesFormEvolution { public speciesId: Species; public preFormKey: string | null; @@ -253,26 +269,25 @@ export class SpeciesFormEvolution { } get description(): string { - if (this.desc.length > 0) { - return this.desc; + if (this.desc.length === 0) { + const strings: string[] = []; + if (this.level > 1) { + strings.push(i18next.t("pokemonEvolutions:level") + ` ${this.level}`); + } + if (this.item) { + const itemDescription = i18next.t(`modifierType:EvolutionItem.${EvolutionItem[this.item].toUpperCase()}`); + const rarity = this.item > 50 ? i18next.t("pokemonEvolutions:ULTRA") : i18next.t("pokemonEvolutions:GREAT"); + strings.push(i18next.t("pokemonEvolutions:using") + itemDescription + ` (${rarity})`); + } + if (this.condition) { + strings.push(this.condition.description); + } + this.desc = strings + .filter(str => str !== "") + .map((str, index) => index > 0 ? str[0].toLowerCase() + str.slice(1) : str) + .join(i18next.t("pokemonEvolutions:connector")); } - const strings: string[] = []; - if (this.level > 1) { - strings.push(i18next.t("pokemonEvolutions:level") + ` ${this.level}`); - } - if (this.item) { - const itemDescription = i18next.t(`modifierType:EvolutionItem.${EvolutionItem[this.item].toUpperCase()}`); - const rarity = this.item > 50 ? i18next.t("pokemonEvolutions:ULTRA") : i18next.t("pokemonEvolutions:GREAT"); - strings.push(i18next.t("pokemonEvolutions:using") + itemDescription + ` (${rarity})`); - } - if (this.condition) { - strings.push(this.condition.description); - } - return strings - .filter(str => str !== "") - .map((str, index) => index > 0 ? str[0].toLowerCase() + str.slice(1) : str) - .join(i18next.t("pokemonEvolutions:connector")); - + return this.desc; } /** @@ -284,12 +299,11 @@ export class SpeciesFormEvolution { */ public validate(pokemon: Pokemon, forFusion: boolean = false, item?: EvolutionItem): boolean { return ( - // If an item is given, check if it's the right one - item === this.item && pokemon.level >= this.level && // Check form key, using the fusion's form key if we're checking the fusion - (isNullOrUndefined(this.preFormKey) || (forFusion ? pokemon.getFormKey() : pokemon.getFusionFormKey()) === this.preFormKey) && - (this.condition === null || this.condition?.conditionsFulfilled(pokemon)) + (isNullOrUndefined(this.preFormKey) || (forFusion ? pokemon.getFusionFormKey() : pokemon.getFormKey()) === this.preFormKey) && + (isNullOrUndefined(this.condition) || this.condition?.conditionsFulfilled(pokemon)) && + ((item ?? EvolutionItem.NONE) === (this.item ?? EvolutionItem.NONE)) ); } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index f53afa50259..a5c7e8cfa5b 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -99,6 +99,7 @@ import { pokemonEvolutions, pokemonPrevolutions, FusionSpeciesFormEvolution, + validateShedinjaEvo, } from "#app/data/balance/pokemon-evolutions"; import { reverseCompatibleTms, @@ -6667,10 +6668,8 @@ export class PlayerPokemon extends Pokemon { }); }; if (preEvolution.speciesId === Species.GIMMIGHOUL) { - const evotracker = - this.getHeldItems().filter(m => m instanceof EvoTrackerModifier)[0] ?? - null; - if (evotracker) { + const evotracker = this.getHeldItems().find(m => m instanceof EvoTrackerModifier); + if (!isNullOrUndefined(evotracker)) { globalScene.removeModifier(evotracker); } } @@ -6699,7 +6698,7 @@ export class PlayerPokemon extends Pokemon { ) { const newEvolution = pokemonEvolutions[evoSpecies.speciesId][1]; - if (newEvolution.validate(this, evoSpecies.speciesId === this.species.speciesId)) { + if (validateShedinjaEvo()) { const newPokemon = globalScene.addPlayerPokemon( this.species, this.level,