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

+118
View File
@@ -0,0 +1,118 @@
import Phaser from "phaser";
import type { ClickerDefinition, ClickerUpgrade, GameResult } from "../types";
const COLORS = {
bg: 0x14162a,
target: 0x4f46e5,
row: 0x23264a,
rowOwned: 0x0d3d38,
rowDisabled: 0x1a1c33,
};
interface UpgradeRow {
bg: Phaser.GameObjects.Rectangle;
label: Phaser.GameObjects.Text;
upgrade: ClickerUpgrade;
index: number;
}
export class ClickerScene extends Phaser.Scene {
private definition!: ClickerDefinition;
private onFinish?: (result: GameResult) => void;
private score = 0;
private pointsPerClick = 1;
private pointsPerSecond = 0;
private ownedUpgrades = new Set<number>();
private scoreText!: Phaser.GameObjects.Text;
private upgradeRows: UpgradeRow[] = [];
private finished = false;
constructor() {
super("ClickerScene");
}
create() {
this.definition = this.registry.get("definition");
this.onFinish = this.registry.get("onFinish");
this.score = 0;
this.pointsPerClick = this.definition.startingPointsPerClick;
this.pointsPerSecond = 0;
this.ownedUpgrades = new Set();
this.upgradeRows = [];
this.finished = false;
this.cameras.main.setBackgroundColor(COLORS.bg);
this.scoreText = this.add
.text(480, 30, "", { fontFamily: "sans-serif", fontSize: "24px", color: "#eef0fb", align: "center" })
.setOrigin(0.5, 0);
const target = this.add.circle(480, 200, 90, COLORS.target).setInteractive({ useHandCursor: true });
const targetLabel = this.add
.text(480, 200, this.definition.targetLabel, { fontFamily: "sans-serif", fontSize: "20px", color: "#ffffff" })
.setOrigin(0.5);
target.on("pointerdown", () => {
if (this.finished) return;
this.score += this.pointsPerClick;
this.tweens.add({ targets: [target, targetLabel], scale: 0.92, duration: 60, yoyo: true });
this.refresh();
});
this.definition.upgrades.forEach((upgrade, index) => {
const y = 340 + index * 54;
const bg = this.add
.rectangle(480, y, 700, 44, COLORS.row)
.setStrokeStyle(1, 0x4f46e5)
.setInteractive({ useHandCursor: true });
const label = this.add
.text(480, y, "", { fontFamily: "sans-serif", fontSize: "15px", color: "#eef0fb" })
.setOrigin(0.5);
bg.on("pointerdown", () => this.buyUpgrade(index));
this.upgradeRows.push({ bg, label, upgrade, index });
});
this.time.addEvent({
delay: 1000,
loop: true,
callback: () => {
if (this.finished) return;
this.score += this.pointsPerSecond;
this.refresh();
},
});
this.refresh();
}
private buyUpgrade(index: number) {
if (this.finished || this.ownedUpgrades.has(index)) return;
const upgrade = this.definition.upgrades[index];
if (this.score < upgrade.cost) return;
this.score -= upgrade.cost;
this.pointsPerClick += upgrade.pointsPerClickBonus;
this.pointsPerSecond += upgrade.pointsPerSecondBonus;
this.ownedUpgrades.add(index);
this.refresh();
}
private refresh() {
this.scoreText.setText(
`${Math.floor(this.score)} / ${this.definition.targetScore}\n+${this.pointsPerClick}/клик +${this.pointsPerSecond}/сек`,
);
this.upgradeRows.forEach(({ bg, label, upgrade, index }) => {
const owned = this.ownedUpgrades.has(index);
const affordable = this.score >= upgrade.cost;
label.setText(owned ? `${upgrade.name} — куплено` : `${upgrade.name} — ${upgrade.cost}`);
bg.setFillStyle(owned ? COLORS.rowOwned : affordable ? COLORS.row : COLORS.rowDisabled);
bg.disableInteractive();
if (!owned && affordable) bg.setInteractive({ useHandCursor: true });
});
if (!this.finished && this.score >= this.definition.targetScore) {
this.finished = true;
this.onFinish?.({ won: true, score: Math.floor(this.score) });
}
}
}