mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 11:52:13 +00:00
MissileSiloExecution
This commit is contained in:
@@ -11,9 +11,9 @@ import { TileRef } from "../game/GameMap";
|
||||
|
||||
export class MissileSiloExecution implements Execution {
|
||||
private active = true;
|
||||
private mg: Game;
|
||||
private player: Player;
|
||||
private silo: Unit;
|
||||
private mg: Game | null = null;
|
||||
private player: Player | null = null;
|
||||
private silo: Unit | null = null;
|
||||
|
||||
constructor(
|
||||
private _owner: PlayerID,
|
||||
@@ -32,7 +32,11 @@ export class MissileSiloExecution implements Execution {
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (this.silo == null) {
|
||||
if (this.mg === null || this.player === null) {
|
||||
throw new Error("Not initialized");
|
||||
}
|
||||
|
||||
if (this.silo === null) {
|
||||
if (!this.player.canBuild(UnitType.MissileSilo, this.tile)) {
|
||||
consolex.warn(
|
||||
`player ${this.player} cannot build missile silo at ${this.tile}`,
|
||||
@@ -44,14 +48,14 @@ export class MissileSiloExecution implements Execution {
|
||||
cooldownDuration: this.mg.config().SiloCooldown(),
|
||||
});
|
||||
|
||||
if (this.player != this.silo.owner()) {
|
||||
if (this.player !== this.silo.owner()) {
|
||||
this.player = this.silo.owner();
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
this.silo.isCooldown() &&
|
||||
this.silo.ticksLeftInCooldown(this.mg.config().SiloCooldown()) == 0
|
||||
this.silo.ticksLeftInCooldown(this.mg.config().SiloCooldown()) === 0
|
||||
) {
|
||||
this.silo.setCooldown(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user