mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-30 21:42:20 +02:00
Added version migration for last resort and co.
buh gumbug
This commit is contained in:
parent
06d250d9e7
commit
ee1b2176bc
@ -63,6 +63,10 @@ import * as v1_8_3 from "./versions/v1_8_3";
|
||||
// biome-ignore lint/style/noNamespaceImport: Convenience
|
||||
import * as v1_9_0 from "./versions/v1_9_0";
|
||||
|
||||
// --- v1.10.0 PATCHES --- //
|
||||
// biome-ignore lint/style/noNamespaceImport: Convenience
|
||||
import * as v1_10_0 from "./versions/v1_10_0";
|
||||
|
||||
/** Current game version */
|
||||
const LATEST_VERSION = version;
|
||||
|
||||
@ -85,6 +89,7 @@ const sessionMigrators: SessionSaveMigrator[] = [];
|
||||
sessionMigrators.push(...v1_0_4.sessionMigrators);
|
||||
sessionMigrators.push(...v1_7_0.sessionMigrators);
|
||||
sessionMigrators.push(...v1_9_0.sessionMigrators);
|
||||
sessionMigrators.push(...v1_10_0.sessionMigrators);
|
||||
|
||||
/** All settings migrators */
|
||||
const settingsMigrators: SettingsSaveMigrator[] = [];
|
||||
|
46
src/system/version_migration/versions/v1_10_0.ts
Normal file
46
src/system/version_migration/versions/v1_10_0.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import type { SessionSaveMigrator } from "#app/@types/SessionSaveMigrator";
|
||||
import type { BattlerIndex } from "#app/battle";
|
||||
import type { MoveResult, TurnMove } from "#app/field/pokemon";
|
||||
import type { SessionSaveData } from "#app/system/game-data";
|
||||
import { MoveUseType } from "#enums/move-use-type";
|
||||
import type { Moves } from "#enums/moves";
|
||||
|
||||
/** Prior signature of `TurnMove`; used to ensure parity */
|
||||
interface OldTurnMove {
|
||||
move: Moves;
|
||||
targets: BattlerIndex[];
|
||||
result?: MoveResult;
|
||||
virtual?: boolean;
|
||||
turn?: number;
|
||||
ignorePP?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix player pokemon move history entries with updated `MoveUseTypes`,
|
||||
* based on the prior values of `virtual` and `ignorePP`.
|
||||
* Needed to ensure Last Resort and move-calling moves still work OK.
|
||||
* @param data - {@linkcode SystemSaveData}
|
||||
*/
|
||||
const fixMoveHistory: SessionSaveMigrator = {
|
||||
version: "1.10.0",
|
||||
migrate: (data: SessionSaveData): void => {
|
||||
const mapTurnMove = (tm: OldTurnMove): TurnMove => ({
|
||||
move: tm.move,
|
||||
targets: tm.targets,
|
||||
result: tm.result,
|
||||
turn: tm.turn,
|
||||
// NOTE: This currently mis-classifies Dancer and Magic Bounce-induced moves, but not much we can do about it tbh
|
||||
useType: tm.virtual ? MoveUseType.FOLLOW_UP : tm.ignorePP ? MoveUseType.IGNORE_PP : MoveUseType.NORMAL,
|
||||
});
|
||||
data.party.forEach(pkmn => {
|
||||
pkmn.summonData.moveHistory = (pkmn.summonData.moveHistory as OldTurnMove[]).map(mapTurnMove);
|
||||
pkmn.summonData.moveQueue = (pkmn.summonData.moveQueue as OldTurnMove[]).map(mapTurnMove);
|
||||
});
|
||||
data.enemyParty.forEach(pkmn => {
|
||||
pkmn.summonData.moveHistory = (pkmn.summonData.moveHistory as OldTurnMove[]).map(mapTurnMove);
|
||||
pkmn.summonData.moveQueue = (pkmn.summonData.moveQueue as OldTurnMove[]).map(mapTurnMove);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export const sessionMigrators: Readonly<SessionSaveMigrator[]> = [fixMoveHistory] as const;
|
Loading…
Reference in New Issue
Block a user