From e661c8b7736b843b416120e3b80faba0a36d2700 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Mon, 7 Jul 2025 09:28:59 -0700 Subject: [PATCH] alliance renewal: fix request to renew when ally is dead, fix translation keys (#1359) ## Description: The EventsDisplay now checks if your ally is alive before sending a "request to renew" event. Also fixed so incorrect translation keys. ## 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 - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/client/graphics/layers/EventsDisplay.ts | 3 ++- .../execution/alliance/AllianceExtensionExecution.ts | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client/graphics/layers/EventsDisplay.ts b/src/client/graphics/layers/EventsDisplay.ts index d2e857a86..4d5fefa5f 100644 --- a/src/client/graphics/layers/EventsDisplay.ts +++ b/src/client/graphics/layers/EventsDisplay.ts @@ -241,7 +241,7 @@ export class EventsDisplay extends LitElement implements Layer { private checkForAllianceExpirations() { const myPlayer = this.game.myPlayer(); - if (!myPlayer) return; + if (!myPlayer?.isAlive()) return; for (const alliance of myPlayer.alliances()) { if ( @@ -262,6 +262,7 @@ export class EventsDisplay extends LitElement implements Layer { this.alliancesCheckedAt.set(alliance.id, this.game.ticks()); const other = this.game.player(alliance.other) as PlayerView; + if (!other.isAlive()) continue; this.addEvent({ description: translateText("events_display.about_to_expire", { diff --git a/src/core/execution/alliance/AllianceExtensionExecution.ts b/src/core/execution/alliance/AllianceExtensionExecution.ts index e43693f89..e0cb14d4d 100644 --- a/src/core/execution/alliance/AllianceExtensionExecution.ts +++ b/src/core/execution/alliance/AllianceExtensionExecution.ts @@ -20,6 +20,14 @@ export class AllianceExtensionExecution implements Execution { return; } const to = mg.player(this.toID); + + if (!this.from.isAlive() || !to.isAlive()) { + console.info( + `[AllianceExtensionExecution] Player ${this.from.id()} or ${this.toID} is not alive`, + ); + return; + } + const alliance = this.from.allianceWith(to); if (!alliance) { console.warn( @@ -35,12 +43,12 @@ export class AllianceExtensionExecution implements Execution { alliance.extend(); mg.displayMessage( - "alliance.renewed", + "events_display.alliance_renewed", MessageType.ALLIANCE_ACCEPTED, this.from.id(), ); mg.displayMessage( - "alliance.renewed", + "events_display.alliance_renewed", MessageType.ALLIANCE_ACCEPTED, this.toID, );