Build MVP: launcher, constructor, and AI game generation

A self-hosted, Roblox-flavored game platform: browse/play published
browser games, build them by hand or by describing them to an LLM.
Fully independent from top-tickets — separate repo, DB, port (8082).

- Auth: email+password accounts (argon2, httpOnly session cookies),
  no admin/agent split — every account can create and play.
- Three game templates (quiz, clicker, maze), each a zod schema paired
  with a Phaser 4 Scene that renders purely from a validated instance
  of that schema — manual and AI-generated games hit the same
  renderer, so a saved game is always guaranteed to load and run. The
  maze schema BFS-validates that the exit is reachable from the start.
- Manual constructor: per-template builder forms, draft/publish/edit/
  delete, a launcher grid of published games, a full-bleed play page.
- AI generation: Anthropic API key configured under Settings → AI
  (encrypted at rest, validated with a live call before saving, same
  shape as top-tickets' mailbox/LDAP settings). Generation uses the
  SDK's zodOutputFormat/messages.parse to force schema-shaped JSON
  output, with one retry feeding back the validation error. Output
  always prefills the manual builder for review — never auto-published
  blind. Clean, distinct error message when no key is configured yet
  (no silent fallback exists here, so it doesn't pretend one does).
- Docker Compose on port 8082 (bakes in the busy_timeout=30000 SQLite
  pragma from day one — top-tickets hit this build-time race twice).

Deferred: more templates/genres, drag-and-drop level editor, likes/
leaderboards, AI-generated sprite assets, multiplayer, moderation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QcXH24ky6zjk2UyK5oZUPH
This commit is contained in:
ogrechkoandClaude Sonnet 5 committed 2026-07-31 17:40:30 +00:00
1 parent df16c90832
commit c9a6c27a7a
60 files changed
+5601 -93

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
import { redirect, notFound } from "next/navigation";
import Link from "next/link";
import { Play } from "lucide-react";
import { getCurrentSession } from "@/lib/auth/session";
import { getGameById } from "@/lib/games/service";
import { TEMPLATE_LABELS } from "@/lib/games/types";
import { QuizBuilder } from "@/components/builders/quiz-builder";
import { ClickerBuilder } from "@/components/builders/clicker-builder";
import { MazeBuilder } from "@/components/builders/maze-builder";
import type { QuizDefinition } from "@/lib/games/quiz";
import type { ClickerDefinition } from "@/lib/games/clicker";
import type { MazeDefinition } from "@/lib/games/maze";
export default async function EditGamePage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const session = await getCurrentSession();
if (!session) redirect("/login");
const game = await getGameById(id);
if (!game || game.ownerId !== session.user.id) notFound();
return (
<div className="mx-auto w-full max-w-2xl flex-1 px-4 py-8 sm:px-6">
<div className="mb-6 flex items-center justify-between gap-4">
<div>
<span className="badge mb-1">{TEMPLATE_LABELS[game.templateType]}</span>
<h1 className="font-display text-2xl font-bold tracking-tight">{game.title}</h1>
</div>
<Link href={`/play/${game.id}`} className="btn btn-ghost">
<Play size={14} />
Играть
</Link>
</div>
{game.templateType === "quiz" && (
<QuizBuilder
mode="edit"
gameId={game.id}
initialTitle={game.title}
initialDescription={game.description ?? ""}
initialDefinition={game.definition as QuizDefinition}
/>
)}
{game.templateType === "clicker" && (
<ClickerBuilder
mode="edit"
gameId={game.id}
initialTitle={game.title}
initialDescription={game.description ?? ""}
initialDefinition={game.definition as ClickerDefinition}
/>
)}
{game.templateType === "maze" && (
<MazeBuilder
mode="edit"
gameId={game.id}
initialTitle={game.title}
initialDescription={game.description ?? ""}
initialDefinition={game.definition as MazeDefinition}
/>
)}
</div>
);
}
+19
View File
@@ -0,0 +1,19 @@
import { redirect } from "next/navigation";
import { getCurrentSession } from "@/lib/auth/session";
import { listGamesByOwner } from "@/lib/games/service";
import { MyGamesList } from "@/components/my-games-list";
export default async function MyGamesPage() {
const session = await getCurrentSession();
if (!session) redirect("/login");
const games = await listGamesByOwner(session.user.id);
return (
<div className="mx-auto w-full max-w-3xl flex-1 px-4 py-8 sm:px-6">
<h1 className="mb-1 font-display text-2xl font-bold tracking-tight">Мои игры</h1>
<p className="mb-6 text-sm text-text-muted">Управляйте своими играми — редактируйте, публикуйте, удаляйте.</p>
<MyGamesList initialGames={games} />
</div>
);
}