server: refresh a player's sight when a connection starts receiving state (#23)
This commit is contained in:
@@ -63,6 +63,11 @@ test('player.setname: the first name, the second hello, a roster to everyone, an
|
||||
const alice = await createPlayer(gm.ws)
|
||||
const bob = await createPlayer(gm.ws)
|
||||
|
||||
// a token Alice controls, so naming her must produce a vision polygon on the resync
|
||||
const sightTok = await gm.ws.request({ t: 'token.create', scene: gm.sceneId, kind: 'pc',
|
||||
pos: [400, 400], descriptive_name: 'Alice',
|
||||
actual_name: 'Alice', controller: alice.id,
|
||||
flags: { vision: true } })
|
||||
const a = await openAs_(s.origin, alice.key)
|
||||
const hello = await a.ws.waitText('hello')
|
||||
assert.equal(hello.me.name, null, 'a fresh key has no name yet')
|
||||
@@ -74,6 +79,10 @@ test('player.setname: the first name, the second hello, a roster to everyone, an
|
||||
const named = await a.ws.waitFor((m, i) => i >= from && m.t === 'hello')
|
||||
assert.equal(named.me.name, 'Alice', 'the name is trimmed before it is stored (6.5)')
|
||||
assert.equal(named.scene.id, 1, 'a named player gets the scene block')
|
||||
// the resync computes this connection's sight for the first time: an unnamed connection never
|
||||
// had a refresh, so a vision token it controls must show up now
|
||||
const vision = await a.ws.waitFor((m, i) => i >= from && m.t === 'vision')
|
||||
assert.deepEqual(vision.polys.map(p => p.id), [sightTok.id])
|
||||
const roster = await a.ws.waitFor((m, i) => i >= from && m.t === 'roster')
|
||||
assert.deepEqual(roster.players.map(p => p.name).sort(), ['Alice', 'GM'],
|
||||
'a player sees the named players only (6.1 leak note 4)')
|
||||
|
||||
Reference in New Issue
Block a user