1
0
Fork 0
polaris-task-force/src/app/(frontend)/minigames/opord/page.tsx
Z8MB1E 33f3f7aa75 feat(minigames): add phasing-out status with estimated removal date
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.
2026-10-14 23:51:37 -04:00

83 lines
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 { ScrollText } from "lucide-react";
import { OpordArena } from "@/components/frontend/minigames/opord/OpordArena";
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
export const metadata: Metadata = {
title: "OPORD Recall (Polaris Task Force)",
description: "Study a live operations order, then recall the details under pressure.",
};
export default async function OpordPage() {
const headers = await nextHeaders();
const payloadConfig = await config;
const payload = await getPayload({ config: payloadConfig });
const { user } = await payload.auth({ headers, canSetHeaders: false });
if (!user) {
redirect(`/login?returnTo=${encodeURIComponent("/minigames/opord")}`);
}
const release = await getMinigameReleaseState(payload, "opord");
if (release.upcoming && release.game) {
return <MinigameComingSoon game={release.game} />;
}
const profileRes = await payload.find({
collection: "profiles",
where: { user: { equals: user.id as number } },
limit: 1,
depth: 0,
overrideAccess: true,
select: {
progression: {
minigames: true,
},
},
});
const opordRecall = profileRes.docs[0]?.progression?.minigames?.opordRecall ?? {};
const stats = {
gamesPlayed: opordRecall.gamesPlayed ?? 0,
bestScore: opordRecall.bestScore ?? 0,
bestAccuracy: opordRecall.bestAccuracy ?? 0,
recruitBestScore: opordRecall.recruitBestScore ?? 0,
veteranBestScore: opordRecall.veteranBestScore ?? 0,
eliteBestScore: opordRecall.eliteBestScore ?? 0,
opordRecallXp: opordRecall.xpEarned ?? 0,
xpEarned: 0,
score: 0,
accuracy: 0,
};
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">
<ScrollText className="size-5 text-muted-foreground" />
<h1 className="text-lg font-semibold">OPORD Recall</h1>
</div>
<p className="text-sm text-muted-foreground">
Study a live operations order, then recall the details under pressure.
</p>
</div>
<OpordArena initialStats={stats} currentUserId={user.id as number} />
<div className="flex flex-col gap-2">
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
<PeriodStandingsCard gameKey="opord" icon="FileTextIcon" currentUserId={user.id as number} />
</div>
</div>
);
}