pokerogue/src/system/version_migration/versions/v1_8_3.ts
NightKev 9dcb904649
[Misc] Improve enum naming (#5933)
* Rename `Abilities` to `AbilityId`

* Rename `abilities.ts` to `ability-id.ts`

* Rename `Moves` to `MoveId`

* Rename `moves.ts` to `move-id.ts`

* Rename `Species` to `SpeciesId`

* Rename `species.ts` to `species-id.ts`

* Rename `Biome` to `BiomeId`

* Rename `biome.ts` to `biome-id.ts`

* Replace `Abilities` with `AbilityId` in comments

* Replace `Biome` with `BiomeId` in comments

* Replace `Moves` with `MoveId` in comments

* Replace `Species` with `SpeciesId` in comments
2025-06-04 14:54:27 -07:00

31 lines
1.2 KiB
TypeScript

import type { SystemSaveMigrator } from "#app/@types/SystemSaveMigrator";
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { DexAttr, type SystemSaveData } from "#app/system/game-data";
import { SpeciesId } from "#enums/species-id";
/**
* If a starter is caught, but the only forms registered as caught are not starterSelectable,
* unlock the default form.
* @param data - {@linkcode SystemSaveData}
*/
const migratePichuForms: SystemSaveMigrator = {
version: "1.8.3",
migrate: (data: SystemSaveData): void => {
if (data.starterData && data.dexData) {
// This is Pichu's Pokédex number
const sd = 172;
const caughtAttr = data.dexData[sd]?.caughtAttr;
const species = getPokemonSpecies(sd);
// An extra check because you never know
if (species.speciesId === SpeciesId.PICHU && caughtAttr) {
// Ensuring that only existing forms are unlocked
data.dexData[sd].caughtAttr &= species.getFullUnlocksData();
// If no forms are unlocked now, since Pichu is caught, we unlock form 0
data.dexData[sd].caughtAttr |= DexAttr.DEFAULT_FORM;
}
}
},
};
export const systemMigrators: Readonly<SystemSaveMigrator[]> = [migratePichuForms] as const;