create troop slider

This commit is contained in:
Evan
2024-11-03 12:37:56 -08:00
parent df0b5a91ac
commit 2afecf0f39
17 changed files with 2673 additions and 2401 deletions
@@ -0,0 +1,37 @@
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
}
}