mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-07 19:06:03 +00:00
format codebase with prettier
This commit is contained in:
@@ -1,49 +1,53 @@
|
||||
import { EventBus, GameEvent } from "../EventBus"
|
||||
import { Execution, Game, Player, PlayerID } from "../game/Game"
|
||||
import { EventBus, GameEvent } from "../EventBus";
|
||||
import { Execution, Game, Player, PlayerID } from "../game/Game";
|
||||
|
||||
export class WinEvent implements GameEvent {
|
||||
constructor(public readonly winner: Player) { }
|
||||
constructor(public readonly winner: Player) {}
|
||||
}
|
||||
|
||||
export class WinCheckExecution implements Execution {
|
||||
private active = true;
|
||||
|
||||
private active = true
|
||||
private mg: Game;
|
||||
|
||||
private mg: Game
|
||||
constructor() {}
|
||||
|
||||
constructor() {
|
||||
init(mg: Game, ticks: number) {
|
||||
this.mg = mg;
|
||||
}
|
||||
|
||||
tick(ticks: number) {
|
||||
if (ticks % 10 != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
init(mg: Game, ticks: number) {
|
||||
this.mg = mg
|
||||
const sorted = this.mg
|
||||
.players()
|
||||
.sort((a, b) => b.numTilesOwned() - a.numTilesOwned());
|
||||
if (sorted.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tick(ticks: number) {
|
||||
if (ticks % 10 != 0) {
|
||||
return
|
||||
}
|
||||
const sorted = this.mg.players().sort((a, b) => b.numTilesOwned() - a.numTilesOwned())
|
||||
if (sorted.length == 0) {
|
||||
return
|
||||
}
|
||||
const max = sorted[0]
|
||||
const numTilesWithoutFallout = this.mg.numLandTiles() - this.mg.numTilesWithFallout()
|
||||
if (max.numTilesOwned() / numTilesWithoutFallout * 100 > this.mg.config().percentageTilesOwnedToWin()) {
|
||||
this.mg.setWinner(max)
|
||||
console.log(`${max.name()} has won the game`)
|
||||
this.active = false
|
||||
}
|
||||
const max = sorted[0];
|
||||
const numTilesWithoutFallout =
|
||||
this.mg.numLandTiles() - this.mg.numTilesWithFallout();
|
||||
if (
|
||||
(max.numTilesOwned() / numTilesWithoutFallout) * 100 >
|
||||
this.mg.config().percentageTilesOwnedToWin()
|
||||
) {
|
||||
this.mg.setWinner(max);
|
||||
console.log(`${max.name()} has won the game`);
|
||||
this.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null
|
||||
}
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user