mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-23 15:59:26 +02:00
Address NITs
This commit is contained in:
parent
b89d1f7028
commit
13233b77e4
@ -14,12 +14,27 @@ export abstract class VersionConverter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through an array of designated migration functions that are each
|
||||
* called one by one to transform the data.
|
||||
* @param data The data to be operated on
|
||||
* @param migrationArr An array of functions that will transform the incoming data
|
||||
*/
|
||||
callMigrators(data: any, migrationArr: readonly any[]) {
|
||||
for (const migrate of migrationArr) {
|
||||
migrate(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the current version the incoming data to determine the starting point
|
||||
* of the migration which will cascade up to the latest version, calling the
|
||||
* necessary migration functions in the process.
|
||||
* @param data The data to be operated on
|
||||
* @param curVersion [0] Current major version
|
||||
* [1] Current minor version
|
||||
* [2] Current patch version
|
||||
*/
|
||||
abstract applyMigration(data: any, curVersion: number[]): void;
|
||||
}
|
||||
|
||||
@ -28,7 +43,7 @@ export class SessionVersionConverter extends VersionConverter {
|
||||
super(data, gameVersion);
|
||||
}
|
||||
|
||||
applyMigration(data: SessionSaveData, curVersion: number[]): void {
|
||||
override applyMigration(data: SessionSaveData, curVersion: number[]): void {
|
||||
const [ curMajor, curMinor, curPatch ] = curVersion;
|
||||
|
||||
switch (curMajor) {
|
||||
@ -52,7 +67,7 @@ export class SystemVersionConverter extends VersionConverter {
|
||||
super(data, gameVersion);
|
||||
}
|
||||
|
||||
applyMigration(data: SystemSaveData, curVersion: number[]): void {
|
||||
override applyMigration(data: SystemSaveData, curVersion: number[]): void {
|
||||
const [ curMajor, curMinor, curPatch ] = curVersion;
|
||||
|
||||
switch (curMajor) {
|
||||
@ -77,7 +92,7 @@ export class SettingsVersionConverter extends VersionConverter {
|
||||
super(data, gameVersion);
|
||||
}
|
||||
|
||||
applyMigration(data: Object, curVersion: number[]): void {
|
||||
override applyMigration(data: Object, curVersion: number[]): void {
|
||||
const [ curMajor, curMinor, curPatch ] = curVersion;
|
||||
|
||||
switch (curMajor) {
|
||||
|
@ -2,15 +2,13 @@ import { SettingKeys } from "../../settings/settings";
|
||||
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "../../game-data";
|
||||
import { allSpecies } from "../../../data/pokemon-species";
|
||||
|
||||
|
||||
export const systemMigrators = [
|
||||
/**
|
||||
* Migrate ability starter data if empty for caught species
|
||||
* Migrate ability starter data if empty for caught species.
|
||||
* @param data {@linkcode SystemSaveData}
|
||||
*/
|
||||
function migrateAbilityData(data: SystemSaveData) {
|
||||
if (data.starterData && data.dexData) {
|
||||
// Migrate ability starter data if empty for caught species
|
||||
Object.keys(data.starterData).forEach(sd => {
|
||||
if (data.dexData[sd]?.caughtAttr && (data.starterData[sd] && !data.starterData[sd].abilityAttr)) {
|
||||
data.starterData[sd].abilityAttr = 1;
|
||||
@ -20,7 +18,7 @@ export const systemMigrators = [
|
||||
},
|
||||
|
||||
/**
|
||||
* Populate legendary Pokémon statistics if they are missing
|
||||
* Populate legendary Pokémon statistics if they are missing.
|
||||
* @param data {@linkcode SystemSaveData}
|
||||
*/
|
||||
function fixLegendaryStats(data: SystemSaveData) {
|
||||
@ -44,7 +42,7 @@ export const systemMigrators = [
|
||||
},
|
||||
|
||||
/**
|
||||
* Unlock all starters' first ability and female gender option
|
||||
* Unlock all starters' first ability and female gender option.
|
||||
* @param data {@linkcode SystemSaveData}
|
||||
*/
|
||||
function fixStarterData(data: SystemSaveData) {
|
||||
|
Loading…
Reference in New Issue
Block a user