- Optional `estimatedReleaseDate` (date and time) on the minigames registry,
with a named migration and regenerated types.
- Sidebar: an `upcoming` game renders greyed out and non-interactive, with a
tooltip carrying the estimate and a live countdown. It is a hoverable row
rather than a disabled menu item, because a disabled Radix item sets
`pointer-events: none` and would swallow the tooltip.
- Page gate: each minigame page checks its registry status and renders
`MinigameComingSoon` instead of the arena while the game is upcoming, so a
typed URL cannot reach unfinished gameplay. The date is display only: the
game goes live when an admin flips `status` to active.
- Leaderboards exclude upcoming games, so they get neither a tab nor a board.
- Pure `countdown.ts` formatter plus a client ticker that computes the
remaining time only after mount, avoiding an SSR hydration mismatch.
Note: `registry.ts`, `payload-types.ts` and `migrations/index.ts` also carry
the Call for Fire registry row and its generated types. That feature was
committed as 6d6a5fb and announced a separate commit for those files; they are
included here because they are entangled with these edits in the same files.
Tests: pure countdown unit tests, registry/gate/leaderboard integration tests,
and an e2e that seeds an upcoming row, hovers the disabled sidebar entry to
assert the tooltip, and checks the coming-soon gate.
225 lines
6.9 KiB
TypeScript
225 lines
6.9 KiB
TypeScript
/**
|
|
* Canonical registry data for the minigames feature.
|
|
*
|
|
* Pure and client-safe (no Payload import): the `minigames` collection seeds
|
|
* its rows from `BUILTIN_MINIGAMES`, the `minigame-rules` global seeds its
|
|
* defaults from `MINIGAME_RULE_DEFAULTS`, and the sidebar can read the same
|
|
* list without a Payload round trip.
|
|
*
|
|
* `icon` is a lucide-react icon name (a string), mapped to a component in the
|
|
* client. Keeping it as data means the registry can be edited in the admin
|
|
* panel without shipping new code.
|
|
*/
|
|
|
|
export type MinigameCategory = "core" | "cardtable";
|
|
export type MinigameStatus = "active" | "retired" | "upcoming";
|
|
|
|
/** The six period-scoring games. Poker and Blackjack stay out of periods. */
|
|
export const CORE_MINIGAME_KEYS = [
|
|
"flappy",
|
|
"eod",
|
|
"radio",
|
|
"qualification",
|
|
"opord",
|
|
"callForFire",
|
|
] as const;
|
|
|
|
export const CARDTABLE_MINIGAME_KEYS = ["poker", "blackjack"] as const;
|
|
|
|
export type CoreMinigameKey = (typeof CORE_MINIGAME_KEYS)[number];
|
|
export type MinigameKey = CoreMinigameKey | (typeof CARDTABLE_MINIGAME_KEYS)[number];
|
|
|
|
export interface BuiltinMinigame {
|
|
key: string;
|
|
label: string;
|
|
description: string;
|
|
route: string;
|
|
/** lucide-react icon name, resolved in the client. */
|
|
icon: string;
|
|
category: MinigameCategory;
|
|
status: MinigameStatus;
|
|
/** Sort order within the sidebar / leaderboards. */
|
|
order: number;
|
|
/** Whether this game's ledger entries feed anchored period boards. */
|
|
countsForPeriods: boolean;
|
|
/** Label for the score column, e.g. "Passes", "Time". */
|
|
scoreLabel: string;
|
|
/**
|
|
* Optional target release instant (ISO 8601, UTC) shown as a countdown while
|
|
* `status` is "upcoming". Display only: the game goes live when an admin
|
|
* changes `status` to "active", so a slipped estimate never exposes it.
|
|
*/
|
|
estimatedReleaseDate?: string | null;
|
|
}
|
|
|
|
/** The seven built-in games, seeded into the `minigames` registry collection. */
|
|
export const BUILTIN_MINIGAMES: BuiltinMinigame[] = [
|
|
{
|
|
key: "flappy",
|
|
label: "Flight Simulator",
|
|
description: "Guide an aircraft through an obstacle course for as many passes as you can manage.",
|
|
route: "/minigames/flappy",
|
|
icon: "Bird",
|
|
category: "core",
|
|
status: "active",
|
|
order: 1,
|
|
countsForPeriods: true,
|
|
scoreLabel: "Passes",
|
|
},
|
|
{
|
|
key: "eod",
|
|
label: "Minefield Clearance",
|
|
description: "Clear a minefield without detonating a charge, against the clock.",
|
|
route: "/minigames/eod",
|
|
icon: "Bomb",
|
|
category: "core",
|
|
status: "active",
|
|
order: 2,
|
|
countsForPeriods: true,
|
|
scoreLabel: "Score",
|
|
},
|
|
{
|
|
key: "radio",
|
|
label: "Radio Traffic",
|
|
description: "Transcribe and repeat radio traffic accurately, sprint or watch mode.",
|
|
route: "/minigames/radio",
|
|
icon: "Radio",
|
|
category: "core",
|
|
status: "active",
|
|
order: 3,
|
|
countsForPeriods: true,
|
|
scoreLabel: "Score",
|
|
},
|
|
{
|
|
key: "qualification",
|
|
label: "Qualification Course",
|
|
description: "Range drill: engage targets quickly and accurately while sparing civilians.",
|
|
route: "/minigames/qualification",
|
|
icon: "Crosshair",
|
|
category: "core",
|
|
status: "active",
|
|
order: 4,
|
|
countsForPeriods: true,
|
|
scoreLabel: "Score",
|
|
},
|
|
{
|
|
key: "opord",
|
|
label: "OPORD Recall",
|
|
description: "Study a briefing, then recall its details under time pressure.",
|
|
route: "/minigames/opord",
|
|
icon: "FileTextIcon",
|
|
category: "core",
|
|
status: "active",
|
|
order: 5,
|
|
countsForPeriods: true,
|
|
scoreLabel: "Score",
|
|
},
|
|
{
|
|
key: "callForFire",
|
|
label: "Call for Fire",
|
|
description: "Bracket artillery onto a hidden target: fewer fire missions score higher.",
|
|
route: "/minigames/call-for-fire",
|
|
icon: "Target",
|
|
category: "core",
|
|
status: "active",
|
|
order: 6,
|
|
countsForPeriods: true,
|
|
scoreLabel: "Score",
|
|
},
|
|
{
|
|
key: "poker",
|
|
label: "Poker",
|
|
description: "Cardtable game. Play chips earned from Core minigames. Keeps its own all-time board.",
|
|
route: "/minigames/poker",
|
|
icon: "Spade",
|
|
category: "cardtable",
|
|
status: "active",
|
|
order: 7,
|
|
countsForPeriods: false,
|
|
scoreLabel: "Chips",
|
|
},
|
|
{
|
|
key: "blackjack",
|
|
label: "Blackjack",
|
|
description: "Cardtable game. Play chips earned from Core minigames. Keeps its own all-time board.",
|
|
route: "/minigames/blackjack",
|
|
icon: "Club",
|
|
category: "cardtable",
|
|
status: "active",
|
|
order: 8,
|
|
countsForPeriods: false,
|
|
scoreLabel: "Chips",
|
|
},
|
|
];
|
|
|
|
/** Anchor for Period 1: the Monday 00:00 UTC the feature goes live. */
|
|
export const MINIGAME_ANCHOR_DATE = "2026-10-12T00:00:00.000Z";
|
|
export const PERIOD_LENGTH_DAYS_DEFAULT = 14;
|
|
export const PLACEMENT_LADDER_TOP_N_DEFAULT = 10;
|
|
export const PRECISION_MIN_ATTEMPTS_DEFAULT = 5;
|
|
|
|
export const MINIGAME_ACHIEVEMENT_TYPES = [
|
|
"period-champion",
|
|
"player-of-month",
|
|
"player-of-year",
|
|
"diligence",
|
|
"dedication",
|
|
"precision",
|
|
"most-improved",
|
|
] as const;
|
|
|
|
export type MinigameAchievementType = (typeof MINIGAME_ACHIEVEMENT_TYPES)[number];
|
|
|
|
export const MINIGAME_ACHIEVEMENT_WINDOWS = ["period", "month", "year"] as const;
|
|
export type MinigameAchievementWindow = (typeof MINIGAME_ACHIEVEMENT_WINDOWS)[number];
|
|
|
|
export const MINIGAME_ACHIEVEMENT_TYPE_LABELS: Record<MinigameAchievementType, string> = {
|
|
"period-champion": "Period Champion",
|
|
"player-of-month": "Player of the Month",
|
|
"player-of-year": "Player of the Year",
|
|
diligence: "Diligence (Most Attempts)",
|
|
dedication: "Dedication (Most Time)",
|
|
precision: "Precision (Accuracy)",
|
|
"most-improved": "Most Improved",
|
|
};
|
|
|
|
export const MINIGAME_ACHIEVEMENT_WINDOW_LABELS: Record<MinigameAchievementWindow, string> = {
|
|
period: "Period",
|
|
month: "Month",
|
|
year: "Year",
|
|
};
|
|
|
|
/**
|
|
* Registry key -> the `profiles.progression.minigames` group name, used by the
|
|
* All-Time tab and any all-time fallback. The ledger is the source of truth for
|
|
* period boards; these profile aggregates are the untouched all-time stats.
|
|
*/
|
|
export const MINIGAME_PROFILE_GAME_KEYS: Record<string, string> = {
|
|
flappy: "flappyBird",
|
|
eod: "eodMinesweeper",
|
|
radio: "radioTraffic",
|
|
qualification: "aimTrainer",
|
|
opord: "opordRecall",
|
|
callForFire: "callForFire",
|
|
poker: "poker",
|
|
blackjack: "blackjack",
|
|
};
|
|
|
|
/** Defaults for the `minigame-rules` global, seeded on first migration. */
|
|
export const MINIGAME_RULE_DEFAULTS = {
|
|
enabled: true,
|
|
periodLengthDays: PERIOD_LENGTH_DAYS_DEFAULT,
|
|
anchorDate: MINIGAME_ANCHOR_DATE,
|
|
placementLadderTopN: PLACEMENT_LADDER_TOP_N_DEFAULT,
|
|
precisionMinAttempts: PRECISION_MIN_ATTEMPTS_DEFAULT,
|
|
} as const;
|
|
|
|
/**
|
|
* A registry row as the client sees it. Same shape as a built-in so the nav and
|
|
* leaderboards render identically whether the data came from the DB or from the
|
|
* built-in fallback (`src/lib/minigames/loadRegistry.ts`).
|
|
*/
|
|
export type RegistryGame = BuiltinMinigame;
|
|
|
|
/** Icon name used when a registry row's `icon` is missing or unknown. */
|
|
export const MINIGAME_ICON_FALLBACK = "Gamepad2";
|