[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
1 changed files with 26 additions and 14 deletions

View File

@ -22,15 +22,25 @@ export function applySessionDataPatches(data: SessionSaveData) {
} else if (m.className === "PokemonResetNegativeStatStageModifier") { } else if (m.className === "PokemonResetNegativeStatStageModifier") {
m.className = "ResetNegativeStatStageModifier"; m.className = "ResetNegativeStatStageModifier";
} else if (m.className === "TempBattleStatBoosterModifier") { } else if (m.className === "TempBattleStatBoosterModifier") {
m.className = "TempStatStageBoosterModifier"; // Dire Hit no longer a part of the TempBattleStatBoosterModifierTypeGenerator
m.typeId = "TEMP_STAT_STAGE_BOOSTER"; if (m.typeId !== "DIRE_HIT") {
m.className = "TempStatStageBoosterModifier";
m.typeId = "TEMP_STAT_STAGE_BOOSTER";
// Migration from TempBattleStat to Stat // Migration from TempBattleStat to Stat
const newStat = m.typePregenArgs[0] + 1; const newStat = m.typePregenArgs[0] + 1;
m.typePregenArgs[0] = newStat; m.typePregenArgs[0] = newStat;
// 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] ];
}
// From [ stat, battlesLeft ] to [ stat, maxBattles, battleCount ]
m.args = [ newStat, 5, m.args[1] ];
} else if (m.className === "DoubleBattleChanceBoosterModifier" && m.args.length === 1) { } else if (m.className === "DoubleBattleChanceBoosterModifier" && m.args.length === 1) {
let maxBattles: number; let maxBattles: number;
switch (m.typeId) { switch (m.typeId) {
@ -73,7 +83,7 @@ export function applySystemDataPatches(data: SystemSaveData) {
case "1.0.3": case "1.0.3":
case "1.0.4": case "1.0.4":
// --- LEGACY PATCHES --- // --- LEGACY PATCHES ---
if (data.starterData) { if (data.starterData && data.dexData) {
// Migrate ability starter data if empty for caught species // Migrate ability starter data if empty for caught species
Object.keys(data.starterData).forEach(sd => { Object.keys(data.starterData).forEach(sd => {
if (data.dexData[sd]?.caughtAttr && (data.starterData[sd] && !data.starterData[sd].abilityAttr)) { if (data.dexData[sd]?.caughtAttr && (data.starterData[sd] && !data.starterData[sd].abilityAttr)) {
@ -104,12 +114,14 @@ export function applySystemDataPatches(data: SystemSaveData) {
// --- PATCHES --- // --- PATCHES ---
// Fix Starter Data // Fix Starter Data
for (const starterId of defaultStarterSpecies) { if (data.starterData && data.dexData) {
if (data.starterData[starterId]?.abilityAttr) { for (const starterId of defaultStarterSpecies) {
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1; if (data.starterData[starterId]?.abilityAttr) {
} data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
if (data.dexData[starterId]?.caughtAttr) { }
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE; if (data.dexData[starterId]?.caughtAttr) {
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE;
}
} }
} }
} }