@table-games-engine/game-kit 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -0
- package/package.json +8 -5
- package/skill/create-store-game.md +1 -9
- package/template/game.json +1 -1
- package/template/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @table-games-engine/game-kit
|
|
2
|
+
|
|
3
|
+
Toolkit for building a turn-based multiplayer browser game (usually with an LLM such as Claude) and getting it ready for the [Logigra](https://logigra.ru) game store. It scaffolds a game package, ships the instructions your LLM follows, and gives you one command (`check`) that runs everything the store's CI runs.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 20 or newer
|
|
8
|
+
- Docker, only for `game-kit preview`
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx @table-games-engine/game-kit create my-game # scaffold + npm install
|
|
14
|
+
cd my-game
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then build the game with your LLM. Point it at the skill shipped in the package:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
node_modules/@table-games-engine/game-kit/skill/create-store-game.md
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
(the scaffold's `AGENTS.md` already says this). Give it your rules text, locales and player count. Iterate with:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx game-kit test # your unit tests
|
|
27
|
+
npx game-kit simulate -n 200 # random full matches, catches loops and illegal moves
|
|
28
|
+
npx game-kit check # everything CI runs; done when it prints "check: OK"
|
|
29
|
+
npx game-kit preview # play both seats locally (needs Docker)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Commands
|
|
33
|
+
|
|
34
|
+
| Command | Flags | What it does |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `game-kit create <slug>` | `--no-install` | Scaffold a new game in `./<slug>`; installs dependencies unless `--no-install`. |
|
|
37
|
+
| `game-kit test` | none | Runs the game's tests (vitest). |
|
|
38
|
+
| `game-kit simulate` | `-n <matches>` (default 1000), `--seed <n>` (default 1), `--preset <id>`, `--players <n>` | Plays random matches to completion. By default covers every preset and every player count in `game.json`. |
|
|
39
|
+
| `game-kit check` | none | Validates `game.json`, lints `logic/`, typechecks, runs tests, simulates, builds the client. |
|
|
40
|
+
| `game-kit preview` | `--preset <id>`, `--locale <xx>` | Runs the game locally with both seats side by side. Needs Docker. |
|
|
41
|
+
|
|
42
|
+
Numeric flags must be whole numbers (`-n` and `--players` at least 1).
|
|
43
|
+
|
|
44
|
+
## What a game looks like
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
game.json metadata: slug, name, players, locales, presets, rules files, client entry
|
|
48
|
+
rules.md rules text (rules.<locale>.md for more locales)
|
|
49
|
+
logic/index.ts server-side game logic: export default a GamePlugin
|
|
50
|
+
client/ vite app (index.html, main.ts) shown to players
|
|
51
|
+
tests/ vitest tests (the template drives a full match)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`game.json` is validated against `schema/game.schema.json` (referenced by `$schema` in the scaffold).
|
|
55
|
+
|
|
56
|
+
**Logic.** `logic/index.ts` default-exports a `GamePlugin` from `@table-games-engine/core`: a manifest, `setup`, `actionHandlers`, `winConditionChecker`, and `legalMoves(state, playerId)`. `legalMoves` is optional in the core type but required by game-kit (`simulate` and `check` need it); it must list every concrete move that player may submit now (and `[]` when it is not their turn or the game is over). Logic must be deterministic and pure: no `Math.random`, `Date`, network or module-level mutable state. Use `ctx.random*` helpers for randomness. `check` enforces these rules.
|
|
57
|
+
|
|
58
|
+
**Client.** The client runs in a sandboxed iframe with no network access. It talks to the store only through the bridge:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { connectBridge, type StatePayload } from '@table-games-engine/game-kit/bridge';
|
|
62
|
+
|
|
63
|
+
const bridge = connectBridge(
|
|
64
|
+
(s: StatePayload) => render(s), // s.view, s.seat, s.legalMoves, s.status, s.result
|
|
65
|
+
(kind) => showNotice(kind), // 'rejected' | 'reconnecting' | 'server-restart' | 'opponent-left'
|
|
66
|
+
);
|
|
67
|
+
// on a click: bridge.send(chosenMove) // only moves from the latest s.legalMoves
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The full contract, with common failures and fixes, is in the skill file above.
|
|
71
|
+
|
|
72
|
+
## Publishing to the store
|
|
73
|
+
|
|
74
|
+
Games are submitted by pull request to the curated Logigra catalog; request access at [logigra.ru](https://logigra.ru/en/docs/publishing/). Full docs: [logigra.ru/en/docs](https://logigra.ru/en/docs/quickstart/). A game must pass `game-kit check`.
|
|
75
|
+
|
|
76
|
+
## Related packages
|
|
77
|
+
|
|
78
|
+
[`@table-games-engine/core`](https://www.npmjs.com/package/@table-games-engine/core) (types and helpers your logic imports); the other `@table-games-engine/*` packages are installed for you.
|
|
79
|
+
|
|
80
|
+
## Licence
|
|
81
|
+
|
|
82
|
+
Apache-2.0. game-kit also depends on `@table-games-engine/nakama-adapter` and `@table-games-engine/persistence`, which are FSL-1.1-ALv2 (any use except a competing commercial service; each release becomes Apache-2.0 two years later). The games you build are yours.
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@table-games-engine/game-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": { "access": "public" },
|
|
6
6
|
"description": "Build, check, simulate and preview store games on table-games-engine.",
|
|
7
|
+
"keywords": ["table-games", "turn-based", "multiplayer", "game-engine", "llm", "game-store"],
|
|
8
|
+
"homepage": "https://www.npmjs.com/package/@table-games-engine/game-kit",
|
|
7
9
|
"type": "module",
|
|
8
10
|
"bin": { "game-kit": "dist/cli.js" },
|
|
9
11
|
"main": "dist/index.js",
|
|
10
12
|
"types": "dist/index.d.ts",
|
|
11
13
|
"exports": {
|
|
12
14
|
".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
|
|
13
|
-
"./bridge": { "types": "./dist/bridge.d.ts", "default": "./dist/bridge.js" }
|
|
15
|
+
"./bridge": { "types": "./dist/bridge.d.ts", "default": "./dist/bridge.js" },
|
|
16
|
+
"./package.json": "./package.json"
|
|
14
17
|
},
|
|
15
18
|
"files": ["dist", "schema", "template", "nakama", "host", "skill"],
|
|
16
19
|
"scripts": {
|
|
@@ -20,9 +23,9 @@
|
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"@heroiclabs/nakama-js": "^2.7.0",
|
|
23
|
-
"@table-games-engine/core": "^0.1.
|
|
24
|
-
"@table-games-engine/nakama-adapter": "^0.1.
|
|
25
|
-
"@table-games-engine/persistence": "^0.1.
|
|
26
|
+
"@table-games-engine/core": "^0.1.1",
|
|
27
|
+
"@table-games-engine/nakama-adapter": "^0.1.1",
|
|
28
|
+
"@table-games-engine/persistence": "^0.1.1",
|
|
26
29
|
"ajv": "^8.17.0",
|
|
27
30
|
"esbuild": "^0.24.0",
|
|
28
31
|
"eslint": "^9.0.0",
|
|
@@ -4,15 +4,7 @@ Build a store game on table-games-engine in a standalone package created by
|
|
|
4
4
|
`game-kit create`. You are done when `npx game-kit check` exits 0 and prints `check: OK`.
|
|
5
5
|
Do not edit anything under `node_modules/`.
|
|
6
6
|
|
|
7
|
-
> **
|
|
8
|
-
> local tarballs (`core`, `persistence`, `nakama-adapter`, `client-sdk`, `game-kit`). Then:
|
|
9
|
-
> ```sh
|
|
10
|
-
> mkdir installer && (cd installer && npm init -y && npm install /path/to/tarballs/*.tgz)
|
|
11
|
-
> npx --prefix ./installer game-kit create <slug> --no-install
|
|
12
|
-
> cd <slug> && npm install /path/to/tarballs/*.tgz
|
|
13
|
-
> ```
|
|
14
|
-
> (`npx --package=<game-kit tgz>` alone fails: it cannot resolve the sibling packages.)
|
|
15
|
-
> Once published, plain `npx @table-games-engine/game-kit create <slug>` installs for you.
|
|
7
|
+
> **Install:** `npx @table-games-engine/game-kit create <slug>` scaffolds the game and installs its dependencies from public npm (add `--no-install` to skip the install).
|
|
16
8
|
|
|
17
9
|
## Inputs (ask the user if missing)
|
|
18
10
|
|
package/template/game.json
CHANGED
package/template/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"preview": "game-kit preview"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@table-games-engine/core": "^0.1.
|
|
14
|
-
"@table-games-engine/game-kit": "^0.1.
|
|
13
|
+
"@table-games-engine/core": "^0.1.1",
|
|
14
|
+
"@table-games-engine/game-kit": "^0.1.1",
|
|
15
15
|
"typescript": "^5.4.0",
|
|
16
16
|
"vite": "^5.4.0",
|
|
17
17
|
"vitest": "^2.0.0"
|