Change how reroll button gets disabled in Modifier Shop Phase

This commit is contained in:
ImperialSympathizer 2024-09-13 19:15:31 -04:00
parent e232fc0f52
commit 28dd929da2
5 changed files with 28 additions and 6 deletions

View File

@ -174,7 +174,7 @@ export const ATrainersTestEncounter: MysteryEncounter =
tier: EggTier.GREAT tier: EggTier.GREAT
}; };
encounter.setDialogueToken("eggType", i18next.t(`${namespace}.eggTypes.rare`)); encounter.setDialogueToken("eggType", i18next.t(`${namespace}.eggTypes.rare`));
setEncounterRewards(scene, { fillRemaining: false, rerollMultiplier: 0 }, [eggOptions]); setEncounterRewards(scene, { fillRemaining: false, rerollMultiplier: -1 }, [eggOptions]);
leaveEncounterWithoutBattle(scene); leaveEncounterWithoutBattle(scene);
} }
) )

View File

@ -2048,6 +2048,7 @@ export interface CustomModifierSettings {
guaranteedModifierTypeOptions?: ModifierTypeOption[]; guaranteedModifierTypeOptions?: ModifierTypeOption[];
guaranteedModifierTypeFuncs?: ModifierTypeFunc[]; guaranteedModifierTypeFuncs?: ModifierTypeFunc[];
fillRemaining?: boolean; fillRemaining?: boolean;
/** Set to negative value to disable rerolls completely in shop */
rerollMultiplier?: number; rerollMultiplier?: number;
allowLuckUpgrades?: boolean; allowLuckUpgrades?: boolean;
} }

View File

@ -524,7 +524,7 @@ export class MysteryEncounterRewardsPhase extends Phase {
encounter.doEncounterRewards(this.scene); encounter.doEncounterRewards(this.scene);
} else if (this.addHealPhase) { } else if (this.addHealPhase) {
this.scene.tryRemovePhase(p => p instanceof SelectModifierPhase); 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)); this.scene.pushPhase(new PostMysteryEncounterPhase(this.scene));

View File

@ -74,7 +74,7 @@ export class SelectModifierPhase extends BattlePhase {
switch (cursor) { switch (cursor) {
case 0: case 0:
const rerollCost = this.getRerollCost(typeOptions, this.scene.lockModifierTiers); 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(); this.scene.ui.playError();
return false; return false;
} else { } else {
@ -241,7 +241,17 @@ export class SelectModifierPhase extends BattlePhase {
} else { } else {
baseValue = 250; 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); return Math.min(Math.ceil(this.scene.currentBattle.waveIndex / 10) * baseValue * Math.pow(2, this.rerollCount) * multiplier, Number.MAX_SAFE_INTEGER);
} }

View File

@ -31,6 +31,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
private rowCursor: integer = 0; private rowCursor: integer = 0;
private player: boolean; 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 rerollCost: integer;
private transferButtonWidth: integer; private transferButtonWidth: integer;
private checkButtonWidth: integer; private checkButtonWidth: integer;
@ -265,7 +269,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.continueButtonContainer.setAlpha(0); this.continueButtonContainer.setAlpha(0);
this.rerollButtonContainer.setVisible(true); this.rerollButtonContainer.setVisible(true);
this.checkButtonContainer.setVisible(true); this.checkButtonContainer.setVisible(true);
this.continueButtonContainer.setVisible(this.rerollCost === 0); this.continueButtonContainer.setVisible(this.rerollCost < 0);
this.lockRarityButtonContainer.setVisible(canLockRarities); this.lockRarityButtonContainer.setVisible(canLockRarities);
this.scene.tweens.add({ this.scene.tweens.add({
@ -276,7 +280,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.scene.tweens.add({ this.scene.tweens.add({
targets: [this.rerollButtonContainer], targets: [this.rerollButtonContainer],
alpha: this.rerollCost === 0 ? 0.5 : 1, alpha: this.rerollCost < 0 ? 0.5 : 1,
duration: 250 duration: 250
}); });
@ -537,6 +541,13 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
} }
updateRerollCostText(): void { 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 canReroll = this.scene.money >= this.rerollCost;
const formattedMoney = Utils.formatMoney(this.scene.moneyFormat, this.rerollCost); const formattedMoney = Utils.formatMoney(this.scene.moneyFormat, this.rerollCost);