Merge pull request #4229 from ben-lear/mystery-encounters
Change how reroll button gets disabled in Modifier Shop Phase
This commit is contained in:
commit
f8f157a319
|
@ -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);
|
||||
}
|
||||
)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import Overrides from "#app/overrides";
|
|||
import i18next from "i18next";
|
||||
import { ShopCursorTarget } from "#app/enums/shop-cursor-target";
|
||||
import { IntegerHolder } from "./../utils";
|
||||
import Phaser from "phaser";
|
||||
|
||||
export const SHOP_OPTIONS_ROW_LIMIT = 6;
|
||||
|
||||
|
@ -31,6 +32,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;
|
||||
|
@ -111,6 +116,11 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||
this.continueButtonContainer.setVisible(false);
|
||||
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
|
||||
const overlayScale = 1;
|
||||
this.moveInfoOverlay = new MoveInfoOverlay(this.scene, {
|
||||
|
@ -192,12 +202,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||
this.options.push(option);
|
||||
}
|
||||
|
||||
// Add continue button
|
||||
if (this.options.length === 0) {
|
||||
const continueButtonText = addTextObject(this.scene, -24, optionsYOffset - 5, i18next.t("modifierSelectUiHandler:continueNextWaveButton"), TextStyle.MESSAGE);
|
||||
continueButtonText.setName("text-continue-btn");
|
||||
this.continueButtonContainer.add(continueButtonText);
|
||||
}
|
||||
// Set "Continue" button height based on number of rows in healing items shop
|
||||
const continueButton = this.continueButtonContainer.getAt(0) as Phaser.GameObjects.Text;
|
||||
continueButton.y = optionsYOffset - 5;
|
||||
continueButton.setVisible(this.options.length === 0);
|
||||
|
||||
for (let m = 0; m < shopTypeOptions.length; m++) {
|
||||
const row = m < SHOP_OPTIONS_ROW_LIMIT ? 0 : 1;
|
||||
|
@ -265,7 +273,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 +284,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 +545,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);
|
||||
|
|
Loading…
Reference in New Issue