bugfix: humans start with zero troops on teams, also removed manpower argument to addPlayer()

This commit is contained in:
Evan
2025-04-04 10:03:00 -07:00
parent 51bbf2becd
commit 924ca2c69e
8 changed files with 13 additions and 23 deletions
+1 -4
View File
@@ -29,10 +29,7 @@ export class SpawnExecution implements Execution {
if (this.mg.hasPlayer(this.playerInfo.id)) {
player = this.mg.player(this.playerInfo.id);
} else {
player = this.mg.addPlayer(
this.playerInfo,
this.mg.config().startManpower(this.playerInfo),
);
player = this.mg.addPlayer(this.playerInfo);
}
player.tiles().forEach((t) => player.relinquish(t));
+1 -1
View File
@@ -433,7 +433,7 @@ export interface Game extends GameMap {
playerByClientID(id: ClientID): Player | null;
playerBySmallID(id: number): Player | TerraNullius;
hasPlayer(id: PlayerID): boolean;
addPlayer(playerInfo: PlayerInfo, manpower: number): Player;
addPlayer(playerInfo: PlayerInfo): Player;
terraNullius(): TerraNullius;
owner(ref: TileRef): Player | TerraNullius;
+4 -10
View File
@@ -107,9 +107,7 @@ export class GameImpl implements Game {
private addHumans() {
if (this.config().gameConfig().gameMode != GameMode.Team) {
this._humans.forEach((p) =>
this.addPlayer(p, this.config().startManpower(p)),
);
this._humans.forEach((p) => this.addPlayer(p));
return;
}
const playerToTeam = assignTeams(this._humans);
@@ -118,7 +116,7 @@ export class GameImpl implements Game {
console.warn(`Player ${playerInfo.name} was kicked from team`);
continue;
}
this.addPlayer(playerInfo, 0, team);
this.addPlayer(playerInfo, team);
}
}
@@ -348,16 +346,12 @@ export class GameImpl implements Game {
return this.player(id);
}
addPlayer(
playerInfo: PlayerInfo,
manpower: number,
team: Team = null,
): Player {
addPlayer(playerInfo: PlayerInfo, team: Team = null): Player {
const player = new PlayerImpl(
this,
this.nextPlayerID,
playerInfo,
manpower,
this.config().startManpower(playerInfo),
team ?? this.maybeAssignTeam(playerInfo),
);
this._playersBySmallID.push(player);