From 8345eaef5a63fb8cf76d7de4a0bddc67ddeef12f Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 28 Nov 2023 14:37:45 -0500 Subject: [PATCH] Fix TM compatibility for certain moves being reversed --- src/data/tms.ts | 9 +++++++++ src/pokemon.ts | 11 ++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/data/tms.ts b/src/data/tms.ts index c5afc5d0e..5411250f1 100644 --- a/src/data/tms.ts +++ b/src/data/tms.ts @@ -6,6 +6,15 @@ interface TmSpecies { [key: integer]: Array> } +export const reverseCompatibleTms: Moves[] = [ + Moves.DOUBLE_EDGE, + Moves.REST, + Moves.ENDURE, + Moves.ATTRACT, + Moves.FACADE, + Moves.CAPTIVATE +]; + export const tmSpecies: TmSpecies = { [Moves.MEGA_PUNCH]: [ Species.CHARMANDER, diff --git a/src/pokemon.ts b/src/pokemon.ts index d6c8ada96..1f9f3a950 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -12,7 +12,7 @@ import { PokeballType } from './data/pokeball'; import { Gender } from './data/gender'; import { initMoveAnim, loadMoveAnimAssets } from './data/battle-anims'; import { Status, StatusEffect } from './data/status-effect'; -import { tmSpecies } from './data/tms'; +import { reverseCompatibleTms, tmSpecies } from './data/tms'; import { pokemonEvolutions, pokemonPrevolutions, SpeciesEvolution, SpeciesEvolutionCondition } from './data/pokemon-evolutions'; import { DamagePhase, FaintPhase, SwitchSummonPhase } from './battle-phases'; import { BattleStat } from './data/battle-stat'; @@ -1624,17 +1624,22 @@ export class PlayerPokemon extends Pokemon { const tms = Object.keys(tmSpecies); for (let tm of tms) { const moveId = parseInt(tm) as Moves; + let compatible = false; for (let p of tmSpecies[tm]) { if (Array.isArray(p)) { if (p[0] === this.species.speciesId || (this.fusionSpecies && p[0] === this.fusionSpecies.speciesId)) { - this.compatibleTms.push(moveId); + compatible = true; break; } } else if (p === this.species.speciesId || (this.fusionSpecies && p === this.fusionSpecies.speciesId)) { - this.compatibleTms.push(moveId); + compatible = true; break; } } + if (reverseCompatibleTms.indexOf(moveId) > -1) + compatible = !compatible; + if (compatible) + this.compatibleTms.push(moveId); } }