Add a "phasingOut" minigame status and an `estimatedRemovalDate` field so a game can be announced as leaving soon while staying fully playable and keeping scoring periods (unlike retired games). Visibility is the only difference: - Sidebar badge + tooltip (amber "Phasing out", countdown to removal) in NavMinigames, via new phasingOutTooltip in countdown.ts. - In-game banner (PhasingOutBanner) on all 9 game pages, wired from getMinigameReleaseState (added the fetch to call-for-fire, which lacked it). - registry.ts status union + field; loadRegistry.ts maps the field; config status select + estimatedRemovalDate date field added. - Migration adds the enum value and column (idempotent); types + db schema regenerated. Adds tests for visibility, round-trip, and period scoring; updates the minigames domain guide.
95 lines
3.3 KiB
TypeScript
95 lines
3.3 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 { MinigameComingSoon } from "@/components/frontend/minigames/MinigameComingSoon";
|
|
import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBanner";
|
|
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
|
import { Spade } from "lucide-react";
|
|
import { PokerArena } from "@/components/frontend/minigames/poker/PokerArena";
|
|
import { readPokerStats } from "@/lib/minigames/poker/stats";
|
|
import { isSuperuser, superuserUserIds } from "@/utils/access-control/hasPermission";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Poker: Polaris Task Force",
|
|
description: "A multiplayer Texas Hold'em training table for Polaris Task Force operators.",
|
|
};
|
|
|
|
interface PokerPageProps {
|
|
searchParams: Promise<{
|
|
table?: string | string[];
|
|
}>;
|
|
}
|
|
|
|
export default async function PokerPage({ searchParams }: PokerPageProps) {
|
|
const headers = await nextHeaders();
|
|
const payload = await getPayload({ config });
|
|
const { user } = await payload.auth({ headers, canSetHeaders: false });
|
|
|
|
if (!user) {
|
|
redirect(`/login?returnTo=${encodeURIComponent("/minigames/poker")}`);
|
|
}
|
|
|
|
const release = await getMinigameReleaseState(payload, "poker");
|
|
if (release.upcoming && release.game) {
|
|
return <MinigameComingSoon game={release.game} />;
|
|
}
|
|
|
|
const superuser = await isSuperuser(payload, user);
|
|
const superuserIds = await superuserUserIds(payload);
|
|
|
|
const profileRes = await payload.find({
|
|
collection: "profiles",
|
|
where: { user: { equals: Number(user.id) } },
|
|
limit: 1,
|
|
depth: 0,
|
|
overrideAccess: true,
|
|
select: {
|
|
progression: {
|
|
minigames: true,
|
|
chipBank: true,
|
|
chipBankRefilledAt: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
const stats = readPokerStats(profileRes.docs[0]);
|
|
const progressionDoc = (profileRes.docs[0]?.progression ?? {}) as {
|
|
chipBank?: number | null;
|
|
chipBankRefilledAt?: string | null;
|
|
};
|
|
const initialChipBank = progressionDoc.chipBank ?? 0;
|
|
const initialChipTopUpAt = progressionDoc.chipBankRefilledAt ?? null;
|
|
const params = await searchParams;
|
|
const tableValue = params.table;
|
|
const initialTableId = Array.isArray(tableValue) ? tableValue[0] : tableValue;
|
|
|
|
return (
|
|
<div className="flex 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">
|
|
<Spade className="size-5 text-muted-foreground" />
|
|
<h1 className="text-lg font-semibold">Poker</h1>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">
|
|
Sit down for a multiplayer Texas Hold'em game. Read the table, manage your stack, and
|
|
outlast the field.
|
|
</p>
|
|
</div>
|
|
|
|
<PokerArena
|
|
initialStats={stats}
|
|
currentUserId={Number(user.id)}
|
|
initialTableId={initialTableId}
|
|
isSuperuser={superuser}
|
|
superuserIds={superuserIds}
|
|
initialChipBank={initialChipBank}
|
|
initialChipTopUpAt={initialChipTopUpAt}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|