Head-to-head artillery duel in a new "multiplayer" registry category (out of periods). Each operator hides a fire-base fleet on a 10x10 grid, then takes turns calling fire: the first mission is a grid designation, every later shot adjusts from that operator's last impact using the single-player range/deflection controls. First to reduce every enemy emplacement wins; a cap decides on emplacements then cells. Pure engine in src/lib/minigames/call-for-fire-versus (engine, views, types, constants) is client-safe and unit-tested. The server-only registry mirrors the blackjack table pattern (globalThis-anchored Map, lobby, per-turn timeout, expiry sweep, single-instance only); its views are built per viewer so the opponent's fleet layout never leaves the server. The client polls the match snapshot (the in-memory SSE bus is unreliable across dev module copies). Rewards on completion update the callForFireVersus profile group, pay XP and chips, and emit minigame:call-for-fire-versus. Wires the game into the registry (new multiplayer category + enum migration), the sidebar grouping, the command palette, and the profile XP aggregation. The registry row seed is split into its own migration because Postgres forbids using a freshly added enum value in the same transaction. Verified: 21 new tests (engine + registry) plus the wider minigame suite pass; tsc clean; a live two-player award run confirmed XP, chips, and the event.
62 lines
2.1 KiB
TypeScript
62 lines
2.1 KiB
TypeScript
/**
|
|
* Tunables for the Call for Fire versus mode (head-to-head artillery duel).
|
|
* Pure and client-safe: no Payload or Node imports.
|
|
*/
|
|
|
|
import type { GridPoint } from "@/lib/minigames/call-for-fire";
|
|
|
|
/** Board is size x size cells; one cell is one 50m grid square (see the CFF lib). */
|
|
export const VERSUS_BOARD_SIZE = 10;
|
|
|
|
/** Seconds a player has to call their next fire mission before the turn is skipped. */
|
|
export const VERSUS_TURN_SECONDS = 60;
|
|
export const VERSUS_TURN_TIMEOUT_MS = VERSUS_TURN_SECONDS * 1000;
|
|
|
|
/** Safety cap on rounds each player may fire before the match ends on points. */
|
|
export const VERSUS_MAX_SHOTS_PER_PLAYER = 40;
|
|
|
|
/** Live matches: registry cap and idle expiry (mirrors the blackjack registry). */
|
|
export const VERSUS_MAX_MATCHES = 20;
|
|
export const VERSUS_MATCH_EXPIRY_MS = 5 * 60_000;
|
|
export const VERSUS_SWEEP_INTERVAL_MS = 30_000;
|
|
|
|
/** Longest match name accepted by the rename/create path. */
|
|
export const VERSUS_MAX_NAME_LENGTH = 40;
|
|
|
|
/** Sentinel userId for the empty seat in a waiting match (never a real user). */
|
|
export const VERSUS_WAITING_USER_ID = 0;
|
|
|
|
export interface FobDefinition {
|
|
readonly id: string;
|
|
readonly label: string;
|
|
/** Occupied cells when placed, laid out in a straight line. */
|
|
readonly size: number;
|
|
}
|
|
|
|
/**
|
|
* The emplacement fleet each player hides. A shorter list keeps a duel brisk;
|
|
* total occupied cells are 8 of 100, so rounds matter without dragging.
|
|
*/
|
|
export const FOB_FLEET: readonly FobDefinition[] = [
|
|
{ id: "command-post", label: "Command Post", size: 3 },
|
|
{ id: "ammo-depot", label: "Ammo Depot", size: 2 },
|
|
{ id: "radar-site", label: "Radar Site", size: 2 },
|
|
{ id: "fob", label: "Forward Operating Base", size: 1 },
|
|
];
|
|
|
|
export type FobOrientation = "h" | "v";
|
|
|
|
export interface FobPlacement {
|
|
readonly assetId: string;
|
|
readonly origin: GridPoint;
|
|
readonly orientation: FobOrientation;
|
|
}
|
|
|
|
/** Scoring: emplacements destroyed dominate; cells struck break ties. */
|
|
export const VERSUS_SCORE_PER_FOB = 100;
|
|
export const VERSUS_SCORE_PER_CELL = 1;
|
|
|
|
/** XP payout on match completion. */
|
|
export const VERSUS_XP_WIN = 40;
|
|
export const VERSUS_XP_LOSS = 10;
|
|
export const VERSUS_XP_PER_FOB = 5;
|