diff --git a/src/components/frontend/minigames/call-for-fire-versus/VersusMatch.tsx b/src/components/frontend/minigames/call-for-fire-versus/VersusMatch.tsx index f716a259..c23d4472 100644 --- a/src/components/frontend/minigames/call-for-fire-versus/VersusMatch.tsx +++ b/src/components/frontend/minigames/call-for-fire-versus/VersusMatch.tsx @@ -25,6 +25,40 @@ import { cn } from "@/lib/utils"; const BOARD = 10; const CORRECTION_STEP = 50; +/** Distinct color per emplacement type, for both the picker chips and grid cells. */ +const FOB_STYLES: Record = { + "command-post": { + cell: "border-amber-500/70 bg-amber-500/30 text-amber-50", + swatch: "bg-amber-400", + ring: "border-amber-500/60", + }, + "ammo-depot": { + cell: "border-rose-500/70 bg-rose-500/30 text-rose-50", + swatch: "bg-rose-400", + ring: "border-rose-500/60", + }, + "radar-site": { + cell: "border-sky-500/70 bg-sky-500/30 text-sky-50", + swatch: "bg-sky-400", + ring: "border-sky-500/60", + }, + fob: { + cell: "border-violet-500/70 bg-violet-500/30 text-violet-50", + swatch: "bg-violet-400", + ring: "border-violet-500/60", + }, +}; + +function fobStyle(id: string) { + return ( + FOB_STYLES[id] ?? { + cell: "border-emerald-500/70 bg-emerald-600/40 text-emerald-50", + swatch: "bg-emerald-400", + ring: "border-emerald-500/60", + } + ); +} + function key(point: GridPoint): string { return `${point.x},${point.y}`; } @@ -91,13 +125,13 @@ function PlacementPhase({ const [busy, setBusy] = useState(false); const occupied = useMemo(() => { - const map = new Map(); + const map = new Map(); for (const definition of FOB_FLEET) { const placement = placements[definition.id]; if (!placement) continue; const cells = cellsForPlacement(placement.origin, placement.orientation, definition.size, BOARD); if (!cells) continue; - for (const cell of cells) map.set(key(cell), { assetId: definition.id, isNew: false }); + for (const cell of cells) map.set(key(cell), definition.id); } return map; }, [placements]); @@ -204,23 +238,29 @@ function PlacementPhase({
{FOB_FLEET.map((definition) => { const placed = Boolean(placements[definition.id]); + const style = fobStyle(definition.id); + const selected = selectedId === definition.id; return ( ); @@ -235,10 +275,10 @@ function PlacementPhase({
-
+
{Array.from({ length: BOARD }, (_, x) => ( @@ -255,6 +295,7 @@ function PlacementPhase({ y={y} occupied={occupied} preview={new Set(previewCells.map(key))} + previewClass={fobStyle(selectedId).cell} disabled={false} onPlace={placeAt} /> @@ -275,12 +316,14 @@ function PlacementRow({ y, occupied, preview, + previewClass, disabled, onPlace, }: { y: number; - occupied: Map; + occupied: Map; preview: Set; + previewClass: string; disabled: boolean; onPlace: (x: number, y: number) => void; }) { @@ -290,7 +333,7 @@ function PlacementRow({ {y + 1}
{Array.from({ length: BOARD }, (_, x) => { - const cell = occupied.get(`${x},${y}`); + const assetId = occupied.get(`${x},${y}`); const isPreview = preview.has(`${x},${y}`); return ( ); })} @@ -434,8 +475,8 @@ function BattlePhase({ key={`${x}-${y}`} label={`grid ${cellLabel(x, y)}`} className={cn( - fob && "border-emerald-500/70 bg-emerald-600/40 text-emerald-50", - destroyed && "border-red-500/70 bg-red-600/50 text-red-50", + fob && !destroyed && fobStyle(fob.id).cell, + fob && destroyed && "border-red-500/70 bg-red-600/50 text-red-50", )} > {fob ? "▣" : ""} @@ -474,9 +515,11 @@ function BattlePhase({ key={`${x}-${y}`} label={`grid ${cellLabel(x, y)}`} className={cn( - (shot?.outcome === "hit" || shot?.outcome === "destroyed") && - "border-amber-500/70 bg-amber-500/20 text-amber-200", + shot?.outcome === "hit" && shot.assetId && fobStyle(shot.assetId).cell, shot?.outcome === "destroyed" && "border-red-500/70 bg-red-600/40 text-red-50", + shot?.outcome === "hit" && + !shot.assetId && + "border-amber-500/70 bg-amber-500/20 text-amber-200", pending && "border-sky-400 ring-2 ring-sky-400/60", )} interactive={Boolean(yourTurn && firstShot)} @@ -548,7 +591,7 @@ function BoardPanel({ children: React.ReactNode; }) { return ( - + {title}

{subtitle}

@@ -556,7 +599,7 @@ function BoardPanel({
{Array.from({ length: BOARD }, (_, x) => ( diff --git a/src/lib/minigames/call-for-fire-versus/types.ts b/src/lib/minigames/call-for-fire-versus/types.ts index 615824a4..bbfceaaa 100644 --- a/src/lib/minigames/call-for-fire-versus/types.ts +++ b/src/lib/minigames/call-for-fire-versus/types.ts @@ -77,6 +77,8 @@ export interface VersusFobView { export interface VersusShotView { readonly grid: GridPoint; readonly outcome: ShotOutcome; + /** Emplacement type struck (known to the shooter), or null on a miss. */ + readonly assetId: string | null; } export interface VersusYouView { diff --git a/src/lib/minigames/call-for-fire-versus/views.ts b/src/lib/minigames/call-for-fire-versus/views.ts index 048099f6..082bf18c 100644 --- a/src/lib/minigames/call-for-fire-versus/views.ts +++ b/src/lib/minigames/call-for-fire-versus/views.ts @@ -24,7 +24,7 @@ export function projectFob(fob: VersusFob): VersusFobView { } function projectShots(shots: readonly VersusShot[]): VersusShotView[] { - return shots.map((shot) => ({ grid: shot.grid, outcome: shot.outcome })); + return shots.map((shot) => ({ grid: shot.grid, outcome: shot.outcome, assetId: shot.assetId })); } /** Build the safe, per-viewer view of a match. */