Skip to content

Commit

Permalink
Fix usedTMs crash (pagefaultgames#4132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fontbane authored Sep 9, 2024
1 parent a30201f commit 16fc3a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/field/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3524,7 +3524,6 @@ export default interface Pokemon {

export class PlayerPokemon extends Pokemon {
public compatibleTms: Moves[];
public usedTms: Moves[];

constructor(scene: BattleScene, species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData) {
super(scene, 106, 148, species, level, abilityIndex, formIndex, gender, shiny, variant, ivs, nature, dataSource);
Expand All @@ -3548,7 +3547,6 @@ export class PlayerPokemon extends Pokemon {
}
}
this.generateCompatibleTms();
this.usedTms = [];
}

initBattleInfo(): void {
Expand Down
6 changes: 6 additions & 0 deletions src/phases/learn-move-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
if (emptyMoveIndex > -1) {
pokemon.setMove(emptyMoveIndex, this.moveId);
if (this.fromTM) {
if (!pokemon.usedTMs) {
pokemon.usedTMs = [];
}
pokemon.usedTMs.push(this.moveId);
}
initMoveAnim(this.scene, this.moveId).then(() => {
Expand Down Expand Up @@ -91,6 +94,9 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
this.scene.ui.showText(i18next.t("battle:learnMoveForgetSuccess", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: pokemon.moveset[moveIndex]!.getName() }), null, () => { // TODO: is the bang correct?
this.scene.ui.showText(i18next.t("battle:learnMoveAnd"), null, () => {
if (this.fromTM) {
if (!pokemon.usedTMs) {
pokemon.usedTMs = [];
}
pokemon.usedTMs.push(this.moveId);
}
pokemon.setMove(moveIndex, Moves.NONE);
Expand Down

0 comments on commit 16fc3a8

Please sign in to comment.