diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 66de18832..98c1fc83e 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -37,7 +37,7 @@ import SettingsUiHandler from './ui/settings-ui-handler'; import MessageUiHandler from './ui/message-ui-handler'; import { Species } from './data/enums/species'; import InvertPostFX from './pipelines/invert'; -import { Achv, ModifierAchv, achvs } from './system/achv'; +import { Achv, ModifierAchv, MoneyAchv, achvs } from './system/achv'; import { Voucher, vouchers } from './system/voucher'; import { Gender } from './data/gender'; import UIPlugin from 'phaser3-rex-plugins/templates/ui/ui-plugin'; @@ -1680,6 +1680,12 @@ export default class BattleScene extends SceneBase { this.phaseQueue.push(new TurnInitPhase(this)); } + addMoney(amount: integer): void { + this.money = Math.min(this.money + amount, Number.MAX_SAFE_INTEGER); + this.updateMoneyText(); + this.validateAchvs(MoneyAchv); + } + getWaveMoneyAmount(moneyMultiplier: number): integer { const waveIndex = this.currentBattle.waveIndex; const waveSetIndex = Math.ceil(waveIndex / 10) - 1; diff --git a/src/battle.ts b/src/battle.ts index b8ac37802..97dec4716 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -157,10 +157,8 @@ export default class Battle { const moneyAmount = new Utils.IntegerHolder(scene.currentBattle.moneyScattered); scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); - scene.money += moneyAmount.value; - scene.updateMoneyText(); - - scene.validateAchvs(MoneyAchv); + scene.addMoney(moneyAmount.value); + scene.queueMessage(`You picked up ₽${moneyAmount.value.toLocaleString('en-US')}!`, null, true); scene.currentBattle.moneyScattered = 0; diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index d327b3857..ca6ef0c75 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -1578,9 +1578,7 @@ export class MoneyRewardModifier extends ConsumableModifier { scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); - scene.money += moneyAmount.value; - scene.updateMoneyText(); - scene.validateAchvs(MoneyAchv); + scene.addMoney(moneyAmount.value); return true; } @@ -1627,9 +1625,7 @@ export class DamageMoneyRewardModifier extends PokemonHeldItemModifier { const scene = (args[0] as Pokemon).scene; const moneyAmount = new Utils.IntegerHolder(Math.floor((args[1] as Utils.IntegerHolder).value * (0.5 * this.getStackCount()))); scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); - scene.money += moneyAmount.value; - scene.updateMoneyText(); - scene.validateAchvs(MoneyAchv); + scene.addMoney(moneyAmount.value); return true; } @@ -1651,9 +1647,7 @@ export class MoneyInterestModifier extends PersistentModifier { apply(args: any[]): boolean { const scene = args[0] as BattleScene; const interestAmount = Math.floor(scene.money * 0.1 * this.getStackCount()); - scene.money += interestAmount; - scene.updateMoneyText(); - scene.validateAchvs(MoneyAchv); + scene.addMoney(interestAmount); scene.queueMessage(`You received interest of ₽${interestAmount.toLocaleString('en-US')}\nfrom the ${this.type.name}!`, null, true); diff --git a/src/phases.ts b/src/phases.ts index 1b3bedd08..7a766211f 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3314,10 +3314,7 @@ export class MoneyRewardPhase extends BattlePhase { this.scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); - this.scene.money += moneyAmount.value; - this.scene.updateMoneyText(); - - this.scene.validateAchvs(MoneyAchv); + this.scene.addMoney(moneyAmount.value); this.scene.ui.showText(`You got ₽${moneyAmount.value.toLocaleString('en-US')}\nfor winning!`, null, () => this.end(), null, true); }