From a3a05f9ed26661d69205f0cf2d5cc21ff2e1a335 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 3 Apr 2025 20:02:22 -0700 Subject: [PATCH] bugfix: start troops were set at zero, username was not set in singleplayer --- src/client/SinglePlayerModal.ts | 10 +++++++++- src/core/game/GameImpl.ts | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/SinglePlayerModal.ts b/src/client/SinglePlayerModal.ts index 7faaa92c1..fbc23d0bd 100644 --- a/src/client/SinglePlayerModal.ts +++ b/src/client/SinglePlayerModal.ts @@ -11,6 +11,7 @@ import "./components/Difficulties"; import { DifficultyDescription } from "./components/Difficulties"; import "./components/Maps"; import { JoinLobbyEvent } from "./Main"; +import { UsernameInput } from "./UsernameInput"; @customElement("single-player-modal") export class SinglePlayerModal extends LitElement { @@ -326,6 +327,13 @@ export class SinglePlayerModal extends LitElement { const clientID = generateID(); const gameID = generateID(); + const usernameInput = document.querySelector( + "username-input", + ) as UsernameInput; + if (!usernameInput) { + consolex.warn("Username input element not found"); + } + this.dispatchEvent( new CustomEvent("join-lobby", { detail: { @@ -337,7 +345,7 @@ export class SinglePlayerModal extends LitElement { { playerID: generateID(), clientID, - username: "PLACEHOLDER", + username: usernameInput.getCurrentUsername(), }, ], config: { diff --git a/src/core/game/GameImpl.ts b/src/core/game/GameImpl.ts index fd0bb9301..dc4807ca6 100644 --- a/src/core/game/GameImpl.ts +++ b/src/core/game/GameImpl.ts @@ -107,7 +107,9 @@ export class GameImpl implements Game { private addHumans() { if (this.config().gameConfig().gameMode != GameMode.Team) { - this._humans.forEach((p) => this.addPlayer(p, 0)); + this._humans.forEach((p) => + this.addPlayer(p, this.config().startManpower(p)), + ); return; } const playerToTeam = assignTeams(this._humans);