1
0
Fork 0
polaris-task-force/src/components/frontend/minigames/eod/EodArena.tsx
Z8MB1E 3c774279aa feat(minigames): superuser developer console dock across all ten games
Adds a shared fixed-position debugging dock (Controls/State/Log tabs) gated
to dynamic superusers, mounted per minigame. Multiplayer games gain synced
server-authoritative admin commands with [dev-admin] audit logging: poker
(force fold, force street, per-viewer reveal-all, clock control, stack
adjust, force expire), blackjack (bankroll adjust, next-card injection,
dealer override, force expire), bomperator (pure applyAdminCommand: crates,
pickups, eliminate, freeze, sudden death, timer, end round; mirrored over
the arena REST path), and CFF Versus (reveal fleets, force shot outcome,
skip turn). Solo games get client-side tuning via persisted dev settings:
flappy physics sliders plus pause and invincibility, EOD layout reveal and
seeded boards, radio transcript view and timer freeze, aim trainer seed and
difficulty overrides plus hitbox overlay, OPORD answer reveal and study
window, call-for-fire target reveal, seeded grids, and free corrections.

Includes 26 new integration specs (command purity, gating, audit lines) and
a poker e2e smoke for the dock. Plan: Minigame Developer Console.
2026-10-20 12:48:27 -04:00

91 lines
3.3 KiB
TypeScript

"use client";
import { useCallback, useEffect, useState } from "react";
import type { EodDifficulty, EodStats } from "@/app/(frontend)/minigames/eod/actions";
import { isEodUnlocked } from "@/lib/minigames/custom/eod";
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
import { useSidebar } from "@/components/ui/sidebar";
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
import { EodLeaderboard } from "./EodLeaderboard";
import { MinesweeperBoard } from "./MinesweeperBoard";
export function EodArena({
initialStats,
currentUserId,
isSuperuser = false,
}: {
initialStats: EodStats;
currentUserId: number | string;
isSuperuser?: boolean;
}) {
const [refreshKey, setRefreshKey] = useState(0);
const [playing, setPlaying] = useState(false);
const [selectedDifficulty, setSelectedDifficulty] = useState<EodDifficulty>("training");
const { isMobile, setOpenMobile } = useSidebar();
const activeTeams = useRealtimePresence("eod", playing, true);
const onPhaseChange = useCallback((phase: "ready" | "playing" | "over") => {
setPlaying(phase === "playing");
}, []);
const customUnlocked = isEodUnlocked({
bestTrainingTime: initialStats.bestTrainingTime,
bestPerimeterTime: initialStats.bestPerimeterTime,
bestSupplyRoadTime: initialStats.bestSupplyRoadTime,
});
const clearedSectors = [
initialStats.bestTrainingTime,
initialStats.bestPerimeterTime,
].filter((time) => time > 0).length;
useEffect(() => {
if (playing && isMobile) setOpenMobile(false);
}, [isMobile, playing, setOpenMobile]);
return (
<div className="flex flex-col items-center gap-6">
{customUnlocked && (
<UgcLinkButton
href="/minigames/eod/custom"
title="UGC Minefields"
subtitle="Play, compete for, and create custom minefields you can share with other unit members! You can even earn XP for playing maps, and as an author, every payout on your map nets you some XP, too."
unlocked={customUnlocked}
className="max-w-5xl"
/>
)}
{!customUnlocked && (
<UnlockNotice
title="custom minefields"
requirement="you have cleared Training Pad and FOB Perimeter"
progress={`${clearedSectors} of 2 sectors cleared`}
/>
)}
<MinesweeperBoard
initialStats={initialStats}
onGameRecorded={() => setRefreshKey((key) => key + 1)}
onPhaseChange={onPhaseChange}
onDifficultyChange={setSelectedDifficulty}
isSuperuser={isSuperuser}
/>
<PeriodStandingsCard
gameKey="eod"
icon="Bomb"
refreshKey={refreshKey}
currentUserId={currentUserId}
presence={{ participants: activeTeams, noun: "team" }}
className="max-w-[520px]"
/>
<AllTimeLeaderboard>
<EodLeaderboard
refreshKey={refreshKey}
currentUserId={currentUserId}
activeTeams={activeTeams}
difficulty={selectedDifficulty}
onDifficultyChange={setSelectedDifficulty}
/>
</AllTimeLeaderboard>
</div>
);
}