mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 10:48:10 +00:00
9c7e0ce32f
## Description: Answering issue: #1017 [Cleanup] Pass Player into the execution constructor instead of PlayerID I have tested the changes running and playing a full game. I do not know other way to test the changes, please inform me ❤️ ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: Lele --------- Co-authored-by: lva <lva@rovsing.dk>
32 lines
727 B
TypeScript
32 lines
727 B
TypeScript
import { Execution, Game, Player } from "../game/Game";
|
|
|
|
export class SetTargetTroopRatioExecution implements Execution {
|
|
private active = true;
|
|
|
|
constructor(
|
|
private player: Player,
|
|
private targetTroopsRatio: number,
|
|
) {}
|
|
|
|
init(mg: Game, ticks: number): void {}
|
|
|
|
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;
|
|
}
|
|
|
|
isActive(): boolean {
|
|
return this.active;
|
|
}
|
|
|
|
activeDuringSpawnPhase(): boolean {
|
|
return false;
|
|
}
|
|
}
|