[P1] Fix System Data Conversion Failure 3 (#4866)
* [P1] Fix System Data Conversion Failure 3 * Use `isNullOrUndefined`, Clean Up Imports * fix pre candy update save data migration for candy * fix pre candy update save data migration for candy part 2... --------- Co-authored-by: Moka <millennium.stitcher@gmail.com>
This commit is contained in:
parent
4aff2ffa1d
commit
c22b48f903
|
@ -506,9 +506,9 @@ export class GameData {
|
||||||
|
|
||||||
const starterIds = Object.keys(this.starterData).map(s => parseInt(s) as Species);
|
const starterIds = Object.keys(this.starterData).map(s => parseInt(s) as Species);
|
||||||
for (const s of starterIds) {
|
for (const s of starterIds) {
|
||||||
this.starterData[s].candyCount += this.dexData[s].caughtCount;
|
this.starterData[s].candyCount += systemData.dexData[s].caughtCount;
|
||||||
this.starterData[s].candyCount += this.dexData[s].hatchedCount * 2;
|
this.starterData[s].candyCount += systemData.dexData[s].hatchedCount * 2;
|
||||||
if (this.dexData[s].caughtAttr & DexAttr.SHINY) {
|
if (systemData.dexData[s].caughtAttr & DexAttr.SHINY) {
|
||||||
this.starterData[s].candyCount += 4;
|
this.starterData[s].candyCount += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { SettingKeys } from "../../settings/settings";
|
import { SettingKeys } from "#app/system/settings/settings";
|
||||||
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "../../game-data";
|
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "#app/system/game-data";
|
||||||
import { allSpecies } from "../../../data/pokemon-species";
|
import { allSpecies } from "#app/data/pokemon-species";
|
||||||
|
import { isNullOrUndefined } from "#app/utils";
|
||||||
|
|
||||||
export const systemMigrators = [
|
export const systemMigrators = [
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +47,7 @@ export const systemMigrators = [
|
||||||
* @param data {@linkcode SystemSaveData}
|
* @param data {@linkcode SystemSaveData}
|
||||||
*/
|
*/
|
||||||
function fixStarterData(data: SystemSaveData) {
|
function fixStarterData(data: SystemSaveData) {
|
||||||
|
if (!isNullOrUndefined(data.starterData)) {
|
||||||
for (const starterId of defaultStarterSpecies) {
|
for (const starterId of defaultStarterSpecies) {
|
||||||
if (data.starterData[starterId]?.abilityAttr) {
|
if (data.starterData[starterId]?.abilityAttr) {
|
||||||
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
|
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
|
||||||
|
@ -55,6 +57,7 @@ export const systemMigrators = [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const settingsMigrators = [
|
export const settingsMigrators = [
|
||||||
|
|
Loading…
Reference in New Issue