From 103c87ec3b5014cf89b0692402b3f1fe66bbdbfc Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Thu, 12 Sep 2024 01:09:44 +0100 Subject: [PATCH 1/5] Undo egg skip event --- src/modifier/modifier-type.ts | 5 +---- src/phases/trainer-victory-phase.ts | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index f7041d55be3..20047e5b81b 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -1545,7 +1545,6 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.TEMP_STAT_STAGE_BOOSTER, 4), new WeightedModifierType(modifierTypes.BERRY, 2), new WeightedModifierType(modifierTypes.TM_COMMON, 2), - new WeightedModifierType(modifierTypes.VOUCHER, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily ? Math.max(1 - rerollCount, 0) : 0, 1), ].map(m => { m.setTier(ModifierTier.COMMON); return m; }), @@ -1616,7 +1615,6 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), new WeightedModifierType(modifierTypes.TERA_SHARD, 1), new WeightedModifierType(modifierTypes.DNA_SPLICERS, (party: Pokemon[]) => party[0].scene.gameMode.isSplicedOnly && party.filter(p => !p.fusionSpecies).length > 1 ? 4 : 0), - new WeightedModifierType(modifierTypes.VOUCHER, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily ? Math.max(3 - rerollCount * 3, 0) : 0, 3), ].map(m => { m.setTier(ModifierTier.GREAT); return m; }), @@ -1697,7 +1695,6 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.RARE_FORM_CHANGE_ITEM, (party: Pokemon[]) => Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 50), 4) * 6, 24), new WeightedModifierType(modifierTypes.MEGA_BRACELET, (party: Pokemon[]) => Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 50), 4) * 9, 36), new WeightedModifierType(modifierTypes.DYNAMAX_BAND, (party: Pokemon[]) => Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 50), 4) * 9, 36), - new WeightedModifierType(modifierTypes.VOUCHER_PLUS, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily ? Math.max(9 - rerollCount * 3, 0) : 0, 9), ].map(m => { m.setTier(ModifierTier.ROGUE); return m; }), @@ -1706,7 +1703,7 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.SHINY_CHARM, 14), new WeightedModifierType(modifierTypes.HEALING_CHARM, 18), new WeightedModifierType(modifierTypes.MULTI_LENS, 18), - new WeightedModifierType(modifierTypes.VOUCHER_PREMIUM, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily && !party[0].scene.gameMode.isEndless && !party[0].scene.gameMode.isSplicedOnly ? Math.max(15 - rerollCount * 5, 0) : 0, 15), + new WeightedModifierType(modifierTypes.VOUCHER_PREMIUM, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily && !party[0].scene.gameMode.isEndless && !party[0].scene.gameMode.isSplicedOnly ? Math.max(5 - rerollCount * 2, 0) : 0, 5), new WeightedModifierType(modifierTypes.DNA_SPLICERS, (party: Pokemon[]) => !party[0].scene.gameMode.isSplicedOnly && party.filter(p => !p.fusionSpecies).length > 1 ? 24 : 0, 24), new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, (party: Pokemon[]) => (!party[0].scene.gameMode.isFreshStartChallenge() && party[0].scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE]) ? 1 : 0, 1), ].map(m => { diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index 7815244c35c..a38874c9acd 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -30,7 +30,7 @@ export class TrainerVictoryPhase extends BattlePhase { const trainerType = this.scene.currentBattle.trainer?.config.trainerType!; // TODO: is this bang correct? if (vouchers.hasOwnProperty(TrainerType[trainerType])) { if (!this.scene.validateVoucher(vouchers[TrainerType[trainerType]]) && this.scene.currentBattle.trainer?.config.isBoss) { - this.scene.unshiftPhase(new ModifierRewardPhase(this.scene, [modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PREMIUM][vouchers[TrainerType[trainerType]].voucherType])); + this.scene.unshiftPhase(new ModifierRewardPhase(this.scene, [modifierTypes.VOUCHER, modifierTypes.VOUCHER, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PREMIUM][vouchers[TrainerType[trainerType]].voucherType])); } } From 801b0a66f715584aa3a61ce3c6684093c58c6f10 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Thu, 12 Sep 2024 01:13:22 +0100 Subject: [PATCH 2/5] Readded vouchers to original weights --- src/modifier/modifier-type.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 20047e5b81b..d6cfd017829 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -1615,6 +1615,7 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), new WeightedModifierType(modifierTypes.TERA_SHARD, 1), new WeightedModifierType(modifierTypes.DNA_SPLICERS, (party: Pokemon[]) => party[0].scene.gameMode.isSplicedOnly && party.filter(p => !p.fusionSpecies).length > 1 ? 4 : 0), + new WeightedModifierType(modifierTypes.VOUCHER, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily ? Math.max(1 - rerollCount, 0) : 0, 1), ].map(m => { m.setTier(ModifierTier.GREAT); return m; }), @@ -1695,6 +1696,7 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.RARE_FORM_CHANGE_ITEM, (party: Pokemon[]) => Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 50), 4) * 6, 24), new WeightedModifierType(modifierTypes.MEGA_BRACELET, (party: Pokemon[]) => Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 50), 4) * 9, 36), new WeightedModifierType(modifierTypes.DYNAMAX_BAND, (party: Pokemon[]) => Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 50), 4) * 9, 36), + new WeightedModifierType(modifierTypes.VOUCHER_PLUS, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily ? Math.max(3 - rerollCount * 1, 0) : 0, 3), ].map(m => { m.setTier(ModifierTier.ROGUE); return m; }), From f4df35a45260f4903e389809d1c052dc75b7cfa1 Mon Sep 17 00:00:00 2001 From: Opaque02 <66582645+Opaque02@users.noreply.github.com> Date: Fri, 13 Sep 2024 00:37:38 +1000 Subject: [PATCH 3/5] Updated admin panel to allow the concept of unlinking accounts --- src/ui/admin-ui-handler.ts | 65 ++++++++++++++++++++++++++++---------- src/ui/menu-ui-handler.ts | 5 ++- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/ui/admin-ui-handler.ts b/src/ui/admin-ui-handler.ts index c48138853fc..b163ec75157 100644 --- a/src/ui/admin-ui-handler.ts +++ b/src/ui/admin-ui-handler.ts @@ -7,6 +7,8 @@ import { Button } from "#app/enums/buttons"; export default class AdminUiHandler extends FormModalUiHandler { + private unlinkAction: Function; + constructor(scene: BattleScene, mode: Mode | null = null) { super(scene, mode); } @@ -24,7 +26,7 @@ export default class AdminUiHandler extends FormModalUiHandler { } getWidth(config?: ModalConfig): number { - return 160; + return 220; } getMargin(config?: ModalConfig): [number, number, number, number] { @@ -32,7 +34,7 @@ export default class AdminUiHandler extends FormModalUiHandler { } getButtonLabels(config?: ModalConfig): string[] { - return ["Link account", "Cancel"]; + return ["Link account", "Unlink account", "Cancel"]; } processInput(button: Button): boolean { @@ -48,6 +50,20 @@ export default class AdminUiHandler extends FormModalUiHandler { if (super.show(args)) { const config = args[0] as ModalConfig; const originalSubmitAction = this.submitAction; + let originAction: number = 0; // this is used to keep track of which button has been pressed + /* This code is here because currently the form-modal-ui-handler is hardcoded to only have a single action button and a cancel button + * This code below adds interactivity and a specific action to the unlink account button. This also sets up the originalAction variable + * from above, which lets us figure out if we're linking or unlinking, which makes this.submitAction do post different API calls + */ + for (let i = 0; i < this.buttonBgs.length - 1; i++) { + this.buttonBgs[i].off("pointerdown"); + this.buttonBgs[i].on("pointerdown", () => { + originAction = i; + if (this.submitAction) { + this.submitAction(); + } + }); + } this.submitAction = (_) => { this.submitAction = originalSubmitAction; this.scene.ui.setMode(Mode.LOADING, { buttonActions: [] }); @@ -61,20 +77,37 @@ export default class AdminUiHandler extends FormModalUiHandler { if (!this.inputs[1].text) { return onFail("Discord Id is required"); } - Utils.apiPost("admin/account/discord-link", `username=${encodeURIComponent(this.inputs[0].text)}&discordId=${encodeURIComponent(this.inputs[1].text)}`, "application/x-www-form-urlencoded", true) - .then(response => { - if (!response.ok) { - console.error(response); - } - this.inputs[0].setText(""); - this.inputs[1].setText(""); - this.scene.ui.revertMode(); - }) - .catch((err) => { - console.error(err); - this.scene.ui.revertMode(); - }); - return false; + if (originAction === 0) { + Utils.apiPost("admin/account/discord-link", `username=${encodeURIComponent(this.inputs[0].text)}&discordId=${encodeURIComponent(this.inputs[1].text)}`, "application/x-www-form-urlencoded", true) + .then(response => { + if (!response.ok) { + console.error(response); + } + this.inputs[0].setText(""); + this.inputs[1].setText(""); + this.scene.ui.revertMode(); + }) + .catch((err) => { + console.error(err); + this.scene.ui.revertMode(); + }); + return false; + } else if (originAction === 1) { + Utils.apiPost("admin/account/discord-unlink", `username=${encodeURIComponent(this.inputs[0].text)}&discordId=${encodeURIComponent(this.inputs[1].text)}`, "application/x-www-form-urlencoded", true) + .then(response => { + if (!response.ok) { + console.error(response); + } + this.inputs[0].setText(""); + this.inputs[1].setText(""); + this.scene.ui.revertMode(); + }) + .catch((err) => { + console.error(err); + this.scene.ui.revertMode(); + }); + return false; + } }; return true; } diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index b8c3cfd1364..bf6ca623df3 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -380,7 +380,7 @@ export default class MenuUiHandler extends MessageUiHandler { keepOpen: true } ]; - if (!bypassLogin && loggedInUser?.hasAdminRole) { + if (!bypassLogin && loggedInUser?.hasAdminRole || true) { communityOptions.push({ label: "Admin", handler: () => { @@ -390,6 +390,9 @@ export default class MenuUiHandler extends MessageUiHandler { () => { ui.revertMode(); }, + () => { + ui.revertMode(); + }, () => { ui.revertMode(); } From 2c0fc385bd756e2b51d6afe79c7022adfa57994c Mon Sep 17 00:00:00 2001 From: Opaque02 <66582645+Opaque02@users.noreply.github.com> Date: Fri, 13 Sep 2024 00:47:57 +1000 Subject: [PATCH 4/5] Don't look too hard at this commit, nothing to see here --- src/ui/menu-ui-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index bf6ca623df3..4725bd5fc4e 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -380,7 +380,7 @@ export default class MenuUiHandler extends MessageUiHandler { keepOpen: true } ]; - if (!bypassLogin && loggedInUser?.hasAdminRole || true) { + if (!bypassLogin && loggedInUser?.hasAdminRole) { communityOptions.push({ label: "Admin", handler: () => { From 7ea608fb8aaa0769e6a9799cbb3b1c45d3dc9474 Mon Sep 17 00:00:00 2001 From: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:56:55 +0200 Subject: [PATCH 5/5] [Bug] Fix Dire Hit & System Data Conversion Failure (#4282) Co-authored-by: xsn34kzx --- src/system/version-converter.ts | 40 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/system/version-converter.ts b/src/system/version-converter.ts index f7996124886..6cb2c24d84d 100644 --- a/src/system/version-converter.ts +++ b/src/system/version-converter.ts @@ -22,15 +22,25 @@ export function applySessionDataPatches(data: SessionSaveData) { } else if (m.className === "PokemonResetNegativeStatStageModifier") { m.className = "ResetNegativeStatStageModifier"; } else if (m.className === "TempBattleStatBoosterModifier") { - m.className = "TempStatStageBoosterModifier"; - m.typeId = "TEMP_STAT_STAGE_BOOSTER"; + // Dire Hit no longer a part of the TempBattleStatBoosterModifierTypeGenerator + if (m.typeId !== "DIRE_HIT") { + m.className = "TempStatStageBoosterModifier"; + m.typeId = "TEMP_STAT_STAGE_BOOSTER"; - // Migration from TempBattleStat to Stat - const newStat = m.typePregenArgs[0] + 1; - m.typePregenArgs[0] = newStat; + // Migration from TempBattleStat to Stat + const newStat = m.typePregenArgs[0] + 1; + 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) { 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,12 +114,14 @@ export function applySystemDataPatches(data: SystemSaveData) { // --- PATCHES --- // Fix Starter Data - for (const starterId of defaultStarterSpecies) { - 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.starterData && data.dexData) { + for (const starterId of defaultStarterSpecies) { + if (data.starterData[starterId]?.abilityAttr) { + data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1; + } + if (data.dexData[starterId]?.caughtAttr) { + data.dexData[starterId].caughtAttr |= DexAttr.FEMALE; + } } } }