From 042820d56cd3bac07a7390a4f4a7db97dab5f57c Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 10 Jun 2026 15:40:07 -0700 Subject: [PATCH] Fix alliance request event display edge cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suppress the "Alliance request sent" event when the action actually accepts an existing incoming request rather than sending a new one. This happens both when clicking "Accept" on a request card and when sending a request to a player who already requested one from us — in both cases EventsDisplay now checks whether the recipient is already requesting an alliance with us and skips the confirmation. Also clear stale incoming alliance request cards in ActionableEvents once the request is resolved: handle AllianceRequestReply to remove the card when accepted/rejected, and drop ALLIANCE_REQUEST cards in tick() whose requestor is no longer requesting an alliance with us. --- src/client/hud/layers/ActionableEvents.ts | 26 +++++++++++++++++++++++ src/client/hud/layers/EventsDisplay.ts | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/src/client/hud/layers/ActionableEvents.ts b/src/client/hud/layers/ActionableEvents.ts index 386338593..b1eab8d16 100644 --- a/src/client/hud/layers/ActionableEvents.ts +++ b/src/client/hud/layers/ActionableEvents.ts @@ -4,6 +4,7 @@ import { EventBus } from "../../../core/EventBus"; import { MessageType, Tick } from "../../../core/game/Game"; import { AllianceExtensionUpdate, + AllianceRequestReplyUpdate, AllianceRequestUpdate, BrokeAllianceUpdate, GameUpdateType, @@ -51,6 +52,10 @@ export class ActionableEvents extends LitElement implements Controller { private updateMap = [ [GameUpdateType.AllianceRequest, this.onAllianceRequestEvent.bind(this)], + [ + GameUpdateType.AllianceRequestReply, + this.onAllianceRequestReplyEvent.bind(this), + ], [GameUpdateType.BrokeAlliance, this.onBrokeAllianceEvent.bind(this)], [ GameUpdateType.AllianceExtension, @@ -248,6 +253,27 @@ export class ActionableEvents extends LitElement implements Controller { }); } + private onAllianceRequestReplyEvent(update: AllianceRequestReplyUpdate) { + const myPlayer = this.game.myPlayer(); + if (!myPlayer || update.request.recipientID !== myPlayer.smallID()) { + return; + } + // The incoming alliance request was resolved (accepted or rejected), so + // remove any pending request card from that player. + const requestorID = update.request.requestorID; + const remaining = this.events.filter( + (event) => + !( + event.type === MessageType.ALLIANCE_REQUEST && + event.focusID === requestorID + ), + ); + if (remaining.length !== this.events.length) { + this.events = remaining; + this.requestUpdate(); + } + } + onBrokeAllianceEvent(update: BrokeAllianceUpdate) { // Cleanup-only: any open renewal prompt for this alliance is now moot. this.removeAllianceRenewalEvents(update.allianceID); diff --git a/src/client/hud/layers/EventsDisplay.ts b/src/client/hud/layers/EventsDisplay.ts index caadf642a..1e4d8dacd 100644 --- a/src/client/hud/layers/EventsDisplay.ts +++ b/src/client/hud/layers/EventsDisplay.ts @@ -145,6 +145,12 @@ export class EventsDisplay extends LitElement implements Controller { if (!myPlayer || e.requestor.id() !== myPlayer.id()) { return; } + // If the recipient already has a pending alliance request to us, this + // action accepts that request instead of sending a new one, so don't + // show the "alliance request sent" confirmation. + if (e.recipient.isRequestingAllianceWith(e.requestor)) { + return; + } this.addEvent({ description: translateText("events_display.alliance_request_sent", { name: e.recipient.name(),