Skip to content

Commit 7ea608f

Browse files
[Bug] Fix Dire Hit & System Data Conversion Failure (#4282)
Co-authored-by: xsn34kzx <xsn34kzx@gmail.com>
1 parent 801b0a6 commit 7ea608f

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/system/version-converter.ts

+26-14
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,25 @@ export function applySessionDataPatches(data: SessionSaveData) {
2222
} else if (m.className === "PokemonResetNegativeStatStageModifier") {
2323
m.className = "ResetNegativeStatStageModifier";
2424
} else if (m.className === "TempBattleStatBoosterModifier") {
25-
m.className = "TempStatStageBoosterModifier";
26-
m.typeId = "TEMP_STAT_STAGE_BOOSTER";
25+
// Dire Hit no longer a part of the TempBattleStatBoosterModifierTypeGenerator
26+
if (m.typeId !== "DIRE_HIT") {
27+
m.className = "TempStatStageBoosterModifier";
28+
m.typeId = "TEMP_STAT_STAGE_BOOSTER";
2729

28-
// Migration from TempBattleStat to Stat
29-
const newStat = m.typePregenArgs[0] + 1;
30-
m.typePregenArgs[0] = newStat;
30+
// Migration from TempBattleStat to Stat
31+
const newStat = m.typePregenArgs[0] + 1;
32+
m.typePregenArgs[0] = newStat;
33+
34+
// From [ stat, battlesLeft ] to [ stat, maxBattles, battleCount ]
35+
m.args = [ newStat, 5, m.args[1] ];
36+
} else {
37+
m.className = "TempCritBoosterModifier";
38+
m.typePregenArgs = [];
39+
40+
// From [ stat, battlesLeft ] to [ maxBattles, battleCount ]
41+
m.args = [ 5, m.args[1] ];
42+
}
3143

32-
// From [ stat, battlesLeft ] to [ stat, maxBattles, battleCount ]
33-
m.args = [ newStat, 5, m.args[1] ];
3444
} else if (m.className === "DoubleBattleChanceBoosterModifier" && m.args.length === 1) {
3545
let maxBattles: number;
3646
switch (m.typeId) {
@@ -73,7 +83,7 @@ export function applySystemDataPatches(data: SystemSaveData) {
7383
case "1.0.3":
7484
case "1.0.4":
7585
// --- LEGACY PATCHES ---
76-
if (data.starterData) {
86+
if (data.starterData && data.dexData) {
7787
// Migrate ability starter data if empty for caught species
7888
Object.keys(data.starterData).forEach(sd => {
7989
if (data.dexData[sd]?.caughtAttr && (data.starterData[sd] && !data.starterData[sd].abilityAttr)) {
@@ -104,12 +114,14 @@ export function applySystemDataPatches(data: SystemSaveData) {
104114
// --- PATCHES ---
105115

106116
// Fix Starter Data
107-
for (const starterId of defaultStarterSpecies) {
108-
if (data.starterData[starterId]?.abilityAttr) {
109-
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
110-
}
111-
if (data.dexData[starterId]?.caughtAttr) {
112-
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE;
117+
if (data.starterData && data.dexData) {
118+
for (const starterId of defaultStarterSpecies) {
119+
if (data.starterData[starterId]?.abilityAttr) {
120+
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
121+
}
122+
if (data.dexData[starterId]?.caughtAttr) {
123+
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE;
124+
}
113125
}
114126
}
115127
}

0 commit comments

Comments
 (0)