feat: GM characters, reveals, who-sees-it and seen_by (#75)
Server: GM token frames gain the additive, GM-only seen_by:[player ids], computed from each player's existing sight (PlayerVision.visibleTo) with no extra polygon pass. Leakcheck BannedAlways bans seen_by; a seenBy fault build is caught as exactly WALLDATA. proto stays 2 (6.2 additive). Client: new cast slice parses character/character_gone/encountered frames and seen_by; gmcast panel adds character create/rename/assign/remove, reveal to one/all, encountered forget (grey entries only) and the who-sees-it list (0/100 in M4). Mounted beside the #74 admin panel. Docs: DESIGN 5.9/6.1/6.2/7.4 record the round-1 shape and the no-bump call. Gates: devbox run test, client-test, e2e green; bench recorded.
This commit is contained in:
+21
-2
@@ -60,6 +60,7 @@ type
|
||||
revealed*: seq[int] ## plain tokens only: who was told the actual name
|
||||
statuses*: seq[StatusEntry] ## every entry, source included (GM only, 6.1)
|
||||
props*: Props ## all three buckets, never nil
|
||||
seenBy*: seq[int] ## who-sees-it, ascending; GM only, additive in proto 2 (6.1, 7.4)
|
||||
|
||||
PlayerTokenView* = object
|
||||
id*: string
|
||||
@@ -224,15 +225,27 @@ proc greyFor*(ctx: Context, playerId: int, entityId: string): bool =
|
||||
|
||||
proc gmView*(ctx: Context): GmView =
|
||||
result.tokens = newSeqOfCap[GmTokenView](ctx.tokens.len)
|
||||
# Who-sees-it (7.4, #75): the players whose *existing* sight already sees each token. The
|
||||
# visibility rule is `PlayerVision.visibleTo`, the same one the player egress uses, so no polygon
|
||||
# is recomputed and no fan is added; the per-player polygons are the ones `refresh` left in place.
|
||||
var viewerIds: seq[int]
|
||||
for pid in ctx.visions.keys:
|
||||
if pid == GmControlled: continue
|
||||
viewerIds.add pid
|
||||
viewerIds.sort()
|
||||
for t in ctx.tokens:
|
||||
let ch = ctx.characterOf(t)
|
||||
var seenBy: seq[int]
|
||||
var fallback: PlayerVision
|
||||
for pid in viewerIds:
|
||||
if visionAt(ctx, pid, fallback)[].visibleTo(t, pid): seenBy.add pid
|
||||
var view = GmTokenView(id: t.id, scene: t.scene,
|
||||
name: (if ch.isSome: ch.get.descriptiveName else: t.descriptiveName),
|
||||
pos: t.pos, radius: effectiveRadius(ctx.scene, t),
|
||||
kind: t.kind, controller: t.owner, gmOnly: t.gmOnly,
|
||||
flags: t.flags, visionRadius: t.visionRadius,
|
||||
radiusOwn: t.radius, characterId: t.characterId,
|
||||
statuses: t.statuses, props: t.props)
|
||||
statuses: t.statuses, props: t.props, seenBy: seenBy)
|
||||
if ch.isNone:
|
||||
# The names and the reveal state of a plain token; a linked token's live on its character.
|
||||
view.descriptiveName = t.descriptiveName
|
||||
@@ -406,7 +419,10 @@ proc gmTokenFrame*(v: GmTokenView): JsonNode =
|
||||
"gm_only": v.gmOnly, "flags": v.flags,
|
||||
"vision_radius": (if v.visionRadius.isSome: %v.visionRadius.get else: newJNull()),
|
||||
"radius_own": (if v.radiusOwn.isSome: %v.radiusOwn.get else: newJNull()),
|
||||
"character_id": (if v.characterId.isSome: %v.characterId.get else: newJNull())
|
||||
"character_id": (if v.characterId.isSome: %v.characterId.get else: newJNull()),
|
||||
# 7.4 who-sees-it: the players whose existing sight sees this token (0/100 in M4). GM-only;
|
||||
# additive within proto 2 (6.2), and banned for players by the leak checker.
|
||||
"seen_by": %*v.seenBy
|
||||
}
|
||||
if v.characterId.isNone:
|
||||
# A linked token's names and reveal state live on the character record (6.1).
|
||||
@@ -444,6 +460,9 @@ proc playerTokenFrame*(v: PlayerTokenView): JsonNode =
|
||||
if faultActive("wallHeight"):
|
||||
# WALLDATA positive control (#54): a wall field name (`height`) in a player token frame.
|
||||
result["height"] = %1.8
|
||||
if faultActive("seenBy"):
|
||||
# WALLDATA positive control (#75): the GM-only who-sees-it field in a player token frame.
|
||||
result["seen_by"] = %*[v.id.len]
|
||||
|
||||
proc tokenGoneFrame*(id: string): JsonNode = %*{"t": "token_gone", "id": id}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user