1
0
Fork 0

chore(call-for-fire-versus): finish place/structure wording in help and errors

Completes the terminology pass: the "How to place" help block and the
engine's user-facing error strings ("Missing structure", "Structures cannot
overlap", "Placement is closed", "The opponent has not placed their
structures") now match the place/structure/target vocabulary used elsewhere
in the duel. Also splits a comment that had been merged onto the scoreOf
declaration. Strings only; no behavior change.
This commit is contained in:
Jason Fraley 2026-10-12 00:01:34 -04:00
parent c3d3c8c574
commit 49782365c2
3 changed files with 14 additions and 13 deletions

View file

@ -426,17 +426,17 @@ function PlacementPhase({
</div> </div>
<div className="rounded-lg border border-border/60 bg-background/40 p-3 text-xs text-muted-foreground"> <div className="rounded-lg border border-border/60 bg-background/40 p-3 text-xs text-muted-foreground">
<p className="mb-1 font-medium text-foreground">How to emplace</p> <p className="mb-1 font-medium text-foreground">How to place</p>
<ul className="list-disc space-y-0.5 pl-4"> <ul className="list-disc space-y-0.5 pl-4">
<li>Select an emplacement above, then click a cell to anchor it there.</li> <li>Select a structure above, then click a cell to anchor it there.</li>
<li>Click a placed emplacement to pick it up, then click a new cell to move it.</li> <li>Click a placed structure to pick it up, then click a new cell to move it.</li>
<li> <li>
Double-click a placed emplacement, or press the rotate toggle, to rotate it in place. Double-click a placed structure, or press the rotate toggle, to rotate it in place.
The Command Post is a fixed 2x2 block and does not rotate; the Ammo Depot is an L and The Command Post is a fixed 2x2 block and does not rotate; the Ammo Depot is an L and
turns through four orientations. turns through four orientations.
</li> </li>
<li>The toggle also sets the orientation used for your next placement.</li> <li>The toggle also sets the orientation used for your next placement.</li>
<li>Emplacements cannot overlap, and your opponent never sees your layout.</li> <li>Structures cannot overlap, and your opponent never sees your layout.</li>
</ul> </ul>
</div> </div>
</CardContent> </CardContent>

View file

@ -159,12 +159,12 @@ export function buildFleet(
for (const definition of FOB_FLEET) { for (const definition of FOB_FLEET) {
const placement = byId.get(definition.id); const placement = byId.get(definition.id);
if (!placement) return { error: `Missing emplacement: ${definition.label}.` }; if (!placement) return { error: `Missing structure: ${definition.label}.` };
const cells = cellsForFob(definition, placement.origin, placement.orientation, boardSize); const cells = cellsForFob(definition, placement.origin, placement.orientation, boardSize);
if (!cells) return { error: `${definition.label} does not fit there.` }; if (!cells) return { error: `${definition.label} does not fit there.` };
for (const cell of cells) { for (const cell of cells) {
const key = cellKey(cell); const key = cellKey(cell);
if (occupied.has(key)) return { error: "Emplacements cannot overlap." }; if (occupied.has(key)) return { error: "Structures cannot overlap." };
occupied.add(key); occupied.add(key);
} }
fleet.push({ fleet.push({
@ -179,7 +179,7 @@ export function buildFleet(
const unknown = placements.find( const unknown = placements.find(
(placement) => !FOB_FLEET.some((definition) => definition.id === placement.assetId), (placement) => !FOB_FLEET.some((definition) => definition.id === placement.assetId),
); );
if (unknown) return { error: `Unknown emplacement: ${unknown.assetId}.` }; if (unknown) return { error: `Unknown structure: ${unknown.assetId}.` };
return { fleet }; return { fleet };
} }
@ -200,7 +200,7 @@ export function placeFleet(
placements: readonly FobPlacement[], placements: readonly FobPlacement[],
now: Date = new Date(), now: Date = new Date(),
): { state: VersusState } | { error: string } { ): { state: VersusState } | { error: string } {
if (state.phase !== "placing") return { error: "Emplacement is closed." }; if (state.phase !== "placing") return { error: "Placement is closed." };
const built = buildFleet(placements, state.boardSize); const built = buildFleet(placements, state.boardSize);
if ("error" in built) return { error: built.error }; if ("error" in built) return { error: built.error };
@ -227,7 +227,8 @@ export function seatPlayer(
return { ...state, players }; return { ...state, players };
} }
/** Score a player's performance this match: emplacements destroyed then cells. */export function scoreOf(player: VersusPlayerState): number { /** Score a player's performance this match: emplacements destroyed then cells. */
export function scoreOf(player: VersusPlayerState): number {
return player.fobsDestroyed * VERSUS_SCORE_PER_FOB + player.cellsHit * VERSUS_SCORE_PER_CELL; return player.fobsDestroyed * VERSUS_SCORE_PER_FOB + player.cellsHit * VERSUS_SCORE_PER_CELL;
} }
@ -274,7 +275,7 @@ export function fireShot(
const player = state.players[index]; const player = state.players[index];
const opponentIndex: 0 | 1 = index === 0 ? 1 : 0; const opponentIndex: 0 | 1 = index === 0 ? 1 : 0;
const opponent = state.players[opponentIndex]; const opponent = state.players[opponentIndex];
if (!opponent.fleet) return { error: "The opponent has not emplaced a fleet." }; if (!opponent.fleet) return { error: "The opponent has not placed their structures." };
let impact: GridPoint; let impact: GridPoint;
if (player.lastImpact === null) { if (player.lastImpact === null) {

View file

@ -94,7 +94,7 @@ describe("call for fire versus: fleet placement", () => {
}); });
it("rejects missing, overlapping, and unknown emplacements", () => { it("rejects missing, overlapping, and unknown emplacements", () => {
expect(buildFleet([fleetAt(0, 0)[0]], 10)).toEqual({ error: "Missing emplacement: Ammo Depot." }); expect(buildFleet([fleetAt(0, 0)[0]], 10)).toEqual({ error: "Missing structure: Ammo Depot." });
const overlapping: FobPlacement[] = [ const overlapping: FobPlacement[] = [
{ assetId: "command-post", origin: { x: 0, y: 0 }, orientation: 0 }, { assetId: "command-post", origin: { x: 0, y: 0 }, orientation: 0 },
@ -102,7 +102,7 @@ describe("call for fire versus: fleet placement", () => {
{ assetId: "radar-site", origin: { x: 0, y: 4 }, orientation: 0 }, { assetId: "radar-site", origin: { x: 0, y: 4 }, orientation: 0 },
{ assetId: "fob", origin: { x: 0, y: 5 }, orientation: 0 }, { assetId: "fob", origin: { x: 0, y: 5 }, orientation: 0 },
]; ];
expect(buildFleet(overlapping, 10)).toEqual({ error: "Emplacements cannot overlap." }); expect(buildFleet(overlapping, 10)).toEqual({ error: "Structures cannot overlap." });
const unknown: FobPlacement[] = [ const unknown: FobPlacement[] = [
...fleetAt(0, 0), ...fleetAt(0, 0),