Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import { TimedEventManager } from "#app/timed-event-manager.js";
import i18next from "i18next";
import IMysteryEncounter, { MysteryEncounterTier, MysteryEncounterVariant } from "./data/mystery-encounters/mystery-encounter";
import { mysteryEncountersByBiome, allMysteryEncounters, BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT, AVERAGE_ENCOUNTERS_PER_RUN_TARGET, WIGHT_INCREMENT_ON_SPAWN_MISS } from "./data/mystery-encounters/mystery-encounters";
import { MysteryEncounterData } from "#app/data/mystery-encounters/mystery-encounter-data";
import { MysteryEncounterData, MysteryEncounterAuras, AuraType } from "#app/data/mystery-encounters/mystery-encounter-data";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";

export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1";
Expand Down Expand Up @@ -216,6 +216,7 @@ export default class BattleScene extends SceneBase {
public pokemonInfoContainer: PokemonInfoContainer;
private party: PlayerPokemon[];
public mysteryEncounterData: MysteryEncounterData = new MysteryEncounterData(null);
public mysteryEncounterAuras: MysteryEncounterAuras = new MysteryEncounterAuras();
public lastMysteryEncounter: IMysteryEncounter;
/** Combined Biome and Wave count text */
private biomeWaveText: Phaser.GameObjects.Text;
Expand Down Expand Up @@ -2151,12 +2152,23 @@ export default class BattleScene extends SceneBase {
}

addMoney(amount: integer): void {
this.money = Math.min(this.money + amount, Number.MAX_SAFE_INTEGER);
const mysteryIncomeAura = this.mysteryEncounterAuras.FindAura(AuraType.INCOME);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving a comment here so I don’t forget, this functionality should probably be moved to an applyModifiers() function

const mysteryIncomeMult = 1 + (mysteryIncomeAura.length > 0 ? this.mysteryEncounterAuras.FindAuraTotals(AuraType.INCOME) : 0);
this.money = Math.min(this.money + Math.floor(amount * mysteryIncomeMult), Number.MAX_SAFE_INTEGER);
this.updateMoneyText();
this.animateMoneyChanged(true);
this.validateAchvs(MoneyAchv);
}

getFormattedMoneyString(moneyAmount: number): string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we having to multiply the current money value in the string by modifiers? Shouldn’t this just be a function to obtain a string.

const userLocale = navigator.language || "en-US";
const mysteryIncomeAura = this.mysteryEncounterAuras.FindAura(AuraType.INCOME);
const mysteryIncomeMult = 1 + (mysteryIncomeAura.length > 0 ? this.mysteryEncounterAuras.FindAuraTotals(AuraType.INCOME) : 0);
const formattedMoneyAmount = (moneyAmount * mysteryIncomeMult).toLocaleString(userLocale);
const message = i18next.t("battle:moneyWon", { moneyAmount: formattedMoneyAmount });
return message;
}

getWaveMoneyAmount(moneyMultiplier: number): integer {
const waveIndex = this.currentBattle.waveIndex;
const waveSetIndex = Math.ceil(waveIndex / 10) - 1;
Expand Down
9 changes: 5 additions & 4 deletions src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Moves } from "#enums/moves";
import { PlayerGender } from "#enums/player-gender";
import { Species } from "#enums/species";
import { TrainerType } from "#enums/trainer-type";
import i18next from "#app/plugins/i18n";
//import i18next from "#app/plugins/i18n";
import IMysteryEncounter, { MysteryEncounterVariant } from "./data/mystery-encounters/mystery-encounter";

export enum BattleType {
Expand Down Expand Up @@ -177,9 +177,10 @@ export default class Battle {

scene.addMoney(moneyAmount.value);

const userLocale = navigator.language || "en-US";
const formattedMoneyAmount = moneyAmount.value.toLocaleString(userLocale);
const message = i18next.t("battle:moneyPickedUp", { moneyAmount: formattedMoneyAmount });
//const userLocale = navigator.language || "en-US";
//const formattedMoneyAmount = moneyAmount.value.toLocaleString(userLocale);
//const message = i18next.t("battle:moneyPickedUp", { moneyAmount: formattedMoneyAmount });
const message = this.scene.getFormattedMoneyString(moneyAmount.value);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, you should probably move the logic of that function back to here where it was before, or at least have the util function in this class

scene.queueMessage(message, null, true);

scene.currentBattle.moneyScattered = 0;
Expand Down
Loading