diff --git a/src/battle-scene.ts b/src/battle-scene.ts index df827f5201c..216809aae06 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1381,8 +1381,7 @@ export default class BattleScene extends SceneBase { if (this.money === undefined) { return; } - const formattedMoney = - this.moneyFormat === MoneyFormat.ABBREVIATED ? Utils.formatFancyLargeNumber(this.money, 3) : this.money.toLocaleString(); + const formattedMoney = Utils.formatMoney(this.moneyFormat, this.money); this.moneyText.setText(`₽${formattedMoney}`); this.fieldUI.moveAbove(this.moneyText, this.luckText); if (forceVisible) { diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 46019281d4b..6901290a306 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -25,6 +25,7 @@ import i18next from "#app/plugins/i18n"; import { getModifierTierTextTint } from "#app/ui/text"; import { BattlerTagType } from "#app/data/enums/battler-tag-type.js"; import * as Overrides from "../overrides"; +import { MoneyMultiplierModifier } from "./modifier"; const outputModifierData = false; const useMaxWeightForOutput = false; @@ -631,9 +632,13 @@ export class MoneyRewardModifierType extends ModifierType { } getDescription(scene: BattleScene): string { + const moneyAmount = new Utils.IntegerHolder(scene.getWaveMoneyAmount(this.moneyMultiplier)); + scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); + const formattedMoney = Utils.formatMoney(scene.moneyFormat, moneyAmount.value); + return i18next.t("modifierType:ModifierType.MoneyRewardModifierType.description", { moneyMultiplier: i18next.t(this.moneyMultiplierDescriptorKey as any), - moneyAmount: scene.getWaveMoneyAmount(this.moneyMultiplier).toLocaleString("en-US"), + moneyAmount: formattedMoney, }); } } diff --git a/src/ui/game-stats-ui-handler.ts b/src/ui/game-stats-ui-handler.ts index eda36919d3b..57a02257810 100644 --- a/src/ui/game-stats-ui-handler.ts +++ b/src/ui/game-stats-ui-handler.ts @@ -89,7 +89,7 @@ const displayStats: DisplayStats = { }, highestMoney: { label_key: "highestMoney", - sourceFunc: gameData => Utils.formatFancyLargeNumber(gameData.gameStats.highestMoney, 3), + sourceFunc: gameData => Utils.formatFancyLargeNumber(gameData.gameStats.highestMoney), }, highestDamage: { label_key: "highestDamage", diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 61941c28b2c..8eb0bb7b82a 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -9,6 +9,7 @@ import { handleTutorial, Tutorial } from "../tutorial"; import {Button} from "../enums/buttons"; import MoveInfoOverlay from "./move-info-overlay"; import { allMoves } from "../data/move"; +import * as Utils from "./../utils"; export const SHOP_OPTIONS_ROW_LIMIT = 6; @@ -398,7 +399,9 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { updateRerollCostText(): void { const canReroll = this.scene.money >= this.rerollCost; - this.rerollCostText.setText(`₽${this.rerollCost.toLocaleString("en-US")}`); + const formattedMoney = Utils.formatMoney(this.scene.moneyFormat, this.rerollCost); + + this.rerollCostText.setText(`₽${formattedMoney}`); this.rerollCostText.setColor(this.getTextColor(canReroll ? TextStyle.MONEY : TextStyle.PARTY_RED)); this.rerollCostText.setShadowColor(this.getTextColor(canReroll ? TextStyle.MONEY : TextStyle.PARTY_RED, true)); } @@ -656,7 +659,9 @@ class ModifierOption extends Phaser.GameObjects.Container { const scene = this.scene as BattleScene; const textStyle = this.modifierTypeOption.cost <= scene.money ? TextStyle.MONEY : TextStyle.PARTY_RED; - this.itemCostText.setText(`₽${this.modifierTypeOption.cost.toLocaleString("en-US")}`); + const formattedMoney = Utils.formatMoney(scene.moneyFormat, this.modifierTypeOption.cost); + + this.itemCostText.setText(`₽${formattedMoney}`); this.itemCostText.setColor(getTextColor(textStyle, false, scene.uiTheme)); this.itemCostText.setShadowColor(getTextColor(textStyle, true, scene.uiTheme)); } diff --git a/src/utils.ts b/src/utils.ts index 6b5e64b7b0d..b8994efce64 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,5 @@ import i18next from "i18next"; +import { MoneyFormat } from "./enums/money-format"; export const MissingTextureKey = "__MISSING"; @@ -237,7 +238,7 @@ export function formatLargeNumber(count: integer, threshold: integer): string { // Abbreviations from 10^0 to 10^33 const AbbreviationsLargeNumber: string[] = ["", "K", "M", "B", "t", "q", "Q", "s", "S", "o", "n", "d"]; -export function formatFancyLargeNumber(number: number, rounded: number = 2): string { +export function formatFancyLargeNumber(number: number, rounded: number = 3): string { let exponent: number; if (number < 1000) { @@ -251,7 +252,14 @@ export function formatFancyLargeNumber(number: number, rounded: number = 2): str number /= Math.pow(1000, exponent); } - return `${(exponent === 0) ? number : number.toFixed(rounded)}${AbbreviationsLargeNumber[exponent]}`; + return `${(exponent === 0) || number % 1 === 0 ? number : number.toFixed(rounded)}${AbbreviationsLargeNumber[exponent]}`; +} + +export function formatMoney(format: MoneyFormat, amount: number) { + if (format === MoneyFormat.ABBREVIATED) { + return formatFancyLargeNumber(amount); + } + return amount.toLocaleString(); } export function formatStat(stat: integer, forHp: boolean = false): string {