Skip to content

Commit

Permalink
[Enhancement] Add Fee Waiving Overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
xsn34kzx committed Jul 29, 2024
1 parent 2d1fe13 commit 5f38091
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class DefaultOverrides {
readonly XP_MULTIPLIER_OVERRIDE: number = null;
/** default 1000 */
readonly STARTING_MONEY_OVERRIDE: integer = 0;
/** Sets all shop item prices to 0 */
readonly WAIVE_SHOP_FEES_OVERRIDE: boolean = false;
/** Sets reroll price to 0 */
readonly WAIVE_ROLL_FEE_OVERRIDE: boolean = false;
readonly FREE_CANDY_UPGRADE_OVERRIDE: boolean = false;
readonly POKEBALL_OVERRIDE: { active: boolean; pokeballs: PokeballCounts } = {
active: false,
Expand Down
22 changes: 14 additions & 8 deletions src/phases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5178,9 +5178,11 @@ export class SelectModifierPhase extends BattlePhase {
this.scene.unshiftPhase(new SelectModifierPhase(this.scene, this.rerollCount + 1, typeOptions.map(o => o.type.tier)));
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
this.scene.money -= rerollCost;
this.scene.updateMoneyText();
this.scene.animateMoneyChanged(false);
if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) {
this.scene.money -= rerollCost;
this.scene.updateMoneyText();
this.scene.animateMoneyChanged(false);
}
this.scene.playSound("buy");
}
break;
Expand Down Expand Up @@ -5221,7 +5223,7 @@ export class SelectModifierPhase extends BattlePhase {
break;
}

if (cost && this.scene.money < cost) {
if (cost && (this.scene.money < cost) && !Overrides.WAIVE_ROLL_FEE_OVERRIDE) {
this.scene.ui.playError();
return false;
}
Expand All @@ -5231,9 +5233,11 @@ export class SelectModifierPhase extends BattlePhase {
if (cost) {
result.then(success => {
if (success) {
this.scene.money -= cost;
this.scene.updateMoneyText();
this.scene.animateMoneyChanged(false);
if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) {
this.scene.money -= cost;
this.scene.updateMoneyText();
this.scene.animateMoneyChanged(false);
}
this.scene.playSound("buy");
(this.scene.ui.getHandler() as ModifierSelectUiHandler).updateCostText();
} else {
Expand Down Expand Up @@ -5313,7 +5317,9 @@ export class SelectModifierPhase extends BattlePhase {

getRerollCost(typeOptions: ModifierTypeOption[], lockRarities: boolean): integer {
let baseValue = 0;
if (lockRarities) {
if (Overrides.WAIVE_ROLL_FEE_OVERRIDE) {
return baseValue;
} else if (lockRarities) {
const tierValues = [50, 125, 300, 750, 2000];
for (const opt of typeOptions) {
baseValue += tierValues[opt.type.tier];
Expand Down
6 changes: 4 additions & 2 deletions src/ui/modifier-select-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {Button} from "#enums/buttons";
import MoveInfoOverlay from "./move-info-overlay";
import { allMoves } from "../data/move";
import * as Utils from "./../utils";
import Overrides from "#app/overrides";
import i18next from "i18next";

export const SHOP_OPTIONS_ROW_LIMIT = 6;
Expand Down Expand Up @@ -726,9 +727,10 @@ class ModifierOption extends Phaser.GameObjects.Container {

updateCostText(): void {
const scene = this.scene as BattleScene;
const textStyle = this.modifierTypeOption.cost <= scene.money ? TextStyle.MONEY : TextStyle.PARTY_RED;
const cost = Overrides.WAIVE_ROLL_FEE_OVERRIDE ? 0 : this.modifierTypeOption.cost;
const textStyle = cost <= scene.money ? TextStyle.MONEY : TextStyle.PARTY_RED;

const formattedMoney = Utils.formatMoney(scene.moneyFormat, this.modifierTypeOption.cost);
const formattedMoney = Utils.formatMoney(scene.moneyFormat, cost);

this.itemCostText.setText(i18next.t("modifierSelectUiHandler:itemCost", { formattedMoney }));
this.itemCostText.setColor(getTextColor(textStyle, false, scene.uiTheme));
Expand Down

0 comments on commit 5f38091

Please sign in to comment.