mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-25 01:32:21 +02:00
Implement save migration
This commit is contained in:
parent
50c7588a37
commit
557d37aec1
@ -273,12 +273,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.fusionGender = dataSource.fusionGender;
|
||||
this.fusionLuck = dataSource.fusionLuck;
|
||||
this.fusionCustomPokemonData = dataSource.fusionCustomPokemonData;
|
||||
this.fusionTeraType = dataSource.teraType;
|
||||
this.fusionTeraType = dataSource.fusionTeraType;
|
||||
this.usedTMs = dataSource.usedTMs ?? [];
|
||||
this.customPokemonData = new CustomPokemonData(dataSource.customPokemonData);
|
||||
this.teraType = dataSource.teraType;
|
||||
this.isTerastallized = dataSource.isTerastallized;
|
||||
this.stellarTypesBoosted = dataSource.stellarTypesBoosted;
|
||||
this.stellarTypesBoosted = dataSource.stellarTypesBoosted ?? [];
|
||||
} else {
|
||||
this.id = Utils.randSeedInt(4294967296);
|
||||
this.ivs = ivs || Utils.getIvsFromId(this.id);
|
||||
|
@ -17,7 +17,7 @@ export default class ArenaData {
|
||||
this.biome = sourceArena ? sourceArena.biomeType : source.biome;
|
||||
this.weather = sourceArena ? sourceArena.weather : source.weather ? new Weather(source.weather.weatherType, source.weather.turnsLeft) : null;
|
||||
this.terrain = sourceArena ? sourceArena.terrain : source.terrain ? new Terrain(source.terrain.terrainType, source.terrain.turnsLeft) : null;
|
||||
this.playerTerasUsed = sourceArena ? sourceArena.playerTerasUsed : source.playerTerasUsed;
|
||||
this.playerTerasUsed = (sourceArena ? sourceArena.playerTerasUsed : source.playerTerasUsed) ?? 0;
|
||||
this.tags = [];
|
||||
|
||||
if (source.tags) {
|
||||
|
@ -57,6 +57,7 @@ export default class PokemonData {
|
||||
public fusionVariant: Variant;
|
||||
public fusionGender: Gender;
|
||||
public fusionLuck: number;
|
||||
public fusionTeraType: Type;
|
||||
|
||||
public boss: boolean;
|
||||
public bossSegments?: number;
|
||||
@ -107,7 +108,7 @@ export default class PokemonData {
|
||||
this.evoCounter = source.evoCounter ?? 0;
|
||||
}
|
||||
this.pokerus = !!source.pokerus;
|
||||
this.teraType = (source.teraType || 0) as Type;
|
||||
this.teraType = source.teraType as Type;
|
||||
this.isTerastallized = source.isTerastallized || false;
|
||||
this.stellarTypesBoosted = source.stellarTypesBoosted || [];
|
||||
|
||||
@ -119,6 +120,7 @@ export default class PokemonData {
|
||||
this.fusionGender = source.fusionGender;
|
||||
this.fusionLuck = source.fusionLuck !== undefined ? source.fusionLuck : (source.fusionShiny ? source.fusionVariant + 1 : 0);
|
||||
this.fusionCustomPokemonData = new CustomPokemonData(source.fusionCustomPokemonData);
|
||||
this.fusionTeraType = (source.fusionTeraType ?? 0) as Type;
|
||||
this.usedTMs = source.usedTMs ?? [];
|
||||
|
||||
this.customPokemonData = new CustomPokemonData(source.customPokemonData);
|
||||
|
@ -7,6 +7,9 @@ import * as v1_0_4 from "./versions/v1_0_4";
|
||||
// --- v1.1.0 PATCHES --- //
|
||||
import * as v1_1_0 from "./versions/v1_1_0";
|
||||
|
||||
// --- v1.1.0 PATCHES --- //
|
||||
import * as v1_6_0 from "./versions/v1_6_0";
|
||||
|
||||
const LATEST_VERSION = version.split(".").map(value => parseInt(value));
|
||||
|
||||
/**
|
||||
@ -138,6 +141,10 @@ class SessionVersionConverter extends VersionConverter {
|
||||
console.log("Applying v1.1.0 session data migration!");
|
||||
this.callMigrators(data, v1_1_0.sessionMigrators);
|
||||
}
|
||||
if (curMinor < 6) {
|
||||
console.log("Applying v1.6.0 session data migration!");
|
||||
this.callMigrators(data, v1_6_0.sessionMigrators);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Session data successfully migrated to v${version}!`);
|
||||
@ -164,6 +171,10 @@ class SystemVersionConverter extends VersionConverter {
|
||||
console.log("Applying v1.1.0 system data migraton!");
|
||||
this.callMigrators(data, v1_1_0.systemMigrators);
|
||||
}
|
||||
if (curMinor < 6) {
|
||||
console.log("Applying v1.6.0 session data migration!");
|
||||
this.callMigrators(data, v1_6_0.systemMigrators);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`System data successfully migrated to v${version}!`);
|
||||
@ -190,6 +201,10 @@ class SettingsVersionConverter extends VersionConverter {
|
||||
console.log("Applying v1.1.0 settings data migraton!");
|
||||
this.callMigrators(data, v1_1_0.settingsMigrators);
|
||||
}
|
||||
if (curMinor < 6) {
|
||||
console.log("Applying v1.6.0 session data migration!");
|
||||
this.callMigrators(data, v1_6_0.settingsMigrators);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`System data successfully migrated to v${version}!`);
|
||||
|
49
src/system/version_migration/versions/v1_6_0.ts
Normal file
49
src/system/version_migration/versions/v1_6_0.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { getPokemonSpeciesForm } from "#app/data/pokemon-species";
|
||||
import type { SessionSaveData } from "#app/system/game-data";
|
||||
import * as Utils from "#app/utils";
|
||||
|
||||
export const systemMigrators = [] as const;
|
||||
|
||||
export const settingsMigrators = [] as const;
|
||||
|
||||
export const sessionMigrators = [
|
||||
function migrateTera(data: SessionSaveData) {
|
||||
for (let i = 0; i < data.modifiers.length;) {
|
||||
if (data.modifiers[i].className === "TerastallizeModifier") {
|
||||
data.party.forEach((p) => {
|
||||
if (p.id === data.modifiers[i].args[0]) {
|
||||
p.teraType = data.modifiers[i].args[1];
|
||||
}
|
||||
});
|
||||
data.modifiers.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < data.enemyModifiers.length;) {
|
||||
if (data.enemyModifiers[i].className === "TerastallizeModifier") {
|
||||
data.enemyParty.forEach((p) => {
|
||||
if (p.id === data.enemyModifiers[i].args[0]) {
|
||||
p.teraType = data.enemyModifiers[i].args[1];
|
||||
}
|
||||
});
|
||||
data.enemyModifiers.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
data.party.forEach(p => {
|
||||
if (Utils.isNullOrUndefined(p.teraType)) {
|
||||
p.teraType = getPokemonSpeciesForm(p.species, p.formIndex).type1;
|
||||
}
|
||||
});
|
||||
|
||||
data.enemyParty.forEach(p => {
|
||||
if (Utils.isNullOrUndefined(p.teraType)) {
|
||||
p.teraType = getPokemonSpeciesForm(p.species, p.formIndex).type1;
|
||||
}
|
||||
});
|
||||
}
|
||||
] as const;
|
Loading…
Reference in New Issue
Block a user