bugfix: start troops were set at zero, username was not set in singleplayer

This commit is contained in:
Evan
2025-04-03 20:02:22 -07:00
parent 9fa3691c5c
commit a3a05f9ed2
2 changed files with 12 additions and 2 deletions
+9 -1
View File
@@ -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: {
+3 -1
View File
@@ -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);