From 28dd929da2420476c6d1a2a5e828a1879ae06c29 Mon Sep 17 00:00:00 2001 From: ImperialSympathizer Date: Fri, 13 Sep 2024 19:15:31 -0400 Subject: [PATCH] Change how reroll button gets disabled in Modifier Shop Phase --- .../encounters/a-trainers-test-encounter.ts | 2 +- src/modifier/modifier-type.ts | 1 + src/phases/mystery-encounter-phases.ts | 2 +- src/phases/select-modifier-phase.ts | 14 ++++++++++++-- src/ui/modifier-select-ui-handler.ts | 15 +++++++++++++-- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts b/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts index 688973d6be3..7f11064f392 100644 --- a/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts +++ b/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts @@ -174,7 +174,7 @@ export const ATrainersTestEncounter: MysteryEncounter = tier: EggTier.GREAT }; encounter.setDialogueToken("eggType", i18next.t(`${namespace}.eggTypes.rare`)); - setEncounterRewards(scene, { fillRemaining: false, rerollMultiplier: 0 }, [eggOptions]); + setEncounterRewards(scene, { fillRemaining: false, rerollMultiplier: -1 }, [eggOptions]); leaveEncounterWithoutBattle(scene); } ) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index b807dc8b7c6..ed1a6d4aea5 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -2048,6 +2048,7 @@ export interface CustomModifierSettings { guaranteedModifierTypeOptions?: ModifierTypeOption[]; guaranteedModifierTypeFuncs?: ModifierTypeFunc[]; fillRemaining?: boolean; + /** Set to negative value to disable rerolls completely in shop */ rerollMultiplier?: number; allowLuckUpgrades?: boolean; } diff --git a/src/phases/mystery-encounter-phases.ts b/src/phases/mystery-encounter-phases.ts index f5539a6f0bb..a3672438c55 100644 --- a/src/phases/mystery-encounter-phases.ts +++ b/src/phases/mystery-encounter-phases.ts @@ -524,7 +524,7 @@ export class MysteryEncounterRewardsPhase extends Phase { encounter.doEncounterRewards(this.scene); } else if (this.addHealPhase) { this.scene.tryRemovePhase(p => p instanceof SelectModifierPhase); - this.scene.unshiftPhase(new SelectModifierPhase(this.scene, 0, undefined, { fillRemaining: false, rerollMultiplier: 0 })); + this.scene.unshiftPhase(new SelectModifierPhase(this.scene, 0, undefined, { fillRemaining: false, rerollMultiplier: -1 })); } this.scene.pushPhase(new PostMysteryEncounterPhase(this.scene)); diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index 8e34f6ce9bd..cb280a2ca80 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -74,7 +74,7 @@ export class SelectModifierPhase extends BattlePhase { switch (cursor) { case 0: const rerollCost = this.getRerollCost(typeOptions, this.scene.lockModifierTiers); - if (rerollCost === 0 || this.scene.money < rerollCost) { + if (rerollCost < 0 || this.scene.money < rerollCost) { this.scene.ui.playError(); return false; } else { @@ -241,7 +241,17 @@ export class SelectModifierPhase extends BattlePhase { } else { baseValue = 250; } - const multiplier = !isNullOrUndefined(this.customModifierSettings?.rerollMultiplier) ? this.customModifierSettings!.rerollMultiplier! : 1; + + let multiplier = 1; + if (!isNullOrUndefined(this.customModifierSettings?.rerollMultiplier)) { + if (this.customModifierSettings!.rerollMultiplier! < 0) { + // Completely overrides reroll cost to -1 and early exits + return -1; + } + + // Otherwise, continue with custom multiplier + multiplier = this.customModifierSettings!.rerollMultiplier!; + } return Math.min(Math.ceil(this.scene.currentBattle.waveIndex / 10) * baseValue * Math.pow(2, this.rerollCount) * multiplier, Number.MAX_SAFE_INTEGER); } diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 8e27a4352b5..9f1d6d24a63 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -31,6 +31,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { private rowCursor: integer = 0; private player: boolean; + /** + * If reroll cost is negative, it is assumed there are 0 items in the shop. + * It will cause reroll button to be disabled, and a "Continue" button to show in the place of shop items + */ private rerollCost: integer; private transferButtonWidth: integer; private checkButtonWidth: integer; @@ -265,7 +269,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.continueButtonContainer.setAlpha(0); this.rerollButtonContainer.setVisible(true); this.checkButtonContainer.setVisible(true); - this.continueButtonContainer.setVisible(this.rerollCost === 0); + this.continueButtonContainer.setVisible(this.rerollCost < 0); this.lockRarityButtonContainer.setVisible(canLockRarities); this.scene.tweens.add({ @@ -276,7 +280,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.scene.tweens.add({ targets: [this.rerollButtonContainer], - alpha: this.rerollCost === 0 ? 0.5 : 1, + alpha: this.rerollCost < 0 ? 0.5 : 1, duration: 250 }); @@ -537,6 +541,13 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { } updateRerollCostText(): void { + const rerollDisabled = this.rerollCost < 0; + if (rerollDisabled) { + this.rerollCostText.setVisible(false); + return; + } else { + this.rerollCostText.setVisible(true); + } const canReroll = this.scene.money >= this.rerollCost; const formattedMoney = Utils.formatMoney(this.scene.moneyFormat, this.rerollCost);