feat(walls): windows — see-through barrier, movement follows blocks_movement (#57)
- geometry.Wall carries the stored blocks_sight/blocks_movement switches; sight asks blocksSight, movement and the status rules ask blocks (open door passes both). - worldmap translates both switches; moverules only pushes on a movement barrier. - leakcheck and the tile oracle read blocks_sight independently. - Walls/token-details/tiles groups prove both forms, sight-through, stuck, push and the locked-window open refusal; existing scenes stay byte-identical. Ref #57 # Conflicts: # server/geometry.nim # server/world.nim # server/worldmap.nim # tools/leakcheck.nim
This commit is contained in:
@@ -317,6 +317,48 @@ test('wall.update presets replace the whole switch set and raw patches only name
|
||||
})
|
||||
})
|
||||
|
||||
test('window: the opening and fixed forms author, echo and derive kind "window" (#57)', async () => {
|
||||
await withGmServer(async (s, gmKey) => {
|
||||
const gm = await gmConnect(s.origin, gmKey)
|
||||
const { id } = await addWall(gm, { a: [10, 10], b: [300, 10], preset: 'window' })
|
||||
const opening = await wallEffect(gm.ws, m => m.t === 'wall' && m.id === id)
|
||||
assert.equal(opening.kind, 'window')
|
||||
assert.equal(opening.blocks_sight, false)
|
||||
assert.equal(opening.blocks_movement, true)
|
||||
assert.equal(opening.door, true, 'the preset form can be opened')
|
||||
assert.equal(opening.open, false)
|
||||
assert.equal(opening.player_marker, true, 'the window preset carries the marker')
|
||||
|
||||
// The fixed form is the same switches with the door switch off; it still derives `window`.
|
||||
assert.equal((await gm.ws.request({ t: 'wall.update', scene: gm.scene, id,
|
||||
door: false })).ok, true)
|
||||
const fixed = await wallEffect(gm.ws, m => m.t === 'wall' && m.id === id && m.door === false)
|
||||
assert.equal(fixed.kind, 'window')
|
||||
assert.equal(fixed.blocks_sight, false)
|
||||
assert.equal(fixed.blocks_movement, true)
|
||||
assert.equal(fixed.open, false)
|
||||
assert.equal(fixed.player_marker, true, 'turning the door off keeps the marker')
|
||||
// A fixed window has no open state, so `door.set` refuses both directions.
|
||||
for (const open of [true, false]) {
|
||||
const ack = await gm.ws.request({ t: 'door.set', scene: gm.scene, id, open })
|
||||
assert.equal(ack.ok, false, String(open))
|
||||
assert.equal(ack.code, 'invalid')
|
||||
}
|
||||
|
||||
// The obvious conversion, `door:true`, yields a closed opening window. `open` in a wall update
|
||||
// is an unknown field and is ignored (it belongs to door.set); the door patch still applies.
|
||||
assert.equal((await gm.ws.request({ t: 'wall.update', scene: gm.scene, id, door: true,
|
||||
open: true })).ok, true)
|
||||
const reopened = await wallEffect(gm.ws, m => m.t === 'wall' && m.id === id && m.door === true)
|
||||
assert.equal(reopened.kind, 'window')
|
||||
assert.equal(reopened.open, false, 'open is not a wall-update patch field')
|
||||
// An update naming only `open` has no patch field at all and is invalid.
|
||||
assert.equal((await gm.ws.request({ t: 'wall.update', scene: gm.scene, id, open: true })).code,
|
||||
'invalid')
|
||||
gm.ws.close()
|
||||
})
|
||||
})
|
||||
|
||||
test('switch-set invariants: door-only settings need a door, and open excludes secret/locked (#55)',
|
||||
async () => {
|
||||
await withGmServer(async (s, gmKey) => {
|
||||
|
||||
Reference in New Issue
Block a user