From 773c9566fc049d3ef7a5bfa027a14a909467acfe Mon Sep 17 00:00:00 2001 From: tnhnblgl <51187395+tnhnblgl@users.noreply.github.com> Date: Sat, 24 May 2025 00:14:57 +0300 Subject: [PATCH] Display betrayal count (Continue #744) (#849) ## Description: . #744 became a mess. Rewrote it ![Screenshot](https://github.com/user-attachments/assets/0e43547f-514a-4e93-9bbc-d022d8dfb75c) ## Please complete the following: - [x] I have added screenshots for all UI updates - [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: dovg --- resources/lang/en.json | 1 + src/client/graphics/layers/PlayerPanel.ts | 10 ++++++++++ src/core/game/GameUpdates.ts | 1 + src/core/game/PlayerImpl.ts | 2 ++ 4 files changed, 14 insertions(+) diff --git a/resources/lang/en.json b/resources/lang/en.json index 390baf730..4add1cf6f 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -402,6 +402,7 @@ "player_panel": { "gold": "Gold", "troops": "Troops", + "betrayals": "Number of betrayals", "traitor": "Traitor", "alliance_time_remaining": "Time Remaining", "embargo": "Stopped trading with you", diff --git a/src/client/graphics/layers/PlayerPanel.ts b/src/client/graphics/layers/PlayerPanel.ts index d9afeab4a..4e82be5bb 100644 --- a/src/client/graphics/layers/PlayerPanel.ts +++ b/src/client/graphics/layers/PlayerPanel.ts @@ -308,6 +308,16 @@ export class PlayerPanel extends LitElement implements Layer { + +
+
+ ${translateText("player_panel.betrayals")} +
+
+ ${other.data.betrayals ?? 0} +
+
+
diff --git a/src/core/game/GameUpdates.ts b/src/core/game/GameUpdates.ts index 839ca330c..1ccc20013 100644 --- a/src/core/game/GameUpdates.ts +++ b/src/core/game/GameUpdates.ts @@ -118,6 +118,7 @@ export interface PlayerUpdate { incomingAttacks: AttackUpdate[]; outgoingAllianceRequests: PlayerID[]; hasSpawned: boolean; + betrayals?: number; } export interface AllianceRequestUpdate { diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index d56f0f205..7295b4e80 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -123,6 +123,7 @@ export class PlayerImpl implements Player { const outgoingAllianceRequests = this.outgoingAllianceRequests().map((ar) => ar.recipient().id(), ); + const stats = this.mg.stats().getPlayerStats(this); return { type: GameUpdateType.Player, @@ -169,6 +170,7 @@ export class PlayerImpl implements Player { ), outgoingAllianceRequests: outgoingAllianceRequests, hasSpawned: this.hasSpawned(), + betrayals: stats?.betrayals, }; }