[Dev] Minor Version Migration Tweaks (#4727)
* [P3] Prevent Unintended ME Migration Application * Change Patch Value from 4 to 5 * Bump Game Version * Fix Imports, Use `isNullOrUndefined`
This commit is contained in:
parent
07f08877c1
commit
1867ac4a9e
|
@ -129,7 +129,7 @@ class SessionVersionConverter extends VersionConverter {
|
||||||
|
|
||||||
if (curMajor === 1) {
|
if (curMajor === 1) {
|
||||||
if (curMinor === 0) {
|
if (curMinor === 0) {
|
||||||
if (curPatch <= 4) {
|
if (curPatch <= 5) {
|
||||||
console.log("Applying v1.0.4 session data migration!");
|
console.log("Applying v1.0.4 session data migration!");
|
||||||
this.callMigrators(data, v1_0_4.sessionMigrators);
|
this.callMigrators(data, v1_0_4.sessionMigrators);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { SettingKeys } from "#app/system/settings/settings";
|
import { SettingKeys } from "#app/system/settings/settings";
|
||||||
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "#app/system/game-data";
|
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "#app/system/game-data";
|
||||||
import { allSpecies } from "#app/data/pokemon-species";
|
import { allSpecies } from "#app/data/pokemon-species";
|
||||||
|
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
||||||
import { isNullOrUndefined } from "#app/utils";
|
import { isNullOrUndefined } from "#app/utils";
|
||||||
|
|
||||||
export const systemMigrators = [
|
export const systemMigrators = [
|
||||||
|
@ -134,5 +135,28 @@ export const sessionMigrators = [
|
||||||
m.className = "ResetNegativeStatStageModifier";
|
m.className = "ResetNegativeStatStageModifier";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Converts old Pokemon natureOverride and mysteryEncounterData
|
||||||
|
* to use the new conjoined {@linkcode Pokemon.customPokemonData} structure instead.
|
||||||
|
* @param data {@linkcode SessionSaveData}
|
||||||
|
*/
|
||||||
|
function migrateCustomPokemonDataAndNatureOverrides(data: SessionSaveData) {
|
||||||
|
// Fix Pokemon nature overrides and custom data migration
|
||||||
|
data.party.forEach(pokemon => {
|
||||||
|
if (pokemon["mysteryEncounterPokemonData"]) {
|
||||||
|
pokemon.customPokemonData = new CustomPokemonData(pokemon["mysteryEncounterPokemonData"]);
|
||||||
|
pokemon["mysteryEncounterPokemonData"] = null;
|
||||||
|
}
|
||||||
|
if (pokemon["fusionMysteryEncounterPokemonData"]) {
|
||||||
|
pokemon.fusionCustomPokemonData = new CustomPokemonData(pokemon["fusionMysteryEncounterPokemonData"]);
|
||||||
|
pokemon["fusionMysteryEncounterPokemonData"] = null;
|
||||||
|
}
|
||||||
|
pokemon.customPokemonData = pokemon.customPokemonData ?? new CustomPokemonData();
|
||||||
|
if (!isNullOrUndefined(pokemon["natureOverride"]) && pokemon["natureOverride"] >= 0) {
|
||||||
|
pokemon.customPokemonData.nature = pokemon["natureOverride"];
|
||||||
|
pokemon["natureOverride"] = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
] as const;
|
] as const;
|
||||||
|
|
|
@ -1,32 +1,5 @@
|
||||||
import { SessionSaveData } from "../../game-data";
|
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
|
||||||
|
|
||||||
export const systemMigrators = [] as const;
|
export const systemMigrators = [] as const;
|
||||||
|
|
||||||
export const settingsMigrators = [] as const;
|
export const settingsMigrators = [] as const;
|
||||||
|
|
||||||
export const sessionMigrators = [
|
export const sessionMigrators = [] as const;
|
||||||
/**
|
|
||||||
* Converts old Pokemon natureOverride and mysteryEncounterData
|
|
||||||
* to use the new conjoined {@linkcode Pokemon.customPokemonData} structure instead.
|
|
||||||
* @param data {@linkcode SessionSaveData}
|
|
||||||
*/
|
|
||||||
function migrateCustomPokemonDataAndNatureOverrides(data: SessionSaveData) {
|
|
||||||
// Fix Pokemon nature overrides and custom data migration
|
|
||||||
data.party.forEach(pokemon => {
|
|
||||||
if (pokemon["mysteryEncounterPokemonData"]) {
|
|
||||||
pokemon.customPokemonData = new CustomPokemonData(pokemon["mysteryEncounterPokemonData"]);
|
|
||||||
pokemon["mysteryEncounterPokemonData"] = null;
|
|
||||||
}
|
|
||||||
if (pokemon["fusionMysteryEncounterPokemonData"]) {
|
|
||||||
pokemon.fusionCustomPokemonData = new CustomPokemonData(pokemon["fusionMysteryEncounterPokemonData"]);
|
|
||||||
pokemon["fusionMysteryEncounterPokemonData"] = null;
|
|
||||||
}
|
|
||||||
pokemon.customPokemonData = pokemon.customPokemonData ?? new CustomPokemonData();
|
|
||||||
if (pokemon["natureOverride"] && pokemon["natureOverride"] >= 0) {
|
|
||||||
pokemon.customPokemonData.nature = pokemon["natureOverride"];
|
|
||||||
pokemon["natureOverride"] = -1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
] as const;
|
|
||||||
|
|
Loading…
Reference in New Issue