Skip to content

Starting gold input in millions with decimal support ✨#3349

Merged
evanpelle merged 1 commit intomainfrom
feat/starting-gold-millions-input
Mar 6, 2026
Merged

Starting gold input in millions with decimal support ✨#3349
evanpelle merged 1 commit intomainfrom
feat/starting-gold-millions-input

Conversation

@FloPinguin
Copy link
Contributor

Description:

Starting gold input: use millions

Changes the starting gold input in singleplayer and host lobby modals to accept values in millions (e.g. enter 5 for 5M gold). Supports decimals like 6.6 for 6.6M. The value is multiplied by 1,000,000 before being sent to the game config.

  • Label updated to "Starting Gold (Millions)"
  • Input uses float parsing with min 0.1, matching gold multiplier behavior
  • JoinLobbyModal shows clean values without unnecessary decimals (e.g. "5M" not "5.00M")

Previous

image image

Now

image image

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

FloPinguin

@FloPinguin FloPinguin added this to the v30 milestone Mar 4, 2026
@FloPinguin FloPinguin requested a review from a team as a code owner March 4, 2026 19:59
@FloPinguin FloPinguin added the UI/UX UI/UX changes including assets, menus, QoL, etc. label Mar 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Walkthrough

Refactored starting gold input handling across game lobby interfaces. Changed UI representation from raw numbers to millions-based input (placeholder "5" represents 5 million). Added float-based validation (0.1–1000), server-side scaling by 1,000,000, and formatted display values for game modifiers.

Changes

Cohort / File(s) Summary
Language Strings
resources/lang/en.json
Updated starting gold label to "Starting Gold (Millions)" and placeholder from "5000000" to "5" to reflect new millions-based input format.
Lobby Input Handlers
src/client/HostLobbyModal.ts, src/client/SinglePlayerModal.ts
Broadened starting gold input from integer to float range (0.1–1000, step "any"). Changed default from 5,000,000 to 5. Added 1,000,000 scaling factor when committing values to game config. Updated event binding from onInput to onChange.
Lobby Display
src/client/JoinLobbyModal.ts
Extended value binding for lobby config items to prefer formattedValue when available, falling back to existing display logic if absent.
Utilities
src/client/Utils.ts
Added optional formattedValue?: string property to ModifierInfo. For starting gold modifiers, compute millions-based badge amount and attach formatted value as "M" to the modifier object.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

Gold input scaled to millions bright,
Five now flows where millions write,
Float bounds dance where integers stood,
Cleaner UI as it should. ✨💰

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: converting starting gold input to accept values in millions with decimal support, which aligns with all modified files and objectives.
Description check ✅ Passed The description directly relates to the changeset, explaining the millions-based input conversion, including label updates, float parsing, and display formatting across all modified components.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/client/Utils.ts (1)

155-166: Consider centralizing million-scale conversion in one helper.

This logic is now duplicated across Utils.ts, HostLobbyModal.ts, and SinglePlayerModal.ts. A shared helper would reduce drift risk (rounding, precision, suffix formatting).

♻️ Suggested direction
+// utilities/GameConfigHelpers.ts
+export const MILLION = 1_000_000;
+
+export function toMillions(rawGold: number): number {
+  return parseFloat((rawGold / MILLION).toPrecision(12));
+}
+
+export function fromMillions(millions: number): number {
+  return Math.round(millions * MILLION);
+}
-const millions = parseFloat((modifiers.startingGold / 1_000_000).toPrecision(12));
+const millions = toMillions(modifiers.startingGold);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/client/Utils.ts` around lines 155 - 166, Extract the repeated
million-scale conversion into a single helper (e.g., formatMillions or
toMillions) and replace the inline logic in Utils.ts, HostLobbyModal.ts, and
SinglePlayerModal.ts with calls to that helper; the helper should take the raw
numeric value (startingGold), compute the millions using the same
parseFloat((value/1_000_000).toPrecision(12)) logic, and return both the numeric
millions and the formatted string with an "M" suffix so
labelKey/badgeParams/value/formattedValue remain consistent across uses; update
the three call sites to use the helper (ensuring they consume {millions,
formatted} or similar) and add a small unit test or comment to lock the
rounding/precision behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/client/HostLobbyModal.ts`:
- Around line 649-660: The UI clears startingGoldValue to undefined which causes
putGameConfig() to omit updates and leave a stale server value; when
parseBoundedFloatFromInput returns invalid/empty, set startingGoldValue to an
explicit clear marker (e.g. null) and ensure putGameConfig() sends that explicit
clear to the server (include startingGold: null or an explicit clear flag in the
payload) so the server apply path will remove the previous value; update the
handling in HostLobbyModal (the parseBoundedFloatFromInput branch and the
symmetric code around lines ~791-793) and adjust putGameConfig() to serialize
the explicit clear marker for startingGold.

In `@src/client/SinglePlayerModal.ts`:
- Around line 594-605: The UI allows the "starting gold" toggle to be on while
the parsed input becomes undefined, which causes the payload to omit
startingGold and the game to default to 0; update the logic so before starting
the game (e.g., in the start handler / method that builds the payload) you check
if the toggle/flag for starting gold is enabled and this.startingGoldValue is
undefined, and then either (a) block the start and surface validation (disable
the start button / show an error) or (b) restore a last-known-good value by
storing lastValidStartingGold when parseBoundedFloatFromInput returns a number
and reassigning it when value === undefined; ensure the check references the
existing symbols this.startingGoldValue, the input parsing code that uses
parseBoundedFloatFromInput, and the start/send-payload routine so no payload is
sent with an enabled-but-undefined startingGold.

---

Nitpick comments:
In `@src/client/Utils.ts`:
- Around line 155-166: Extract the repeated million-scale conversion into a
single helper (e.g., formatMillions or toMillions) and replace the inline logic
in Utils.ts, HostLobbyModal.ts, and SinglePlayerModal.ts with calls to that
helper; the helper should take the raw numeric value (startingGold), compute the
millions using the same parseFloat((value/1_000_000).toPrecision(12)) logic, and
return both the numeric millions and the formatted string with an "M" suffix so
labelKey/badgeParams/value/formattedValue remain consistent across uses; update
the three call sites to use the helper (ensuring they consume {millions,
formatted} or similar) and add a small unit test or comment to lock the
rounding/precision behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b741003-e53d-4e83-9e8a-bbede73ad4d4

📥 Commits

Reviewing files that changed from the base of the PR and between e137fca and 1f06043.

📒 Files selected for processing (5)
  • resources/lang/en.json
  • src/client/HostLobbyModal.ts
  • src/client/JoinLobbyModal.ts
  • src/client/SinglePlayerModal.ts
  • src/client/Utils.ts

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Mar 4, 2026
@github-project-automation github-project-automation bot moved this from Development to Final Review in OpenFront Release Management Mar 6, 2026
@evanpelle evanpelle merged commit c594487 into main Mar 6, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from Final Review to Complete in OpenFront Release Management Mar 6, 2026
@evanpelle evanpelle deleted the feat/starting-gold-millions-input branch March 6, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

UI/UX UI/UX changes including assets, menus, QoL, etc.

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants