Fix alliance request event display edge cases

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.
This commit is contained in:
evanpelle
2026-06-10 15:40:07 -07:00
parent 90efb84168
commit 042820d56c
2 changed files with 32 additions and 0 deletions
+26
View File
@@ -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);
+6
View File
@@ -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(),