nuke icon (#207)

- **feat: white nuke icon next to name if player nukes you**
![Capture d'écran 2025-03-10
220439](https://github.com/user-attachments/assets/1b717b2d-bffb-45fc-96ea-2feb57d25de0)
- **feat: red nuke icon if player sends nuke towards you**
- 
![Capture d'écran 2025-03-10
220358](https://github.com/user-attachments/assets/b755fa06-9510-4bd1-8312-7180dc681d85)
This commit is contained in:
Ilan Schemoul
2025-03-11 15:44:45 -07:00
committed by GitHub
parent 5cf75c71a7
commit 3ce5785d1e
11 changed files with 193 additions and 42 deletions
+19 -2
View File
@@ -2,6 +2,7 @@ import {
GameUpdates,
MapPos,
MessageType,
nukeTypes,
Player,
PlayerActions,
PlayerProfile,
@@ -30,6 +31,7 @@ import { WorkerClient } from "../worker/WorkerClient";
import { GameMap, GameMapImpl, TileRef, TileUpdate } from "./GameMap";
import { GameUpdateViewData } from "./GameUpdates";
import { DefenseGrid } from "./DefensePostGrid";
import { consolex } from "../Consolex";
export class UnitView {
public _wasUpdated = true;
@@ -91,8 +93,23 @@ export class UnitView {
constructionType(): UnitType | undefined {
return this.data.constructionType;
}
targetId() {
return this.data.targetId;
dstPortId(): number {
if (this.type() != UnitType.TradeShip) {
throw Error("Must be a trade ship");
}
return this.data.dstPortId;
}
detonationDst(): TileRef {
if (!nukeTypes.includes(this.type())) {
throw Error("Must be a nuke");
}
return this.data.detonationDst;
}
warshipTargetId(): number {
if (this.type() != UnitType.Warship) {
throw Error("Must be a warship");
}
return this.data.warshipTargetId;
}
}