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
This commit is contained in:
PilkeySEK
2025-05-21 10:15:28 +02:00
committed by GitHub
parent 2f1fc5e998
commit 772b72dfef
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -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)) {
+9 -1
View File
@@ -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();
}