feat: initial project scaffold with all three D&D tools
This commit is contained in:
1 parent
48b414dd7a
commit
3e93f0df9a
33 files changed
+2312
-189
No files matched your search
@@ -0,0 +1,7 @@
|
||||
# LLM Proxy (get from vault: sk-lp-*)
|
||||
LLM_API_KEY=sk-lp-your-key-here
|
||||
LLM_BASE_URL=https://llm.molberg.cloud/v1
|
||||
|
||||
# Optional: override default model (gpt-4o)
|
||||
LLM_MODEL=gpt-4o
|
||||
LLM_MODEL_FALLBACK=gpt-4o-mini
|
||||
+19
-31
@@ -1,41 +1,29 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/versions
|
||||
# Next.js
|
||||
.next/
|
||||
out/
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
# Debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
# TypeScript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# Misc
|
||||
*.pem
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json package-lock.json* ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy source
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
# Copy built artifacts
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
@@ -1,36 +1,90 @@
|
||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||
# DungeonMaster.tools
|
||||
|
||||
AI-powered tools for D&D 5th Edition Dungeon Masters. Generate encounters, NPCs, and quest hooks instantly.
|
||||
|
||||
## Features
|
||||
|
||||
- **Encounter Generator** — Generate balanced, thematic combat encounters with monsters, terrain, tactics, and loot
|
||||
- **NPC Generator** — Create vivid, memorable NPCs with personality, motivations, quirks, and ready-to-use adventure hooks
|
||||
- **Quest Hooks** — Spark your next adventure with creative quest premises, NPCs, locations, and complications
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- **Framework:** Next.js 15 (App Router)
|
||||
- **Styling:** Tailwind CSS + shadcn/ui
|
||||
- **AI:** LLM Proxy (OpenAI-compatible API)
|
||||
- **Deployment:** Coolify (Docker)
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
### Prerequisites
|
||||
|
||||
- Node.js 20+
|
||||
- npm or pnpm
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/Zebratic/dungeonmaster-tools.git
|
||||
cd dungeonmaster-tools
|
||||
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Copy environment variables
|
||||
cp .env.example .env.local
|
||||
# Then edit .env.local and add your LLM API key
|
||||
```
|
||||
|
||||
### Development
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
Open [http://localhost:3000](http://localhost:3000) to start using the tools.
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
### Production Build
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
```bash
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
## Learn More
|
||||
## Configuration
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
### Environment Variables
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
| Variable | Description | Default |
|
||||
|---|---|---|
|
||||
| `LLM_API_KEY` | Your LLM Proxy API key (sk-lp-xxx) | Required |
|
||||
| `LLM_BASE_URL` | LLM Proxy base URL | `https://llm.molberg.cloud/v1` |
|
||||
| `LLM_MODEL` | Default model | `gpt-4o` |
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||
## Project Structure
|
||||
|
||||
## Deploy on Vercel
|
||||
```
|
||||
app/
|
||||
├── page.tsx # Landing page
|
||||
├── encounters/page.tsx # Encounter Generator
|
||||
├── npc/page.tsx # NPC Generator
|
||||
└── quest-hooks/page.tsx # Quest Hooks Generator
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
components/
|
||||
├── nav.tsx # Site navigation
|
||||
├── tool-card.tsx # Homepage tool cards
|
||||
├── loading-dice.tsx # Loading animation
|
||||
└── result-card.tsx # Generated content display
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||
lib/
|
||||
├── llm.ts # LLM Proxy client
|
||||
├── types.ts # Shared TypeScript types
|
||||
└── prompts/ # AI prompt templates
|
||||
|
||||
app/[tool]/actions.ts # Server actions for each tool
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,42 @@
|
||||
"use server";
|
||||
|
||||
import { z } from "zod";
|
||||
import { callLLM } from "@/lib/llm";
|
||||
import { SYSTEM_PROMPT, buildEncounterPrompt } from "@/lib/prompts/encounters";
|
||||
import type { EncounterResult } from "@/lib/types";
|
||||
|
||||
const EncounterFormSchema = z.object({
|
||||
difficulty: z.enum(["Easy", "Medium", "Hard", "Deadly"]),
|
||||
partySize: z.number().min(1).max(8),
|
||||
crMin: z.number().min(0).max(30),
|
||||
crMax: z.number().min(0).max(30),
|
||||
terrain: z.string().min(1),
|
||||
monsterTypes: z.array(z.string()),
|
||||
});
|
||||
|
||||
export async function generateEncounter(
|
||||
formData: z.infer<typeof EncounterFormSchema>
|
||||
): Promise<EncounterResult> {
|
||||
const parsed = EncounterFormSchema.parse(formData);
|
||||
|
||||
if (parsed.crMin > parsed.crMax) {
|
||||
throw new Error("Min CR cannot be greater than Max CR");
|
||||
}
|
||||
|
||||
const userPrompt = buildEncounterPrompt(parsed);
|
||||
|
||||
let raw: string;
|
||||
try {
|
||||
raw = await callLLM(SYSTEM_PROMPT, userPrompt);
|
||||
} catch (e) {
|
||||
// Retry once
|
||||
raw = await callLLM(SYSTEM_PROMPT, userPrompt);
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as EncounterResult;
|
||||
return parsed;
|
||||
} catch {
|
||||
throw new Error("Failed to parse encounter response. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Nav } from "@/components/nav";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Slider } from "@/components/ui/slider";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { LoadingDice } from "@/components/loading-dice";
|
||||
import { ResultCard, Field, ListField, SectionDivider } from "@/components/result-card";
|
||||
import { generateEncounter } from "./actions";
|
||||
import { TERRAINS, MONSTER_TYPES, ENCOUNTER_DIFFICULTIES, type EncounterResult } from "@/lib/types";
|
||||
import { Swords, RefreshCw, Copy, Check } from "lucide-react";
|
||||
|
||||
export default function EncountersPage() {
|
||||
const [difficulty, setDifficulty] = useState<"Easy" | "Medium" | "Hard" | "Deadly">("Medium");
|
||||
const [partySize, setPartySize] = useState(4);
|
||||
const [crRange, setCrRange] = useState<[number, number]>([1, 5]);
|
||||
const [terrain, setTerrain] = useState("Forest");
|
||||
const [selectedTypes, setSelectedTypes] = useState<string[]>([]);
|
||||
const [result, setResult] = useState<EncounterResult | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const toggleMonsterType = (type: string) => {
|
||||
setSelectedTypes((prev) =>
|
||||
prev.includes(type) ? prev.filter((t) => t !== type) : [...prev, type]
|
||||
);
|
||||
};
|
||||
|
||||
const handleGenerate = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResult(null);
|
||||
try {
|
||||
const res = await generateEncounter({
|
||||
difficulty,
|
||||
partySize,
|
||||
crMin: crRange[0],
|
||||
crMax: crRange[1],
|
||||
terrain,
|
||||
monsterTypes: selectedTypes,
|
||||
});
|
||||
setResult(res);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to generate encounter");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopy = () => {
|
||||
if (!result) return;
|
||||
const text = `${result.title}\n\n${result.description}\n\nMonsters:\n${result.monsters.map(m => `• ${m.count}x ${m.name} (CR ${m.cr})`).join("\n")}\n\nLoot: ${result.loot}\n\nTactics: ${result.tactics}\n\nNotes: ${result.notes}`;
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<Nav />
|
||||
<main className="flex-1 mx-auto w-full max-w-3xl px-4 py-8 sm:px-6">
|
||||
<div className="mb-8">
|
||||
<h1
|
||||
className="mb-2 font-heading text-3xl font-bold text-gradient-gold sm:text-4xl"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
Encounter Generator
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Generate balanced, thematic D&D 5e encounters in seconds.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Form */}
|
||||
<Card className="mb-6 border-border/50 bg-card/80">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 font-heading text-lg" style={{ fontFamily: "var(--font-cinzel), serif" }}>
|
||||
<Swords className="h-5 w-5 text-[var(--gold)]" />
|
||||
Configure Encounter
|
||||
</CardTitle>
|
||||
<CardDescription>Adjust the parameters to generate your encounter</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Difficulty */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Difficulty</Label>
|
||||
<div className="grid grid-cols-2 gap-2 sm:grid-cols-4">
|
||||
{ENCOUNTER_DIFFICULTIES.map((d) => (
|
||||
<button
|
||||
key={d}
|
||||
onClick={() => setDifficulty(d as typeof difficulty)}
|
||||
className={`rounded-md border px-3 py-2 text-sm font-medium transition-colors min-h-[44px] ${
|
||||
difficulty === d
|
||||
? "border-[var(--gold)] bg-[var(--gold)]/10 text-[var(--gold)]"
|
||||
: "border-border text-muted-foreground hover:bg-secondary"
|
||||
}`}
|
||||
>
|
||||
{d}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Party Size */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">
|
||||
Party Size: <span className="text-[var(--gold)]">{partySize}</span>
|
||||
</Label>
|
||||
<input
|
||||
type="range"
|
||||
min={1}
|
||||
max={8}
|
||||
value={partySize}
|
||||
onChange={(e) => setPartySize(Number(e.target.value))}
|
||||
className="w-full accent-[var(--gold)]"
|
||||
/>
|
||||
<div className="mt-1 flex justify-between text-xs text-muted-foreground">
|
||||
<span>1</span>
|
||||
<span>8</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* CR Range */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">
|
||||
CR Range: <span className="text-[var(--gold)]">{crRange[0]} – {crRange[1]}</span>
|
||||
</Label>
|
||||
<Slider
|
||||
value={crRange}
|
||||
onValueChange={(val) => setCrRange(val as [number, number])}
|
||||
min={0}
|
||||
max={30}
|
||||
step={1}
|
||||
className="[&_[role=slider]]:bg-[var(--gold)] [&_[role=slider]]:border-[var(--gold)]"
|
||||
/>
|
||||
<div className="mt-1 flex justify-between text-xs text-muted-foreground">
|
||||
<span>0</span>
|
||||
<span>30</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Terrain */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Terrain</Label>
|
||||
<select
|
||||
value={terrain}
|
||||
onChange={(e) => setTerrain(e.target.value)}
|
||||
className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring min-h-[44px]"
|
||||
>
|
||||
{TERRAINS.map((t) => (
|
||||
<option key={t} value={t}>{t}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Monster Types */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">
|
||||
Monster Types{" "}
|
||||
<span className="text-xs text-muted-foreground">(optional)</span>
|
||||
</Label>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{MONSTER_TYPES.map((type) => (
|
||||
<button
|
||||
key={type}
|
||||
onClick={() => toggleMonsterType(type)}
|
||||
className={`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors min-h-[32px] ${
|
||||
selectedTypes.includes(type)
|
||||
? "border-[var(--accent)] bg-[var(--accent)]/20 text-[var(--accent-foreground)]"
|
||||
: "border-border text-muted-foreground hover:bg-secondary"
|
||||
}`}
|
||||
>
|
||||
{type}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Generate Button */}
|
||||
<Button
|
||||
onClick={handleGenerate}
|
||||
disabled={loading}
|
||||
className="w-full min-h-[48px] bg-[var(--gold)] text-black hover:bg-[var(--gold)]/90 font-semibold text-base"
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<RefreshCw className="mr-2 h-4 w-4 animate-spin" />
|
||||
Generating...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Swords className="mr-2 h-4 w-4" />
|
||||
Generate Encounter
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{error && (
|
||||
<p className="text-sm text-destructive">{error}</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Loading State */}
|
||||
{loading && <LoadingDice />}
|
||||
|
||||
{/* Result */}
|
||||
{result && !loading && (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2
|
||||
className="font-heading text-xl font-semibold"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
Your Encounter
|
||||
</h2>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleCopy}
|
||||
className="gap-2 min-h-[36px]"
|
||||
>
|
||||
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
|
||||
{copied ? "Copied!" : "Copy"}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<ResultCard title={result.title} variant="encounter">
|
||||
<Field label="Description">{result.description}</Field>
|
||||
<SectionDivider />
|
||||
|
||||
<ListField
|
||||
label="Monsters"
|
||||
items={result.monsters.map(
|
||||
(m) => `${m.count}x ${m.name} (CR ${m.cr})`
|
||||
)}
|
||||
/>
|
||||
<SectionDivider />
|
||||
|
||||
<Field label="Loot">{result.loot}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="Tactics">{result.tactics}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="DM Notes">{result.notes}</Field>
|
||||
</ResultCard>
|
||||
|
||||
<Button
|
||||
onClick={handleGenerate}
|
||||
variant="outline"
|
||||
className="w-full gap-2 min-h-[44px]"
|
||||
>
|
||||
<RefreshCw className="h-4 w-4" />
|
||||
Generate Another
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+140
-68
@@ -7,9 +7,9 @@
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--font-sans: var(--font-sans);
|
||||
--font-sans: var(--font-crimson-pro);
|
||||
--font-heading: var(--font-cinzel);
|
||||
--font-mono: var(--font-geist-mono);
|
||||
--font-heading: var(--font-sans);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
@@ -30,7 +30,7 @@
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted: var(--minted);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
@@ -46,75 +46,93 @@
|
||||
--radius-2xl: calc(var(--radius) * 1.8);
|
||||
--radius-3xl: calc(var(--radius) * 2.2);
|
||||
--radius-4xl: calc(var(--radius) * 2.6);
|
||||
|
||||
/* Fantasy gold accent */
|
||||
--color-gold: var(--gold);
|
||||
--color-gold-foreground: var(--gold-foreground);
|
||||
/* Fantasy purple accent */
|
||||
--color-arcane: var(--arcane);
|
||||
--color-arcane-foreground: var(--arcane-foreground);
|
||||
}
|
||||
|
||||
:root {
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.87 0 0);
|
||||
--chart-2: oklch(0.556 0 0);
|
||||
--chart-3: oklch(0.439 0 0);
|
||||
--chart-4: oklch(0.371 0 0);
|
||||
--chart-5: oklch(0.269 0 0);
|
||||
--radius: 0.625rem;
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
--background: #0c0a14;
|
||||
--foreground: #e8e4d9;
|
||||
--card: #161220;
|
||||
--card-foreground: #e8e4d9;
|
||||
--popover: #161220;
|
||||
--popover-foreground: #e8e4d9;
|
||||
--primary: #c9a84c;
|
||||
--primary-foreground: #0c0a14;
|
||||
--secondary: #1e1830;
|
||||
--secondary-foreground: #c9a84c;
|
||||
--muted: #1e1830;
|
||||
--muted-foreground: #9b8fb0;
|
||||
--accent: #7c3aed;
|
||||
--accent-foreground: #f0e8ff;
|
||||
--destructive: #dc2626;
|
||||
--border: #2d2640;
|
||||
--input: #2d2640;
|
||||
--ring: #7c3aed;
|
||||
--chart-1: #c9a84c;
|
||||
--chart-2: #7c3aed;
|
||||
--chart-3: #10b981;
|
||||
--chart-4: #f59e0b;
|
||||
--chart-5: #ef4444;
|
||||
--sidebar: #161220;
|
||||
--sidebar-foreground: #e8e4d9;
|
||||
--sidebar-primary: #c9a84c;
|
||||
--sidebar-primary-foreground: #0c0a14;
|
||||
--sidebar-accent: #1e1830;
|
||||
--sidebar-accent-foreground: #c9a84c;
|
||||
--sidebar-border: #2d2640;
|
||||
--sidebar-ring: #7c3aed;
|
||||
--gold: #c9a84c;
|
||||
--gold-foreground: #0c0a14;
|
||||
--arcane: #7c3aed;
|
||||
--arcane-foreground: #f0e8ff;
|
||||
--radius: 0.5rem;
|
||||
--minted: #1e1830;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.205 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.87 0 0);
|
||||
--chart-2: oklch(0.556 0 0);
|
||||
--chart-3: oklch(0.439 0 0);
|
||||
--chart-4: oklch(0.371 0 0);
|
||||
--chart-5: oklch(0.269 0 0);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(1 0 0 / 10%);
|
||||
--sidebar-ring: oklch(0.556 0 0);
|
||||
--background: #0c0a14;
|
||||
--foreground: #e8e4d9;
|
||||
--card: #161220;
|
||||
--card-foreground: #e8e4d9;
|
||||
--popover: #161220;
|
||||
--popover-foreground: #e8e4d9;
|
||||
--primary: #c9a84c;
|
||||
--primary-foreground: #0c0a14;
|
||||
--secondary: #1e1830;
|
||||
--secondary-foreground: #c9a84c;
|
||||
--muted: #1e1830;
|
||||
--muted-foreground: #9b8fb0;
|
||||
--accent: #7c3aed;
|
||||
--accent-foreground: #f0e8ff;
|
||||
--destructive: #dc2626;
|
||||
--border: #2d2640;
|
||||
--input: #2d2640;
|
||||
--ring: #7c3aed;
|
||||
--chart-1: #c9a84c;
|
||||
--chart-2: #7c3aed;
|
||||
--chart-3: #10b981;
|
||||
--chart-4: #f59e0b;
|
||||
--chart-5: #ef4444;
|
||||
--sidebar: #161220;
|
||||
--sidebar-foreground: #e8e4d9;
|
||||
--sidebar-primary: #c9a84c;
|
||||
--sidebar-primary-foreground: #0c0a14;
|
||||
--sidebar-accent: #1e1830;
|
||||
--sidebar-accent-foreground: #c9a84c;
|
||||
--sidebar-border: #2d2640;
|
||||
--sidebar-ring: #7c3aed;
|
||||
--gold: #c9a84c;
|
||||
--gold-foreground: #0c0a14;
|
||||
--arcane: #7c3aed;
|
||||
--arcane-foreground: #f0e8ff;
|
||||
--radius: 0.5rem;
|
||||
--minted: #1e1830;
|
||||
}
|
||||
|
||||
@layer base {
|
||||
@@ -125,6 +143,60 @@
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
html {
|
||||
@apply font-sans;
|
||||
@apply font-sans scroll-smooth;
|
||||
}
|
||||
}
|
||||
|
||||
/* Custom scrollbar for dark fantasy theme */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: #0c0a14;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #2d2640;
|
||||
border-radius: 4px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #7c3aed;
|
||||
}
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.font-heading {
|
||||
font-family: var(--font-cinzel), serif;
|
||||
}
|
||||
|
||||
/* Fantasy glow effects */
|
||||
.glow-gold {
|
||||
box-shadow: 0 0 20px rgba(201, 168, 76, 0.3);
|
||||
}
|
||||
|
||||
.glow-arcane {
|
||||
box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
|
||||
}
|
||||
|
||||
/* Subtle parchment texture overlay */
|
||||
.fantasy-texture {
|
||||
background-image:
|
||||
radial-gradient(ellipse at top, rgba(201, 168, 76, 0.03) 0%, transparent 60%),
|
||||
radial-gradient(ellipse at bottom, rgba(124, 58, 237, 0.03) 0%, transparent 60%);
|
||||
}
|
||||
|
||||
/* Gold gradient text */
|
||||
.text-gradient-gold {
|
||||
background: linear-gradient(135deg, #c9a84c 0%, #f0d78c 50%, #c9a84c 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
/* Arcane gradient border */
|
||||
.border-arcane {
|
||||
border-color: rgba(124, 58, 237, 0.6);
|
||||
}
|
||||
|
||||
.border-gold {
|
||||
border-color: rgba(201, 168, 76, 0.5);
|
||||
}
|
||||
}
|
||||
+19
-12
@@ -1,20 +1,26 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import { Cinzel, Crimson_Pro } from "next/font/google";
|
||||
import "./globals.css";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
const cinzel = Cinzel({
|
||||
variable: "--font-cinzel",
|
||||
subsets: ["latin"],
|
||||
weight: ["400", "500", "600", "700"],
|
||||
});
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: "--font-geist-mono",
|
||||
const crimsonPro = Crimson_Pro({
|
||||
variable: "--font-crimson-pro",
|
||||
subsets: ["latin"],
|
||||
weight: ["300", "400", "500", "600"],
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
title: "DungeonMaster.tools | AI-Powered D&D Tools",
|
||||
description:
|
||||
"AI-powered tools for D&D Dungeon Masters. Generate encounters, NPCs, and quest hooks instantly.",
|
||||
icons: {
|
||||
icon: "/favicon.svg",
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
@@ -23,11 +29,12 @@ export default function RootLayout({
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html
|
||||
lang="en"
|
||||
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
||||
>
|
||||
<body className="min-h-full flex flex-col">{children}</body>
|
||||
<html lang="en" className="dark">
|
||||
<body
|
||||
className={`${cinzel.variable} ${crimsonPro.variable} min-h-screen flex flex-col antialiased fantasy-texture`}
|
||||
>
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
"use server";
|
||||
|
||||
import { z } from "zod";
|
||||
import { callLLM } from "@/lib/llm";
|
||||
import { SYSTEM_PROMPT, buildNPCPrompt } from "@/lib/prompts/npc";
|
||||
import type { NPCResult } from "@/lib/types";
|
||||
|
||||
const NPCFormSchema = z.object({
|
||||
race: z.string().min(1),
|
||||
class: z.string().min(1),
|
||||
alignment: z.string().min(1),
|
||||
traits: z.array(z.string()),
|
||||
tone: z.enum(["Serious", "Lighthearted", "Mysterious", "Ominous"]),
|
||||
});
|
||||
|
||||
export async function generateNPC(
|
||||
formData: z.infer<typeof NPCFormSchema>
|
||||
): Promise<NPCResult> {
|
||||
const parsed = NPCFormSchema.parse(formData);
|
||||
const userPrompt = buildNPCPrompt(parsed);
|
||||
|
||||
let raw: string;
|
||||
try {
|
||||
raw = await callLLM(SYSTEM_PROMPT, userPrompt);
|
||||
} catch (e) {
|
||||
// Retry once
|
||||
raw = await callLLM(SYSTEM_PROMPT, userPrompt);
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as NPCResult;
|
||||
return parsed;
|
||||
} catch {
|
||||
throw new Error("Failed to parse NPC response. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Nav } from "@/components/nav";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { LoadingDice } from "@/components/loading-dice";
|
||||
import { ResultCard, Field, ListField, SectionDivider } from "@/components/result-card";
|
||||
import { generateNPC } from "./actions";
|
||||
import { RACES, CLASSES, ALIGNMENTS, NPC_TRAITS, NPC_TONES, type NPCResult } from "@/lib/types";
|
||||
import { Users, RefreshCw, Copy, Check } from "lucide-react";
|
||||
|
||||
export default function NPCPage() {
|
||||
const [race, setRace] = useState("Human");
|
||||
const [npcClass, setNpcClass] = useState("Fighter");
|
||||
const [alignment, setAlignment] = useState("Any");
|
||||
const [traits, setTraits] = useState<string[]>([]);
|
||||
const [tone, setTone] = useState<"Serious" | "Lighthearted" | "Mysterious" | "Ominous">("Serious");
|
||||
const [result, setResult] = useState<NPCResult | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const toggleTrait = (trait: string) => {
|
||||
setTraits((prev) =>
|
||||
prev.includes(trait) ? prev.filter((t) => t !== trait) : [...prev, trait]
|
||||
);
|
||||
};
|
||||
|
||||
const handleGenerate = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResult(null);
|
||||
try {
|
||||
const res = await generateNPC({
|
||||
race,
|
||||
class: npcClass,
|
||||
alignment,
|
||||
traits,
|
||||
tone,
|
||||
});
|
||||
setResult(res);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to generate NPC");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopy = () => {
|
||||
if (!result) return;
|
||||
const text = `${result.name} (${result.race} ${result.class})\n\nAppearance: ${result.appearance}\n\nPersonality: ${result.personality}\n\nMotivation: ${result.motivation}\n\nQuirk: ${result.quirk}\n\nSecret: ${result.secret}\n\nHooks:\n${result.hooks.map((h, i) => `${i + 1}. ${h}`).join("\n")}`;
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<Nav />
|
||||
<main className="flex-1 mx-auto w-full max-w-3xl px-4 py-8 sm:px-6">
|
||||
<div className="mb-8">
|
||||
<h1
|
||||
className="mb-2 font-heading text-3xl font-bold text-gradient-gold sm:text-4xl"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
NPC Generator
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Create vivid, memorable NPCs ready for your table in seconds.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Form */}
|
||||
<Card className="mb-6 border-border/50 bg-card/80">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 font-heading text-lg" style={{ fontFamily: "var(--font-cinzel), serif" }}>
|
||||
<Users className="h-5 w-5 text-[var(--accent)]" />
|
||||
Configure NPC
|
||||
</CardTitle>
|
||||
<CardDescription>Define the traits and parameters for your NPC</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Race & Class */}
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Race</Label>
|
||||
<select
|
||||
value={race}
|
||||
onChange={(e) => setRace(e.target.value)}
|
||||
className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring min-h-[44px]"
|
||||
>
|
||||
{RACES.map((r) => (
|
||||
<option key={r} value={r}>{r}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Class</Label>
|
||||
<select
|
||||
value={npcClass}
|
||||
onChange={(e) => setNpcClass(e.target.value)}
|
||||
className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring min-h-[44px]"
|
||||
>
|
||||
{CLASSES.map((c) => (
|
||||
<option key={c} value={c}>{c}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Alignment */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Alignment</Label>
|
||||
<select
|
||||
value={alignment}
|
||||
onChange={(e) => setAlignment(e.target.value)}
|
||||
className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring min-h-[44px]"
|
||||
>
|
||||
{ALIGNMENTS.map((a) => (
|
||||
<option key={a} value={a}>{a}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Tone */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Tone</Label>
|
||||
<div className="grid grid-cols-2 gap-2 sm:grid-cols-4">
|
||||
{NPC_TONES.map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
onClick={() => setTone(t as typeof tone)}
|
||||
className={`rounded-md border px-3 py-2 text-sm font-medium transition-colors min-h-[44px] ${
|
||||
tone === t
|
||||
? "border-[var(--accent)] bg-[var(--accent)]/10 text-[var(--accent-foreground)]"
|
||||
: "border-border text-muted-foreground hover:bg-secondary"
|
||||
}`}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Traits */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">
|
||||
Personality Traits{" "}
|
||||
<span className="text-xs text-muted-foreground">(optional)</span>
|
||||
</Label>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{NPC_TRAITS.map((trait) => (
|
||||
<button
|
||||
key={trait}
|
||||
onClick={() => toggleTrait(trait)}
|
||||
className={`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors min-h-[32px] ${
|
||||
traits.includes(trait)
|
||||
? "border-[var(--gold)] bg-[var(--gold)]/20 text-[var(--gold)]"
|
||||
: "border-border text-muted-foreground hover:bg-secondary"
|
||||
}`}
|
||||
>
|
||||
{trait}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Generate Button */}
|
||||
<Button
|
||||
onClick={handleGenerate}
|
||||
disabled={loading}
|
||||
className="w-full min-h-[48px] bg-[var(--accent)] text-[var(--accent-foreground)] hover:bg-[var(--accent)]/90 font-semibold text-base"
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<RefreshCw className="mr-2 h-4 w-4 animate-spin" />
|
||||
Generating...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Users className="mr-2 h-4 w-4" />
|
||||
Generate NPC
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{error && (
|
||||
<p className="text-sm text-destructive">{error}</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Loading State */}
|
||||
{loading && <LoadingDice />}
|
||||
|
||||
{/* Result */}
|
||||
{result && !loading && (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2
|
||||
className="font-heading text-xl font-semibold"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
{result.name}
|
||||
</h2>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleCopy}
|
||||
className="gap-2 min-h-[36px]"
|
||||
>
|
||||
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
|
||||
{copied ? "Copied!" : "Copy"}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<ResultCard title={`${result.race} ${result.class}`} variant="npc">
|
||||
<Field label="Appearance">{result.appearance}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="Personality">{result.personality}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="Motivation">{result.motivation}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="Quirk">{result.quirk}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="Secret">
|
||||
<span className="italic text-muted-foreground">{result.secret}</span>
|
||||
</Field>
|
||||
<SectionDivider />
|
||||
<ListField label="Adventure Hooks" items={result.hooks} />
|
||||
</ResultCard>
|
||||
|
||||
<Button
|
||||
onClick={handleGenerate}
|
||||
variant="outline"
|
||||
className="w-full gap-2 min-h-[44px]"
|
||||
>
|
||||
<RefreshCw className="h-4 w-4" />
|
||||
Generate Another
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+114
-56
@@ -1,65 +1,123 @@
|
||||
import Image from "next/image";
|
||||
import { Nav } from "@/components/nav";
|
||||
import { ToolCard } from "@/components/tool-card";
|
||||
import { Swords, Users, Scroll } from "lucide-react";
|
||||
|
||||
export default function Home() {
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
|
||||
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={100}
|
||||
height={20}
|
||||
priority
|
||||
/>
|
||||
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
|
||||
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
|
||||
To get started, edit the page.tsx file.
|
||||
</h1>
|
||||
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
||||
Looking for a starting point or more instructions? Head over to{" "}
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<Nav />
|
||||
<main className="flex-1">
|
||||
{/* Hero */}
|
||||
<section className="relative overflow-hidden py-16 sm:py-24">
|
||||
{/* Background gradient orbs */}
|
||||
<div className="pointer-events-none absolute inset-0 overflow-hidden">
|
||||
<div className="absolute -left-32 -top-32 h-64 w-64 rounded-full bg-[var(--gold)]/5 blur-3xl" />
|
||||
<div className="absolute -right-32 bottom-0 h-64 w-64 rounded-full bg-[var(--accent)]/5 blur-3xl" />
|
||||
</div>
|
||||
|
||||
<div className="relative mx-auto max-w-5xl px-4 sm:px-6 text-center">
|
||||
<h1
|
||||
className="text-gradient-gold mb-4 text-4xl font-bold tracking-tight sm:text-5xl lg:text-6xl"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
Templates
|
||||
</a>{" "}
|
||||
or the{" "}
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Learning
|
||||
</a>{" "}
|
||||
center.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
DungeonMaster.tools
|
||||
</h1>
|
||||
<p className="mx-auto mb-10 max-w-2xl text-lg text-muted-foreground sm:text-xl">
|
||||
AI-powered tools for D&D 5th Edition Dungeon Masters. Generate encounters,
|
||||
NPCs, and quest hooks in seconds.
|
||||
</p>
|
||||
<div className="flex flex-wrap justify-center gap-3">
|
||||
<a
|
||||
href="#tools"
|
||||
className="rounded-md bg-[var(--gold)] px-6 py-3 text-sm font-semibold text-black transition-colors hover:bg-[var(--gold)]/90 min-h-[44px] flex items-center"
|
||||
>
|
||||
Explore Tools
|
||||
</a>
|
||||
<a
|
||||
href="/encounters"
|
||||
className="rounded-md border border-border px-6 py-3 text-sm font-semibold transition-colors hover:bg-secondary min-h-[44px] flex items-center"
|
||||
>
|
||||
Quick Start — Encounters
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Tools Grid */}
|
||||
<section id="tools" className="mx-auto max-w-5xl px-4 pb-20 sm:px-6">
|
||||
<h2
|
||||
className="mb-8 text-center font-heading text-2xl font-semibold tracking-wide text-foreground sm:text-3xl"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={16}
|
||||
height={16}
|
||||
Your Adventurer's Toolkit
|
||||
</h2>
|
||||
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<ToolCard
|
||||
title="Encounter Generator"
|
||||
description="Generate balanced, thematic combat encounters with monsters, terrain, tactics, and loot."
|
||||
href="/encounters"
|
||||
icon={Swords}
|
||||
/>
|
||||
Deploy Now
|
||||
</a>
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
</div>
|
||||
<ToolCard
|
||||
title="NPC Generator"
|
||||
description="Create vivid, memorable NPCs with personality, motivations, quirks, and ready-to-use hooks."
|
||||
href="/npc"
|
||||
icon={Users}
|
||||
/>
|
||||
<ToolCard
|
||||
title="Quest Hooks"
|
||||
description="Spark your next adventure with creative quest premises, NPCs, locations, and complications."
|
||||
href="/quest-hooks"
|
||||
icon={Scroll}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Features */}
|
||||
<section className="border-t border-border bg-secondary/20 py-16">
|
||||
<div className="mx-auto max-w-5xl px-4 sm:px-6">
|
||||
<h2
|
||||
className="mb-10 text-center font-heading text-2xl font-semibold tracking-wide sm:text-3xl"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
Built for Dungeon Masters
|
||||
</h2>
|
||||
<div className="grid gap-8 sm:grid-cols-3">
|
||||
{[
|
||||
{
|
||||
title: "Instant Generation",
|
||||
desc: "No signup, no waiting. Get ready-to-use D&D content in seconds.",
|
||||
},
|
||||
{
|
||||
title: "D&D 5e Rules",
|
||||
desc: "Powered by the D&D 5th Edition ruleset. Balanced encounters and usable NPCs.",
|
||||
},
|
||||
{
|
||||
title: "Dark Fantasy Theme",
|
||||
desc: "Built with a dark fantasy aesthetic. The tools feel as epic as your campaigns.",
|
||||
},
|
||||
].map(({ title, desc }) => (
|
||||
<div key={title} className="text-center">
|
||||
<h3
|
||||
className="mb-2 font-heading text-lg font-semibold text-[var(--gold)]"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
{title}
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground">{desc}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="border-t border-border py-6 text-center">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
DungeonMaster.tools — AI-powered D&D tools. Not affiliated with Wizards of the Coast.
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
"use server";
|
||||
|
||||
import { z } from "zod";
|
||||
import { callLLM } from "@/lib/llm";
|
||||
import { SYSTEM_PROMPT, buildQuestHookPrompt } from "@/lib/prompts/quest-hooks";
|
||||
import type { QuestResult } from "@/lib/types";
|
||||
|
||||
const QuestFormSchema = z.object({
|
||||
setting: z.string().min(1),
|
||||
tone: z.string().min(1),
|
||||
difficulty: z.string().min(1),
|
||||
seed: z.string().optional(),
|
||||
});
|
||||
|
||||
export async function generateQuestHook(
|
||||
formData: z.infer<typeof QuestFormSchema>
|
||||
): Promise<QuestResult> {
|
||||
const parsed = QuestFormSchema.parse(formData);
|
||||
const userPrompt = buildQuestHookPrompt({
|
||||
setting: parsed.setting,
|
||||
tone: parsed.tone,
|
||||
difficulty: parsed.difficulty,
|
||||
seed: parsed.seed,
|
||||
});
|
||||
|
||||
let raw: string;
|
||||
try {
|
||||
raw = await callLLM(SYSTEM_PROMPT, userPrompt);
|
||||
} catch (e) {
|
||||
// Retry once
|
||||
raw = await callLLM(SYSTEM_PROMPT, userPrompt);
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as QuestResult;
|
||||
return parsed;
|
||||
} catch {
|
||||
throw new Error("Failed to parse quest hook response. Please try again.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Nav } from "@/components/nav";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { LoadingDice } from "@/components/loading-dice";
|
||||
import { ResultCard, Field, ListField, SectionDivider } from "@/components/result-card";
|
||||
import { generateQuestHook } from "./actions";
|
||||
import { QUEST_SETTINGS, QUEST_TONES, QUEST_DIFFICULTIES, type QuestResult } from "@/lib/types";
|
||||
import { Scroll, RefreshCw, Copy, Check } from "lucide-react";
|
||||
|
||||
export default function QuestHooksPage() {
|
||||
const [setting, setSetting] = useState("Fantasy");
|
||||
const [tone, setTone] = useState("Epic");
|
||||
const [difficulty, setDifficulty] = useState("Medium");
|
||||
const [seed, setSeed] = useState("");
|
||||
const [result, setResult] = useState<QuestResult | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const handleGenerate = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setResult(null);
|
||||
try {
|
||||
const res = await generateQuestHook({
|
||||
setting,
|
||||
tone,
|
||||
difficulty,
|
||||
seed: seed || undefined,
|
||||
});
|
||||
setResult(res);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to generate quest hook");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopy = () => {
|
||||
if (!result) return;
|
||||
const text = `${result.title}\n\nPremise: ${result.premise}\n\nHook: ${result.hook}\n\nNPCs:\n${result.npcs.map((n, i) => `${i + 1}. ${n}`).join("\n")}\n\nLocations:\n${result.locations.map((l, i) => `${i + 1}. ${l}`).join("\n")}\n\nRewards: ${result.rewards}\n\nComplications: ${result.complications}`;
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<Nav />
|
||||
<main className="flex-1 mx-auto w-full max-w-3xl px-4 py-8 sm:px-6">
|
||||
<div className="mb-8">
|
||||
<h1
|
||||
className="mb-2 font-heading text-3xl font-bold text-gradient-gold sm:text-4xl"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
Quest Hooks
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Spark your next adventure with creative, ready-to-use quest hooks.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Form */}
|
||||
<Card className="mb-6 border-border/50 bg-card/80">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 font-heading text-lg" style={{ fontFamily: "var(--font-cinzel), serif" }}>
|
||||
<Scroll className="h-5 w-5 text-emerald-500" />
|
||||
Configure Quest
|
||||
</CardTitle>
|
||||
<CardDescription>Set the tone and setting for your quest</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Setting */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Setting</Label>
|
||||
<select
|
||||
value={setting}
|
||||
onChange={(e) => setSetting(e.target.value)}
|
||||
className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring min-h-[44px]"
|
||||
>
|
||||
{QUEST_SETTINGS.map((s) => (
|
||||
<option key={s} value={s}>{s}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Tone */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Tone</Label>
|
||||
<div className="grid grid-cols-2 gap-2 sm:grid-cols-4">
|
||||
{QUEST_TONES.map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
onClick={() => setTone(t)}
|
||||
className={`rounded-md border px-3 py-2 text-sm font-medium transition-colors min-h-[44px] ${
|
||||
tone === t
|
||||
? "border-emerald-500 bg-emerald-500/10 text-emerald-400"
|
||||
: "border-border text-muted-foreground hover:bg-secondary"
|
||||
}`}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Difficulty */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">Difficulty</Label>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{QUEST_DIFFICULTIES.map((d) => (
|
||||
<button
|
||||
key={d}
|
||||
onClick={() => setDifficulty(d)}
|
||||
className={`rounded-md border px-3 py-2 text-sm font-medium transition-colors min-h-[44px] ${
|
||||
difficulty === d
|
||||
? "border-emerald-500 bg-emerald-500/10 text-emerald-400"
|
||||
: "border-border text-muted-foreground hover:bg-secondary"
|
||||
}`}
|
||||
>
|
||||
{d}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Seed Prompt */}
|
||||
<div>
|
||||
<Label className="mb-2 block text-sm font-medium">
|
||||
Starting Premise{" "}
|
||||
<span className="text-xs text-muted-foreground">(optional)</span>
|
||||
</Label>
|
||||
<Textarea
|
||||
value={seed}
|
||||
onChange={(e) => setSeed(e.target.value)}
|
||||
placeholder="E.g., 'A merchant's daughter has gone missing in the woods...'"
|
||||
className="min-h-[100px] resize-none border-input bg-background"
|
||||
maxLength={500}
|
||||
/>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
Leave blank for a completely random quest hook.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Generate Button */}
|
||||
<Button
|
||||
onClick={handleGenerate}
|
||||
disabled={loading}
|
||||
className="w-full min-h-[48px] bg-emerald-600 hover:bg-emerald-700 text-white font-semibold text-base"
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<RefreshCw className="mr-2 h-4 w-4 animate-spin" />
|
||||
Generating...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Scroll className="mr-2 h-4 w-4" />
|
||||
Generate Quest Hook
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{error && (
|
||||
<p className="text-sm text-destructive">{error}</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Loading State */}
|
||||
{loading && <LoadingDice />}
|
||||
|
||||
{/* Result */}
|
||||
{result && !loading && (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2
|
||||
className="font-heading text-xl font-semibold"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
{result.title}
|
||||
</h2>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleCopy}
|
||||
className="gap-2 min-h-[36px]"
|
||||
>
|
||||
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
|
||||
{copied ? "Copied!" : "Copy"}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<ResultCard title="Quest Details" variant="quest">
|
||||
<Field label="Premise">{result.premise}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="The Hook">{result.hook}</Field>
|
||||
<SectionDivider />
|
||||
<ListField label="Key NPCs" items={result.npcs} />
|
||||
<SectionDivider />
|
||||
<ListField label="Locations" items={result.locations} />
|
||||
<SectionDivider />
|
||||
<Field label="Rewards">{result.rewards}</Field>
|
||||
<SectionDivider />
|
||||
<Field label="Complications">{result.complications}</Field>
|
||||
</ResultCard>
|
||||
|
||||
<Button
|
||||
onClick={handleGenerate}
|
||||
variant="outline"
|
||||
className="w-full gap-2 min-h-[44px]"
|
||||
>
|
||||
<RefreshCw className="h-4 w-4" />
|
||||
Generate Another
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
export function LoadingDice() {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center gap-4 py-8">
|
||||
<div className="relative">
|
||||
{/* Outer ring */}
|
||||
<div className="h-16 w-16 animate-spin rounded-full border-4 border-[var(--gold)]/20" />
|
||||
{/* Inner dice icon */}
|
||||
<div className="absolute inset-0 flex items-center justify-center">
|
||||
<svg
|
||||
viewBox="0 0 32 32"
|
||||
className="h-8 w-8 animate-pulse text-[var(--gold)]"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<polygon
|
||||
points="16,2 28,10 28,22 16,30 4,22 4,10"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
/>
|
||||
<circle cx="16" cy="16" r="3" fill="currentColor" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground animate-pulse">
|
||||
Rolling the dice...
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Menu, X, Swords, Users, Scroll } from "lucide-react";
|
||||
|
||||
const NAV_LINKS = [
|
||||
{ href: "/encounters", label: "Encounters", icon: Swords },
|
||||
{ href: "/npc", label: "NPCs", icon: Users },
|
||||
{ href: "/quest-hooks", label: "Quest Hooks", icon: Scroll },
|
||||
];
|
||||
|
||||
export function Nav() {
|
||||
const pathname = usePathname();
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<nav className="sticky top-0 z-50 w-full border-b border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80">
|
||||
<div className="mx-auto flex h-16 max-w-5xl items-center justify-between px-4 sm:px-6">
|
||||
{/* Logo */}
|
||||
<Link href="/" className="flex items-center gap-2 group">
|
||||
<svg
|
||||
viewBox="0 0 32 32"
|
||||
className="h-8 w-8 fill-[var(--gold)] transition-transform group-hover:scale-110"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{/* D20 icon */}
|
||||
<polygon points="16,2 28,10 28,22 16,30 4,22 4,10" fill="none" stroke="currentColor" strokeWidth="2" />
|
||||
<circle cx="16" cy="16" r="4" />
|
||||
<line x1="16" y1="6" x2="16" y2="12" stroke="currentColor" strokeWidth="1.5" />
|
||||
<line x1="16" y1="20" x2="16" y2="26" stroke="currentColor" strokeWidth="1.5" />
|
||||
<line x1="8" y1="13" x2="13" y2="14.5" stroke="currentColor" strokeWidth="1.5" />
|
||||
<line x1="19" y1="17.5" x2="24" y2="19" stroke="currentColor" strokeWidth="1.5" />
|
||||
<line x1="24" y1="13" x2="19" y2="14.5" stroke="currentColor" strokeWidth="1.5" />
|
||||
<line x1="13" y1="17.5" x2="8" y2="19" stroke="currentColor" strokeWidth="1.5" />
|
||||
</svg>
|
||||
<span
|
||||
className="font-heading text-lg font-semibold tracking-wide text-[var(--gold)]"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
DungeonMaster
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
{/* Desktop Nav */}
|
||||
<div className="hidden items-center gap-1 sm:flex">
|
||||
{NAV_LINKS.map(({ href, label, icon: Icon }) => {
|
||||
const active = pathname === href;
|
||||
return (
|
||||
<Link
|
||||
key={href}
|
||||
href={href}
|
||||
className={`flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-colors min-h-[44px] ${
|
||||
active
|
||||
? "bg-[var(--accent)] text-[var(--accent-foreground)]"
|
||||
: "text-muted-foreground hover:bg-secondary hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Mobile menu button */}
|
||||
<button
|
||||
className="flex h-11 w-11 items-center justify-center rounded-md sm:hidden"
|
||||
onClick={() => setMobileOpen(!mobileOpen)}
|
||||
aria-label="Toggle menu"
|
||||
>
|
||||
{mobileOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Mobile Nav */}
|
||||
{mobileOpen && (
|
||||
<div className="border-t border-border sm:hidden">
|
||||
<div className="mx-auto max-w-5xl px-4 py-3 space-y-1">
|
||||
{NAV_LINKS.map(({ href, label, icon: Icon }) => {
|
||||
const active = pathname === href;
|
||||
return (
|
||||
<Link
|
||||
key={href}
|
||||
href={href}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
className={`flex items-center gap-2 rounded-md px-3 py-3 text-sm font-medium transition-colors min-h-[44px] ${
|
||||
active
|
||||
? "bg-[var(--accent)] text-[var(--accent-foreground)]"
|
||||
: "text-muted-foreground hover:bg-secondary hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
"use client";
|
||||
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Scroll } from "lucide-react";
|
||||
|
||||
interface ResultCardProps {
|
||||
title: string;
|
||||
children: React.ReactNode;
|
||||
variant?: "encounter" | "npc" | "quest";
|
||||
}
|
||||
|
||||
const VARIANT_COLORS = {
|
||||
encounter: "border-l-4 border-l-[var(--gold)]",
|
||||
npc: "border-l-4 border-l-[var(--accent)]",
|
||||
quest: "border-l-4 border-l-emerald-500",
|
||||
};
|
||||
|
||||
export function ResultCard({ title, children, variant = "encounter" }: ResultCardProps) {
|
||||
return (
|
||||
<Card className={`bg-card border-border ${VARIANT_COLORS[variant]}`}>
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<Scroll className="h-5 w-5 text-[var(--gold)]" />
|
||||
<CardTitle
|
||||
className="font-heading text-lg"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
{title}
|
||||
</CardTitle>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{children}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
interface FieldProps {
|
||||
label: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Field({ label, children }: FieldProps) {
|
||||
return (
|
||||
<div>
|
||||
<dt className="text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1">
|
||||
{label}
|
||||
</dt>
|
||||
<dd className="text-sm leading-relaxed text-foreground">{children}</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface ListFieldProps {
|
||||
label: string;
|
||||
items: string[];
|
||||
}
|
||||
|
||||
export function ListField({ label, items }: ListFieldProps) {
|
||||
return (
|
||||
<div>
|
||||
<dt className="text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2">
|
||||
{label}
|
||||
</dt>
|
||||
<dd className="flex flex-wrap gap-2">
|
||||
{items.map((item, i) => (
|
||||
<Badge key={i} variant="outline" className="border-border/50 bg-secondary/50">
|
||||
{item}
|
||||
</Badge>
|
||||
))}
|
||||
</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SectionDivider() {
|
||||
return <hr className="border-border/50" />;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import Link from "next/link";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
|
||||
interface ToolCardProps {
|
||||
title: string;
|
||||
description: string;
|
||||
href: string;
|
||||
icon: LucideIcon;
|
||||
}
|
||||
|
||||
export function ToolCard({ title, description, href, icon: Icon }: ToolCardProps) {
|
||||
return (
|
||||
<Link href={href} className="block group">
|
||||
<Card className="h-full border-border/50 bg-card/80 backdrop-blur transition-all duration-300 group-hover:border-[var(--gold)]/50 group-hover:shadow-lg group-hover:shadow-[var(--gold)]/5 group-hover:-translate-y-1">
|
||||
<CardHeader>
|
||||
<div className="mb-3 flex h-12 w-12 items-center justify-center rounded-lg bg-[var(--gold)]/10 text-[var(--gold)] group-hover:bg-[var(--gold)]/20 transition-colors">
|
||||
<Icon className="h-6 w-6" />
|
||||
</div>
|
||||
<CardTitle
|
||||
className="font-heading text-xl"
|
||||
style={{ fontFamily: "var(--font-cinzel), serif" }}
|
||||
>
|
||||
{title}
|
||||
</CardTitle>
|
||||
<CardDescription className="text-muted-foreground">{description}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<span className="inline-flex items-center text-sm font-medium text-[var(--gold)] group-hover:underline">
|
||||
Launch tool →
|
||||
</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { mergeProps } from "@base-ui/react/merge-props"
|
||||
import { useRender } from "@base-ui/react/use-render"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const badgeVariants = cva(
|
||||
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
||||
destructive:
|
||||
"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
||||
outline:
|
||||
"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
||||
ghost:
|
||||
"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
variant = "default",
|
||||
render,
|
||||
...props
|
||||
}: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
|
||||
return useRender({
|
||||
defaultTagName: "span",
|
||||
props: mergeProps<"span">(
|
||||
{
|
||||
className: cn(badgeVariants({ variant }), className),
|
||||
},
|
||||
props
|
||||
),
|
||||
render,
|
||||
state: {
|
||||
slot: "badge",
|
||||
variant,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
@@ -0,0 +1,103 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Card({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-header"
|
||||
className={cn(
|
||||
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-title"
|
||||
className={cn(
|
||||
"font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-action"
|
||||
className={cn(
|
||||
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-content"
|
||||
className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-footer"
|
||||
className={cn(
|
||||
"flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardFooter,
|
||||
CardTitle,
|
||||
CardAction,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Label({ className, ...props }: React.ComponentProps<"label">) {
|
||||
return (
|
||||
<label
|
||||
data-slot="label"
|
||||
className={cn(
|
||||
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Label }
|
||||
@@ -0,0 +1,201 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Select as SelectPrimitive } from "@base-ui/react/select"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
|
||||
|
||||
const Select = SelectPrimitive.Root
|
||||
|
||||
function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Group
|
||||
data-slot="select-group"
|
||||
className={cn("scroll-my-1 p-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Value
|
||||
data-slot="select-value"
|
||||
className={cn("flex flex-1 text-left", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectTrigger({
|
||||
className,
|
||||
size = "default",
|
||||
children,
|
||||
...props
|
||||
}: SelectPrimitive.Trigger.Props & {
|
||||
size?: "sm" | "default"
|
||||
}) {
|
||||
return (
|
||||
<SelectPrimitive.Trigger
|
||||
data-slot="select-trigger"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SelectPrimitive.Icon
|
||||
render={
|
||||
<ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
|
||||
}
|
||||
/>
|
||||
</SelectPrimitive.Trigger>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectContent({
|
||||
className,
|
||||
children,
|
||||
side = "bottom",
|
||||
sideOffset = 4,
|
||||
align = "center",
|
||||
alignOffset = 0,
|
||||
alignItemWithTrigger = true,
|
||||
...props
|
||||
}: SelectPrimitive.Popup.Props &
|
||||
Pick<
|
||||
SelectPrimitive.Positioner.Props,
|
||||
"align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
|
||||
>) {
|
||||
return (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Positioner
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
alignItemWithTrigger={alignItemWithTrigger}
|
||||
className="isolate z-50"
|
||||
>
|
||||
<SelectPrimitive.Popup
|
||||
data-slot="select-content"
|
||||
data-align-trigger={alignItemWithTrigger}
|
||||
className={cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
||||
{...props}
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.List>{children}</SelectPrimitive.List>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Popup>
|
||||
</SelectPrimitive.Positioner>
|
||||
</SelectPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectLabel({
|
||||
className,
|
||||
...props
|
||||
}: SelectPrimitive.GroupLabel.Props) {
|
||||
return (
|
||||
<SelectPrimitive.GroupLabel
|
||||
data-slot="select-label"
|
||||
className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectItem({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: SelectPrimitive.Item.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Item
|
||||
data-slot="select-item"
|
||||
className={cn(
|
||||
"relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
|
||||
{children}
|
||||
</SelectPrimitive.ItemText>
|
||||
<SelectPrimitive.ItemIndicator
|
||||
render={
|
||||
<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
|
||||
}
|
||||
>
|
||||
<CheckIcon className="pointer-events-none" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</SelectPrimitive.Item>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectSeparator({
|
||||
className,
|
||||
...props
|
||||
}: SelectPrimitive.Separator.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Separator
|
||||
data-slot="select-separator"
|
||||
className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectScrollUpButton({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollUpArrow
|
||||
data-slot="select-scroll-up-button"
|
||||
className={cn(
|
||||
"top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronUpIcon
|
||||
/>
|
||||
</SelectPrimitive.ScrollUpArrow>
|
||||
)
|
||||
}
|
||||
|
||||
function SelectScrollDownButton({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollDownArrow
|
||||
data-slot="select-scroll-down-button"
|
||||
className={cn(
|
||||
"bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronDownIcon
|
||||
/>
|
||||
</SelectPrimitive.ScrollDownArrow>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectLabel,
|
||||
SelectScrollDownButton,
|
||||
SelectScrollUpButton,
|
||||
SelectSeparator,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Slider as SliderPrimitive } from "@base-ui/react/slider"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Slider({
|
||||
className,
|
||||
defaultValue,
|
||||
value,
|
||||
min = 0,
|
||||
max = 100,
|
||||
...props
|
||||
}: SliderPrimitive.Root.Props) {
|
||||
const _values = React.useMemo(
|
||||
() =>
|
||||
Array.isArray(value)
|
||||
? value
|
||||
: Array.isArray(defaultValue)
|
||||
? defaultValue
|
||||
: [min, max],
|
||||
[value, defaultValue, min, max]
|
||||
)
|
||||
|
||||
return (
|
||||
<SliderPrimitive.Root
|
||||
className={cn("data-horizontal:w-full data-vertical:h-full", className)}
|
||||
data-slot="slider"
|
||||
defaultValue={defaultValue}
|
||||
value={value}
|
||||
min={min}
|
||||
max={max}
|
||||
thumbAlignment="edge"
|
||||
{...props}
|
||||
>
|
||||
<SliderPrimitive.Control className="relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col">
|
||||
<SliderPrimitive.Track
|
||||
data-slot="slider-track"
|
||||
className="relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1"
|
||||
>
|
||||
<SliderPrimitive.Indicator
|
||||
data-slot="slider-range"
|
||||
className="bg-primary select-none data-horizontal:h-full data-vertical:w-full"
|
||||
/>
|
||||
</SliderPrimitive.Track>
|
||||
{Array.from({ length: _values.length }, (_, index) => (
|
||||
<SliderPrimitive.Thumb
|
||||
data-slot="slider-thumb"
|
||||
key={index}
|
||||
className="relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"
|
||||
/>
|
||||
))}
|
||||
</SliderPrimitive.Control>
|
||||
</SliderPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
export { Slider }
|
||||
@@ -0,0 +1,32 @@
|
||||
"use client"
|
||||
|
||||
import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Switch({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: SwitchPrimitive.Root.Props & {
|
||||
size?: "sm" | "default"
|
||||
}) {
|
||||
return (
|
||||
<SwitchPrimitive.Root
|
||||
data-slot="switch"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<SwitchPrimitive.Thumb
|
||||
data-slot="switch-thumb"
|
||||
className="pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"
|
||||
/>
|
||||
</SwitchPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
export { Switch }
|
||||
@@ -0,0 +1,18 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
return (
|
||||
<textarea
|
||||
data-slot="textarea"
|
||||
className={cn(
|
||||
"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Textarea }
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import OpenAI from "openai";
|
||||
|
||||
const llm = new OpenAI({
|
||||
baseURL: process.env.LLM_BASE_URL || "https://llm.molberg.cloud/v1",
|
||||
apiKey: process.env.LLM_API_KEY,
|
||||
});
|
||||
|
||||
export async function callLLM(
|
||||
systemPrompt: string,
|
||||
userPrompt: string,
|
||||
options?: {
|
||||
model?: string;
|
||||
temperature?: number;
|
||||
maxTokens?: number;
|
||||
}
|
||||
): Promise<string> {
|
||||
const model = options?.model || process.env.LLM_MODEL || "gpt-4o";
|
||||
const temperature = options?.temperature ?? 0.8;
|
||||
const maxTokens = options?.maxTokens ?? 1024;
|
||||
|
||||
const response = await llm.chat.completions.create({
|
||||
model,
|
||||
messages: [
|
||||
{ role: "system", content: systemPrompt },
|
||||
{ role: "user", content: userPrompt },
|
||||
],
|
||||
temperature,
|
||||
max_tokens: maxTokens,
|
||||
});
|
||||
|
||||
const content = response.choices[0]?.message?.content;
|
||||
if (!content) {
|
||||
throw new Error("No response from LLM");
|
||||
}
|
||||
|
||||
// Strip markdown code blocks if present
|
||||
return content.replace(/^```json\s*/i, "").replace(/```$/i, "").trim();
|
||||
}
|
||||
|
||||
export { llm };
|
||||
@@ -0,0 +1,30 @@
|
||||
export const SYSTEM_PROMPT = `You are a D&D 5e expert dungeon master assistant. Generate balanced, thematic encounters suitable for tabletop RPG play. Return ONLY valid JSON with no markdown, no explanation.`;
|
||||
|
||||
export function buildEncounterPrompt(params: {
|
||||
difficulty: string;
|
||||
partySize: number;
|
||||
crMin: number;
|
||||
crMax: number;
|
||||
terrain: string;
|
||||
monsterTypes: string[];
|
||||
}): string {
|
||||
const types = params.monsterTypes.length > 0
|
||||
? `Preferred monster types: ${params.monsterTypes.join(", ")}.`
|
||||
: "";
|
||||
|
||||
return `Generate a ${params.difficulty} D&D 5e encounter for a party of ${params.partySize} adventurers (CR range: ${params.crMin}–${params.crMax}).
|
||||
Terrain: ${params.terrain}.
|
||||
${types}
|
||||
|
||||
Return JSON with this exact shape:
|
||||
{
|
||||
"title": "Encounter name",
|
||||
"description": "2-3 sentence scene description for the DM to read aloud",
|
||||
"monsters": [
|
||||
{ "name": "Monster Name", "cr": "CR value", "count": number, "terrainBehavior": "how this monster uses the terrain" }
|
||||
],
|
||||
"loot": "Minor treasure, gold, and items to award",
|
||||
"tactics": "How the monsters fight — include any lair actions, legendary actions, or special abilities",
|
||||
"notes": "Tips for the DM on running this encounter"
|
||||
}`;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
export const SYSTEM_PROMPT = `You are a D&D 5e expert dungeon master assistant. Generate vivid, memorable, and immediately usable NPCs for tabletop RPG play. Return ONLY valid JSON with no markdown, no explanation.`;
|
||||
|
||||
export function buildNPCPrompt(params: {
|
||||
race: string;
|
||||
class: string;
|
||||
alignment: string;
|
||||
traits: string[];
|
||||
tone: string;
|
||||
}): string {
|
||||
const traits = params.traits.length > 0
|
||||
? `Personality traits: ${params.traits.join(", ")}.`
|
||||
: "";
|
||||
|
||||
return `Generate a ${params.tone.toLowerCase()}-toned D&D 5e NPC:
|
||||
Race: ${params.race}
|
||||
Class: ${params.class}
|
||||
Alignment: ${params.alignment}
|
||||
${traits}
|
||||
|
||||
Return JSON with this exact shape:
|
||||
{
|
||||
"name": "NPC Full Name",
|
||||
"race": "Race",
|
||||
"class": "Class",
|
||||
"appearance": "Physical description — distinctive features, clothing, posture",
|
||||
"personality": "How they act, speak, and carry themselves",
|
||||
"motivation": "What drives them right now — a clear goal or desire",
|
||||
"quirk": "One memorable oddity that makes them memorable",
|
||||
"secret": "A hidden truth the party might discover (rumor, backstory twist, or hidden agenda)",
|
||||
"hooks": ["Short adventure hook 1", "Short adventure hook 2", "Short adventure hook 3"]
|
||||
}
|
||||
|
||||
Make them memorable and ready to use at a table in under 60 seconds.`;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
export const SYSTEM_PROMPT = `You are a D&D 5e expert dungeon master assistant. Generate creative, inspiring quest hooks that spark adventure. Return ONLY valid JSON with no markdown, no explanation.`;
|
||||
|
||||
export function buildQuestHookPrompt(params: {
|
||||
setting: string;
|
||||
tone: string;
|
||||
difficulty: string;
|
||||
seed?: string;
|
||||
}): string {
|
||||
const seed = params.seed ? `Starting premise: ${params.seed}` : "";
|
||||
|
||||
return `Generate a ${params.difficulty.toLowerCase()}-difficulty quest hook for a ${params.setting.toLowerCase()} setting with a ${params.tone.toLowerCase()} tone.
|
||||
${seed}
|
||||
|
||||
Return JSON with this exact shape:
|
||||
{
|
||||
"title": "Quest Title",
|
||||
"premise": "2-3 sentences setting up the situation and why the party gets involved",
|
||||
"hook": "The inciting incident or discovery that kicks off the adventure",
|
||||
"npcs": ["NPC name + one-line description", "NPC name + one-line description"],
|
||||
"locations": ["Location name — brief description", "Location name — brief description"],
|
||||
"rewards": "What the party earns — gold, magic items, favors, information",
|
||||
"complications": "What makes this quest harder than it first appears"
|
||||
}
|
||||
|
||||
Make it exciting and immediately usable.`;
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
// Shared types for DungeonMaster.tools
|
||||
|
||||
export const TERRAINS = [
|
||||
"Forest",
|
||||
"Dungeon",
|
||||
"Mountain",
|
||||
"Swamp",
|
||||
"Urban",
|
||||
"Desert",
|
||||
"Arctic",
|
||||
"Underdark",
|
||||
"Coastal",
|
||||
] as const;
|
||||
|
||||
export const MONSTER_TYPES = [
|
||||
"Aberration",
|
||||
"Beast",
|
||||
"Celestial",
|
||||
"Construct",
|
||||
"Dragon",
|
||||
"Elemental",
|
||||
"Fey",
|
||||
"Fiend",
|
||||
"Giant",
|
||||
"Humanoid",
|
||||
"Monstrosity",
|
||||
"Ooze",
|
||||
"Plant",
|
||||
"Undead",
|
||||
] as const;
|
||||
|
||||
export const RACES = [
|
||||
"Human",
|
||||
"Elf",
|
||||
"Dwarf",
|
||||
"Halfling",
|
||||
"Gnome",
|
||||
"Half-Elf",
|
||||
"Half-Orc",
|
||||
"Tiefling",
|
||||
"Dragonborn",
|
||||
"Goliath",
|
||||
"Drow",
|
||||
"Tabaxi",
|
||||
"Firbolg",
|
||||
"Kenku",
|
||||
"Lizardfolk",
|
||||
"Aasimar",
|
||||
"Genasi",
|
||||
"Githyanki",
|
||||
"Triton",
|
||||
"Warforged",
|
||||
] as const;
|
||||
|
||||
export const CLASSES = [
|
||||
"Barbarian",
|
||||
"Bard",
|
||||
"Cleric",
|
||||
"Druid",
|
||||
"Fighter",
|
||||
"Monk",
|
||||
"Paladin",
|
||||
"Ranger",
|
||||
"Rogue",
|
||||
"Sorcerer",
|
||||
"Warlock",
|
||||
"Wizard",
|
||||
"Artificer",
|
||||
] as const;
|
||||
|
||||
export const ALIGNMENTS = [
|
||||
"Lawful Good",
|
||||
"Neutral Good",
|
||||
"Chaotic Good",
|
||||
"Lawful Neutral",
|
||||
"True Neutral",
|
||||
"Chaotic Neutral",
|
||||
"Lawful Evil",
|
||||
"Neutral Evil",
|
||||
"Chaotic Evil",
|
||||
"Any",
|
||||
] as const;
|
||||
|
||||
export const NPC_TRAITS = [
|
||||
"Noble",
|
||||
"Criminal",
|
||||
"Religious",
|
||||
"Scholarly",
|
||||
"Mercantile",
|
||||
"Wanderer",
|
||||
"Military",
|
||||
"Artistic",
|
||||
"Naturalist",
|
||||
"Mysterious",
|
||||
] as const;
|
||||
|
||||
export const NPC_TONES = ["Serious", "Lighthearted", "Mysterious", "Ominous"] as const;
|
||||
|
||||
export const QUEST_SETTINGS = ["Fantasy", "Horror", "Intrigue", "Exploration", "Social"] as const;
|
||||
export const QUEST_TONES = ["Epic", "Grounded", "Comedic", "Dark"] as const;
|
||||
export const QUEST_DIFFICULTIES = ["Low", "Medium", "High"] as const;
|
||||
|
||||
export const ENCOUNTER_DIFFICULTIES = ["Easy", "Medium", "Hard", "Deadly"] as const;
|
||||
|
||||
// Result types
|
||||
export interface Monster {
|
||||
name: string;
|
||||
cr: string;
|
||||
count: number;
|
||||
terrainBehavior: string;
|
||||
}
|
||||
|
||||
export interface EncounterResult {
|
||||
title: string;
|
||||
description: string;
|
||||
monsters: Monster[];
|
||||
loot: string;
|
||||
tactics: string;
|
||||
notes: string;
|
||||
}
|
||||
|
||||
export interface NPCResult {
|
||||
name: string;
|
||||
race: string;
|
||||
class: string;
|
||||
appearance: string;
|
||||
personality: string;
|
||||
motivation: string;
|
||||
quirk: string;
|
||||
secret: string;
|
||||
hooks: string[];
|
||||
}
|
||||
|
||||
export interface QuestResult {
|
||||
title: string;
|
||||
premise: string;
|
||||
hook: string;
|
||||
npcs: string[];
|
||||
locations: string[];
|
||||
rewards: string;
|
||||
complications: string;
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
output: "standalone",
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
Generated
+24
-1
@@ -13,11 +13,13 @@
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.577.0",
|
||||
"next": "16.2.1",
|
||||
"openai": "^6.32.0",
|
||||
"react": "19.2.4",
|
||||
"react-dom": "19.2.4",
|
||||
"shadcn": "^4.1.0",
|
||||
"tailwind-merge": "^3.5.0",
|
||||
"tw-animate-css": "^1.4.0"
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
@@ -7442,6 +7444,27 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/openai": {
|
||||
"version": "6.32.0",
|
||||
"resolved": "https://registry.npmjs.org/openai/-/openai-6.32.0.tgz",
|
||||
"integrity": "sha512-j3k+BjydAf8yQlcOI7WUQMQTbbF5GEIMAE2iZYCOzwwB3S2pCheaWYp+XZRNAch4jWVc52PMDGRRjutao3lLCg==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"openai": "bin/cli"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"ws": "^8.18.0",
|
||||
"zod": "^3.25 || ^4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"ws": {
|
||||
"optional": true
|
||||
},
|
||||
"zod": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.4",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
|
||||
|
||||
+3
-1
@@ -14,11 +14,13 @@
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.577.0",
|
||||
"next": "16.2.1",
|
||||
"openai": "^6.32.0",
|
||||
"react": "19.2.4",
|
||||
"react-dom": "19.2.4",
|
||||
"shadcn": "^4.1.0",
|
||||
"tailwind-merge": "^3.5.0",
|
||||
"tw-animate-css": "^1.4.0"
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
|
||||
<rect width="32" height="32" rx="4" fill="#0c0a14"/>
|
||||
<polygon points="16,3 28,10.5 28,21.5 16,29 4,21.5 4,10.5" fill="none" stroke="#c9a84c" stroke-width="1.5"/>
|
||||
<polygon points="16,6 25,12 25,20 16,26 7,20 7,12" fill="#c9a84c" fill-opacity="0.15" stroke="#c9a84c" stroke-width="0.5"/>
|
||||
<circle cx="16" cy="16" r="2.5" fill="#c9a84c"/>
|
||||
<text x="16" y="17.5" font-family="serif" font-size="4" fill="#0c0a14" text-anchor="middle" dominant-baseline="middle" font-weight="bold">20</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 573 B |
Reference in new issue
Block a user