From 6691e0234f1e3da606a570c74f35419ad9bf0020 Mon Sep 17 00:00:00 2001 From: PrabbyDD Date: Tue, 24 Sep 2024 11:39:37 -0700 Subject: [PATCH] fixing tests and allowing rotom unique moves to be learned as tms for that rotom form --- src/field/pokemon.ts | 4 ++-- src/test/field/pokemon.test.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 7e1431c1fa2..5af6b8dac26 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3972,8 +3972,8 @@ export class PlayerPokemon extends Pokemon { let compatible = false; for (const p of tmSpecies[tm]) { if (Array.isArray(p)) { - const [pkm, ...forms] = p; - if ((pkm === this.species.speciesId || this.fusionSpecies && pkm === this.fusionSpecies.speciesId) && forms.some(form => form === this.species.forms[this.formIndex])) { + const [pkm, form] = p; + if ((pkm === this.species.speciesId || this.fusionSpecies && pkm === this.fusionSpecies.speciesId) && form === this.getFormKey()) { compatible = true; break; } diff --git a/src/test/field/pokemon.test.ts b/src/test/field/pokemon.test.ts index f7c1cf8bc3d..ba752aa0d8d 100644 --- a/src/test/field/pokemon.test.ts +++ b/src/test/field/pokemon.test.ts @@ -3,6 +3,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "../utils/gameManager"; import { PokeballType } from "#app/enums/pokeball"; import BattleScene from "#app/battle-scene"; +import { tmSpecies } from "#app/data/tms"; describe("Spec - Pokemon", () => { let phaserGame: Phaser.Game; @@ -63,4 +64,32 @@ describe("Spec - Pokemon", () => { }); }); }); + it("pokemon that have form changes and different tms per form should not share tms between forms", async () => { + game.override.starterForms({ [Species.ROTOM]: 4 }); + await game.classicMode.startBattle([Species.ROTOM]); + const playerPokemon = game.scene.getPlayerPokemon()!; + + // 59 is blizzard, fan rotom should not be in that array + const compatible1 = tmSpecies[59].some(p => { + if (Array.isArray(p)) { + const [pkm, form] = p; + return pkm === playerPokemon.species.speciesId && playerPokemon.getFormKey() === form; + } + return false; + }); + + // Air slash is 403, fan rotom should be in it + const compatible2 = tmSpecies[403].some(p => { + if (Array.isArray(p)) { + const [pkm, form] = p; + return pkm === playerPokemon.species.speciesId && playerPokemon.getFormKey() === form; + } + return false; + }); + + expect(playerPokemon.compatibleTms.includes(59)).toBeFalsy(); + expect(playerPokemon.compatibleTms.includes(403)).toBeTruthy(); + expect(compatible1).toBeFalsy(); + expect(compatible2).toBeTruthy(); + }); });