mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-17 05:34:37 +00:00
control panel dissappears when player dies
This commit is contained in:
@@ -58,12 +58,12 @@ export class ControlPanel extends LitElement implements Layer {
|
|||||||
tick() {
|
tick() {
|
||||||
// Update game state based on numTroops value if needed
|
// Update game state based on numTroops value if needed
|
||||||
if (!this._isVisible && !this.game.inSpawnPhase()) {
|
if (!this._isVisible && !this.game.inSpawnPhase()) {
|
||||||
this.toggleVisibility();
|
this.setVisibile(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = this.game.playerByClientID(this.clientID)
|
const player = this.game.playerByClientID(this.clientID)
|
||||||
if (player == null) {
|
if (player == null || !player.isAlive()) {
|
||||||
this._isVisible = false
|
this.setVisibile(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this._population = player.population()
|
this._population = player.population()
|
||||||
@@ -87,11 +87,12 @@ export class ControlPanel extends LitElement implements Layer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleVisibility() {
|
setVisibile(visible: boolean) {
|
||||||
this._isVisible = !this._isVisible;
|
this._isVisible = visible
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
targetTroops(): number {
|
targetTroops(): number {
|
||||||
return this._manpower * this.targetTroopRatio
|
return this._manpower * this.targetTroopRatio
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user