mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-03 14:20:44 +00:00
feat: WarShips red color outside if target current player
Hard to know when warship captures your trade so if they target one of your trade or war ship they are highlighted in red. Known limitation: doesn't work well if the WarShip is already in red (player's color)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Colord } from "colord";
|
||||
import { colord, Colord } from "colord";
|
||||
import { Theme } from "../../../core/configuration/Config";
|
||||
import { Unit, UnitType, Player } from "../../../core/game/Game";
|
||||
import { Layer } from "./Layer";
|
||||
@@ -240,15 +240,20 @@ export class UnitLayer implements Layer {
|
||||
return;
|
||||
}
|
||||
|
||||
let outerColor = this.theme.territoryColor(unit.owner().info());
|
||||
if (unit.targetId()) {
|
||||
const targetOwner = this.game
|
||||
.units()
|
||||
.find((u) => u.id() == unit.targetId())
|
||||
.owner();
|
||||
if (targetOwner == this.myPlayer) {
|
||||
outerColor = colord({ r: 200, b: 0, g: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
// Paint outer territory
|
||||
for (const t of this.game.bfs(unit.tile(), euclDistFN(unit.tile(), 5))) {
|
||||
this.paintCell(
|
||||
this.game.x(t),
|
||||
this.game.y(t),
|
||||
rel,
|
||||
this.theme.territoryColor(unit.owner().info()),
|
||||
255,
|
||||
);
|
||||
this.paintCell(this.game.x(t), this.game.y(t), rel, outerColor, 255);
|
||||
}
|
||||
|
||||
// Paint border
|
||||
|
||||
Reference in New Issue
Block a user