mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 11:31:21 +00:00
37 lines
926 B
TypeScript
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
|
|
}
|
|
|
|
} |