Switch from tmSpecies to speciesTmList

This commit is contained in:
AJ Fontaine 2025-08-04 00:14:58 -04:00
parent 8a2b888971
commit 63bc36b39b
7 changed files with 1220 additions and 68641 deletions

File diff suppressed because one or more lines are too long

View File

@ -13,10 +13,12 @@ import {
pokemonSpeciesLevelMoves, pokemonSpeciesLevelMoves,
} from "#balance/pokemon-level-moves"; } from "#balance/pokemon-level-moves";
import { speciesStarterCosts } from "#balance/starters"; import { speciesStarterCosts } from "#balance/starters";
import { speciesFormTmList, speciesTmList } from "#balance/tms";
import type { GrowthRate } from "#data/exp"; import type { GrowthRate } from "#data/exp";
import { Gender } from "#data/gender"; import { Gender } from "#data/gender";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { DexAttr } from "#enums/dex-attr"; import { DexAttr } from "#enums/dex-attr";
import type { MoveId } from "#enums/move-id";
import { PartyMemberStrength } from "#enums/party-member-strength"; import { PartyMemberStrength } from "#enums/party-member-strength";
import type { PokemonType } from "#enums/pokemon-type"; import type { PokemonType } from "#enums/pokemon-type";
import { SpeciesFormKey } from "#enums/species-form-key"; import { SpeciesFormKey } from "#enums/species-form-key";
@ -351,6 +353,17 @@ export abstract class PokemonSpeciesForm {
return `pokemon_icons_${this.generation}${isVariant ? "v" : ""}`; return `pokemon_icons_${this.generation}${isVariant ? "v" : ""}`;
} }
getCompatibleTms(formIndex?: number): MoveId[] {
const tms: MoveId[] = [];
tms.push(...speciesTmList[this.speciesId]);
if (speciesFormTmList.hasOwnProperty(this.speciesId)) {
formIndex = this.formIndex ?? formIndex ?? -1;
const formKey = getPokemonSpecies(this.speciesId).forms[formIndex].formKey;
tms.push(...(speciesFormTmList[this.speciesId][formKey] ?? []));
}
return tms;
}
getIconId(female: boolean, formIndex?: number, shiny?: boolean, variant?: number): string { getIconId(female: boolean, formIndex?: number, shiny?: boolean, variant?: number): string {
if (formIndex === undefined) { if (formIndex === undefined) {
formIndex = this.formIndex; formIndex = this.formIndex;

View File

@ -2,7 +2,7 @@ import { timedEventManager } from "#app/global-event-manager";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import { pokemonEvolutions, pokemonPrevolutions } from "#balance/pokemon-evolutions"; import { pokemonEvolutions, pokemonPrevolutions } from "#balance/pokemon-evolutions";
import { signatureSpecies } from "#balance/signature-species"; import { signatureSpecies } from "#balance/signature-species";
import { tmSpecies } from "#balance/tms"; import { speciesTmList } from "#balance/tms";
import { modifierTypes } from "#data/data-lists"; import { modifierTypes } from "#data/data-lists";
import { doubleBattleDialogue } from "#data/double-battle-dialogue"; import { doubleBattleDialogue } from "#data/double-battle-dialogue";
import { Gender } from "#data/gender"; import { Gender } from "#data/gender";
@ -1446,7 +1446,7 @@ export const trainerConfigs: TrainerConfigs = {
.setSpeciesFilter(s => s.isOfType(PokemonType.ELECTRIC)), .setSpeciesFilter(s => s.isOfType(PokemonType.ELECTRIC)),
[TrainerType.HARLEQUIN]: new TrainerConfig(++t) [TrainerType.HARLEQUIN]: new TrainerConfig(++t)
.setEncounterBgm(TrainerType.PSYCHIC) .setEncounterBgm(TrainerType.PSYCHIC)
.setSpeciesFilter(s => tmSpecies[MoveId.TRICK_ROOM].indexOf(s.speciesId) > -1), .setSpeciesFilter(s => speciesTmList[s.speciesId].includes(MoveId.TRICK_ROOM)),
[TrainerType.HIKER]: new TrainerConfig(++t) [TrainerType.HIKER]: new TrainerConfig(++t)
.setEncounterBgm(TrainerType.BACKPACKER) .setEncounterBgm(TrainerType.BACKPACKER)
.setPartyTemplates( .setPartyTemplates(
@ -1590,7 +1590,7 @@ export const trainerConfigs: TrainerConfigs = {
trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_AVG,
trainerPartyTemplates.THREE_AVG, trainerPartyTemplates.THREE_AVG,
) )
.setSpeciesFilter(s => tmSpecies[MoveId.FLY].indexOf(s.speciesId) > -1), .setSpeciesFilter(s => speciesTmList[s.speciesId].includes(MoveId.FLY)),
[TrainerType.POKEFAN]: new TrainerConfig(++t) [TrainerType.POKEFAN]: new TrainerConfig(++t)
.setMoneyMultiplier(1.4) .setMoneyMultiplier(1.4)
.setName("PokéFan") .setName("PokéFan")
@ -1606,7 +1606,7 @@ export const trainerConfigs: TrainerConfigs = {
trainerPartyTemplates.FIVE_WEAK, trainerPartyTemplates.FIVE_WEAK,
trainerPartyTemplates.SIX_WEAKER_SAME, trainerPartyTemplates.SIX_WEAKER_SAME,
) )
.setSpeciesFilter(s => tmSpecies[MoveId.HELPING_HAND].indexOf(s.speciesId) > -1), .setSpeciesFilter(s => speciesTmList[s.speciesId].includes(MoveId.HELPING_HAND)),
[TrainerType.PRESCHOOLER]: new TrainerConfig(++t) [TrainerType.PRESCHOOLER]: new TrainerConfig(++t)
.setMoneyMultiplier(0.2) .setMoneyMultiplier(0.2)
.setEncounterBgm(TrainerType.YOUNGSTER) .setEncounterBgm(TrainerType.YOUNGSTER)

View File

@ -18,7 +18,7 @@ import type { LevelMoves } from "#balance/pokemon-level-moves";
import { EVOLVE_MOVE, RELEARN_MOVE } from "#balance/pokemon-level-moves"; import { EVOLVE_MOVE, RELEARN_MOVE } from "#balance/pokemon-level-moves";
import { BASE_HIDDEN_ABILITY_CHANCE, BASE_SHINY_CHANCE, SHINY_EPIC_CHANCE, SHINY_VARIANT_CHANCE } from "#balance/rates"; import { BASE_HIDDEN_ABILITY_CHANCE, BASE_SHINY_CHANCE, SHINY_EPIC_CHANCE, SHINY_VARIANT_CHANCE } from "#balance/rates";
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#balance/starters"; import { getStarterValueFriendshipCap, speciesStarterCosts } from "#balance/starters";
import { reverseCompatibleTms, tmPoolTiers, tmSpecies } from "#balance/tms"; import { tmPoolTiers } from "#balance/tms";
import type { SuppressAbilitiesTag } from "#data/arena-tag"; import type { SuppressAbilitiesTag } from "#data/arena-tag";
import { NoCritTag, WeakenMoveScreenTag } from "#data/arena-tag"; import { NoCritTag, WeakenMoveScreenTag } from "#data/arena-tag";
import { import {
@ -3084,27 +3084,13 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
} }
if (this.hasTrainer()) { if (this.hasTrainer()) {
const tms = Object.keys(tmSpecies); const tmset = new Set(this.species.getCompatibleTms(this.formIndex));
for (const tm of tms) { if (this.fusionSpecies) {
const moveId = Number.parseInt(tm) as MoveId; this.fusionSpecies.getCompatibleTms(this.fusionFormIndex).forEach(m => tmset.add(m));
let compatible = false;
for (const p of tmSpecies[tm]) {
if (Array.isArray(p)) {
if (
p[0] === this.species.speciesId ||
(this.fusionSpecies &&
p[0] === this.fusionSpecies.speciesId &&
p.slice(1).indexOf(this.species.forms[this.formIndex]) > -1)
) {
compatible = true;
break;
} }
} else if (p === this.species.speciesId || (this.fusionSpecies && p === this.fusionSpecies.speciesId)) { const tms = Array.from(tmset);
compatible = true; for (const moveId of tms) {
break; if (!movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)")) {
}
}
if (compatible && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)")) {
if (tmPoolTiers[moveId] === ModifierTier.COMMON && this.level >= 15) { if (tmPoolTiers[moveId] === ModifierTier.COMMON && this.level >= 15) {
movePool.push([moveId, 4]); movePool.push([moveId, 4]);
} else if (tmPoolTiers[moveId] === ModifierTier.GREAT && this.level >= 30) { } else if (tmPoolTiers[moveId] === ModifierTier.GREAT && this.level >= 30) {
@ -5737,34 +5723,11 @@ export class PlayerPokemon extends Pokemon {
} }
generateCompatibleTms(): void { generateCompatibleTms(): void {
this.compatibleTms = []; const tms = new Set(this.species.getCompatibleTms(this.formIndex));
if (this.fusionSpecies) {
const tms = Object.keys(tmSpecies); this.fusionSpecies.getCompatibleTms(this.fusionFormIndex).forEach(m => tms.add(m));
for (const tm of tms) {
const moveId = Number.parseInt(tm) as MoveId;
let compatible = false;
for (const p of tmSpecies[tm]) {
if (Array.isArray(p)) {
const [pkm, form] = p;
if (
(pkm === this.species.speciesId || (this.fusionSpecies && pkm === this.fusionSpecies.speciesId)) &&
form === this.getFormKey()
) {
compatible = true;
break;
}
} else if (p === this.species.speciesId || (this.fusionSpecies && p === this.fusionSpecies.speciesId)) {
compatible = true;
break;
}
}
if (reverseCompatibleTms.indexOf(moveId) > -1) {
compatible = !compatible;
}
if (compatible) {
this.compatibleTms.push(moveId);
}
} }
this.compatibleTms = Array.from(tms);
} }
tryPopulateMoveset(moveset: StarterMoveset): boolean { tryPopulateMoveset(moveset: StarterMoveset): boolean {

View File

@ -4,7 +4,7 @@ import { globalScene } from "#app/global-scene";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
import { EvolutionItem, pokemonEvolutions } from "#balance/pokemon-evolutions"; import { EvolutionItem, pokemonEvolutions } from "#balance/pokemon-evolutions";
import { tmPoolTiers, tmSpecies } from "#balance/tms"; import { tmPoolTiers } from "#balance/tms";
import { getBerryEffectDescription, getBerryName } from "#data/berry"; import { getBerryEffectDescription, getBerryName } from "#data/berry";
import { allMoves, modifierTypes } from "#data/data-lists"; import { allMoves, modifierTypes } from "#data/data-lists";
import { SpeciesFormChangeItemTrigger } from "#data/form-change-triggers"; import { SpeciesFormChangeItemTrigger } from "#data/form-change-triggers";
@ -1144,7 +1144,7 @@ export class TmModifierType extends PokemonModifierType {
get name(): string { get name(): string {
return i18next.t("modifierType:ModifierType.TmModifierType.name", { return i18next.t("modifierType:ModifierType.TmModifierType.name", {
moveId: padInt(Object.keys(tmSpecies).indexOf(this.moveId.toString()) + 1, 3), moveId: padInt(Object.keys(tmPoolTiers).indexOf(this.moveId.toString()) + 1, 3),
moveName: allMoves[this.moveId].name, moveName: allMoves[this.moveId].name,
}); });
} }

View File

@ -16,7 +16,6 @@ import {
getValueReductionCandyCounts, getValueReductionCandyCounts,
speciesStarterCosts, speciesStarterCosts,
} from "#balance/starters"; } from "#balance/starters";
import { speciesTmMoves } from "#balance/tms";
import { allAbilities, allMoves, allSpecies } from "#data/data-lists"; import { allAbilities, allMoves, allSpecies } from "#data/data-lists";
import { Egg, getEggTierForSpecies } from "#data/egg"; import { Egg, getEggTierForSpecies } from "#data/egg";
import { GrowthRate, getGrowthRateColor } from "#data/exp"; import { GrowthRate, getGrowthRateColor } from "#data/exp";
@ -841,10 +840,7 @@ export class PokedexPageUiHandler extends MessageUiHandler {
); );
this.tmMoves = this.tmMoves =
speciesTmMoves[species.speciesId] species.getCompatibleTms(formIndex).sort((a, b) => (allMoves[a].name > allMoves[b].name ? 1 : -1)) ?? [];
?.filter(m => (Array.isArray(m) ? m[0] === formKey : true))
.map(m => (Array.isArray(m) ? m[1] : m))
.sort((a, b) => (allMoves[a].name > allMoves[b].name ? 1 : -1)) ?? [];
const passiveId = starterPassiveAbilities.hasOwnProperty(species.speciesId) const passiveId = starterPassiveAbilities.hasOwnProperty(species.speciesId)
? species.speciesId ? species.speciesId

View File

@ -12,7 +12,6 @@ import {
POKERUS_STARTER_COUNT, POKERUS_STARTER_COUNT,
speciesStarterCosts, speciesStarterCosts,
} from "#balance/starters"; } from "#balance/starters";
import { speciesTmMoves } from "#balance/tms";
import { allAbilities, allMoves, allSpecies } from "#data/data-lists"; import { allAbilities, allMoves, allSpecies } from "#data/data-lists";
import type { PokemonForm, PokemonSpecies } from "#data/pokemon-species"; import type { PokemonForm, PokemonSpecies } from "#data/pokemon-species";
import { normalForm } from "#data/pokemon-species"; import { normalForm } from "#data/pokemon-species";
@ -1380,7 +1379,7 @@ export class PokedexUiHandler extends MessageUiHandler {
const levelMoves = pokemonSpeciesLevelMoves[species.speciesId].map(m => allMoves[m[1]].name); const levelMoves = pokemonSpeciesLevelMoves[species.speciesId].map(m => allMoves[m[1]].name);
// This always gets egg moves from the starter // This always gets egg moves from the starter
const eggMoves = speciesEggMoves[starterId]?.map(m => allMoves[m].name) ?? []; const eggMoves = speciesEggMoves[starterId]?.map(m => allMoves[m].name) ?? [];
const tmMoves = speciesTmMoves[species.speciesId]?.map(m => allMoves[Array.isArray(m) ? m[1] : m].name) ?? []; const tmMoves = species.getCompatibleTms().map(m => allMoves[m].name) ?? [];
const selectedMove1 = this.filterText.getValue(FilterTextRow.MOVE_1); const selectedMove1 = this.filterText.getValue(FilterTextRow.MOVE_1);
const selectedMove2 = this.filterText.getValue(FilterTextRow.MOVE_2); const selectedMove2 = this.filterText.getValue(FilterTextRow.MOVE_2);