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
This commit is contained in:
evanpelle
2025-07-07 09:28:59 -07:00
committed by GitHub
parent 58996bf1b3
commit e661c8b773
2 changed files with 12 additions and 3 deletions
+2 -1
View File
@@ -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", {
@@ -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,
);