pokerogue/src/phases/money-reward-phase.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

import BattleScene from "#app/battle-scene";
import { ArenaTagType } from "#app/enums/arena-tag-type";
import { MoneyMultiplierModifier } from "#app/modifier/modifier";
2024-08-19 03:23:52 +01:00
import i18next from "i18next";
import * as Utils from "#app/utils";
2024-08-19 03:23:52 +01:00
import { BattlePhase } from "./battle-phase";
export class MoneyRewardPhase extends BattlePhase {
private moneyMultiplier: number;
constructor(scene: BattleScene, moneyMultiplier: number) {
super(scene);
this.moneyMultiplier = moneyMultiplier;
}
start() {
const moneyAmount = new Utils.IntegerHolder(this.scene.getWaveMoneyAmount(this.moneyMultiplier));
this.scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);
if (this.scene.arena.getTag(ArenaTagType.HAPPY_HOUR)) {
moneyAmount.value *= 2;
}
this.scene.addMoney(moneyAmount.value);
const userLocale = navigator.language || "en-US";
const formattedMoneyAmount = moneyAmount.value.toLocaleString(userLocale);
const message = i18next.t("battle:moneyWon", { moneyAmount: formattedMoneyAmount });
this.scene.ui.showText(message, null, () => this.end(), null, true);
}
}