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
};
encounter.setDialogueToken("eggType", i18next.t(`${namespace}.eggTypes.rare`));
setEncounterRewards(scene, { fillRemaining: false, rerollMultiplier: 0 }, [eggOptions]);
setEncounterRewards(scene, { fillRemaining: false, rerollMultiplier: -1 }, [eggOptions]);
leaveEncounterWithoutBattle(scene);
}
)

View File

@ -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;
}

View File

@ -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));

View File

@ -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);
}

View File

@ -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);