mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-02 07:18:07 +00:00
QoL: Add billions to money utils (#4460)
## Description: A simple QoL to handle cases where money surpasses $1B. I have seen this happen in both custom games and post-game, and generally looks nicer than just showing a thousand millions. <img width="242" height="71" alt="image" src="https://github.com/user-attachments/assets/abc9adb5-2e8f-485f-93ff-47a43a019d85" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: bijx
This commit is contained in:
+7
-1
@@ -285,7 +285,13 @@ export function renderNumber(
|
||||
num = Number(num);
|
||||
num = Math.max(num, 0);
|
||||
|
||||
if (num >= 10_000_000) {
|
||||
if (num >= 10_000_000_000) {
|
||||
const value = Math.floor(num / 100000000) / 10;
|
||||
return value.toFixed(fixedPoints ?? 1) + "B";
|
||||
} else if (num >= 1_000_000_000) {
|
||||
const value = Math.floor(num / 10000000) / 100;
|
||||
return value.toFixed(fixedPoints ?? 2) + "B";
|
||||
} else if (num >= 10_000_000) {
|
||||
const value = Math.floor(num / 100000) / 10;
|
||||
return value.toFixed(fixedPoints ?? 1) + "M";
|
||||
} else if (num >= 1_000_000) {
|
||||
|
||||
Reference in New Issue
Block a user