Merge pull request #4229 from ben-lear/mystery-encounters

Change how reroll button gets disabled in Modifier Shop Phase
This commit is contained in:
ImperialSympathizer 2024-09-13 19:29:09 -04:00 committed by GitHub
commit f8f157a319
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 38 additions and 12 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

@ -14,6 +14,7 @@ import Overrides from "#app/overrides";
import i18next from "i18next"; import i18next from "i18next";
import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target";
import { IntegerHolder } from "./../utils"; import { IntegerHolder } from "./../utils";
import Phaser from "phaser";
export const SHOP_OPTIONS_ROW_LIMIT = 6; export const SHOP_OPTIONS_ROW_LIMIT = 6;
@ -31,6 +32,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;
@ -111,6 +116,11 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.continueButtonContainer.setVisible(false); this.continueButtonContainer.setVisible(false);
ui.add(this.continueButtonContainer); ui.add(this.continueButtonContainer);
// Create continue button
const continueButtonText = addTextObject(this.scene, -24, 5, i18next.t("modifierSelectUiHandler:continueNextWaveButton"), TextStyle.MESSAGE);
continueButtonText.setName("text-continue-btn");
this.continueButtonContainer.add(continueButtonText);
// prepare move overlay // prepare move overlay
const overlayScale = 1; const overlayScale = 1;
this.moveInfoOverlay = new MoveInfoOverlay(this.scene, { this.moveInfoOverlay = new MoveInfoOverlay(this.scene, {
@ -192,12 +202,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.options.push(option); this.options.push(option);
} }
// Add continue button // Set "Continue" button height based on number of rows in healing items shop
if (this.options.length === 0) { const continueButton = this.continueButtonContainer.getAt(0) as Phaser.GameObjects.Text;
const continueButtonText = addTextObject(this.scene, -24, optionsYOffset - 5, i18next.t("modifierSelectUiHandler:continueNextWaveButton"), TextStyle.MESSAGE); continueButton.y = optionsYOffset - 5;
continueButtonText.setName("text-continue-btn"); continueButton.setVisible(this.options.length === 0);
this.continueButtonContainer.add(continueButtonText);
}
for (let m = 0; m < shopTypeOptions.length; m++) { for (let m = 0; m < shopTypeOptions.length; m++) {
const row = m < SHOP_OPTIONS_ROW_LIMIT ? 0 : 1; const row = m < SHOP_OPTIONS_ROW_LIMIT ? 0 : 1;
@ -265,7 +273,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 +284,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 +545,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);