server: wall and door intents, GM wall snapshot and fan-out (#19)
wall.add, wall.update, wall.remove and door.set leave the unknown-type rollout
list: field shapes and ranges per 6.1 (and the payload rules recorded FIXED in
4.4/6.1), lookup failures not-found, non-GM refused by the existing GM-only
gate. wall.add acks {id} from the scene's next_wall_id; wall.update patches
a/b/kind/flags only (open belongs to door.set); door.set is invalid on a plain
wall. Effects go to every GM connection only: wall / wall_gone, plus one walls
snapshot right after hello (the wall part of the 6.3 resync). Players receive
no wall data in any message (3.1, T2).
protocol.nim gains the wallObject/wallsFrame/wallFrame/wallGoneFrame builders
(no n: the sender stamps it per recipient) and the five wall intents in the
implemented set.
This commit is contained in:
+42
-3
@@ -40,7 +40,7 @@ suite "envelope (6.5 step 2)":
|
||||
|
||||
test "the catalogue is the 29 intents of 6.1 and the built set is a subset":
|
||||
check IntentCatalogue.len == 29
|
||||
check ImplementedIntents.len == 5
|
||||
check ImplementedIntents.len == 9 # slice 3's five + slice 4's four wall intents
|
||||
for t in ImplementedIntents:
|
||||
check t in IntentCatalogue
|
||||
check isCatalogueIntent(t)
|
||||
@@ -55,11 +55,15 @@ suite "envelope (6.5 step 2)":
|
||||
for t in GmOnlyIntents:
|
||||
check isCatalogueIntent(t)
|
||||
|
||||
test "only this slice's intents answer with a real handler":
|
||||
test "only the built slices' intents answer with a real handler":
|
||||
check isImplementedIntent("conn.ping")
|
||||
check isImplementedIntent("key.create")
|
||||
for t in ["wall.add", "wall.update", "wall.remove", "door.set"]:
|
||||
check isImplementedIntent(t)
|
||||
check isGmOnlyIntent(t) # walls are GM-only (3.1, T2)
|
||||
check not isImplementedIntent("player.setname")
|
||||
check not isImplementedIntent("wall.add")
|
||||
check not isImplementedIntent("scene.set")
|
||||
check not isImplementedIntent("token.create")
|
||||
|
||||
suite "intent rate limit (6.4: 30/s, burst 100)":
|
||||
test "a fresh bucket allows exactly the burst, then refuses":
|
||||
@@ -187,3 +191,38 @@ suite "server frames (6.1)":
|
||||
check CloseMalformedFlood == 1008
|
||||
check [ReasonRevoked, ReasonEvicted, ReasonProtoMismatch, ReasonMalformedFlood] ==
|
||||
["revoked", "evicted", "proto-mismatch", "malformed-flood"]
|
||||
|
||||
suite "wall frames (6.1 `walls`, `wall`, `wall_gone`; GM only)":
|
||||
test "one wall carries id, a, b, kind, open and flags in the 6.1 shape":
|
||||
let w = wallObject(7, (10.0, 20.5), (300.0, 20.5), "door", true, %*{"locked": false})
|
||||
check w["id"].getInt == 7
|
||||
check w["a"][0].getFloat == 10.0
|
||||
check w["a"][1].getFloat == 20.5
|
||||
check w["b"][0].getFloat == 300.0
|
||||
check w["kind"].getStr == "door"
|
||||
check w["open"].getBool
|
||||
check w["flags"]["locked"].getBool == false
|
||||
# an absent flags object is still an object on the wire
|
||||
check wallObject(1, (0.0, 0.0), (1.0, 0.0), "wall", false, nil)["flags"].kind == JObject
|
||||
|
||||
test "`walls` is the full list plus the scene, `wall` is one upsert, `wall_gone` an id":
|
||||
let snap = wallsFrame(1, @[wallObject(1, (0.0, 0.0), (9.0, 0.0), "wall", false, nil)])
|
||||
check snap["t"].getStr == "walls"
|
||||
check snap["scene"].getInt == 1
|
||||
check snap["walls"].len == 1
|
||||
check snap["walls"][0]["id"].getInt == 1
|
||||
let one = wallFrame(1, wallObject(2, (0.0, 5.0), (9.0, 5.0), "door", false, nil))
|
||||
check one["t"].getStr == "wall"
|
||||
check one["scene"].getInt == 1
|
||||
check one["id"].getInt == 2
|
||||
check one["kind"].getStr == "door"
|
||||
let gone = wallGoneFrame(1, 2)
|
||||
check gone["t"].getStr == "wall_gone"
|
||||
check gone["scene"].getInt == 1
|
||||
check gone["id"].getInt == 2
|
||||
|
||||
test "the fan-out frames carry no n: the sender stamps it per recipient":
|
||||
check not wallsFrame(1, @[]).hasKey("n")
|
||||
check not wallFrame(1, wallObject(1, (0.0, 0.0), (1.0, 1.0), "wall", false, nil)).hasKey("n")
|
||||
check not wallGoneFrame(1, 1).hasKey("n")
|
||||
check withN(wallGoneFrame(1, 1), 12)["n"].getInt == 12
|
||||
|
||||
Reference in New Issue
Block a user