From 772b72dfef48ad663e18412d6c007124f0733df8 Mon Sep 17 00:00:00 2001 From: PilkeySEK <156579268+PilkeySEK@users.noreply.github.com> Date: Wed, 21 May 2025 10:15:28 +0200 Subject: [PATCH] Donate the attackratio instead of 1/3 (#534) ## Description: The changes introduce a new public uiState property to the PlayerPanel class and ensure it is assigned from the shared UI state in the createRenderer function. The troop donation logic in PlayerPanel is updated to use the attackRatio from uiState to determine the number of troops to donate, replacing the previous static or null value. ## 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: PilkeySEK --- src/client/graphics/GameRenderer.ts | 1 + src/client/graphics/layers/PlayerPanel.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/client/graphics/GameRenderer.ts b/src/client/graphics/GameRenderer.ts index 9cc5b8282..9b2240732 100644 --- a/src/client/graphics/GameRenderer.ts +++ b/src/client/graphics/GameRenderer.ts @@ -145,6 +145,7 @@ export function createRenderer( playerPanel.g = game; playerPanel.eventBus = eventBus; playerPanel.emojiTable = emojiTable; + playerPanel.uiState = uiState; const chatModal = document.querySelector("chat-modal") as ChatModal; if (!(chatModal instanceof ChatModal)) { diff --git a/src/client/graphics/layers/PlayerPanel.ts b/src/client/graphics/layers/PlayerPanel.ts index a8b773b15..d9afeab4a 100644 --- a/src/client/graphics/layers/PlayerPanel.ts +++ b/src/client/graphics/layers/PlayerPanel.ts @@ -24,6 +24,7 @@ import { SendTargetPlayerIntentEvent, } from "../../Transport"; import { renderNumber, renderTroops } from "../../Utils"; +import { UIState } from "../UIState"; import { ChatModal } from "./ChatModal"; import { EmojiTable } from "./EmojiTable"; import { Layer } from "./Layer"; @@ -33,6 +34,7 @@ export class PlayerPanel extends LitElement implements Layer { public g: GameView; public eventBus: EventBus; public emojiTable: EmojiTable; + public uiState: UIState; private actions: PlayerActions | null = null; private tile: TileRef | null = null; @@ -86,7 +88,13 @@ export class PlayerPanel extends LitElement implements Layer { other: PlayerView, ) { e.stopPropagation(); - this.eventBus.emit(new SendDonateTroopsIntentEvent(myPlayer, other, null)); + this.eventBus.emit( + new SendDonateTroopsIntentEvent( + myPlayer, + other, + myPlayer.troops() * this.uiState.attackRatio, + ), + ); this.hide(); }