Scaffold monorepo: engine, server, and web packages
npm workspaces with three TypeScript packages: @wizwar/engine (pure game logic), @wizwar/server (Node websocket authority), @wizwar/web (Svelte 5 + Vite client). Server handshake and client build verified. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
node_modules/
|
||||
dist/
|
||||
*.local
|
||||
.env
|
||||
.DS_Store
|
||||
Generated
+2429
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "wizwar",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"description": "Web-based Wiz-War (6th edition rules)",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "npm run dev --workspace=@wizwar/server & npm run dev --workspace=@wizwar/web",
|
||||
"build": "npm run build --workspaces",
|
||||
"test": "npm run test --workspaces --if-present",
|
||||
"typecheck": "npm run typecheck --workspaces"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@wizwar/engine",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.6.0",
|
||||
"vitest": "^2.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// @wizwar/engine — pure, deterministic game logic. No I/O, no timers, no
|
||||
// network: the server drives it in real time, the async mode replays it from
|
||||
// stored commands, and future AI players call it to evaluate moves.
|
||||
//
|
||||
// Card data, board layouts, and precise rule mechanics are pending
|
||||
// transcription of the 6th edition materials (see /research).
|
||||
|
||||
export interface PlayerId {
|
||||
readonly id: string;
|
||||
}
|
||||
|
||||
/** A single square on a sector board. Walls live on edges between squares. */
|
||||
export interface Position {
|
||||
readonly x: number;
|
||||
readonly y: number;
|
||||
}
|
||||
|
||||
export type GamePhase = "setup" | "playing" | "finished";
|
||||
|
||||
export interface GameState {
|
||||
readonly phase: GamePhase;
|
||||
readonly turn: number;
|
||||
readonly activePlayer: string;
|
||||
// TODO: board (sectors, walls, doors), players (position, life, hand,
|
||||
// sustained spells, carried items/treasures), deck & discard, RNG seed.
|
||||
}
|
||||
|
||||
/** Commands are player intents; the engine validates and applies them. */
|
||||
export type Command = { type: "todo" };
|
||||
|
||||
/** Events are what actually happened; clients render from these. */
|
||||
export type GameEvent = { type: "todo" };
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@wizwar/server",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wizwar/engine": "*",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/ws": "^8.5.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.6.0",
|
||||
"vitest": "^2.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { WebSocketServer } from "ws";
|
||||
|
||||
const port = Number(process.env.PORT ?? 8787);
|
||||
const wss = new WebSocketServer({ port });
|
||||
|
||||
wss.on("connection", (socket) => {
|
||||
socket.send(JSON.stringify({ type: "hello", game: "wizwar" }));
|
||||
socket.on("message", (data) => {
|
||||
// TODO: route client commands into game rooms once the engine exists.
|
||||
console.log("received:", data.toString());
|
||||
});
|
||||
});
|
||||
|
||||
console.log(`wizwar server listening on ws://localhost:${port}`);
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wiz-War</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@wizwar/web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"typecheck": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wizwar/engine": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"typescript": "^5.6.0",
|
||||
"vite": "^5.4.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<script lang="ts">
|
||||
let status = $state("disconnected");
|
||||
|
||||
const ws = new WebSocket("ws://localhost:8787");
|
||||
ws.onopen = () => (status = "connected");
|
||||
ws.onclose = () => (status = "disconnected");
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<h1>Wiz-War</h1>
|
||||
<p>server: {status}</p>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
main {
|
||||
font-family: system-ui, sans-serif;
|
||||
padding: 2rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,6 @@
|
||||
import { mount } from "svelte";
|
||||
import App from "./App.svelte";
|
||||
|
||||
const app = mount(App, { target: document.getElementById("app")! });
|
||||
|
||||
export default app;
|
||||
@@ -0,0 +1,5 @@
|
||||
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
||||
|
||||
export default {
|
||||
preprocess: vitePreprocess(),
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"types": ["svelte", "vite/client"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"declaration": true,
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user