Repository navigation
Conversation
|
Warning Rate limit exceeded@ryanbarlow97 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 38 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (5)
WalkthroughAdds dynamic center-button icon and color resolution, split-button support, config- and setting-gated Donate Gold/Troops menu items, relaxes donation friendliness check to require only both players alive, converts donate flags to properties/getters, adds UI toggle and tests. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as RadialMenu (SVG)
participant RM as RadialMenu.Controller
participant Game as Game Logic
User->>UI: open radial menu / hover
UI->>RM: request menu items (params)
RM->>RM: build items via RadialMenuElements\n(determine donate visibility)
RM->>UI: render menu (items + center button)
alt center button has dynamic icon/color
RM->>RM: call centerButton.icon(params)\ncall centerButton.color(params)
RM->>UI: update center icon & fill
end
User->>UI: click center
UI->>RM: handle click
RM->>Game: execute center action (may be donate)
Game-->>RM: result
RM->>UI: update menu / close
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/client/graphics/layers/RadialMenu.ts(5 hunks)src/client/graphics/layers/RadialMenuElements.ts(4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-06-16T03:03:59.778Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1192
File: src/client/graphics/layers/RadialMenuElements.ts:312-314
Timestamp: 2025-06-16T03:03:59.778Z
Learning: In RadialMenuElements.ts, when fixing undefined params errors in subMenu functions, use explicit checks like `if (params === undefined || params.selected === null)` rather than optional chaining, as it makes the intent clearer and matches the specific error scenarios where params can be undefined during spawn phase operations.
Applied to files:
src/client/graphics/layers/RadialMenuElements.tssrc/client/graphics/layers/RadialMenu.ts
📚 Learning: 2025-08-12T00:31:50.144Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
🧬 Code graph analysis (2)
src/client/graphics/layers/RadialMenuElements.ts (3)
src/client/graphics/layers/RadialMenu.ts (1)
TooltipItem(18-21)src/core/game/PlayerImpl.ts (1)
isFriendly(792-797)src/core/game/GameView.ts (1)
isFriendly(384-386)
src/client/graphics/layers/RadialMenu.ts (2)
src/client/graphics/layers/RadialMenuElements.ts (1)
MenuElement(51-70)src/client/Utils.ts (1)
getSvgAspectRatio(249-300)
🪛 GitHub Actions: 🧪 CI
src/client/graphics/layers/RadialMenuElements.ts
[error] 596-596: TypeError: params.myPlayer.isFriendly is not a function. Expected 'isFriendly' to be a function, but it was not.
[error] 596-596: In function 'subMenu', the call 'params.myPlayer.isFriendly' failed because 'isFriendly' is not a function on 'myPlayer'.
…r hide or show the buttons)
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/client/graphics/layers/PlayerPanel.ts(3 hunks)src/client/graphics/layers/RadialMenuElements.ts(4 hunks)src/core/game/PlayerImpl.ts(2 hunks)tests/client/graphics/RadialMenuElements.test.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-08-12T00:31:50.144Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
Applied to files:
src/client/graphics/layers/PlayerPanel.tssrc/client/graphics/layers/RadialMenuElements.tstests/client/graphics/RadialMenuElements.test.tssrc/core/game/PlayerImpl.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: For the window close confirmation feature in `ClientGameRunner.ts`, the troop count requirement (>10,000 troops) from issue #2137 was intentionally removed because it was arbitrary and troop count can be reported as low despite having significant land. The confirmation now triggers for any alive player regardless of troop count.
Applied to files:
src/client/graphics/layers/PlayerPanel.tssrc/core/game/PlayerImpl.ts
📚 Learning: 2025-05-31T18:15:03.445Z
Learnt from: 1brucben
Repo: openfrontio/OpenFrontIO PR: 977
File: src/core/execution/AttackExecution.ts:123-125
Timestamp: 2025-05-31T18:15:03.445Z
Learning: The removeTroops function in PlayerImpl.ts already prevents negative troop counts by using minInt(this._troops, toInt(troops)) to ensure it never removes more troops than available.
Applied to files:
src/client/graphics/layers/PlayerPanel.tssrc/core/game/PlayerImpl.ts
📚 Learning: 2025-10-20T20:15:28.858Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:51-51
Timestamp: 2025-10-20T20:15:28.858Z
Learning: In src/core/execution/FakeHumanExecution.ts, game balance constants like MIRV_COOLDOWN_TICKS, MIRV_HESITATION_ODDS, VICTORY_DENIAL_TEAM_THRESHOLD, VICTORY_DENIAL_INDIVIDUAL_THRESHOLD, and STEAMROLL_CITY_GAP_MULTIPLIER are experimental tuning parameters subject to frequent change during balance testing. Do not flag changes to these values as issues or compare them against previous values.
Applied to files:
src/client/graphics/layers/PlayerPanel.ts
📚 Learning: 2025-06-16T03:03:59.778Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1192
File: src/client/graphics/layers/RadialMenuElements.ts:312-314
Timestamp: 2025-06-16T03:03:59.778Z
Learning: In RadialMenuElements.ts, when fixing undefined params errors in subMenu functions, use explicit checks like `if (params === undefined || params.selected === null)` rather than optional chaining, as it makes the intent clearer and matches the specific error scenarios where params can be undefined during spawn phase operations.
Applied to files:
src/client/graphics/layers/RadialMenuElements.tstests/client/graphics/RadialMenuElements.test.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: In `ClientGameRunner.ts`, the `myPlayer` field is always set when `shouldPreventWindowClose()` is called, so the null check in that method is sufficient without needing to fetch it again from `gameView.playerByClientID()`.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-11-01T00:24:33.860Z
Learnt from: FloPinguin
Repo: openfrontio/OpenFrontIO PR: 2161
File: src/core/execution/FakeHumanExecution.ts:670-678
Timestamp: 2025-11-01T00:24:33.860Z
Learning: In OpenFrontIO, PlayerType.Bot entities cannot be in teams and do not have friendliness relationships. Only PlayerType.Human and PlayerType.FakeHuman can participate in teams and alliances. Therefore, when targeting bot-owned tiles, friendliness checks like `owner.isFriendly(this.player)` are unnecessary and meaningless for bots.
Applied to files:
src/core/game/PlayerImpl.ts
🧬 Code graph analysis (3)
src/client/graphics/layers/PlayerPanel.ts (1)
src/core/game/PlayerImpl.ts (2)
canDonateTroops(615-636)canDonateGold(592-613)
src/client/graphics/layers/RadialMenuElements.ts (1)
src/client/graphics/layers/RadialMenu.ts (1)
TooltipItem(18-21)
tests/client/graphics/RadialMenuElements.test.ts (2)
src/client/graphics/layers/RadialMenuElements.ts (1)
rootMenuElement(577-618)src/core/game/GameView.ts (1)
PlayerView(181-446)
🪛 GitHub Actions: 🧪 CI
src/client/graphics/layers/RadialMenuElements.ts
[error] 595-595: params.game.config(...).donateGold is not a function
[error] 595-595: params.game.config(...).donateGold is not a function
[error] 595-595: params.game.config(...).donateGold is not a function
🔇 Additional comments (10)
src/core/game/PlayerImpl.ts (2)
592-613: LGTM - Donation eligibility relaxed as intended.The friendliness requirement has been removed, allowing donations between any two alive players. This aligns with the PR objective to encourage donations in team game modes.
615-636: LGTM - Consistent with gold donation changes.The troop donation logic correctly mirrors the gold donation changes, requiring only that both players are alive.
src/client/graphics/layers/PlayerPanel.ts (3)
656-666: LGTM - Proper dual-gating for troops donation.The button correctly requires both backend permission (
canDonateTroops) and config flag (donateTroopsEnabled) to render.
667-677: LGTM - Consistent dual-gating for gold donation.The gold donation button correctly mirrors the troops donation pattern with dual-gating.
622-624: No issues found. Code correctly uses the established config pattern.The code in
PlayerPanel.ts(lines 622-624) correctly callsthis.g.config().donateGold()andthis.g.config().donateTroops().GameView.config()(line 647 ofGameView.ts) returns aConfigobject that exposes both methods. This is the same pattern used successfully throughout the codebase—including inPlayerImpl.ts,RadialMenuElements.ts, and all existing tests.tests/client/graphics/RadialMenuElements.test.ts (1)
477-686: Excellent test coverage for donation functionality.The test suite comprehensively covers all combinations of config flags, permissions, and player relationships. The tests clearly verify that donation buttons appear only when both config and backend permissions allow it.
src/client/graphics/layers/RadialMenuElements.ts (4)
43-49: LGTM - Clean interface for split-button actions.The
SplitButtonActioninterface is well-typed and follows the existing patterns in the codebase.
66-69: LGTM - Clean extension of MenuElement interface.The optional
splitButtonproperty maintains backward compatibility while adding new functionality.
229-229: Good UX improvement - gold color for gold donation.Changing from green (
COLORS.ally) to gold (COLORS.tooltip.cost) makes the gold donation button more intuitive and visually distinct.
604-613: Conditional inclusion logic is sound, pending config fix.The triple-gating (selection exists, config enabled, backend permission) is correctly implemented. However, this depends on fixing the config method calls at lines 595-596.
|
I would like to avoid adding more options to the radial to keep it less busy. Maybe instead the center button (sword) could be used to donate? since you can't attack an ally anyways. |
I'm thinking the center button can donate troops, since I believe that is more common. |
|
@evanpelle like so instead of the grayed out sword icon being their, its the donate buttons (maybe half and half for gold / troops), thoses buttons are disabled / hide btw when the lobby does not allow donation for gold or troops |
|
@evanpelle or maybe i could make the center grey sword be a donate icon (generic) and then it opens a sub radial menu just like how the build icon does, if i dont hear back soon, ill go with this option as its more clean |
|
but also, every single person who seen this feature be wip has loved the idea, and even people i didnt tell, has mentioned me and said they like it since it helps in team games encourge donations |
|
@RjManhas Could be as discussed here indeed https://discord.com/channels/1359946986937258015/1434955373546176654/1434967081044152493 With the half/half donate troops/gold. And directly donate the % based on the attack %. So it is actually quick instead of having to go through another popup. If people want advanced options, they can still use the existing popup from the player info panel. Hotkeys for donating troops and gold could have the same simple use of the attack ratio %. Btw attack ratio % was used in the past for donating as you might know, so using it again would not be far of from what players were used to. |
|
@VariableVince like the button, does both gold and troops? |
|
based off the attack ratio |
|
@RjManhas no two buttons, so the attack button would be split in half like i think you meant with "maybe half and half for gold / troops". OTOH such small buttons could degrade mobile UX so not sure, maybe only have a donate troops button there like Evan suggested. Or use the center button to donate troops, and the place of the Ally button to donate gold? That way the radial menu doesn't get busier, no extra button spots (with the delete button now moved to the boat button spot, the menu is back to 4 buttons in the circle instead of 5 and i think Evan prefers keep it at 4). |
|
@VariableVince issue with replacing the ally button is in duo games or FFA games or when donating to a non teamate and a ally, thats where the break alliance button is, so unless we make this update only affect teamates in team games and forget about all the other situlations where you can donate, then we can not replace that button. |
|
@VariableVince so i should replace the sword button with gold (due to it being smaller and less used) and then where the build button would go for your own land, replace it with donate troops |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/client/graphics/layers/RadialMenu.ts (1)
390-464: Consider extracting split-button detection logic.The angle calculation logic for determining left vs right split-button halves is duplicated between
onHover(lines 397-448) andonClick(lines 510-570). Extracting this into a helper method would reduce duplication and make the code easier to maintain.Example helper:
private getSplitButtonSide( d: d3.PieArcDatum<MenuElement>, event: MouseEvent, pathElement: SVGPathElement, level: number ): 'left' | 'right' { const svg = pathElement.ownerSVGElement; if (!svg) return 'left'; const pt = svg.createSVGPoint(); pt.x = event.clientX; pt.y = event.clientY; const svgPoint = pt.matrixTransform(svg.getScreenCTM()?.inverse()); const innerRadius = this.getInnerRadiusForLevel(level); const outerRadius = this.getOuterRadiusForLevel(level); const arc = d3.arc<d3.PieArcDatum<MenuElement>>() .innerRadius(innerRadius) .outerRadius(outerRadius); const centroid = arc.centroid(d); const clickAngle = Math.atan2( svgPoint.y - centroid[1], svgPoint.x - centroid[0] ); const arcMidAngle = (d.startAngle + d.endAngle) / 2; const normalizeAngle = (angle: number) => { while (angle < 0) angle += 2 * Math.PI; while (angle >= 2 * Math.PI) angle -= 2 * Math.PI; return angle; }; const normalizedClickAngle = normalizeAngle(clickAngle); const normalizedMidAngle = normalizeAngle(arcMidAngle); let angleDiff = normalizedClickAngle - normalizedMidAngle; if (angleDiff > Math.PI) angleDiff -= 2 * Math.PI; if (angleDiff < -Math.PI) angleDiff += 2 * Math.PI; return angleDiff < 0 ? 'left' : 'right'; }src/client/graphics/layers/RadialMenuElements.ts (1)
692-748: Consider extracting donation visibility helper.The donation visibility logic in
rootMenuElement.subMenuis quite complex with nested conditions. Consider extracting ashouldShowDonateGold()helper similar toshouldShowDonateTroops()to improve readability.Example:
function shouldShowDonateGold(params: MenuElementParams, isOwnTerritory: boolean): boolean { if (!isOwnTerritory || !params.selected) return false; const donateGoldEnabled = Boolean(params.game.config().donateGold ?? false); if (!donateGoldEnabled) return false; if (!params.playerActions?.interaction?.canDonateGold) return false; const isTeammateOrAlly = params.myPlayer.isOnSameTeam(params.selected) || params.myPlayer.isAlliedWith(params.selected); if (!isTeammateOrAlly) return false; const gameMode = params.game.config().gameConfig.gameMode; if (gameMode === GameMode.FFA) { return params.game.config().userSettings().quickDonateButtonsInFFA(); } return true; }This would simplify the main submenu logic and make the conditions more explicit.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
resources/lang/en.json(1 hunks)src/client/UserSettingModal.ts(2 hunks)src/client/graphics/layers/RadialMenu.ts(8 hunks)src/client/graphics/layers/RadialMenuElements.ts(7 hunks)src/core/game/UserSettings.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: 2025-08-12T00:31:50.144Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
Applied to files:
src/client/UserSettingModal.tsresources/lang/en.jsonsrc/core/game/UserSettings.tssrc/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-06-02T14:27:37.609Z
Learnt from: andrewNiziolek
Repo: openfrontio/OpenFrontIO PR: 1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
Applied to files:
resources/lang/en.json
📚 Learning: 2025-08-16T10:52:08.292Z
Learnt from: TheGiraffe3
Repo: openfrontio/OpenFrontIO PR: 884
File: resources/lang/en.json:456-461
Timestamp: 2025-08-16T10:52:08.292Z
Learning: In OpenFrontIO, translation files in resources/lang/*.json (except en.json) should not be updated in regular PRs. Only dedicated translation PRs titled "mls" and made by Aotumori should update non-English locale files. Regular PRs should only update en.json when adding or modifying translation keys.
Applied to files:
resources/lang/en.json
📚 Learning: 2025-07-12T08:41:35.101Z
Learnt from: Aotumuri
Repo: openfrontio/OpenFrontIO PR: 1357
File: resources/lang/de.json:523-540
Timestamp: 2025-07-12T08:41:35.101Z
Learning: In OpenFrontIO project localization files, always check the en.json source file before flagging potential spelling errors in other language files, as some keys may intentionally use non-standard spellings that need to be consistent across all translations.
Applied to files:
resources/lang/en.json
📚 Learning: 2025-05-30T03:53:52.231Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 949
File: resources/lang/en.json:8-10
Timestamp: 2025-05-30T03:53:52.231Z
Learning: For the OpenFrontIO project, do not suggest updating translation files in resources/lang/*.json except for en.json. The project has a dedicated translation team that handles all other locale files.
Applied to files:
resources/lang/en.json
📚 Learning: 2025-08-21T21:42:45.277Z
Learnt from: plazmaezio
Repo: openfrontio/OpenFrontIO PR: 1883
File: src/client/HostLobbyModal.ts:227-245
Timestamp: 2025-08-21T21:42:45.277Z
Learning: In openfrontio/OpenFrontIO, the en.json file contains difficulty translation keys using the descriptive names ("Relaxed", "Balanced", "Intense", "Impossible") rather than the enum values ("Easy", "Medium", "Hard", "Impossible"). The DifficultyDescription mapping in src/client/components/Difficulties.ts correctly maps enum values to these descriptive translation keys.
Applied to files:
resources/lang/en.json
📚 Learning: 2025-06-16T03:03:59.778Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1192
File: src/client/graphics/layers/RadialMenuElements.ts:312-314
Timestamp: 2025-06-16T03:03:59.778Z
Learning: In RadialMenuElements.ts, when fixing undefined params errors in subMenu functions, use explicit checks like `if (params === undefined || params.selected === null)` rather than optional chaining, as it makes the intent clearer and matches the specific error scenarios where params can be undefined during spawn phase operations.
Applied to files:
src/client/graphics/layers/RadialMenu.tssrc/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-20T20:15:28.858Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:51-51
Timestamp: 2025-10-20T20:15:28.858Z
Learning: In src/core/execution/FakeHumanExecution.ts, game balance constants like MIRV_COOLDOWN_TICKS, MIRV_HESITATION_ODDS, VICTORY_DENIAL_TEAM_THRESHOLD, VICTORY_DENIAL_INDIVIDUAL_THRESHOLD, and STEAMROLL_CITY_GAP_MULTIPLIER are experimental tuning parameters subject to frequent change during balance testing. Do not flag changes to these values as issues or compare them against previous values.
Applied to files:
src/core/game/UserSettings.tssrc/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-06-09T02:20:43.637Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: In `ClientGameRunner.ts`, the `myPlayer` field is always set when `shouldPreventWindowClose()` is called, so the null check in that method is sufficient without needing to fetch it again from `gameView.playerByClientID()`.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: For the window close confirmation feature in `ClientGameRunner.ts`, the troop count requirement (>10,000 troops) from issue #2137 was intentionally removed because it was arbitrary and troop count can be reported as low despite having significant land. The confirmation now triggers for any alive player regardless of troop count.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-05-31T18:15:03.445Z
Learnt from: 1brucben
Repo: openfrontio/OpenFrontIO PR: 977
File: src/core/execution/AttackExecution.ts:123-125
Timestamp: 2025-05-31T18:15:03.445Z
Learning: The removeTroops function in PlayerImpl.ts already prevents negative troop counts by using minInt(this._troops, toInt(troops)) to ensure it never removes more troops than available.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
🧬 Code graph analysis (3)
src/client/UserSettingModal.ts (1)
src/client/LangSelector.ts (1)
translateText(254-274)
src/client/graphics/layers/RadialMenu.ts (2)
src/client/graphics/layers/RadialMenuElements.ts (1)
MenuElement(56-75)src/client/Utils.ts (1)
getSvgAspectRatio(249-300)
src/client/graphics/layers/RadialMenuElements.ts (2)
src/client/graphics/layers/RadialMenu.ts (1)
TooltipItem(18-21)src/core/game/UserSettings.ts (1)
quickDonateButtonsInFFA(202-204)
🪛 GitHub Actions: 🧪 CI
src/client/graphics/layers/RadialMenuElements.ts
[error] 697-697: TypeError: params.game.config(...).gameConfig is not a function
[error] 697-697: TypeError: params.game.config(...).gameConfig is not a function
[error] 697-697: TypeError: params.game.config(...).gameConfig is not a function
[error] 697-697: TypeError: params.game.config(...).gameConfig is not a function
[error] 697-697: TypeError: params.game.config(...).gameConfig is not a function
🔇 Additional comments (9)
src/core/game/UserSettings.ts (1)
202-211: LGTM!The implementation follows the established pattern for user settings. The default value of
falseis appropriate for an opt-in feature.src/client/UserSettingModal.ts (2)
209-214: LGTM!The toggle handler follows the established pattern with proper payload validation.
374-385: LGTM!The UI toggle is properly wired to the user setting and follows the consistent pattern used throughout the settings modal.
resources/lang/en.json (1)
339-340: LGTM!The translation keys are clear and descriptive, following the project's naming conventions.
src/client/graphics/layers/RadialMenu.ts (2)
656-725: LGTM!The split-button rendering logic correctly handles icon positioning, aspect ratios, and disabled states for each side independently.
1083-1134: LGTM!The dynamic center button icon and color support is well-implemented with proper fallback to defaults when no override is provided.
src/client/graphics/layers/RadialMenuElements.ts (3)
48-88: LGTM!The new interface definitions are clean and well-typed. The optional fields are appropriately marked, and the structure supports the split-button functionality effectively.
236-236: LGTM!Changing the Donate Gold button color to gold/yellow (
COLORS.tooltip.cost) instead of green (COLORS.ally) improves visual clarity and matches the action's purpose.
557-637: LGTM after fixing gameConfig access!The center button logic cleanly switches between Attack and Donate Troops based on context. The dynamic icon and color support is well-implemented. This will work correctly once the
gameConfig()method calls are changed to property access.
yeah that sounds good |
and if we can't donate but are still friendly then it should be a grayed out donate button. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/client/graphics/layers/RadialMenuElements.ts (2)
48-74: Unused interface - consider removing or implementing.The
SplitButtonActioninterface andsplitButtonfield are defined but never used in this file. The PR discussion mentioned split buttons as an option, but the implementation uses dynamic center button replacement instead.If split buttons aren't needed in this PR, consider removing these definitions to reduce unused code. If they're planned for future use, consider adding a comment explaining the intent.
662-719: Consider extracting donation eligibility checks.The logic correctly implements the FFA user setting and team game behavior per the PR objectives. However, the donation eligibility check
(params.myPlayer.isOnSameTeam(params.selected) || params.myPlayer.isAlliedWith(params.selected))is repeated at lines 692-693 and 712-713.Consider extracting this check into the helper:
+ const canDonateToSelected = () => { + if (!params.selected) return false; + return ( + params.myPlayer.isOnSameTeam(params.selected) || + params.myPlayer.isAlliedWith(params.selected) + ); + }; + const shouldShowDonateGold = isOwnTerritory && - params.selected && shouldShowQuickDonateButtons() && params.playerActions?.interaction?.canDonateGold && - (params.myPlayer.isOnSameTeam(params.selected) || - params.myPlayer.isAlliedWith(params.selected)); + canDonateToSelected();Then reuse
canDonateToSelected()at line 712 as well.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/client/graphics/layers/RadialMenu.ts(3 hunks)src/client/graphics/layers/RadialMenuElements.ts(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/client/graphics/layers/RadialMenu.ts
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
📚 Learning: 2025-06-16T03:03:59.778Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1192
File: src/client/graphics/layers/RadialMenuElements.ts:312-314
Timestamp: 2025-06-16T03:03:59.778Z
Learning: In RadialMenuElements.ts, when fixing undefined params errors in subMenu functions, use explicit checks like `if (params === undefined || params.selected === null)` rather than optional chaining, as it makes the intent clearer and matches the specific error scenarios where params can be undefined during spawn phase operations.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-08-12T00:31:50.144Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-06-09T02:20:43.637Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: In `ClientGameRunner.ts`, the `myPlayer` field is always set when `shouldPreventWindowClose()` is called, so the null check in that method is sufficient without needing to fetch it again from `gameView.playerByClientID()`.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: For the window close confirmation feature in `ClientGameRunner.ts`, the troop count requirement (>10,000 troops) from issue #2137 was intentionally removed because it was arbitrary and troop count can be reported as low despite having significant land. The confirmation now triggers for any alive player regardless of troop count.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-20T20:15:28.858Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:51-51
Timestamp: 2025-10-20T20:15:28.858Z
Learning: In src/core/execution/FakeHumanExecution.ts, game balance constants like MIRV_COOLDOWN_TICKS, MIRV_HESITATION_ODDS, VICTORY_DENIAL_TEAM_THRESHOLD, VICTORY_DENIAL_INDIVIDUAL_THRESHOLD, and STEAMROLL_CITY_GAP_MULTIPLIER are experimental tuning parameters subject to frequent change during balance testing. Do not flag changes to these values as issues or compare them against previous values.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-05-31T18:15:03.445Z
Learnt from: 1brucben
Repo: openfrontio/OpenFrontIO PR: 977
File: src/core/execution/AttackExecution.ts:123-125
Timestamp: 2025-05-31T18:15:03.445Z
Learning: The removeTroops function in PlayerImpl.ts already prevents negative troop counts by using minInt(this._troops, toInt(troops)) to ensure it never removes more troops than available.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
🧬 Code graph analysis (1)
src/client/graphics/layers/RadialMenuElements.ts (2)
src/client/graphics/layers/RadialMenu.ts (1)
TooltipItem(18-21)src/core/game/UserSettings.ts (1)
quickDonateButtonsInFFA(202-204)
🪛 GitHub Actions: 🧪 CI
src/client/graphics/layers/RadialMenuElements.ts
[error] 663-663: TypeError: params.game.config is not a function
[error] 667-667: TypeError: params.game.config(...).gameConfig is not a function
[error] 663-663: TypeError: params.game.config(...).gameConfig is not a function
[error] 663-663: TypeError: params.game.config(...).gameConfig is not a function
🔇 Additional comments (2)
src/client/graphics/layers/RadialMenuElements.ts (2)
558-643: Clean implementation of dynamic center button.The center button logic correctly switches between Attack and Donate Troops based on
canDonateTroops. The implementation is consistent acrossdisabled,action,icon, andcolorfunctions, with proper fallback to defaults.
236-236: Good color choice for gold donation.Changing the Donate Gold button to use gold/yellow color (
COLORS.tooltip.cost) instead of green makes it visually distinct from the Donate Troops button and thematically appropriate.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/client/graphics/layers/RadialMenuElements.ts (1)
336-360: Callparams.game.config()instead of passingparams.game.configat line 376.In the codebase,
configis accessed as a method (e.g.,this.mg.config(),this.game.config()). At line 376, the function call passes the method reference instead of invoking it. Change:params.game.config,to:
params.game.config(),
♻️ Duplicate comments (1)
src/client/graphics/layers/RadialMenuElements.ts (1)
667-667: Fix gameConfig property access - pipeline failure.Line 667 calls
params.game.config.gameConfig()butgameConfigis a property, not a method.Apply this fix:
- const gameMode = params.game.config.gameConfig().gameMode; + const gameMode = params.game.config.gameConfig.gameMode;
🧹 Nitpick comments (2)
src/client/graphics/layers/RadialMenuElements.ts (2)
640-643: Consider renaming for clarity.The helper name
shouldShowDonateTroopsimplies a UI visibility decision, but it only checks thecanDonateTroopspermission. Consider renaming tocanDonateTroopsorisDonateTroopsEnabledfor clarity.However, the logic correctly follows past feedback to rely solely on the
canDonateTroopsflag.
686-714: Consider extracting helper for donate gold visibility.The logic at lines 686-692 and 707-714 has overlapping conditions (checking quick donate, permissions, and team/ally status). Extract a shared helper to reduce duplication and clarify the difference:
shouldShowDonateGoldrequires own territory to replace Build, while the second check allows appending Donate Gold from any location.Example:
const canShowDonateGoldToTarget = () => { return ( params.selected && shouldShowQuickDonateButtons() && params.playerActions?.interaction?.canDonateGold && (params.myPlayer.isOnSameTeam(params.selected) || params.myPlayer.isAlliedWith(params.selected)) ); }; const shouldShowDonateGold = isOwnTerritory && canShowDonateGoldToTarget();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/client/graphics/layers/RadialMenuElements.ts(8 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
📚 Learning: 2025-06-16T03:03:59.778Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1192
File: src/client/graphics/layers/RadialMenuElements.ts:312-314
Timestamp: 2025-06-16T03:03:59.778Z
Learning: In RadialMenuElements.ts, when fixing undefined params errors in subMenu functions, use explicit checks like `if (params === undefined || params.selected === null)` rather than optional chaining, as it makes the intent clearer and matches the specific error scenarios where params can be undefined during spawn phase operations.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-08-12T00:31:50.144Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 1752
File: src/core/game/Game.ts:750-752
Timestamp: 2025-08-12T00:31:50.144Z
Learning: In the OpenFrontIO codebase, changes to the PlayerInteraction interface (like adding canDonateGold and canDonateTroops flags) do not require corresponding updates to src/core/Schemas.ts or server serialization code.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: In `ClientGameRunner.ts`, the `myPlayer` field is always set when `shouldPreventWindowClose()` is called, so the null check in that method is sufficient without needing to fetch it again from `gameView.playerByClientID()`.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-20T20:15:28.858Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:51-51
Timestamp: 2025-10-20T20:15:28.858Z
Learning: In src/core/execution/FakeHumanExecution.ts, game balance constants like MIRV_COOLDOWN_TICKS, MIRV_HESITATION_ODDS, VICTORY_DENIAL_TEAM_THRESHOLD, VICTORY_DENIAL_INDIVIDUAL_THRESHOLD, and STEAMROLL_CITY_GAP_MULTIPLIER are experimental tuning parameters subject to frequent change during balance testing. Do not flag changes to these values as issues or compare them against previous values.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-10-08T17:14:49.369Z
Learnt from: Foorack
Repo: openfrontio/OpenFrontIO PR: 2141
File: src/client/ClientGameRunner.ts:228-234
Timestamp: 2025-10-08T17:14:49.369Z
Learning: For the window close confirmation feature in `ClientGameRunner.ts`, the troop count requirement (>10,000 troops) from issue #2137 was intentionally removed because it was arbitrary and troop count can be reported as low despite having significant land. The confirmation now triggers for any alive player regardless of troop count.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
📚 Learning: 2025-05-31T18:15:03.445Z
Learnt from: 1brucben
Repo: openfrontio/OpenFrontIO PR: 977
File: src/core/execution/AttackExecution.ts:123-125
Timestamp: 2025-05-31T18:15:03.445Z
Learning: The removeTroops function in PlayerImpl.ts already prevents negative troop counts by using minInt(this._troops, toInt(troops)) to ensure it never removes more troops than available.
Applied to files:
src/client/graphics/layers/RadialMenuElements.ts
🧬 Code graph analysis (1)
src/client/graphics/layers/RadialMenuElements.ts (2)
src/client/graphics/layers/RadialMenu.ts (1)
TooltipItem(18-21)src/core/game/UserSettings.ts (1)
quickDonateButtonsInFFA(202-204)
🪛 GitHub Actions: 🧪 CI
src/client/graphics/layers/RadialMenuElements.ts
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 340-340: TypeError: config.isUnitDisabled is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
[error] 667-667: TypeError: params.game.config.gameConfig is not a function
🔇 Additional comments (3)
src/client/graphics/layers/RadialMenuElements.ts (3)
48-87: LGTM - interface additions support dynamic donate UI.The new
SplitButtonActioninterface and extensions toMenuElementandCenterButtonElementare well-typed and align with the PR objectives to add flexible donate button options.
558-637: LGTM - center button logic correctly implements donate troops.The center button now dynamically switches between spawn/attack/donate-troops based on context. The logic flow is clean with early returns, and the icon/color functions properly reflect the action state.
676-678: userSettings() API is correct.Verification confirms
userSettings()is a method on Config that returnsUserSettings. The call at line 677 is correct and consistent with usage throughout the codebase.
|
looks like the build is failing |
|
Closed during PR review |
If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #(issue number)
Description:
adds quick buttons to donate gold and troops to help encourge it in team gamemodes
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
DISCORD_USERNAME
notifxy (1379678982676676639)