From 16ac6a3fe7aa94a984ea7da99202858dfe1afc4c Mon Sep 17 00:00:00 2001 From: Rj Manhas Date: Tue, 11 Nov 2025 11:15:30 -0700 Subject: [PATCH] fixed: coderabit suggestions --- src/client/graphics/layers/EventsDisplay.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/graphics/layers/EventsDisplay.ts b/src/client/graphics/layers/EventsDisplay.ts index 4f4b38c25..ad9dd8576 100644 --- a/src/client/graphics/layers/EventsDisplay.ts +++ b/src/client/graphics/layers/EventsDisplay.ts @@ -163,20 +163,26 @@ export class EventsDisplay extends LitElement implements Layer { .units(UnitType.TransportShip) .filter((u) => u.owner().smallID() === attackerID && u.isActive()); + let fallbackBoat: UnitView | null = null; + for (const boat of boats) { const targetTile = boat.targetTile(); if (!targetTile) continue; const targetOwnerSmallID = this.game.ownerID(targetTile); if (targetOwnerSmallID === target.smallID()) { - // Prefer exact troop match, but accept any boat heading to target if no match + // Track first boat heading to target as fallback + fallbackBoat ??= boat; + + // Prefer exact troop match, return immediately if found if (troops === 0 || Math.abs(boat.troops() - troops) < 10) { return boat; } } } - return null; + // Return fallback boat if no preferred match found + return fallbackBoat; } private renderToggleButton(src: string, category: MessageCategory) { @@ -773,9 +779,7 @@ export class EventsDisplay extends LitElement implements Layer { // Format the message for NAVAL_INVASION_INBOUND to display formatted troop count let description = event.message; if (event.messageType === MessageType.NAVAL_INVASION_INBOUND && unitView) { - const actualTroops = Math.round(Math.round(unitView.troops()) / 10); - const cleanTroopsValue = actualTroops * 10; - const formattedTroops = renderTroops(cleanTroopsValue); + const formattedTroops = this.renderTroopsWholeNumber(unitView.troops()); description = event.message.replace( /Boat: \d+/, `Boat: ${formattedTroops}`,