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:
parent
c3d3c8c574
commit
49782365c2
3 changed files with 14 additions and 13 deletions
|
|
@ -426,17 +426,17 @@ function PlacementPhase({
|
|||
</div>
|
||||
|
||||
<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">
|
||||
<li>Select an emplacement 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>Select a structure above, then click a cell to anchor it there.</li>
|
||||
<li>Click a placed structure to pick it up, then click a new cell to move it.</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
|
||||
turns through four orientations.
|
||||
</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>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
|
|
|||
|
|
@ -159,12 +159,12 @@ export function buildFleet(
|
|||
|
||||
for (const definition of FOB_FLEET) {
|
||||
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);
|
||||
if (!cells) return { error: `${definition.label} does not fit there.` };
|
||||
for (const cell of cells) {
|
||||
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);
|
||||
}
|
||||
fleet.push({
|
||||
|
|
@ -179,7 +179,7 @@ export function buildFleet(
|
|||
const unknown = placements.find(
|
||||
(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 };
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ export function placeFleet(
|
|||
placements: readonly FobPlacement[],
|
||||
now: Date = new Date(),
|
||||
): { 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);
|
||||
if ("error" in built) return { error: built.error };
|
||||
|
||||
|
|
@ -227,7 +227,8 @@ export function seatPlayer(
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -274,7 +275,7 @@ export function fireShot(
|
|||
const player = state.players[index];
|
||||
const opponentIndex: 0 | 1 = index === 0 ? 1 : 0;
|
||||
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;
|
||||
if (player.lastImpact === null) {
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ describe("call for fire versus: fleet placement", () => {
|
|||
});
|
||||
|
||||
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[] = [
|
||||
{ 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: "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[] = [
|
||||
...fleetAt(0, 0),
|
||||
|
|
|
|||
Loading…
Reference in a new issue