Repository navigation
Delete unit: 5s > 15s cooldown and new location in Radial Menu - #2345
Conversation
WalkthroughConsolidates radial menu composition into a single conditional spread that picks one of two root item arrays based on territory ownership; increases delete-unit cooldown from 50 to 150 ticks; updates tests to advance time past the new cooldown and to expect the new menu items. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Player as Player State
participant Logic as RadialMenuElements
participant UI as RadialMenu UI
Note over Player,Logic: User opens radial menu over a territory
Player->>Logic: supply isOwnTerritory
alt isOwnTerritory == true
rect rgb(220,240,255)
Logic->>UI: render [deleteUnit, ally, buildMenu]
end
else isOwnTerritory == false
rect rgb(255,240,220)
Logic->>UI: render [boatMenu, ally, attackMenu]
end
end
UI->>Player: user selects action (delete/build/attack/boat/ally)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
evanpelle
left a comment
There was a problem hiding this comment.
thanks, this is a much better place for it!
7ddcec2
|
looks like a test is failing |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/DeleteUnitExecution.test.ts (1)
56-57: LGTM! Cooldown timing correctly handled.The test now waits for the delete unit cooldown to elapse after spawn phase completion, which aligns with the increased cooldown from 50 to 150 ticks. The +1 ensures we're past the threshold.
Optional: Consider adding a clarifying comment.
A brief comment explaining why we wait here would help future readers understand this timing requirement:
+ // Wait for delete unit cooldown to elapse before building test units executeTicks(game, game.config().deleteUnitCooldown() + 1);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/DeleteUnitExecution.test.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
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.
📚 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:
tests/DeleteUnitExecution.test.ts
📚 Learning: 2025-10-18T17:54:01.311Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:172-173
Timestamp: 2025-10-18T17:54:01.311Z
Learning: In src/core/execution/FakeHumanExecution.ts, MIRVs and ground attacks should not be mutually exclusive. The considerMIRV() method should not short-circuit maybeAttack() - both actions can occur in the same tick.
Applied to files:
tests/DeleteUnitExecution.test.ts
📚 Learning: 2025-08-29T16:16:11.309Z
Learnt from: BrewedCoffee
Repo: openfrontio/OpenFrontIO PR: 1957
File: src/core/execution/PlayerExecution.ts:40-52
Timestamp: 2025-08-29T16:16:11.309Z
Learning: In OpenFrontIO PlayerExecution.ts, when Defense Posts are captured due to tile ownership changes, the intended behavior is to first call u.decreaseLevel() to downgrade them, then still transfer them to the capturing player via captureUnit(). This is not a bug - Defense Posts should be both downgraded and captured, not destroyed outright.
Applied to files:
tests/DeleteUnitExecution.test.ts
📚 Learning: 2025-10-20T11:02:16.969Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:57-57
Timestamp: 2025-10-20T11:02:16.969Z
Learning: In src/core/execution/FakeHumanExecution.ts, the correct MIRV victory denial thresholds are VICTORY_DENIAL_TEAM_THRESHOLD = 0.8 (80% for team games) and VICTORY_DENIAL_INDIVIDUAL_THRESHOLD = 0.65 (65% for individual players), not 0.85 and 0.7 as might be mentioned in some documentation.
Applied to files:
tests/DeleteUnitExecution.test.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:
tests/DeleteUnitExecution.test.ts
🧬 Code graph analysis (1)
tests/DeleteUnitExecution.test.ts (1)
tests/util/utils.ts (1)
executeTicks(32-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Deploy to openfront.dev
|
Yep first some DeleteExecution tests failed, fixed those. Only then the CI test failed for some RadialMenuElements tests. Fixed those too now. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/client/graphics/RadialMenuElements.test.ts (1)
330-335: Optional: Consider testing both cases explicitly.The test name says "in both cases" but only checks the own territory scenario. To match the name, you could add an enemy territory check:
it("should include info menu in both cases", () => { + // Own territory const subMenu = rootMenuElement.subMenu!(mockParams); const infoMenu = subMenu.find((item) => item.id === Slot.Info); expect(infoMenu).toBeDefined(); + + // Enemy territory + const enemyPlayer = { + id: () => 2, + isPlayer: jest.fn(() => true), + } as unknown as PlayerView; + mockGame.owner = jest.fn(() => enemyPlayer); + + const enemySubMenu = rootMenuElement.subMenu!(mockParams); + const enemyInfoMenu = enemySubMenu.find((item) => item.id === Slot.Info); + + expect(enemyInfoMenu).toBeDefined(); });Not critical since the previous tests already cover both scenarios implicitly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/client/graphics/RadialMenuElements.test.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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.
📚 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:
tests/client/graphics/RadialMenuElements.test.ts
🧬 Code graph analysis (1)
tests/client/graphics/RadialMenuElements.test.ts (1)
src/client/graphics/layers/RadialMenuElements.ts (1)
rootMenuElement(567-593)
🔇 Additional comments (2)
tests/client/graphics/RadialMenuElements.test.ts (2)
302-311: LGTM! Test correctly verifies Delete menu on own territory.The test properly checks that the Delete menu appears on own territory alongside Build, while Attack remains absent. This aligns with the PR objective to position the Delete button where Boat was, making them mutually exclusive based on territory ownership.
313-328: LGTM! Test correctly verifies Boat menu on enemy territory.The test properly checks that the Boat menu appears on enemy territory alongside Attack, while Build remains absent. This confirms the mutual exclusivity between Boat (enemy territory) and Delete (own territory) mentioned in the PR description.
…rontio#2345) ## Description: - Move the Delete button to where the Boat button is otherwise. The Boat and Delete button already mutually exclude eachother anyway; boat button is only visible on other's tiles, delete button is only visible on your own tiles. Evan agreed to this new position: https://discord.com/channels/1359946986937258015/1381293863712591872/1429147325049077860 - Increase the cooldown between deletions from 5 to 15 seconds. PR openfrontio#2216 introduced a destruction time (deletionMarkDuration) making it take 15s to delete a building. With the cooldown of 15s between clicking the Delete button (deleteUnitCooldown) on top of that, you can actually only delete a building every 15 seconds while it also takes that same time to destruct it. Players have voiced between 10s to 30s or more so 15s is still a reasonable time, keeping deletion of mistakenly placed buildings still possible, while also keeping a small 'scorched earth' option during an attack but probably only being able to delete 1-2 units in an attack. Evan and Vivacious Box agreed with the mentioned 10-15s cooldown too: https://discord.com/channels/1359946986937258015/1381293863712591872/1429103999088459897 **Video: Delete button new location and 15s cooldown:** https://github.com/user-attachments/assets/b0b13fc1-1e50-4a7a-8f32-55f7891f9945 **Delete button new location disabled:** <img width="310" height="316" alt="Delete button disabled new location radial menu" src="https://github.com/user-attachments/assets/f65b88ad-5859-4982-be53-8f2f693f5767" /> **Delete button new location enabled:** <img width="332" height="305" alt="Delete button enabled new location radial menu" src="https://github.com/user-attachments/assets/037f07c5-622a-4857-9ab8-fc20981de816" /> **Radial menu unchanged on others' tiles:** <img width="346" height="307" alt="Radial menu unchanged on other territory" src="https://github.com/user-attachments/assets/085b2043-096f-4c44-8917-467adb8a7213" /> ## 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 - [x] 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: tryout33 --------- Co-authored-by: Vivacious Box <jon@rouillard.org>
Description:
Move the Delete button to where the Boat button is otherwise. The Boat and Delete button already mutually exclude eachother anyway; boat button is only visible on other's tiles, delete button is only visible on your own tiles. Evan agreed to this new position: https://discord.com/channels/1359946986937258015/1381293863712591872/1429147325049077860
Increase the cooldown between deletions from 5 to 15 seconds. PR Add deletion duration and indicators #2216 introduced a destruction time (deletionMarkDuration) making it take 15s to delete a building. With the cooldown of 15s between clicking the Delete button (deleteUnitCooldown) on top of that, you can actually only delete a building every 15 seconds while it also takes that same time to destruct it. Players have voiced between 10s to 30s or more so 15s is still a reasonable time, keeping deletion of mistakenly placed buildings still possible, while also keeping a small 'scorched earth' option during an attack but probably only being able to delete 1-2 units in an attack. Evan and Vivacious Box agreed with the mentioned 10-15s cooldown too: https://discord.com/channels/1359946986937258015/1381293863712591872/1429103999088459897
Video: Delete button new location and 15s cooldown:
https://github.com/user-attachments/assets/b0b13fc1-1e50-4a7a-8f32-55f7891f9945
Delete button new location disabled:

Delete button new location enabled:

Radial menu unchanged on others' tiles:

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