Cap money at max safe integer

pull/201/head^2
Flashfyre 2024-04-21 21:17:07 -04:00
parent 8838d36bf4
commit 291f8570e9
4 changed files with 13 additions and 18 deletions

View File

@ -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;

View File

@ -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.addMoney(moneyAmount.value);
scene.validateAchvs(MoneyAchv);
scene.queueMessage(`You picked up ₽${moneyAmount.value.toLocaleString('en-US')}!`, null, true);
scene.currentBattle.moneyScattered = 0;

View File

@ -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);

View File

@ -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);
}