docs: update Agents.md
This commit is contained in:
parent
acb2fc82ba
commit
0e7aaea7da
19
AGENTS.md
19
AGENTS.md
|
|
@ -9,35 +9,34 @@ A Phaser 3 framework for building web board games, built on top of `boardgame-co
|
|||
|
||||
## boardgame-core Usage
|
||||
|
||||
For detailed boardgame-core API documentation and examples, see **[boardgame-core Guide](docs/boardgame-core-guide.md)**.
|
||||
For detailed boardgame-core API documentation and examples, see `packages/framework/node_modules/boardgame-core/`
|
||||
|
||||
Key concepts:
|
||||
- **MutableSignal** — Reactive state container with `.value` and `.produce()`
|
||||
- **Command System** — CLI-style parsing with schema validation and prompt support
|
||||
- **Region System** — Spatial management with `createRegion()`, `applyAlign()`, `shuffle()`, `moveToRegion()`
|
||||
- **Part System** — Game pieces with `createPart()`, `createPartPool()`, `flip()`, `roll()`
|
||||
- **Part System** — Game pieces with `createPartsFromTable()`, `flip()`, `roll()`
|
||||
- **RNG** — Deterministic PRNG via `createRNG(seed)` for reproducible game states
|
||||
|
||||
### Quick Example
|
||||
|
||||
```ts
|
||||
import { createGameCommandRegistry, createRegion, MutableSignal } from 'boardgame-core';
|
||||
import { createGameCommandRegistry, createRegion, IGameContext } from 'boardgame-core';
|
||||
|
||||
type GameState = {
|
||||
board: Region;
|
||||
parts: Part<{ player: 'X' | 'O' }>[];
|
||||
currentPlayer: 'X' | 'O';
|
||||
};
|
||||
type Game = IGameContext<GameState>;
|
||||
|
||||
const registration = createGameCommandRegistry<GameState>();
|
||||
export const registry = registration.registry;
|
||||
const registry = createGameCommandRegistry<GameState>();
|
||||
|
||||
registration.add('place <row:number> <col:number>', async function(cmd) {
|
||||
const [row, col] = cmd.params as [number, number];
|
||||
this.context.produce(state => {
|
||||
registry.register('place <row:number> <col:number>', async function(game: Game, row: number, col: number) {
|
||||
await game.produceAsync(state => {
|
||||
state.parts.push({ id: `p-${row}-${col}`, regionId: 'board', position: [row, col], player: state.currentPlayer });
|
||||
});
|
||||
return { success: true };
|
||||
return true;
|
||||
});
|
||||
```
|
||||
|
||||
|
|
@ -71,7 +70,7 @@ pnpm --filter sample-game typecheck # tsc --noEmit (add to scripts first)
|
|||
```bash
|
||||
# boardgame-core is a local dependency via symlink (link:../../../boardgame-core)
|
||||
# After changes to boardgame-core, simply rebuild it:
|
||||
cd ../boardgame-core && pnpm build
|
||||
cd ../boardgame-core && npm build
|
||||
# The symlink automatically resolves to the updated dist/
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue