feat(walls): proto 2 typed wall record, inert geometry, derived kind (#54)

wall.add/wall.update take thickness, position, height and the eight raw
switches; kind is output-only and the GM wall frames echo the full typed
record. Geometry is stored but inert (0/full/centre behaviour), and the
legacy kind/open wire adapter is gone. proto is bumped to 2 with the
harness default, and BannedAlways gains every wall field name with a
WALLDATA positive control.

Tests: schema-7 migrated scene vs the same walls authored via raw switches
gives byte-identical player frames, refusals and per-tile statuses.
Nim 382 / Node 113 green.
This commit is contained in:
2026-11-19 22:21:47 +01:00
parent c1b1e9cf91
commit 77fa2dfe4c
23 changed files with 852 additions and 318 deletions
+5 -5
View File
@@ -9,9 +9,9 @@ proc sceneWith(walls: seq[WallRec]): SceneRec =
visionRadiusDefault: 400, tokenRadiusDefault: 20, artVersion: 1, nextWallId: 1,
extra: newJObject(), walls: walls)
proc wall(ax, ay, bx, by: float, kind = wkWall, open = false): WallRec =
proc wall(ax, ay, bx, by: float, door = false, open = false): WallRec =
result = defaultWall((ax, ay), (bx, by))
result.kind = kind
result.door = door
result.open = open
proc tok(id: string, x, y: float, owner: int, visionFlag = true, gmOnly = false): TokenRec =
@@ -55,8 +55,8 @@ suite "polygons (5.1: one per controlled token with the `vision` flag)":
for p in pts: check hypot(p.x - 400, p.y - 400) <= 121
test "an open door does not block; closing it does (5.1, 5.5)":
let closed = sceneWith(@[wall(700, 0, 700, 4096, wkDoor, open = false)])
let open = sceneWith(@[wall(700, 0, 700, 4096, wkDoor, open = true)])
let closed = sceneWith(@[wall(700, 0, 700, 4096, door = true, open = false)])
let open = sceneWith(@[wall(700, 0, 700, 4096, door = true, open = true)])
let tokens = @[tok("me", 400, 400, 2)]
check computePolys(closed, tokens, 2)[0].pts.allIt(it.x <= 701)
check computePolys(open, tokens, 2)[0].pts.anyIt(it.x > 790)
@@ -90,7 +90,7 @@ suite "explored (5.1, 8: strictly per player, only grows)":
check not pv.insideAny((400.0, 400.0))
test "a closed door hides the cells behind it; opening it adds them":
var sc = sceneWith(@[wall(700, 0, 700, 4096, wkDoor, open = false)])
var sc = sceneWith(@[wall(700, 0, 700, 4096, door = true, open = false)])
var pv: PlayerVision
pv.refresh(sc, @[tok("me", 400, 400, 2)], 2)
let behind = sc.cellIndex(23, 12) # x ~ 750, past the closed door