From d6a0d5fcaa1b77b3f128f420001988bad980d506 Mon Sep 17 00:00:00 2001 From: Zelow79 <32428876+Zelow79@users.noreply.github.com> Date: Fri, 20 Jan 2023 08:06:50 -0500 Subject: [PATCH] BUGFIX: Corrected error in formatReallyBigNumber and updated BB UI to be more large number friendly (#331) --- src/Bladeburner/Bladeburner.tsx | 26 ++++++++++++++------------ src/Bladeburner/ui/Stats.tsx | 11 +++++++---- src/ui/numeralFormat.ts | 6 +++--- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index 57a0ffc3d..64c4573b9 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -1288,12 +1288,14 @@ export class Bladeburner { this.changeRank(person, gain); if (isOperation && this.logging.ops) { this.log( - `${person.whoAmI()}: ${action.name} successfully completed! Gained ${formatNumber(gain, 3)} rank`, + `${person.whoAmI()}: ${ + action.name + } successfully completed! Gained ${numeralWrapper.formatReallyBigNumber(gain)} rank`, ); } else if (!isOperation && this.logging.contracts) { this.log( `${person.whoAmI()}: ${action.name} contract successfully completed! Gained ` + - `${formatNumber(gain, 3)} rank and ${numeralWrapper.formatMoney(moneyGain)}`, + `${numeralWrapper.formatReallyBigNumber(gain)} rank and ${numeralWrapper.formatMoney(moneyGain)}`, ); } } @@ -1450,15 +1452,15 @@ export class Bladeburner { this.log( `${person.whoAmI()}: ` + "Training completed. Gained: " + - formatNumber(strExpGain, 1) + + numeralWrapper.formatExp(strExpGain) + " str exp, " + - formatNumber(defExpGain, 1) + + numeralWrapper.formatExp(defExpGain) + " def exp, " + - formatNumber(dexExpGain, 1) + + numeralWrapper.formatExp(dexExpGain) + " dex exp, " + - formatNumber(agiExpGain, 1) + + numeralWrapper.formatExp(agiExpGain) + " agi exp, " + - formatNumber(staminaGain, 3) + + numeralWrapper.formatReallyBigNumber(staminaGain) + " max stamina", ); } @@ -1486,9 +1488,9 @@ export class Bladeburner { if (this.logging.general) { this.log( `${person.whoAmI()}: ` + - `Field analysis completed. Gained ${formatNumber(rankGain, 2)} rank, ` + - `${formatNumber(hackingExpGain, 1)} hacking exp, and ` + - `${formatNumber(charismaExpGain, 1)} charisma exp`, + `Field analysis completed. Gained ${numeralWrapper.formatReallyBigNumber(rankGain)} rank, ` + + `${numeralWrapper.formatExp(hackingExpGain)} hacking exp, and ` + + `${numeralWrapper.formatExp(charismaExpGain)} charisma exp`, ); } break; @@ -1504,7 +1506,7 @@ export class Bladeburner { this.log( `${person.whoAmI()}: ` + "Successfully recruited a team member! Gained " + - formatNumber(expGain, 1) + + numeralWrapper.formatExp(expGain) + " charisma exp", ); } @@ -1515,7 +1517,7 @@ export class Bladeburner { this.log( `${person.whoAmI()}: ` + "Failed to recruit a team member. Gained " + - formatNumber(expGain, 1) + + numeralWrapper.formatExp(expGain) + " charisma exp", ); } diff --git a/src/Bladeburner/ui/Stats.tsx b/src/Bladeburner/ui/Stats.tsx index 87766733a..2f3385345 100644 --- a/src/Bladeburner/ui/Stats.tsx +++ b/src/Bladeburner/ui/Stats.tsx @@ -59,7 +59,7 @@ export function Stats(props: IProps): React.ReactElement { Your rank within the Bladeburner division.}> - Rank: {formatNumber(props.bladeburner.rank, 2)} + Rank: {numeralWrapper.formatReallyBigNumber(props.bladeburner.rank)}
@@ -88,7 +88,8 @@ export function Stats(props: IProps): React.ReactElement { } > - Stamina: {formatNumber(props.bladeburner.stamina, 3)} / {formatNumber(props.bladeburner.maxStamina, 3)} + Stamina: {numeralWrapper.formatReallyBigNumber(props.bladeburner.stamina)} /{" "} + {numeralWrapper.formatReallyBigNumber(props.bladeburner.maxStamina)} @@ -140,7 +141,9 @@ export function Stats(props: IProps): React.ReactElement { } > - City Chaos: {formatNumber(props.bladeburner.getCurrentCity().chaos)} + + City Chaos: {numeralWrapper.formatReallyBigNumber(props.bladeburner.getCurrentCity().chaos)} +
@@ -166,7 +169,7 @@ export function Stats(props: IProps): React.ReactElement {
)} - Skill Points: {formatNumber(props.bladeburner.skillPoints, 0)} + Skill Points: {numeralWrapper.formatReallyBigNumber(props.bladeburner.skillPoints)}
Aug. Success Chance mult: {formatNumber(Player.mults.bladeburner_success_chance * 100, 1)}% diff --git a/src/ui/numeralFormat.ts b/src/ui/numeralFormat.ts index 3eab220d4..04ec612e0 100644 --- a/src/ui/numeralFormat.ts +++ b/src/ui/numeralFormat.ts @@ -61,7 +61,7 @@ class NumeralFormatter { const nAbs = Math.abs(n as number); if (n === Infinity) return "∞"; for (let i = 0; i < extraFormats.length; i++) { - if (extraFormats[i] < nAbs && nAbs <= extraFormats[i] * 1000) { + if (extraFormats[i] <= nAbs && nAbs < extraFormats[i] * 1000) { return this.format((n as number) / extraFormats[i], "0." + "0".repeat(decimalPlaces)) + extraNotations[i]; } } @@ -152,11 +152,11 @@ class NumeralFormatter { } formatPopulation(n: number): string { - return this.format(n, "0.000a"); + return this.formatReallyBigNumber(n); } formatStamina(n: number): string { - return this.format(n, "0.0"); + return this.formatReallyBigNumber(n); } formatShares(n: number): string {