Add a 2-8 player free-for-all Bomberman-style charge-clearing drill at /minigames/bomperator, category multiplayer. Pure engine plus a single-instance in-memory match registry, mirroring the call-for-fire-versus split but upgraded from turn-based to a fixed ~10 Hz tick loop. Engine (src/lib/minigames/bomperator): seeded RNG via state.rngState/gridSeed; grid is 15x13 with border, even/even pillars and seeded crates; classic pickups bomb/range/speed/kick. Movement is grid-locked with sub-cell interpolation, charges fuse about 2.5s, cross-flames stop at walls, crates are destroyed and charges chain-detonate and kick-push. Round ends at one alive; sudden death spawns random explosions after 150s with a draw guard. Registry (registry.ts): one setInterval per live match started on startMatch and cleared on complete/dissolve; globalThis-anchored map; holds seats across a reconnect window then eliminates; below two active seats it dissolves. On a manual end, broadcasts a bomperator-terminated event so remaining players see a toast, then awards rewards via stats.ts (minigame:bomperator, profile group bomperator: matchesPlayed/matchWins/roundsWon/kills/xpEarned). Clients POST rate-limited inputs and poll fetchBomperatorMatch; the SSE bus pushes snapshots with a guarded slow-poll fallback. Registry row ships as upcoming so the page renders the coming-soon shell until an admin flips it active. Adds the migration for the stats group, the minigame:bomperator event type, XP aggregation on the profile, generated types, and real-time event wiring.
87 lines
2.9 KiB
TypeScript
87 lines
2.9 KiB
TypeScript
import type { Metadata } from "next";
|
|
import config from "@payload-config";
|
|
import { getPayload } from "payload";
|
|
import { headers as nextHeaders } from "next/headers";
|
|
import { redirect } from "next/navigation";
|
|
import { Bomb } from "lucide-react";
|
|
import { MinigameComingSoon } from "@/components/frontend/minigames/MinigameComingSoon";
|
|
import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBanner";
|
|
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
|
import { BomperatorArena } from "@/components/frontend/minigames/bomperator/BomperatorArena";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Ordnance Disposal (Polaris Task Force)",
|
|
description:
|
|
"Multiplayer charge-clearing drill: a real-time free-for-all on the depot grid. Last technician standing wins.",
|
|
};
|
|
|
|
interface BomperatorPageProps {
|
|
searchParams: Promise<{
|
|
match?: string | string[];
|
|
}>;
|
|
}
|
|
|
|
export default async function BomperatorPage({ searchParams }: BomperatorPageProps) {
|
|
const headers = await nextHeaders();
|
|
const payload = await getPayload({ config: await config });
|
|
const { user } = await payload.auth({ headers, canSetHeaders: false });
|
|
|
|
if (!user) {
|
|
redirect(`/login?returnTo=${encodeURIComponent("/minigames/bomperator")}`);
|
|
}
|
|
|
|
const release = await getMinigameReleaseState(payload, "bomperator");
|
|
if (release.upcoming && release.game) {
|
|
return <MinigameComingSoon game={release.game} />;
|
|
}
|
|
|
|
const profileRes = await payload.find({
|
|
collection: "profiles",
|
|
where: { user: { equals: Number(user.id) } },
|
|
limit: 1,
|
|
depth: 0,
|
|
overrideAccess: true,
|
|
select: {
|
|
progression: {
|
|
minigames: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
const bomp = profileRes.docs[0]?.progression?.minigames?.bomperator ?? {};
|
|
const stats = {
|
|
matchesPlayed: bomp.matchesPlayed ?? 0,
|
|
matchWins: bomp.matchWins ?? 0,
|
|
roundsWon: bomp.roundsWon ?? 0,
|
|
kills: bomp.kills ?? 0,
|
|
xpEarned: bomp.xpEarned ?? 0,
|
|
};
|
|
|
|
const params = await searchParams;
|
|
const matchValue = params.match;
|
|
const initialMatchId = Array.isArray(matchValue) ? matchValue[0] : matchValue;
|
|
|
|
return (
|
|
<div className="flex min-w-0 flex-col gap-6 p-5">
|
|
{release.game?.status === "phasingOut" && (
|
|
<PhasingOutBanner estimatedRemovalDate={release.game.estimatedRemovalDate} />
|
|
)}
|
|
<div className="flex flex-col gap-1">
|
|
<div className="flex items-center gap-2">
|
|
<Bomb className="size-5 text-muted-foreground" />
|
|
<h1 className="text-lg font-semibold">Ordnance Disposal</h1>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">
|
|
A real-time free-for-all on the depot grid. Grab power-ups from supply stacks, plant charges,
|
|
and blow your rivals off the field. Last technician standing takes the round.
|
|
</p>
|
|
</div>
|
|
|
|
<BomperatorArena
|
|
initialStats={stats}
|
|
currentUserId={Number(user.id)}
|
|
initialMatchId={initialMatchId}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|