[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);
|
||||
for (const s of starterIds) {
|
||||
this.starterData[s].candyCount += this.dexData[s].caughtCount;
|
||||
this.starterData[s].candyCount += this.dexData[s].hatchedCount * 2;
|
||||
if (this.dexData[s].caughtAttr & DexAttr.SHINY) {
|
||||
this.starterData[s].candyCount += systemData.dexData[s].caughtCount;
|
||||
this.starterData[s].candyCount += systemData.dexData[s].hatchedCount * 2;
|
||||
if (systemData.dexData[s].caughtAttr & DexAttr.SHINY) {
|
||||
this.starterData[s].candyCount += 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { SettingKeys } from "../../settings/settings";
|
||||
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "../../game-data";
|
||||
import { allSpecies } from "../../../data/pokemon-species";
|
||||
import { SettingKeys } from "#app/system/settings/settings";
|
||||
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "#app/system/game-data";
|
||||
import { allSpecies } from "#app/data/pokemon-species";
|
||||
import { isNullOrUndefined } from "#app/utils";
|
||||
|
||||
export const systemMigrators = [
|
||||
/**
|
||||
|
@ -46,12 +47,14 @@ export const systemMigrators = [
|
|||
* @param data {@linkcode SystemSaveData}
|
||||
*/
|
||||
function fixStarterData(data: SystemSaveData) {
|
||||
for (const starterId of defaultStarterSpecies) {
|
||||
if (data.starterData[starterId]?.abilityAttr) {
|
||||
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
|
||||
}
|
||||
if (data.dexData[starterId]?.caughtAttr) {
|
||||
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE;
|
||||
if (!isNullOrUndefined(data.starterData)) {
|
||||
for (const starterId of defaultStarterSpecies) {
|
||||
if (data.starterData[starterId]?.abilityAttr) {
|
||||
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
|
||||
}
|
||||
if (data.dexData[starterId]?.caughtAttr) {
|
||||
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue