feat(bgm): derive definition names from role.type

A definition is identified by role.type and named role.type.lang
(package.lang for packages). Code blocks declare it via role= on the
info string; real files by their filename. Blocks and files without a
matching role.type are ignored. file= still overrides the auto-name.

Relative asset and $variants paths now resolve against the markdown
file's directory (baseDir) rather than the virtual name. Same role.type
with different ids groups under one name; duplicate type#id still
errors. Migrate fixtures and example games to role=.
This commit is contained in:
2026-08-10 16:36:57 +08:00
parent 23332ab786
commit 13b3eaed78
12 changed files with 211 additions and 173 deletions
+4 -11
View File
@@ -4,8 +4,7 @@ A standard 52-card poker deck, laid out on a table with a draw pile and
community-card slots. Exercises the bgm loader's `$variants` expansion to
generate a full deck from a single part definition.
```yaml file=poker.yaml
role: package
```yaml role=package
id: poker
title: Poker
designer: Public Domain
@@ -21,9 +20,7 @@ picks a cell from the `13×4` face sheet (`cards-13x4.jpg`) — 13 ranks across,
4 suits down. All cards share the same back from the `4×1` back sheet
(`back-4x1.png`).
```yaml file=cards.yaml
role: part
type: card
```yaml role=part.card
face: ./cards-13x4.jpg
back: ./back-4x1.png
size: [63, 88, 0.3]
@@ -93,10 +90,8 @@ ac,A,clubs,[12;3;13;4],[0;0;4;1]
A table with a draw pile on the left and five community-card slots across the
middle. The deck pile fans its stacked cards along a curve.
```yaml file=board.yaml
type: board
```yaml role=surface.board
id: poker
role: surface
size: [600, 400]
layout:
- route: /deck
@@ -129,9 +124,7 @@ Deal the whole deck facedown onto the draw pile (`poker:card` expands to every
card of that type, `facing: back`), then flip a flop onto the community slots
and stand a couple of drawn cards on their bottom edge.
```yaml file=main.yaml
role: setup
type: game
```yaml role=setup.game
id: main
setup:
- path: /deck