feat: scaffold character sheet generator with multi-game support
- Set up Vite + React + TypeScript + Tailwind v4 + React Router v7 - Implement pluggable GameModule architecture for multiple RPG systems - Add Mothership, Mothership Karth, and Mythic Bastionland game modules - Create A5 sheet (148x210mm) and A4 print layout (landscape, 2-up) - Add print flow via iframe with proper @page A4 sizing - Add game selector home page and per-game editor with live preview
This commit is contained in:
commit
2dd55d15b9
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
# React + TypeScript + Vite
|
||||||
|
|
||||||
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||||
|
|
||||||
|
Currently, two official plugins are available:
|
||||||
|
|
||||||
|
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||||
|
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||||
|
|
||||||
|
## React Compiler
|
||||||
|
|
||||||
|
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||||
|
|
||||||
|
## Expanding the ESLint configuration
|
||||||
|
|
||||||
|
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(['dist']),
|
||||||
|
{
|
||||||
|
files: ['**/*.{ts,tsx}'],
|
||||||
|
extends: [
|
||||||
|
// Other configs...
|
||||||
|
|
||||||
|
// Remove tseslint.configs.recommended and replace with this
|
||||||
|
tseslint.configs.recommendedTypeChecked,
|
||||||
|
// Alternatively, use this for stricter rules
|
||||||
|
tseslint.configs.strictTypeChecked,
|
||||||
|
// Optionally, add this for stylistic rules
|
||||||
|
tseslint.configs.stylisticTypeChecked,
|
||||||
|
|
||||||
|
// Other configs...
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
// other options...
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// eslint.config.js
|
||||||
|
import reactX from 'eslint-plugin-react-x'
|
||||||
|
import reactDom from 'eslint-plugin-react-dom'
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(['dist']),
|
||||||
|
{
|
||||||
|
files: ['**/*.{ts,tsx}'],
|
||||||
|
extends: [
|
||||||
|
// Other configs...
|
||||||
|
// Enable lint rules for React
|
||||||
|
reactX.configs['recommended-typescript'],
|
||||||
|
// Enable lint rules for React DOM
|
||||||
|
reactDom.configs.recommended,
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
// other options...
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import js from '@eslint/js'
|
||||||
|
import globals from 'globals'
|
||||||
|
import reactHooks from 'eslint-plugin-react-hooks'
|
||||||
|
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||||
|
import tseslint from 'typescript-eslint'
|
||||||
|
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(['dist']),
|
||||||
|
{
|
||||||
|
files: ['**/*.{ts,tsx}'],
|
||||||
|
extends: [
|
||||||
|
js.configs.recommended,
|
||||||
|
tseslint.configs.recommended,
|
||||||
|
reactHooks.configs.flat.recommended,
|
||||||
|
reactRefresh.configs.vite,
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
globals: globals.browser,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>char-sheet</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"name": "char-sheet",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc -b && vite build",
|
||||||
|
"lint": "eslint .",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@tailwindcss/vite": "^4.3.1",
|
||||||
|
"react": "^19.2.6",
|
||||||
|
"react-dom": "^19.2.6",
|
||||||
|
"react-icons": "^5.6.0",
|
||||||
|
"react-router-dom": "^7.18.0",
|
||||||
|
"tailwindcss": "^4.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^10.0.1",
|
||||||
|
"@types/node": "^24.12.3",
|
||||||
|
"@types/react": "^19.2.14",
|
||||||
|
"@types/react-dom": "^19.2.3",
|
||||||
|
"@vitejs/plugin-react": "^6.0.1",
|
||||||
|
"eslint": "^10.3.0",
|
||||||
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
|
"eslint-plugin-react-refresh": "^0.5.2",
|
||||||
|
"globals": "^17.6.0",
|
||||||
|
"typescript": "~6.0.2",
|
||||||
|
"typescript-eslint": "^8.59.2",
|
||||||
|
"vite": "^8.0.12"
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.3 KiB |
|
|
@ -0,0 +1,24 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||||
|
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||||
|
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||||
|
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||||
|
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||||
|
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||||
|
</symbol>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.9 KiB |
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||||
|
import { routes } from "@/routes";
|
||||||
|
|
||||||
|
const router = createBrowserRouter(routes);
|
||||||
|
|
||||||
|
export function App() {
|
||||||
|
return <RouterProvider router={router} />;
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.5 KiB |
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { Outlet, Link, useLocation } from "react-router-dom";
|
||||||
|
import { gameList } from "@/games";
|
||||||
|
|
||||||
|
export function AppShell() {
|
||||||
|
const location = useLocation();
|
||||||
|
const currentGameId = location.pathname.split("/")[1];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-screen flex-col bg-stone-100 text-stone-900">
|
||||||
|
<header className="no-print flex items-center gap-4 border-b border-stone-300 bg-white px-6 py-3 shadow-sm">
|
||||||
|
<Link to="/" className="text-lg font-bold tracking-tight">
|
||||||
|
CharSheet
|
||||||
|
</Link>
|
||||||
|
<nav className="flex gap-1">
|
||||||
|
{gameList.map((game) => (
|
||||||
|
<Link
|
||||||
|
key={game.id}
|
||||||
|
to={`/${game.id}`}
|
||||||
|
className={`rounded px-3 py-1.5 text-sm transition ${
|
||||||
|
currentGameId === game.id
|
||||||
|
? "bg-stone-800 text-white"
|
||||||
|
: "text-stone-600 hover:bg-stone-200"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{game.name}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<main className="flex-1 overflow-auto">
|
||||||
|
<Outlet />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
interface A4PrintLayoutProps {
|
||||||
|
left: ReactNode;
|
||||||
|
right: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function A4PrintLayout({
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
className = "",
|
||||||
|
}: A4PrintLayoutProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`flex bg-white print-only ${className}`}
|
||||||
|
style={{
|
||||||
|
width: "297mm",
|
||||||
|
height: "210mm",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="flex-shrink-0" style={{ width: "148mm", height: "210mm" }}>
|
||||||
|
{left}
|
||||||
|
</div>
|
||||||
|
<div className="flex-shrink-0" style={{ width: "148mm", height: "210mm" }}>
|
||||||
|
{right}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
interface A5SheetProps {
|
||||||
|
children: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function A5Sheet({ children, className = "" }: A5SheetProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`relative overflow-hidden bg-white text-black shadow-lg print:shadow-none ${className}`}
|
||||||
|
style={{
|
||||||
|
width: "148mm",
|
||||||
|
height: "210mm",
|
||||||
|
minWidth: "148mm",
|
||||||
|
minHeight: "210mm",
|
||||||
|
fontSize: "9pt",
|
||||||
|
lineHeight: 1.3,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { useReactToPrint } from "./useReactToPrint";
|
||||||
|
|
||||||
|
interface PrintButtonProps {
|
||||||
|
previewRef: React.RefObject<HTMLDivElement | null>;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PrintButton({ previewRef, className = "" }: PrintButtonProps) {
|
||||||
|
const printFn = useReactToPrint(previewRef);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
onClick={printFn}
|
||||||
|
className={`rounded bg-stone-700 px-4 py-2 text-sm text-white hover:bg-stone-600 cursor-pointer ${className}`}
|
||||||
|
>
|
||||||
|
Print
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { useRef, useCallback } from "react";
|
||||||
|
|
||||||
|
export function useReactToPrint(
|
||||||
|
contentRef: React.RefObject<HTMLDivElement | null>,
|
||||||
|
) {
|
||||||
|
const originalTitleRef = useRef("");
|
||||||
|
const printFrameRef = useRef<HTMLIFrameElement | null>(null);
|
||||||
|
|
||||||
|
return useCallback(() => {
|
||||||
|
const content = contentRef.current;
|
||||||
|
if (!content) return;
|
||||||
|
|
||||||
|
originalTitleRef.current = document.title;
|
||||||
|
|
||||||
|
const frame = document.createElement("iframe");
|
||||||
|
frame.style.display = "none";
|
||||||
|
document.body.appendChild(frame);
|
||||||
|
printFrameRef.current = frame;
|
||||||
|
|
||||||
|
const frameDoc = frame.contentDocument!;
|
||||||
|
frameDoc.write(`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Character Sheet</title>
|
||||||
|
${Array.from(document.querySelectorAll("style, link[rel='stylesheet']"))
|
||||||
|
.map((el) => el.outerHTML)
|
||||||
|
.join("")}
|
||||||
|
<style>
|
||||||
|
@page { size: A4 landscape; margin: 0; }
|
||||||
|
html, body { width: 297mm; height: 210mm; margin: 0; padding: 0; }
|
||||||
|
* { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
${content.outerHTML}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`);
|
||||||
|
frameDoc.close();
|
||||||
|
|
||||||
|
frame.onload = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
frame.contentWindow?.print();
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(frame);
|
||||||
|
printFrameRef.current = null;
|
||||||
|
document.title = originalTitleRef.current;
|
||||||
|
}, 100);
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
}, [contentRef]);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import type { GameModule } from "@/types/shared";
|
||||||
|
import { mothership } from "@/games/mothership";
|
||||||
|
import { mothershipKarth } from "@/games/mothership-karth";
|
||||||
|
import { mythicBastionland } from "@/games/mythic-bastionland";
|
||||||
|
|
||||||
|
export type GameId = "mothership" | "mothership-karth" | "mythic-bastionland";
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
export const games: Record<GameId, GameModule<any>> = {
|
||||||
|
mothership,
|
||||||
|
"mothership-karth": mothershipKarth,
|
||||||
|
"mythic-bastionland": mythicBastionland,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const gameList = Object.values(games);
|
||||||
|
|
||||||
|
export function getGame(id: string): GameModule | undefined {
|
||||||
|
return games[id as GameId];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import type { MothershipCharacter } from "@/games/mothership/types";
|
||||||
|
import { karthDefaults } from "./types";
|
||||||
|
import { MothershipSheetViewer } from "@/games/mothership/components/SheetViewer";
|
||||||
|
import { MothershipSheetEditor } from "@/games/mothership/components/SheetEditor";
|
||||||
|
import type { GameModule } from "@/types/shared";
|
||||||
|
|
||||||
|
export const mothershipKarth: GameModule<MothershipCharacter> = {
|
||||||
|
id: "mothership-karth",
|
||||||
|
name: "Mothership Karth",
|
||||||
|
description: "Karth variant of the Mothership system",
|
||||||
|
defaults: karthDefaults,
|
||||||
|
SheetViewer: MothershipSheetViewer,
|
||||||
|
SheetEditor: MothershipSheetEditor,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import type { MothershipCharacter } from "@/games/mothership/types";
|
||||||
|
export type { MothershipCharacter as KarthCharacter } from "@/games/mothership/types";
|
||||||
|
|
||||||
|
export const karthDefaults: MothershipCharacter = {
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
name: "",
|
||||||
|
gameId: "mothership-karth",
|
||||||
|
data: {
|
||||||
|
className: "",
|
||||||
|
level: 1,
|
||||||
|
stats: { strength: 0, speed: 0, intellect: 0, combat: 0 },
|
||||||
|
saves: { sanity: 0, fear: 0, body: 0 },
|
||||||
|
health: { max: 0, current: 0 },
|
||||||
|
wounds: { max: 0, current: 0 },
|
||||||
|
stress: { min: 2, current: 2 },
|
||||||
|
armor: 0,
|
||||||
|
skills: [],
|
||||||
|
equipment: [],
|
||||||
|
notes: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
import type { MothershipCharacter } from "../types";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
character: MothershipCharacter;
|
||||||
|
onChange: (c: MothershipCharacter) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MothershipSheetEditor({ character, onChange }: Props) {
|
||||||
|
const d = character.data;
|
||||||
|
|
||||||
|
const update = (fn: (d: MothershipCharacter["data"]) => void) => {
|
||||||
|
const next = structuredClone(d);
|
||||||
|
fn(next);
|
||||||
|
onChange({ ...character, data: next });
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateName = (name: string) => onChange({ ...character, name });
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-3 text-sm">
|
||||||
|
<label className="flex flex-col gap-1">
|
||||||
|
<span className="font-medium">Name</span>
|
||||||
|
<input
|
||||||
|
value={character.name}
|
||||||
|
onChange={(e) => updateName(e.target.value)}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1"
|
||||||
|
placeholder="Character name"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<label className="flex flex-col gap-1">
|
||||||
|
<span className="font-medium">Class</span>
|
||||||
|
<input
|
||||||
|
value={d.className}
|
||||||
|
onChange={(e) => update((d) => (d.className = e.target.value))}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="flex flex-col gap-1">
|
||||||
|
<span className="font-medium">Level</span>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={d.level}
|
||||||
|
onChange={(e) =>
|
||||||
|
update((d) => (d.level = Number(e.target.value)))
|
||||||
|
}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<fieldset className="rounded border border-stone-300 p-2">
|
||||||
|
<legend className="px-1 font-medium">Stats</legend>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
{(["strength", "speed", "intellect", "combat"] as const).map(
|
||||||
|
(stat) => (
|
||||||
|
<label key={stat} className="flex items-center justify-between">
|
||||||
|
<span className="capitalize">{stat}</span>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={d.stats[stat]}
|
||||||
|
onChange={(e) =>
|
||||||
|
update(
|
||||||
|
(d) =>
|
||||||
|
(d.stats[stat] = Number(e.target.value)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="w-14 rounded border border-stone-300 px-2 py-1 text-center"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset className="rounded border border-stone-300 p-2">
|
||||||
|
<legend className="px-1 font-medium">Saves</legend>
|
||||||
|
<div className="grid grid-cols-3 gap-2">
|
||||||
|
{(["sanity", "fear", "body"] as const).map((save) => (
|
||||||
|
<label key={save} className="flex flex-col items-center gap-1">
|
||||||
|
<span className="capitalize text-xs">{save}</span>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={d.saves[save]}
|
||||||
|
onChange={(e) =>
|
||||||
|
update((d) => (d.saves[save] = Number(e.target.value)))
|
||||||
|
}
|
||||||
|
className="w-full rounded border border-stone-300 px-2 py-1 text-center"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset className="rounded border border-stone-300 p-2">
|
||||||
|
<legend className="px-1 font-medium">Combat</legend>
|
||||||
|
<div className="grid grid-cols-3 gap-2">
|
||||||
|
{(["health", "wounds", "stress"] as const).map((field) => (
|
||||||
|
<label key={field} className="flex flex-col items-center gap-1">
|
||||||
|
<span className="capitalize text-xs">{field}</span>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={d[field].current}
|
||||||
|
onChange={(e) =>
|
||||||
|
update((d) => (d[field].current = Number(e.target.value)))
|
||||||
|
}
|
||||||
|
className="w-full rounded border border-stone-300 px-2 py-1 text-center"
|
||||||
|
placeholder="Cur"
|
||||||
|
/>
|
||||||
|
{field !== "stress" && (
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={d[field].max}
|
||||||
|
onChange={(e) =>
|
||||||
|
update((d) => (d[field].max = Number(e.target.value)))
|
||||||
|
}
|
||||||
|
className="w-full rounded border border-stone-300 px-2 py-1 text-center"
|
||||||
|
placeholder="Max"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
import type { MothershipCharacter } from "../types";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
character: MothershipCharacter;
|
||||||
|
onChange?: (c: MothershipCharacter) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MothershipSheetViewer({ character }: Props) {
|
||||||
|
const d = character.data;
|
||||||
|
const stats = ["strength", "speed", "intellect", "combat"] as const;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col p-3">
|
||||||
|
<div className="border-b-2 border-black pb-1 text-center text-sm font-bold uppercase tracking-wider">
|
||||||
|
Mothership Character Sheet
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-1 flex items-center gap-2 border-b border-black pb-1 text-sm">
|
||||||
|
<span className="font-bold">Name:</span>
|
||||||
|
<span>{character.name || "________"}</span>
|
||||||
|
<span className="ml-auto">
|
||||||
|
<span className="font-bold">Class:</span> {d.className || "________"}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span className="font-bold">Lvl:</span> {d.level}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-2 grid grid-cols-4 gap-1">
|
||||||
|
{stats.map((stat) => (
|
||||||
|
<div key={stat} className="border border-black px-1 py-0.5 text-center">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">{stat}</div>
|
||||||
|
<div className="text-lg font-bold">{d.stats[stat]}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-2 grid grid-cols-3 gap-1">
|
||||||
|
{(["sanity", "fear", "body"] as const).map((save) => (
|
||||||
|
<div key={save} className="border border-black px-1 py-0.5 text-center">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">{save}</div>
|
||||||
|
<div className="text-lg font-bold">{d.saves[save]}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-2 grid grid-cols-3 gap-1 text-center text-[8pt]">
|
||||||
|
<div className="border border-black p-1">
|
||||||
|
<div className="font-bold">Health</div>
|
||||||
|
<div>
|
||||||
|
{d.health.current}/{d.health.max}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="border border-black p-1">
|
||||||
|
<div className="font-bold">Wounds</div>
|
||||||
|
<div>
|
||||||
|
{d.wounds.current}/{d.wounds.max}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="border border-black p-1">
|
||||||
|
<div className="font-bold">Stress</div>
|
||||||
|
<div>{d.stress.current}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-2 flex-1">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">Skills</div>
|
||||||
|
<div className="border border-black">
|
||||||
|
{d.skills.length === 0 && (
|
||||||
|
<div className="px-1 py-0.5 text-[7pt] text-stone-400 italic">
|
||||||
|
No skills
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{d.skills.map((s, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="flex justify-between border-b border-stone-300 px-1 py-0.5 text-[7pt] last:border-b-0"
|
||||||
|
>
|
||||||
|
<span>{s.name}</span>
|
||||||
|
<span className="font-bold">{s.value}%</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-1">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">Equipment</div>
|
||||||
|
<div className="border border-black">
|
||||||
|
{d.equipment.length === 0 && (
|
||||||
|
<div className="px-1 py-0.5 text-[7pt] text-stone-400 italic">
|
||||||
|
No equipment
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{d.equipment.map((e, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="border-b border-stone-300 px-1 py-0.5 text-[7pt] last:border-b-0"
|
||||||
|
>
|
||||||
|
<span className="font-bold">{e.name}</span>
|
||||||
|
{e.notes && (
|
||||||
|
<span className="text-stone-500"> — {e.notes}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import type { MothershipCharacter } from "./types";
|
||||||
|
|
||||||
|
export const mothershipDefaults: MothershipCharacter = {
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
name: "",
|
||||||
|
gameId: "mothership",
|
||||||
|
data: {
|
||||||
|
className: "",
|
||||||
|
level: 1,
|
||||||
|
stats: { strength: 0, speed: 0, intellect: 0, combat: 0 },
|
||||||
|
saves: { sanity: 0, fear: 0, body: 0 },
|
||||||
|
health: { max: 0, current: 0 },
|
||||||
|
wounds: { max: 0, current: 0 },
|
||||||
|
stress: { min: 2, current: 2 },
|
||||||
|
armor: 0,
|
||||||
|
skills: [],
|
||||||
|
equipment: [],
|
||||||
|
notes: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import type { GameModule } from "@/types/shared";
|
||||||
|
import type { MothershipCharacter } from "./types";
|
||||||
|
import { mothershipDefaults } from "./defaults";
|
||||||
|
import { MothershipSheetViewer } from "./components/SheetViewer";
|
||||||
|
import { MothershipSheetEditor } from "./components/SheetEditor";
|
||||||
|
|
||||||
|
export { type MothershipCharacter } from "./types";
|
||||||
|
|
||||||
|
export const mothership: GameModule<MothershipCharacter> = {
|
||||||
|
id: "mothership",
|
||||||
|
name: "Mothership",
|
||||||
|
description: "Sci-fi horror RPG",
|
||||||
|
defaults: mothershipDefaults,
|
||||||
|
SheetViewer: MothershipSheetViewer,
|
||||||
|
SheetEditor: MothershipSheetEditor,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
export interface MothershipCharacter {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
gameId: string;
|
||||||
|
data: {
|
||||||
|
className: string;
|
||||||
|
level: number;
|
||||||
|
stats: {
|
||||||
|
strength: number;
|
||||||
|
speed: number;
|
||||||
|
intellect: number;
|
||||||
|
combat: number;
|
||||||
|
};
|
||||||
|
saves: {
|
||||||
|
sanity: number;
|
||||||
|
fear: number;
|
||||||
|
body: number;
|
||||||
|
};
|
||||||
|
health: { max: number; current: number };
|
||||||
|
wounds: { max: number; current: number };
|
||||||
|
stress: { min: number; current: number };
|
||||||
|
armor: number;
|
||||||
|
skills: { name: string; value: number }[];
|
||||||
|
equipment: { name: string; notes: string }[];
|
||||||
|
notes: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
import type { MythicBastionlandCharacter } from "../types";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
character: MythicBastionlandCharacter;
|
||||||
|
onChange: (c: MythicBastionlandCharacter) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MythicBastionlandSheetEditor({ character, onChange }: Props) {
|
||||||
|
const d = character.data;
|
||||||
|
|
||||||
|
const update = (fn: (d: MythicBastionlandCharacter["data"]) => void) => {
|
||||||
|
const next = structuredClone(d);
|
||||||
|
fn(next);
|
||||||
|
onChange({ ...character, data: next });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-3 text-sm">
|
||||||
|
<label className="flex flex-col gap-1">
|
||||||
|
<span className="font-medium">Knight Name</span>
|
||||||
|
<input
|
||||||
|
value={character.name}
|
||||||
|
onChange={(e) => onChange({ ...character, name: e.target.value })}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1"
|
||||||
|
placeholder="Name"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<label className="flex flex-col gap-1">
|
||||||
|
<span className="font-medium">Title</span>
|
||||||
|
<input
|
||||||
|
value={d.title}
|
||||||
|
onChange={(e) => update((d) => (d.title = e.target.value))}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="flex flex-col gap-1">
|
||||||
|
<span className="font-medium">Knight Type</span>
|
||||||
|
<input
|
||||||
|
value={d.knightType}
|
||||||
|
onChange={(e) => update((d) => (d.knightType = e.target.value))}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<fieldset className="rounded border border-stone-300 p-2">
|
||||||
|
<legend className="px-1 font-medium">Omens</legend>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<label className="flex flex-col items-center gap-1">
|
||||||
|
<span className="text-xs">Current</span>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={d.omens.current}
|
||||||
|
onChange={(e) =>
|
||||||
|
update((d) => (d.omens.current = Number(e.target.value)))
|
||||||
|
}
|
||||||
|
className="w-full rounded border border-stone-300 px-2 py-1 text-center"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="flex flex-col items-center gap-1">
|
||||||
|
<span className="text-xs">Max</span>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={d.omens.max}
|
||||||
|
onChange={(e) =>
|
||||||
|
update((d) => (d.omens.max = Number(e.target.value)))
|
||||||
|
}
|
||||||
|
className="w-full rounded border border-stone-300 px-2 py-1 text-center"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span className="font-medium">Virtues</span>
|
||||||
|
<p className="text-xs text-stone-500">
|
||||||
|
Add virtues in format: Name (d4-d12)
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span className="font-medium">Blessings</span>
|
||||||
|
<p className="text-xs text-stone-500">Each on a new line</p>
|
||||||
|
<textarea
|
||||||
|
value={d.blessings.join("\n")}
|
||||||
|
onChange={(e) =>
|
||||||
|
update(
|
||||||
|
(d) =>
|
||||||
|
(d.blessings = e.target.value
|
||||||
|
.split("\n")
|
||||||
|
.filter(Boolean)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1 text-sm"
|
||||||
|
rows={3}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span className="font-medium">Oaths</span>
|
||||||
|
<p className="text-xs text-stone-500">Each on a new line</p>
|
||||||
|
<textarea
|
||||||
|
value={d.oaths.join("\n")}
|
||||||
|
onChange={(e) =>
|
||||||
|
update(
|
||||||
|
(d) => (d.oaths = e.target.value.split("\n").filter(Boolean)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="rounded border border-stone-300 px-2 py-1 text-sm"
|
||||||
|
rows={3}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
import type { MythicBastionlandCharacter } from "../types";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
character: MythicBastionlandCharacter;
|
||||||
|
onChange?: (c: MythicBastionlandCharacter) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MythicBastionlandSheetViewer({ character }: Props) {
|
||||||
|
const d = character.data;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col p-3">
|
||||||
|
<div className="border-b-2 border-black pb-1 text-center text-sm font-bold uppercase tracking-wider">
|
||||||
|
Mythic Bastionland
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-1 flex items-center gap-2 border-b border-black pb-1 text-sm">
|
||||||
|
<span className="font-bold">Knight:</span>
|
||||||
|
<span>{character.name || "________"}</span>
|
||||||
|
<span className="ml-auto">
|
||||||
|
<span className="font-bold">Title:</span> {d.title || "________"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-2 flex items-center justify-between border border-black px-2 py-1">
|
||||||
|
<span className="text-sm font-bold">Omens</span>
|
||||||
|
<span className="text-lg font-bold">
|
||||||
|
{d.omens.current}/{d.omens.max}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-2 flex-1">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">Virtues</div>
|
||||||
|
<div className="border border-black">
|
||||||
|
{d.virtues.length === 0 && (
|
||||||
|
<div className="px-1 py-0.5 text-[7pt] text-stone-400 italic">
|
||||||
|
No virtues
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{d.virtues.map((v, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="flex justify-between border-b border-stone-300 px-1 py-0.5 text-[7pt] last:border-b-0"
|
||||||
|
>
|
||||||
|
<span>{v.name}</span>
|
||||||
|
<span className="font-bold">d{v.value}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-1">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">Blessings</div>
|
||||||
|
<div className="border border-black">
|
||||||
|
{d.blessings.length === 0 && (
|
||||||
|
<div className="px-1 py-0.5 text-[7pt] text-stone-400 italic">
|
||||||
|
No blessings
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{d.blessings.map((b, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="border-b border-stone-300 px-1 py-0.5 text-[7pt] last:border-b-0"
|
||||||
|
>
|
||||||
|
{b}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-1">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">Oaths</div>
|
||||||
|
<div className="border border-black">
|
||||||
|
{d.oaths.length === 0 && (
|
||||||
|
<div className="px-1 py-0.5 text-[7pt] text-stone-400 italic">
|
||||||
|
No oaths
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{d.oaths.map((o, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="border-b border-stone-300 px-1 py-0.5 text-[7pt] last:border-b-0"
|
||||||
|
>
|
||||||
|
{o}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-1">
|
||||||
|
<div className="text-[7pt] font-bold uppercase">Inventory</div>
|
||||||
|
<div className="border border-black">
|
||||||
|
{d.inventory.length === 0 && (
|
||||||
|
<div className="px-1 py-0.5 text-[7pt] text-stone-400 italic">
|
||||||
|
No items
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{d.inventory.map((item, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="flex justify-between border-b border-stone-300 px-1 py-0.5 text-[7pt] last:border-b-0"
|
||||||
|
>
|
||||||
|
<span>{item.name}</span>
|
||||||
|
<span className="text-stone-500">{item.uses} uses</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import type { MythicBastionlandCharacter } from "./types";
|
||||||
|
|
||||||
|
export const mythicBastionlandDefaults: MythicBastionlandCharacter = {
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
name: "",
|
||||||
|
gameId: "mythic-bastionland",
|
||||||
|
data: {
|
||||||
|
title: "",
|
||||||
|
knightType: "",
|
||||||
|
omens: { max: 3, current: 3 },
|
||||||
|
virtues: [],
|
||||||
|
blessings: [],
|
||||||
|
oaths: [],
|
||||||
|
inventory: [],
|
||||||
|
bonds: [],
|
||||||
|
notes: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import type { GameModule } from "@/types/shared";
|
||||||
|
import type { MythicBastionlandCharacter } from "./types";
|
||||||
|
import { mythicBastionlandDefaults } from "./defaults";
|
||||||
|
import { MythicBastionlandSheetViewer } from "./components/SheetViewer";
|
||||||
|
import { MythicBastionlandSheetEditor } from "./components/SheetEditor";
|
||||||
|
|
||||||
|
export { type MythicBastionlandCharacter } from "./types";
|
||||||
|
|
||||||
|
export const mythicBastionland: GameModule<MythicBastionlandCharacter> = {
|
||||||
|
id: "mythic-bastionland",
|
||||||
|
name: "Mythic Bastionland",
|
||||||
|
description: "Mythic bastion-building RPG",
|
||||||
|
defaults: mythicBastionlandDefaults,
|
||||||
|
SheetViewer: MythicBastionlandSheetViewer,
|
||||||
|
SheetEditor: MythicBastionlandSheetEditor,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
export interface MythicBastionlandCharacter {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
gameId: string;
|
||||||
|
data: {
|
||||||
|
title: string;
|
||||||
|
knightType: string;
|
||||||
|
omens: { max: number; current: number };
|
||||||
|
virtues: { name: string; value: number }[];
|
||||||
|
blessings: string[];
|
||||||
|
oaths: string[];
|
||||||
|
inventory: { name: string; uses: number }[];
|
||||||
|
bonds: string[];
|
||||||
|
notes: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
@custom-variant print (@media print);
|
||||||
|
|
||||||
|
@page {
|
||||||
|
size: A4 landscape;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
width: 297mm;
|
||||||
|
height: 210mm;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-print {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-only {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen {
|
||||||
|
.print-only {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { StrictMode } from "react";
|
||||||
|
import { createRoot } from "react-dom/client";
|
||||||
|
import { App } from "./App";
|
||||||
|
import "./index.css";
|
||||||
|
|
||||||
|
createRoot(document.getElementById("root")!).render(
|
||||||
|
<StrictMode>
|
||||||
|
<App />
|
||||||
|
</StrictMode>,
|
||||||
|
);
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import { gameList } from "@/games";
|
||||||
|
import { FiFileText } from "react-icons/fi";
|
||||||
|
|
||||||
|
export function HomePage() {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-1 items-center justify-center p-8">
|
||||||
|
<div className="w-full max-w-lg text-center">
|
||||||
|
<h1 className="mb-2 text-3xl font-bold">Character Sheet Generator</h1>
|
||||||
|
<p className="mb-8 text-stone-500">
|
||||||
|
Create and print A5 character sheets for your favorite RPGs.
|
||||||
|
</p>
|
||||||
|
<div className="grid gap-3">
|
||||||
|
{gameList.map((game) => (
|
||||||
|
<Link
|
||||||
|
key={game.id}
|
||||||
|
to={`/${game.id}`}
|
||||||
|
className="flex items-center gap-4 rounded-lg border border-stone-300 bg-white p-4 text-left shadow-sm transition hover:border-stone-500 hover:shadow-md"
|
||||||
|
>
|
||||||
|
<FiFileText className="text-2xl text-stone-400" />
|
||||||
|
<div>
|
||||||
|
<div className="font-semibold">{game.name}</div>
|
||||||
|
<div className="text-sm text-stone-500">{game.description}</div>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { AppShell } from "@/components/layout/AppShell";
|
||||||
|
import { HomePage } from "@/routes/home";
|
||||||
|
import { SheetPage } from "@/routes/sheet";
|
||||||
|
import type { RouteObject } from "react-router-dom";
|
||||||
|
|
||||||
|
export const routes: RouteObject[] = [
|
||||||
|
{
|
||||||
|
element: <AppShell />,
|
||||||
|
children: [
|
||||||
|
{ path: "/", element: <HomePage /> },
|
||||||
|
{ path: "/:gameId", element: <SheetPage /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { useParams, Navigate } from "react-router-dom";
|
||||||
|
import { useRef, useState } from "react";
|
||||||
|
import { getGame } from "@/games";
|
||||||
|
import { A5Sheet } from "@/components/print/A5Sheet";
|
||||||
|
import { A4PrintLayout } from "@/components/print/A4PrintLayout";
|
||||||
|
import { PrintButton } from "@/components/print/PrintButton";
|
||||||
|
import type { CharacterData } from "@/types/shared";
|
||||||
|
|
||||||
|
export function SheetPage() {
|
||||||
|
const { gameId } = useParams<{ gameId: string }>();
|
||||||
|
const game = gameId ? getGame(gameId) : undefined;
|
||||||
|
const printRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
if (!game) return <Navigate to="/" replace />;
|
||||||
|
|
||||||
|
const [character, setCharacter] = useState<CharacterData>({
|
||||||
|
...game.defaults,
|
||||||
|
gameId: game.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { SheetViewer, SheetEditor } = game;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full">
|
||||||
|
<div className="no-print w-80 flex-shrink-0 overflow-auto border-r border-stone-300 bg-white p-4">
|
||||||
|
<h2 className="mb-4 text-lg font-semibold">{game.name} Editor</h2>
|
||||||
|
<SheetEditor character={character} onChange={setCharacter} />
|
||||||
|
<div className="mt-6">
|
||||||
|
<PrintButton previewRef={printRef} className="w-full" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex-1 overflow-auto bg-stone-200 p-4">
|
||||||
|
<div className="flex items-start justify-center gap-4">
|
||||||
|
<div ref={printRef} className="flex gap-0 print-only">
|
||||||
|
<A4PrintLayout
|
||||||
|
left={
|
||||||
|
<A5Sheet>
|
||||||
|
<SheetViewer character={character} />
|
||||||
|
</A5Sheet>
|
||||||
|
}
|
||||||
|
right={
|
||||||
|
<A5Sheet>
|
||||||
|
<SheetViewer character={character} />
|
||||||
|
</A5Sheet>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="print:hidden">
|
||||||
|
<A5Sheet>
|
||||||
|
<SheetViewer character={character} />
|
||||||
|
</A5Sheet>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import type { ComponentType } from "react";
|
||||||
|
|
||||||
|
export interface CharacterData {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
gameId: string;
|
||||||
|
data: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GameModule<T extends CharacterData = CharacterData> {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
defaults: T;
|
||||||
|
SheetViewer: ComponentType<{ character: T; onChange?: (c: T) => void }>;
|
||||||
|
SheetEditor: ComponentType<{ character: T; onChange: (c: T) => void }>;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
"target": "ES2022",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUncheckedSideEffectImports": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src", "vite-env.d.ts"]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{ "path": "./tsconfig.app.json" },
|
||||||
|
{ "path": "./tsconfig.node.json" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
"target": "es2023",
|
||||||
|
"lib": ["ES2023"],
|
||||||
|
"module": "esnext",
|
||||||
|
"types": ["node"],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"erasableSyntaxOnly": true,
|
||||||
|
"noFallthroughCasesInSwitch": true
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts"]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { defineConfig } from "vite";
|
||||||
|
import react from "@vitejs/plugin-react";
|
||||||
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [tailwindcss(), react()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@": "/src",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue