@bordiko/sdk
v0.4.0
Published
Author Bordiko board games: defineGame, the deterministic engine, the hybrid board schema, and the sandboxed custom-UI client. Compile to WebAssembly and publish to the marketplace.
Downloads
837
Maintainers
Readme
@bordiko/sdk
Everything you need to author a Bordiko board game: defineGame, the deterministic
engine, the hybrid board schema, and the sandboxed custom-UI client
(@bordiko/sdk/ui). Pairs with @bordiko/cli to scaffold, play in a local
sandbox, compile to WebAssembly, and publish — all from your own repo.
Now (Phase 1)
defineGame(def)— validates a game definition (kebab-case id, player range, non-empty moves, setup present,meta.displayName) and brands it.BoardSchema— declarative boards:grid | hex | network | tableau | custom.- Re-exports everything from
@bordiko/engine(createMatch,applyMove,applyTick,getPlayerView,replay,INVALID_MOVE,TickContext, types, …).
Real-time (action) games
Give your definition a tick(G, dt, ctx) and the host drives a fixed-rate clock,
so the world advances even without input — turn-based games just omit it.
export default defineGame({
name: "sumo", minPlayers: 2, maxPlayers: 2,
setup: () => ({ /* disks, velocities … */ }),
initialActive: (G) => G.disks.map((d) => d.id), // all seats act at once
moves: { input: (G, p, ctx) => { /* record held thrust into G only */ } },
tick: (G, dt) => { /* integrate physics by the FIXED step dt (ms) */ },
});Declare it in the manifest: "realtime": { "tick": true, "tickRate": 15 } (≤ 30).
Keep tick deterministic (fixed dt, no wall clock, ctx.random only). Your UI
subscribes with connectBordiko().onState(...), sends move("input", …), and
interpolates with requestAnimationFrame. @bordiko/sdk/ui also exposes
fullscreen() (asks the host to fullscreen the game stage). See games/sumo.
Debugging
The sandbox has no host-visible console. Open a game with ?debug (or press
Ctrl+Shift+D) for a developer panel that shows the live state + legal moves and
the sandbox's forwarded logs. Uncaught errors, console.error/console.warn are
forwarded automatically; use connectBordiko().debug(...) for intentional output.
import { defineGame } from "@bordiko/sdk";
export default defineGame({
name: "my-game", minPlayers: 2, maxPlayers: 2,
setup: () => ({ /* ... */ }),
moves: { /* ... */ },
meta: { displayName: "My Game", board: { kind: "grid", rows: 3, cols: 3 } },
});The workflow (with @bordiko/cli)
npm create @bordiko/game my-game # scaffold a project
cd my-game && npm install
npm run dev # local sandbox: every seat, bots, hot-reload, custom-UI preview
npm test # plain Node, no build
npm run build # compile to WebAssembly (auto-downloads Javy, no Docker)
npm run publish:game # ship to the marketplaceFull guide: https://bordiko.com/developers
Run the SDK tests: npm test.
