Skip to content

feat: added '2 step confirm' for allience breakage#3150

Open
RjManhas wants to merge 6 commits intoopenfrontio:mainfrom
RjManhas:confirm-betrayal
Open

feat: added '2 step confirm' for allience breakage#3150
RjManhas wants to merge 6 commits intoopenfrontio:mainfrom
RjManhas:confirm-betrayal

Conversation

@RjManhas
Copy link
Contributor

@RjManhas RjManhas commented Feb 7, 2026

Resolves:

https://discord.com/channels/1284581928254701718/1466749482170454192
https://discord.com/channels/1284581928254701718/1384910711788146779 (some what, they want a more general confirm system)
https://discord.com/channels/1284581928254701718/1384543980414570607
https://discord.com/channels/1284581928254701718/1341874291452411915

Description:

A toggle able setting which is disabled by default, which will when enabled show a modal popup to confirm that you want to attack someone that who you are allied with.

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:

notifxy (1379678982676676639 )

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

Walkthrough

Adds a confirm-break-alliance flow: new modal component, localization keys, user setting and UI toggle, two transport events and Transport constructor change to accept userSettings, renderer wiring for the modal, and execution guard when no alliance exists. (≤50 words)

Changes

Cohort / File(s) Summary
HTML / Localization
index.html, resources/lang/en.json
Added confirm-break-alliance-modal tag to DOM and new localization entries for the confirmation dialog and the setting label/description.
User Settings UI & Model
src/core/game/UserSettings.ts, src/client/UserSettingModal.ts
Added confirmBreakAlliance() and toggleConfirmBreakAlliance() in model; added a settings toggle control and handler bound to settings.confirmBreakAlliance.
Transport & Runner
src/client/Transport.ts, src/client/ClientGameRunner.ts
Transport constructor now accepts userSettings; added RequestConfirmBreakAllianceEvent and ConfirmedBreakAllianceIntentEvent; Transport emits request event when setting enabled and sends break intent on confirmation.
Modal Component
src/client/graphics/layers/ConfirmBreakAllianceModal.ts
New exported LitElement ConfirmBreakAllianceModal: subscribes to request events, shows dialog with requestor/recipient, validates game state and alliance on confirm, emits confirmed event, manages lifecycle and focus/keyboard behavior.
Renderer Integration
src/client/graphics/GameRenderer.ts
Imported and initialized ConfirmBreakAllianceModal from DOM, type-checked element, wired eventBus and game.
Execution Logic
src/core/execution/alliance/BreakAllianceExecution.ts
tick now disables the action and returns early when no alliance exists instead of logging and continuing.

Sequence Diagram

sequenceDiagram
    participant User
    participant Transport
    participant EventBus
    participant Modal as ConfirmBreakAllianceModal
    participant Game
    participant Execution

    User->>Transport: SendBreakAllianceIntentEvent
    Transport->>Transport: check userSettings.confirmBreakAlliance()
    alt setting enabled
        Transport->>EventBus: emit RequestConfirmBreakAllianceEvent
        EventBus->>Modal: deliver RequestConfirmBreakAllianceEvent
        Modal->>User: display confirmation dialog
        User->>Modal: click Confirm
        Modal->>Modal: validate game state & alliance
        Modal->>EventBus: emit ConfirmedBreakAllianceIntentEvent
        EventBus->>Transport: deliver ConfirmedBreakAllianceIntentEvent
        Transport->>Game: send break alliance intent
    else setting disabled
        Transport->>Game: send break alliance intent
    end
    Game->>Execution: execute break alliance
    Execution->>Execution: check alliance exists
    alt alliance found
        Execution->>Game: break alliance, update relations
    else no alliance
        Execution->>Execution: disable action, return early
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

⚔️ A modal asks before the blow,
A quiet pause where choices grow,
Confirm, cancel, thought kept whole,
Settings guide the careful soul,
Alliances end with gentle flow.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a two-step confirmation feature for breaking alliances, which is the primary objective of this pull request.
Description check ✅ Passed The description is clearly related to the changeset, explaining the toggleable setting for confirming alliance breakage, providing context with Discord issue links, and documenting the UI changes with screenshots.

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


No actionable comments were generated in the recent review. 🎉


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: 1

🤖 Fix all issues with AI agents
In `@src/client/graphics/layers/ConfirmBreakAllianceModal.ts`:
- Around line 48-59: The updated method currently only subscribes when eventBus
becomes available but never unsubscribes the previous bus if eventBus is
replaced; modify updated to detect when changed.has("eventBus") and, if
this._subscribed is true and this.eventBus !== previousEventBus, call the old
bus's unsubscribe method (e.g., eventBus.off or removeListener) for
RequestConfirmBreakAllianceEvent with this.requestConfirmHandler before
assigning the new bus, then subscribe the new bus and ensure this._subscribed
reflects the current subscription; update logic in the updated method and use
the unique symbols updated, eventBus, _subscribed, and requestConfirmHandler to
locate and apply the change.
🧹 Nitpick comments (3)
src/client/UserSettingModal.ts (1)

822-830: Missing id attribute on the setting toggle.

Other setting-toggle elements in this file have an id (e.g., "alert-frame-toggle", "emoji-toggle"). This one is missing it. Add one for consistency and potential future DOM queries.

Suggested fix
       <setting-toggle
         label="${translateText("user_setting.confirm_break_alliance_label")}"
         description="${translateText(
           "user_setting.confirm_break_alliance_desc",
         )}"
+        id="confirm-break-alliance-toggle"
         .checked=${this.userSettings.confirmBreakAlliance()}
         `@change`=${this.toggleConfirmBreakAlliance}
       ></setting-toggle>
src/client/graphics/layers/ConfirmBreakAllianceModal.ts (2)

33-35: Empty connectedCallback can be removed.

This override does nothing beyond calling super.connectedCallback(). LitElement already calls it. Safe to delete these three lines.

Proposed cleanup
-  connectedCallback() {
-    super.connectedCallback();
-  }
-

20-25: requestUpdate() calls are redundant when mutating @state properties.

In LitElement, setting a @state() decorated property automatically schedules an update. The explicit this.requestUpdate() on Lines 24 and 71 is unnecessary.

Proposed cleanup
   private requestConfirmHandler = (e: RequestConfirmBreakAllianceEvent) => {
     this.requestor = e.requestor;
     this.recipient = e.recipient;
     this.open = true;
-    this.requestUpdate();
   };
   private closeModal() {
     this.open = false;
     this.recipient = null;
     this.requestor = null;
-    this.requestUpdate();
   }

Also applies to: 67-72

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Feb 7, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 7, 2026
@RjManhas
Copy link
Contributor Author

RjManhas commented Feb 8, 2026

@evanpelle when you are free, please review this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

1 participant