- 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.
6 KiB
AGENTS.md: Training Minigames
Parent:
../../../AGENTS.md(root guide: commands, Server Actions convention, domain guide index).
Five XP-earning minigames under one parent: routes live at /minigames/* (moved from /qualification, /radio, /flappy, /eod, /opord; next.config.mjs redirects keep the old URLs working), components under src/components/frontend/minigames/<game>/ (shared bits like UnlockNotice.tsx at the root), game-rule libs under src/lib/minigames/ (custom-content libs in src/lib/minigames/custom/), stats under Profiles progression.minigames.*. The realtime presence channel strings ("eod", "radio", ...) are unchanged:
- Qualification Course (aim trainer):
/minigames/qualification(src/app/(frontend)/minigames/qualification/), game rules insrc/lib/minigames/aim-trainer.ts(recruit/veteran/elite difficulties, civilian targets, scoring/accuracy/XP, injected rng). Components:src/components/frontend/minigames/qualification/(AimTrainerArena,AimTrainerGame,AimTrainerCanvas,AimTrainerLeaderboard). ActionsubmitAimTrainerResultvalidates result bounds, updates profile stats, awards XP, emitsminigame:aim-trainer. - Radio Traffic:
/minigames/radio, sprint + watch modes, procedural message generation (src/components/frontend/minigames/radio/messageGenerator.ts). ActionsubmitRadioResultemitsminigame:radio-traffic; stats underprogression.minigames.radioTraffic(incl.bestSprintTimeMs). - Flight Simulator:
/minigames/flappy(canvas game + leaderboard). Minefield Clearance (EOD):/minigames/eod. OPORD Recall:/minigames/opord(src/lib/minigames/opord-recall.ts). - Call for Fire (artillery observer):
/minigames/call-for-fire, game rules insrc/lib/minigames/call-for-fire.ts(patrol/checkpoint/compound difficulties, compass bearing observer reports, ADD/DROP + RIGHT/LEFT corrections, scoring/accuracy/XP, injected rng, pure). Components:src/components/frontend/minigames/call-for-fire/(CallForFireArena,FireMissionBoard,CallForFireLeaderboard). ActionsubmitCallForFireResultvalidates result bounds, updates profile stats, awards XP + chips, emitsminigame:call-for-fire, and records the ledger entry (accuracy is distance-to-target on a win, null on a loss). - Leaderboards match active players by user id (not display name) — see commit
72715c4if leaderboard queries look wrong.
Periods, achievements & the game registry
Anchored 14-day scoring periods, close-time achievements, and a registry that lets games be phased in and out without losing history. Full behavior is documented in the code; the invariants are:
- Scope: only the Core five (flappy, eod, radio, qualification, opord) score periods. Poker and Blackjack keep their all-time profile boards and are out of periods.
- Anchor:
minigame-rules.anchorDate(default2026-10-12T00:00:00Z) starts Period 1 and is treated as immutable; changing it re-slices and re-labels every period. All math is UTC. - Ledger:
minigame-entriesis an append-only row per completed scored run, written ONLY by the five submit actions throughrecordMinigameEntry(src/lib/minigames/periods/record.ts), which swallows failures so a ledger hiccup never breaks a submission. Each row carriesoccurredAt(the run's own instant) plus itsperiod. - Boards & awards:
src/lib/minigames/periods/boards.tsis pure. Best score ranks each board, the top-N placement ladder (default 10) sums across the Core boards, and ties break on raw period score then earliest submission. Period awards: period-champion, diligence, dedication, precision (minprecisionMinAttempts), most-improved (skipped in Period 1). - Close pipeline:
src/lib/minigames/periods/lifecycle.tscloses a period, writes itsachievementsrows and marks it closed. Idempotent: the status is re-checked before committing and theachievementsunique key (type:windowStart:user) makes a duplicate close insert nothing.closeCalendarWindowsadditionally crowns Player of the Month and Player of the Year for completed calendar windows (scored by runoccurredAt; the first window of each kind is partial). - Tick & override: the
period-tickbin (src/scripts/periodTick.ts, external cron) runs the sweep; the admin close/reopen control (src/components/admin/minigames/PeriodCloseControl.tsx→POST /api/minigame-periods/close, permissionminigame-periods:close) is the manual override. - Registry:
minigamesdrives the sidebar grouping and period scoring. Retired games leave the nav and stop accruing next-period points while their ledger history stays. Period scoring uses core games withcountsForPeriods;loadMinigameRegistryfalls back toBUILTIN_MINIGAMESif the collection is empty. - Surfaces:
/minigames/leaderboards(period selector + game tabs + achievements honor roll, fed byGET /api/minigames/leaderboards?period=current|<id>|all-time) and aPeriodStandingsCardon each Core game page. All-Time reads the untouchedprofiles.progression.minigames.*bests. - Notifications: winners are notified in-app on close (
minigame:achievement, muteable); the Discord bot servicesrc/bot/services/achievementAnnouncements.tsposts ONE embed per window toDISCORD_ANNOUNCE_CHANNEL_IDand stampsannouncedAt+discordMessageId. - Upcoming games: a registry row with
status: "upcoming"shows in the sidebar greyed out and non-interactive (a hoverable row, not a disabled menu item, because a disabled item setspointer-events: noneand would swallow its tooltip). The tooltip and the game page carry a countdown to the optionalestimatedReleaseDate. Upcoming games are excluded from the leaderboards, and their page rendersMinigameComingSooninstead of the arena. The date is display only: the game goes live when an admin flipsstatusto active. Countdown formatting:src/lib/minigames/countdown.ts; page gate:getMinigameReleaseStateplus a per-page check.