63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { 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 { Bird } from "lucide-react";
|
|
import { FlappyArena } from "@/components/frontend/flappy/FlappyArena";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Flight Simulator — Polaris Task Force",
|
|
description: "Side training sim. Definitely not Flappy Bird.",
|
|
};
|
|
|
|
export default async function FlappyPage() {
|
|
const headers = await nextHeaders();
|
|
const payloadConfig = await config;
|
|
const payload = await getPayload({ config });
|
|
const { user } = await payload.auth({ headers, canSetHeaders: false });
|
|
|
|
if (!user) {
|
|
redirect("/login");
|
|
}
|
|
|
|
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 flappy = profileRes.docs[0]?.progression?.minigames?.flappyBird ?? {};
|
|
|
|
const stats = {
|
|
gamesPlayed: flappy.gamesPlayed ?? 0,
|
|
totalPasses: flappy.totalPasses ?? 0,
|
|
bestScore: flappy.bestScore ?? 0,
|
|
flappyXp: flappy.xpEarned ?? 0,
|
|
xpEarned: 0,
|
|
};
|
|
|
|
return (
|
|
<div className="p-5 flex flex-col gap-6">
|
|
<div className="flex flex-col gap-1">
|
|
<div className="flex items-center gap-2">
|
|
<Bird className="size-5 text-muted-foreground" />
|
|
<h1 className="text-lg font-semibold">Flight Simulator</h1>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">
|
|
An unofficial side activity. (Definitely not Flappy Bird.) Earn 1 XP per 15 obstacles
|
|
passed in a single run.
|
|
</p>
|
|
</div>
|
|
|
|
<FlappyArena initialStats={stats} currentUserId={user.id as number} />
|
|
</div>
|
|
);
|
|
}
|