From f214ae460d90b1071ee6ae661d68020216c98fd8 Mon Sep 17 00:00:00 2001 From: Samuel Safahi <60489622+samisbakedham@users.noreply.github.com> Date: Mon, 28 Apr 2025 00:01:23 -0700 Subject: [PATCH] add dynamic traitor debuff duration and improve betrayal message formatting Updated the betrayal event message to dynamically show the current traitor defense debuff and duration based on this.game.config().traitorDuration. Implemented singular/plural grammar handling (e.g., "1 second" vs. "30 seconds"). Preserved and improved the original betrayal message ("You broke your alliance with ${betrayed.name()}, making you a TRAITOR") by appending debuff information. Fixed syntax issues and removed redundant/invalid code from onBrokeAllianceEvent. Ensured future updates to traitor debuff duration are automatically reflected without manual message edits. --- src/client/graphics/layers/EventsDisplay.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/client/graphics/layers/EventsDisplay.ts b/src/client/graphics/layers/EventsDisplay.ts index 55a37e677..ede2f7422 100644 --- a/src/client/graphics/layers/EventsDisplay.ts +++ b/src/client/graphics/layers/EventsDisplay.ts @@ -263,23 +263,31 @@ export class EventsDisplay extends LitElement implements Layer { onBrokeAllianceEvent(update: BrokeAllianceUpdate) { const myPlayer = this.game.playerByClientID(this.clientID); if (!myPlayer) return; - + const betrayed = this.game.playerBySmallID(update.betrayedID) as PlayerView; const traitor = this.game.playerBySmallID(update.traitorID) as PlayerView; - + if (!betrayed.isTraitor() && traitor === myPlayer) { const malusPercent = Math.round( (1 - this.game.config().traitorDefenseDebuff()) * 100, ); + const traitorDurationRaw = this.game.config().traitorDuration / 10; + const traitorDurationSeconds = Math.floor(traitorDurationRaw); + + const durationText = traitorDurationSeconds === 1 + ? '1 second' + : `${traitorDurationSeconds} seconds`; + this.addEvent({ - description: + description: `You broke your alliance with ${betrayed.name()}, making you a TRAITOR ` + - `(${malusPercent}% defense debuff for 30 seconds)`, + `(${malusPercent}% defense debuff for ${durationText})`, type: MessageType.ERROR, highlight: true, createdAt: this.game.ticks(), focusID: update.betrayedID, }); + } else if (betrayed === myPlayer) { this.addEvent({ description: `${traitor.name()} broke their alliance with you`, @@ -290,6 +298,9 @@ export class EventsDisplay extends LitElement implements Layer { }); } } + + + onAllianceExpiredEvent(update: AllianceExpiredUpdate) { const myPlayer = this.game.playerByClientID(this.clientID);