mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 13:52:45 +00:00
bugfix: SpawnExecution was not attaching PlayerExecution to humans
bugfix: WinModal was saying player died even if they hadn't spawned added hasSpawned() method to player
This commit is contained in:
@@ -215,7 +215,8 @@ export class WinModal extends LitElement implements Layer {
|
||||
!this.hasShownDeathModal &&
|
||||
myPlayer &&
|
||||
!myPlayer.isAlive() &&
|
||||
!this.game.inSpawnPhase()
|
||||
!this.game.inSpawnPhase() &&
|
||||
myPlayer.hasSpawned()
|
||||
) {
|
||||
this.hasShownDeathModal = true;
|
||||
this._title = "You died";
|
||||
|
||||
@@ -25,26 +25,28 @@ export class SpawnExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
let player: Player = null;
|
||||
if (this.mg.hasPlayer(this.playerInfo.id)) {
|
||||
const existing = this.mg.player(this.playerInfo.id);
|
||||
existing.tiles().forEach((t) => existing.relinquish(t));
|
||||
getSpawnTiles(this.mg, this.tile).forEach((t) => {
|
||||
existing.conquer(t);
|
||||
});
|
||||
return;
|
||||
player = this.mg.player(this.playerInfo.id);
|
||||
} else {
|
||||
player = this.mg.addPlayer(
|
||||
this.playerInfo,
|
||||
this.mg.config().startManpower(this.playerInfo),
|
||||
);
|
||||
}
|
||||
|
||||
const player = this.mg.addPlayer(
|
||||
this.playerInfo,
|
||||
this.mg.config().startManpower(this.playerInfo),
|
||||
);
|
||||
player.tiles().forEach((t) => player.relinquish(t));
|
||||
getSpawnTiles(this.mg, this.tile).forEach((t) => {
|
||||
player.conquer(t);
|
||||
});
|
||||
this.mg.addExecution(new PlayerExecution(player.id()));
|
||||
if (player.type() == PlayerType.Bot) {
|
||||
this.mg.addExecution(new BotExecution(player));
|
||||
|
||||
if (!player.hasSpawned()) {
|
||||
this.mg.addExecution(new PlayerExecution(player.id()));
|
||||
if (player.type() == PlayerType.Bot) {
|
||||
this.mg.addExecution(new BotExecution(player));
|
||||
}
|
||||
}
|
||||
player.setHasSpawned(true);
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
|
||||
@@ -316,6 +316,9 @@ export interface Player {
|
||||
largestClusterBoundingBox: { min: Cell; max: Cell } | null;
|
||||
lastTileChange(): Tick;
|
||||
|
||||
hasSpawned(): boolean;
|
||||
setHasSpawned(hasSpawned: boolean): void;
|
||||
|
||||
// Territory
|
||||
tiles(): ReadonlySet<TileRef>;
|
||||
borderTiles(): ReadonlySet<TileRef>;
|
||||
|
||||
@@ -111,6 +111,7 @@ export interface PlayerUpdate {
|
||||
incomingAttacks: AttackUpdate[];
|
||||
outgoingAllianceRequests: PlayerID[];
|
||||
stats: PlayerStats;
|
||||
hasSpawned: boolean;
|
||||
}
|
||||
|
||||
export interface AllianceRequestUpdate {
|
||||
|
||||
@@ -266,6 +266,9 @@ export class PlayerView {
|
||||
stats(): PlayerStats {
|
||||
return this.data.stats;
|
||||
}
|
||||
hasSpawned(): boolean {
|
||||
return this.data.hasSpawned;
|
||||
}
|
||||
}
|
||||
|
||||
export class GameView implements GameMap {
|
||||
|
||||
@@ -94,6 +94,8 @@ export class PlayerImpl implements Player {
|
||||
public _outgoingAttacks: Attack[] = [];
|
||||
public _outgoingLandAttacks: Attack[] = [];
|
||||
|
||||
private _hasSpawned = false;
|
||||
|
||||
constructor(
|
||||
private mg: GameImpl,
|
||||
private _smallID: number,
|
||||
@@ -162,6 +164,7 @@ export class PlayerImpl implements Player {
|
||||
),
|
||||
outgoingAllianceRequests: outgoingAllianceRequests,
|
||||
stats: this.mg.stats().getPlayerStats(this.id()),
|
||||
hasSpawned: this.hasSpawned(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -291,6 +294,14 @@ export class PlayerImpl implements Player {
|
||||
return this._tiles.size > 0;
|
||||
}
|
||||
|
||||
hasSpawned(): boolean {
|
||||
return this._hasSpawned;
|
||||
}
|
||||
|
||||
setHasSpawned(hasSpawned: boolean): void {
|
||||
this._hasSpawned = hasSpawned;
|
||||
}
|
||||
|
||||
incomingAllianceRequests(): AllianceRequest[] {
|
||||
return this.mg.allianceRequests.filter((ar) => ar.recipient() == this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user