Skip to content

Delete unit: 5s > 15s cooldown and new location in Radial Menu - #2345

Merged
evanpelle merged 4 commits into
mainfrom
delete-cooldown-button
Nov 1, 2025
Merged

evanpelle merged 4 commits into
mainfrom
delete-cooldown-button

Conversation

@VariableVince

@VariableVince VariableVince commented Oct 31, 2025 •

Copy link
Copy Markdown
Contributor

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 disabled new location radial menu

Delete button new location enabled:
Delete button enabled new location radial menu

Radial menu unchanged on others' tiles:
Radial menu unchanged on other territory

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:

tryout33

@VariableVince
VariableVince requested a review from a team as a code owner October 31, 2025 21:13
@CLAassistant

CLAassistant commented Oct 31, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Oct 31, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Consolidates 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

Cohort / File(s) Change Summary
Radial menu refactor
src/client/graphics/layers/RadialMenuElements.ts
Replaced separate if/else pushes with a ternary-driven spread that selects root menu items: owned => [deleteUnitElement, ally, buildMenuElement]; not-owned => [boatMenuElement, ally, attackMenuElement].
Cooldown adjustment
src/core/configuration/DefaultConfig.ts
Increased deleteUnitCooldown() from 5 * 10 to 15 * 10 ticks (50 → 150 ticks).
Test timing update
tests/DeleteUnitExecution.test.ts
Advance game by deleteUnitCooldown() + 1 ticks after spawn so subsequent steps run after the longer cooldown.
Radial menu tests updated
tests/client/graphics/RadialMenuElements.test.ts
Updated expectations to match new root submenu composition: own-territory now includes Delete and Build; enemy-territory includes Boat and Attack; removed Boat from info submenu expectations.

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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to inspect:
    • RadialMenuElements.ts: ensure menu ordering and presence of items for both branches, and verify no inadvertent duplicates.
    • DefaultConfig.ts: confirm cooldown increase is intentional and consistent with gameplay rules.
    • tests/*: verify timing adjustments and updated expectations align with new behavior.

Possibly related PRs

Suggested labels

Feature - Frontend, Feature - Backend, UI/UX

Suggested reviewers

  • evanpelle
  • scottanderson

Poem

🌿 Menus swap places, tidy and neat,
Delete for home, boats for the fleet,
Cooldowns lengthen, tests wait their turn,
Small changes hum so systems learn,
Code and tests align — a quiet feat.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Delete unit: 5s > 15s cooldown and new location in Radial Menu" directly and clearly summarizes the two main changes in the changeset: the cooldown increase (5s to 15s as reflected in DefaultConfig.ts changing 510 to 1510 ticks) and the Delete button repositioning in the radial menu (as shown in RadialMenuElements.ts). The title is concise, specific, and uses clear language that would help a teammate quickly understand the primary changes when scanning history.
Description Check ✅ Passed The PR description is comprehensive and directly related to the changeset. It explains both key changes (button repositioning with rationale about mutual exclusivity, and cooldown increase with detailed reasoning referencing PR #2216 and community feedback), includes supporting Discord links showing reviewer agreement, provides video and screenshots demonstrating the changes, confirms completion of required tasks (UI text localization, test additions, thorough testing), and supplies a Discord contact username. The description goes well beyond a basic requirement and substantively documents the decisions behind the changes.

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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 31, 2025
evanpelle
evanpelle previously approved these changes Oct 31, 2025

@evanpelle evanpelle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks, this is a much better place for it!

@evanpelle

Copy link
Copy Markdown
Collaborator

looks like a test is failing

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between fc27e3d and 7ddcec2.

📒 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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 1, 2025
@VariableVince

Copy link
Copy Markdown
Contributor Author

Yep first some DeleteExecution tests failed, fixed those.

Only then the CI test failed for some RadialMenuElements tests. Fixed those too now.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ddcec2 and 440827d.

📒 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.

@jrouillard
jrouillard enabled auto-merge November 1, 2025 16:01
@evanpelle evanpelle added this to the v27 milestone Nov 1, 2025
@evanpelle
evanpelle disabled auto-merge November 1, 2025 17:48
@evanpelle
evanpelle merged commit 64e8733 into main Nov 1, 2025
1 of 2 checks passed
@evanpelle
evanpelle deleted the delete-cooldown-button branch November 1, 2025 17:48
Lavodan pushed a commit to Lavodan/OpenFrontIO_changes that referenced this pull request Nov 1, 2025
…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>

This branch was previously deployed

1 inactive deployment
staging — daa05520 Deployed Nov 1, 2025 by openfrontio[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants