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:
@@ -184,6 +184,78 @@ test('stuck from a wall and from a GM placement, cleared by the removal and by a
|
||||
})
|
||||
})
|
||||
|
||||
test('windows: see-through, movement and statuses follow blocks_movement, closing pushes (#57)',
|
||||
async () => {
|
||||
await withGmServer(async (s, gmKey) => {
|
||||
const gm = await gmConnect(s.origin, gmKey)
|
||||
const alice = await namedPlayer(s.origin, gm, 'Alice')
|
||||
const tok = await gm.ws.request({ t: 'token.create', scene: gm.sceneId, kind: 'pc',
|
||||
pos: [300, 300], descriptive_name: 'Alice',
|
||||
actual_name: 'Alice', controller: alice.id,
|
||||
flags: { vision: true }, vision_radius: 400 })
|
||||
// A fixed window (blocks_sight off, movement on, no door) is the only barrier between Alice
|
||||
// and Bob: Bob must reach her through it, because sight passes along the whole segment.
|
||||
await gm.ws.request({ t: 'wall.add', scene: gm.sceneId, a: [400, 150],
|
||||
b: [400, 450], blocks_sight: false })
|
||||
const bob = await gm.ws.request({ t: 'token.create', scene: gm.sceneId, kind: 'npc',
|
||||
pos: [500, 300], descriptive_name: 'a guard',
|
||||
actual_name: 'Vex' })
|
||||
const a = await openAs(s.origin, alice.key)
|
||||
await a.ws.waitText('hello')
|
||||
const seenBob = await a.ws.waitFor(m => m.t === 'token' && m.id === bob.id)
|
||||
assert.deepEqual(seenBob.pos, [500, 300], 'a window lets the player see through it')
|
||||
|
||||
// Movement does not: the same segment still blocks the crossing exactly as a solid wall.
|
||||
assert.equal((await gm.ws.request({ t: 'token.move', id: tok.id, pos: [360, 300] })).ok, true)
|
||||
const nack = await a.ws.request({ t: 'token.move', id: tok.id, pos: [440, 300] })
|
||||
assert.equal(nack.ok, false, 'a fixed window blocks movement')
|
||||
assert.deepEqual(nack.pos, [360, 300])
|
||||
|
||||
// A window added over the token gives stuck(walls), like a solid wall (movement switch on).
|
||||
const over = await mutate(gm.ws, { t: 'wall.add', scene: gm.sceneId, a: [360, 200],
|
||||
b: [360, 400], blocks_sight: false })
|
||||
let frame = await over.wait(m => m.t === 'token' && m.id === tok.id && m.statuses.length > 0)
|
||||
assert.deepEqual(frame.statuses, [{ status: 'stuck', source: 'walls' }])
|
||||
const cleared = await mutate(gm.ws, { t: 'wall.remove', scene: gm.sceneId, id: over.ack.id })
|
||||
assert.equal(cleared.ack.ok, true)
|
||||
frame = await cleared.wait(m => m.t === 'token' && m.id === tok.id && m.statuses.length === 0)
|
||||
assert.deepEqual(frame.statuses, [])
|
||||
|
||||
// The movement switch decides the status, not the see-through shape: a custom barrier with
|
||||
// both switches off overlaps the token without sticking it.
|
||||
const pass = await mutate(gm.ws, { t: 'wall.add', scene: gm.sceneId, a: [360, 200],
|
||||
b: [360, 400], blocks_sight: false,
|
||||
blocks_movement: false })
|
||||
const passFrame = await gm.ws.waitFor(m => m.t === 'wall' && m.id === pass.ack.id)
|
||||
assert.equal(passFrame.kind, 'custom')
|
||||
await sleep(80)
|
||||
assert.deepEqual(frameOf(gm.ws, tok.id).statuses, [], 'blocks_movement off: no stuck')
|
||||
|
||||
// Closing an opening window pushes exactly as a closing solid wall does. The token sits on
|
||||
// the line while the leaf is open (no overlap: an open door blocks nothing), then is moved
|
||||
// clear to the wall's left side by the close.
|
||||
const opening = await gm.ws.request({ t: 'wall.add', scene: gm.sceneId, a: [1000, 150],
|
||||
b: [1000, 450], preset: 'window' })
|
||||
assert.equal((await gm.ws.request({ t: 'door.set', scene: gm.sceneId, id: opening.id,
|
||||
open: true })).ok, true)
|
||||
const onLine = await mutate(gm.ws, { t: 'token.move', id: tok.id, pos: [1000, 300] })
|
||||
frame = await onLine.wait(m => m.t === 'token' && m.id === tok.id && m.pos[0] === 1000)
|
||||
assert.deepEqual(frame.statuses, [], 'an open window blocks nothing')
|
||||
const closed = await mutate(gm.ws, { t: 'door.set', scene: gm.sceneId, id: opening.id,
|
||||
open: false })
|
||||
assert.equal(closed.ack.ok, true)
|
||||
frame = await closed.wait(m => m.t === 'token' && m.id === tok.id && m.pos[0] !== 1000)
|
||||
assert.ok(Math.abs(frame.pos[0] - 980) < 0.01, `pushed off the leaf: ${JSON.stringify(frame.pos)}`)
|
||||
assert.equal(frame.pos[1], 300)
|
||||
assert.deepEqual(frame.statuses, [], 'a pushed token is clear of every blocking wall')
|
||||
// Re-opening makes the same segment a gap the player can walk through.
|
||||
assert.equal((await gm.ws.request({ t: 'door.set', scene: gm.sceneId, id: opening.id,
|
||||
open: true })).ok, true)
|
||||
assert.equal((await a.ws.request({ t: 'token.move', id: tok.id, pos: [1020, 300] })).ok, true)
|
||||
a.ws.close(); gm.ws.close()
|
||||
})
|
||||
})
|
||||
|
||||
test('status.set and status.clear: the GM source, single entries, and the codes of 6.1', async () => {
|
||||
await withGmServer(async (s, gmKey) => {
|
||||
const gm = await gmConnect(s.origin, gmKey)
|
||||
|
||||
Reference in New Issue
Block a user