[Bug] Fix Dire Hit & System Data Conversion Failure (#4282)

Co-authored-by: xsn34kzx <xsn34kzx@gmail.com>
This commit is contained in:
MokaStitcher 2024-09-16 11:56:55 +02:00 committed by GitHub
parent 801b0a66f7
commit 7ea608fb8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,6 +22,8 @@ export function applySessionDataPatches(data: SessionSaveData) {
} else if (m.className === "PokemonResetNegativeStatStageModifier") {
m.className = "ResetNegativeStatStageModifier";
} else if (m.className === "TempBattleStatBoosterModifier") {
// Dire Hit no longer a part of the TempBattleStatBoosterModifierTypeGenerator
if (m.typeId !== "DIRE_HIT") {
m.className = "TempStatStageBoosterModifier";
m.typeId = "TEMP_STAT_STAGE_BOOSTER";
@ -31,6 +33,14 @@ export function applySessionDataPatches(data: SessionSaveData) {
// From [ stat, battlesLeft ] to [ stat, maxBattles, battleCount ]
m.args = [ newStat, 5, m.args[1] ];
} else {
m.className = "TempCritBoosterModifier";
m.typePregenArgs = [];
// From [ stat, battlesLeft ] to [ maxBattles, battleCount ]
m.args = [ 5, m.args[1] ];
}
} else if (m.className === "DoubleBattleChanceBoosterModifier" && m.args.length === 1) {
let maxBattles: number;
switch (m.typeId) {
@ -73,7 +83,7 @@ export function applySystemDataPatches(data: SystemSaveData) {
case "1.0.3":
case "1.0.4":
// --- LEGACY PATCHES ---
if (data.starterData) {
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)) {
@ -104,6 +114,7 @@ export function applySystemDataPatches(data: SystemSaveData) {
// --- PATCHES ---
// Fix Starter Data
if (data.starterData && data.dexData) {
for (const starterId of defaultStarterSpecies) {
if (data.starterData[starterId]?.abilityAttr) {
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
@ -113,6 +124,7 @@ export function applySystemDataPatches(data: SystemSaveData) {
}
}
}
}
data.gameVersion = LATEST_VERSION;
}