have Team be an enum instead of an object, this was causing equality problems.

This commit is contained in:
Evan
2025-04-05 21:39:12 -07:00
parent f620264ce3
commit c7356a7348
16 changed files with 72 additions and 93 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
import { blue, red } from "../../../core/configuration/Colors";
import { GameMode, TeamName } from "../../../core/game/Game";
import { GameMode, Team } from "../../../core/game/Game";
import { GameView } from "../../../core/game/GameView";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer";
@@ -28,12 +28,12 @@ export class SpawnTimer implements Layer {
const numBlueTiles = this.game
.players()
.filter((p) => p.teamName() == TeamName.Blue)
.filter((p) => p.team() == Team.Blue)
.reduce((acc, p) => acc + p.numTilesOwned(), 0);
const numRedTiles = this.game
.players()
.filter((p) => p.teamName() == TeamName.Red)
.filter((p) => p.team() == Team.Red)
.reduce((acc, p) => acc + p.numTilesOwned(), 0);
this.ratio = numBlueTiles / (numBlueTiles + numRedTiles);
+3 -7
View File
@@ -1,7 +1,7 @@
import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus";
import { TeamName } from "../../../core/game/Game";
import { Team } from "../../../core/game/Game";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { PseudoRandom } from "../../../core/PseudoRandom";
@@ -226,13 +226,9 @@ export class WinModal extends LitElement implements Layer {
this.game.updatesSinceLastTick()[GameUpdateType.Win].forEach((wu) => {
if (wu.winnerType === "team") {
this.eventBus.emit(
new SendWinnerEvent(
wu.winner as TeamName,
wu.allPlayersStats,
"team",
),
new SendWinnerEvent(wu.winner as Team, wu.allPlayersStats, "team"),
);
if (wu.winner == this.game.myPlayer()?.teamName()) {
if (wu.winner == this.game.myPlayer()?.team()) {
this._title = "Your team won!";
this.won = true;
} else {