feat(walls): door refusals and secret/locked equivalence gate (#56)
- door.set: opening a secret or locked door is invalid; closing either is allowed; a fixed window/non-door still has no open state. - new tools/doors.test.mjs: two fresh servers, one identical script, three equivalence pairs (secret/wall, secret+locked/wall, locked/closed door), canonicalised frame + full per-player tile sweeps, an open-door positive control and a pinned zero-thickness close-push. - secretgap fault hook (sight-only) makes the pair fail as exactly SECRETGAP; the clean pair passes and the shipped binary carries no fault hook. - docs/TESTING.md T2/T17 and the door-equivalence/10.3 sections: built. Ref #56
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ proc cellOf*(sc: SceneRec, idx: int): (int, int) =
|
||||
proc computePolys*(sc: SceneRec, tokens: seq[TokenRec], playerId: int): seq[Poly] =
|
||||
## One polygon per token of this player that has vision, in token order (a stable wire order).
|
||||
if playerId <= 0: return
|
||||
let walls = geometryWalls(sc)
|
||||
let walls = geometryWalls(sc, forSight = true)
|
||||
for t in tokens:
|
||||
if t.owner != playerId or not t.hasVision: continue
|
||||
result.add Poly(tokenId: t.id,
|
||||
|
||||
+7
-3
@@ -504,11 +504,15 @@ proc removeWall*(db: DbConn, sc: var SceneRec, id: int): WallApply =
|
||||
waOk
|
||||
|
||||
proc setDoor*(db: DbConn, sc: var SceneRec, id: int, open: bool): WallApply =
|
||||
## `door.set`: only a door can be opened or closed (`invalid` on a plain wall).
|
||||
## `door.set`: only a door has an open state (`invalid` on a plain wall or a fixed window). A
|
||||
## secret door is always closed and a locked door only refuses opening, so `open:true` on either
|
||||
## is `invalid`; closing either is allowed (it is already closed, DESIGN 5.8, 6.1, #56).
|
||||
let idx = wallIndex(sc, id)
|
||||
if idx.isNone: return waNotFound
|
||||
if sc.walls[idx.get].door == false: return waNotDoor
|
||||
var stored = sc.walls[idx.get]
|
||||
let current = sc.walls[idx.get]
|
||||
if current.door == false: return waNotDoor
|
||||
if open and (current.secret or current.locked): return waInvalid
|
||||
var stored = current
|
||||
stored.open = open
|
||||
authoringTransaction(db):
|
||||
db.exec(sql"UPDATE wall SET open = ? WHERE scene_id = ? AND id = ?",
|
||||
|
||||
+8
-3
@@ -15,13 +15,18 @@
|
||||
## copies a token record before it applies an outcome, and a Nim seq assignment shares its buffer, so
|
||||
## in-place edits would reach the authoritative list before the transaction commits (4.2 step 6).
|
||||
import std/options
|
||||
import geometry, moverules, tokens, world
|
||||
import geometry, moverules, tokens, world, faults
|
||||
|
||||
proc geometryWalls*(sc: SceneRec): seq[Wall] =
|
||||
proc geometryWalls*(sc: SceneRec, forSight = false): seq[Wall] =
|
||||
## The scene's walls as the vision code sees them: an open door does not block (5.1).
|
||||
## `forSight` is only the sight computation; `LEAK_FAULT=secretgap` (a -d:leakfault build only)
|
||||
## opens a secret door there, the negative control for the door-equivalence group (#56).
|
||||
result = newSeqOfCap[Wall](sc.walls.len)
|
||||
for w in sc.walls:
|
||||
result.add Wall(a: w.a, b: w.b, door: w.door, open: w.open)
|
||||
var wall = Wall(a: w.a, b: w.b, door: w.door, open: w.open)
|
||||
if forSight and w.secret and faultActive("secretgap"):
|
||||
wall.open = true
|
||||
result.add wall
|
||||
|
||||
proc ruleWall*(w: WallRec): Wall =
|
||||
## The same wall as the move rules see it (they need `door`/`open` to know what blocks).
|
||||
|
||||
Reference in New Issue
Block a user