Skip to content

Commit

Permalink
[Hotfix] Fix Gimmighoul evolution (#4473)
Browse files Browse the repository at this point in the history
* Fix Gimmighoul evolution

* Fix counter

* Stack text fix

* Fix Treasure tracker not saving

* Apply suggestions from code review

Co-authored-by: NightKev <[email protected]>

---------

Co-authored-by: flx-sta <[email protected]>
Co-authored-by: NightKev <[email protected]>
  • Loading branch information
3 people authored Sep 29, 2024
1 parent a69da4b commit 7bb49a3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
11 changes: 9 additions & 2 deletions src/data/pokemon-evolutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { TimeOfDay } from "#enums/time-of-day";
import { DamageMoneyRewardModifier, ExtraModifierModifier, MoneyMultiplierModifier } from "#app/modifier/modifier";

export enum SpeciesWildEvolutionDelay {
NONE,
Expand Down Expand Up @@ -1647,8 +1648,14 @@ export const pokemonEvolutions: PokemonEvolutions = {
new SpeciesEvolution(Species.FROSMOTH, 1, null, new SpeciesFriendshipEvolutionCondition(90, p => p.scene.arena.getTimeOfDay() === TimeOfDay.DUSK || p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.MEDIUM)
],
[Species.GIMMIGHOUL]: [
new SpeciesFormEvolution(Species.GHOLDENGO, "chest", "", 1, null, new SpeciesEvolutionCondition( p => p.evoCounter > 9 ), SpeciesWildEvolutionDelay.VERY_LONG),
new SpeciesFormEvolution(Species.GHOLDENGO, "roaming", "", 1, null, new SpeciesEvolutionCondition( p => p.evoCounter > 9 ), SpeciesWildEvolutionDelay.VERY_LONG)
new SpeciesFormEvolution(Species.GHOLDENGO, "chest", "", 1, null, new SpeciesEvolutionCondition(p => p.evoCounter
+ p.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length
+ p.scene.findModifiers(m => m instanceof MoneyMultiplierModifier
|| m instanceof ExtraModifierModifier).length > 9), SpeciesWildEvolutionDelay.VERY_LONG),
new SpeciesFormEvolution(Species.GHOLDENGO, "roaming", "", 1, null, new SpeciesEvolutionCondition(p => p.evoCounter
+ p.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length
+ p.scene.findModifiers(m => m instanceof MoneyMultiplierModifier
|| m instanceof ExtraModifierModifier).length > 9), SpeciesWildEvolutionDelay.VERY_LONG)
]
};

Expand Down
3 changes: 2 additions & 1 deletion src/modifier/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,8 @@ export const modifierTypes = {
FORM_CHANGE_ITEM: () => new FormChangeItemModifierTypeGenerator(false),
RARE_FORM_CHANGE_ITEM: () => new FormChangeItemModifierTypeGenerator(true),

EVOLUTION_TRACKER_GIMMIGHOUL: () => new PokemonHeldItemModifierType("modifierType:ModifierType.EVOLUTION_TRACKER_GIMMIGHOUL", "relic_gold", (type, _args) => new Modifiers.EvoTrackerModifier(type, (_args[0] as Pokemon).id, Species.GIMMIGHOUL, 10)),
EVOLUTION_TRACKER_GIMMIGHOUL: () => new PokemonHeldItemModifierType("modifierType:ModifierType.EVOLUTION_TRACKER_GIMMIGHOUL", "relic_gold",
(type, args) => new Modifiers.EvoTrackerModifier(type, (args[0] as Pokemon).id, Species.GIMMIGHOUL, 10)),

MEGA_BRACELET: () => new ModifierType("modifierType:ModifierType.MEGA_BRACELET", "mega_bracelet", (type, _args) => new Modifiers.MegaEvolutionAccessModifier(type)),
DYNAMAX_BAND: () => new ModifierType("modifierType:ModifierType.DYNAMAX_BAND", "dynamax_band", (type, _args) => new Modifiers.GigantamaxAccessModifier(type)),
Expand Down
44 changes: 32 additions & 12 deletions src/modifier/modifier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ModifierTypes from "./modifier-type";
import { ModifierType, modifierTypes } from "./modifier-type";
import { getModifierType, ModifierType, modifierTypes } from "./modifier-type";
import BattleScene from "../battle-scene";
import { getLevelTotalExp } from "../data/exp";
import { MAX_PER_TYPE_POKEBALLS, PokeballType } from "../data/pokeball";
Expand Down Expand Up @@ -852,26 +852,47 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier {
}

matchType(modifier: Modifier): boolean {
if (modifier instanceof EvoTrackerModifier) {
return (modifier as EvoTrackerModifier).species === this.species;
}
return false;
return modifier instanceof EvoTrackerModifier && modifier.species === this.species && modifier.required === this.required;
}

clone(): PersistentModifier {
return new EvoTrackerModifier(this.type, this.pokemonId, this.species, this.stackCount);
return new EvoTrackerModifier(this.type, this.pokemonId, this.species, this.required, this.stackCount);
}

getArgs(): any[] {
return super.getArgs().concat(this.species);
return super.getArgs().concat([this.species, this.required]);
}

apply(args: any[]): boolean {
return true;
}

getMaxHeldItemCount(_pokemon: Pokemon): integer {
return this.required;
getIconStackText(scene: BattleScene, virtual?: boolean): Phaser.GameObjects.BitmapText | null {
if (this.getMaxStackCount(scene) === 1 || (virtual && !this.virtualStackCount)) {
return null;
}

const pokemon = scene.getPokemonById(this.pokemonId);

this.stackCount = pokemon
? pokemon.evoCounter + pokemon.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length
+ pokemon.scene.findModifiers(m => m instanceof MoneyMultiplierModifier || m instanceof ExtraModifierModifier).length
: this.stackCount;

const text = scene.add.bitmapText(10, 15, "item-count", this.stackCount.toString(), 11);
text.letterSpacing = -0.5;
if (this.getStackCount() >= this.required) {
text.setTint(0xf89890);
}
text.setOrigin(0, 0);

return text;
}

getMaxHeldItemCount(pokemon: Pokemon): integer {
this.stackCount = pokemon.evoCounter + pokemon.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length
+ pokemon.scene.findModifiers(m => m instanceof MoneyMultiplierModifier || m instanceof ExtraModifierModifier).length;
return 999;
}
}

Expand Down Expand Up @@ -2414,9 +2435,8 @@ export class MoneyRewardModifier extends ConsumableModifier {

scene.getParty().map(p => {
if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) {
p.evoCounter++;
const modifierType: ModifierType = modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL();
const modifier = modifierType!.newModifier(p);
p.evoCounter ? p.evoCounter++ : p.evoCounter = 1;
const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier;
scene.addModifier(modifier);
}
});
Expand Down

0 comments on commit 7bb49a3

Please sign in to comment.