Files
OpenFrontIO/src/core/execution/SetTargetTroopRatioExecution.ts
T
2024-11-03 12:37:56 -08:00

37 lines
926 B
TypeScript

import { Execution, MutableGame, MutablePlayer, PlayerID } from "../game/Game";
export class SetTargetTroopRatioExecution implements Execution {
private player: MutablePlayer
private active = true
constructor(private playerID: PlayerID, private targetTroopsRatio: number) { }
init(mg: MutableGame, ticks: number): void {
this.player = mg.player(this.playerID)
}
tick(ticks: number): void {
if (this.targetTroopsRatio < 0 || this.targetTroopsRatio > 1) {
console.warn(`target troop ratio of ${this.targetTroopsRatio} for player ${this.player} invalid`)
} else {
this.player.setTargetTroopRatio(this.targetTroopsRatio)
}
this.active = false
}
owner(): MutablePlayer {
return null
}
isActive(): boolean {
return this.active
}
activeDuringSpawnPhase(): boolean {
return false
}
}