The host can give a stuck player's seat to the clockwork and make a phrase that brings a seat back, and a socket in a background tab no longer drops every minute
A "seats" button beside "transfer seat" opens the host's panel. In a game under way, "give to the clockwork" lets an automaton play a person's seat from the next beat, with their hand, treasures and place untouched; a standIn line on the ledger records it, the chronicle says so, the stand-in never talks under the person's name, and the person's token opens nothing after. "Make a phrase" mints the four-word phrase for any person's seat; claiming it re-seats on a new token, and a seat the clockwork stood in for goes back to its person mid-turn. A rematch holds a stood-in seat for its person. The gallery now has its own claim box, for a player who opens the invite link in a fresh browser. The client's watchdog pinged and then closed a socket quiet for 45 seconds. A background tab's timers run about once a minute, so the last pong was always a minute old when it looked, and idle tabs reconnected every 58 seconds. It now closes only when its own ping went unanswered. The server pings every socket at the protocol level every 30 seconds and drops one that left the last ping unanswered, so a crashed browser's socket no longer lingers until TCP gives up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0141G6xqLeNRYEtviLWSB5Up
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7ef0c1bc14
commit
4b7e05713d
+6
-1
@@ -53,7 +53,12 @@ longer replays becomes unreachable after restart, so this is not optional.
|
||||
script, configure rclone (the script refuses to run while the config still
|
||||
holds its CHANGE_ME placeholder), and add the cron entry by hand.
|
||||
- A player whose browser lost their seat (Safari's seven days, an app's own
|
||||
browser, cleared data) writes to the keeper. On the droplet,
|
||||
browser, cleared data) asks the host, whose "seats" button makes a
|
||||
four-word phrase that re-seats them on a new token. The same panel lets the
|
||||
host give a seat to the clockwork in a game under way, for a player who
|
||||
cannot take their turns; a `standIn` line on the ledger records it, and a
|
||||
later reseat gives the seat back. Failing the host, they write to the
|
||||
keeper. On the droplet,
|
||||
`wizwar-reseat.sh ROOM` lists who sits at the table and when each last
|
||||
moved or spoke; `wizwar-reseat.sh ROOM NAME` gives that wizard's seat a new
|
||||
token and prints a link carrying it in the fragment. The old token opens
|
||||
|
||||
@@ -41,6 +41,7 @@ for f in glob.glob("/var/lib/wizwar/rooms/*.jsonl"):
|
||||
ca = meta.get("createdAt", "")
|
||||
if not ca: continue
|
||||
humans = [meta["hostId"]]; bots = []; started = False; cmds = 0; chat = []; last = ca; steps = []
|
||||
standing = set(); stood = [] # seats the host gave the clockwork, and who and when
|
||||
for l in lines[1:]:
|
||||
try: x = json.loads(l)
|
||||
except Exception: continue
|
||||
@@ -48,15 +49,19 @@ for f in glob.glob("/var/lib/wizwar/rooms/*.jsonl"):
|
||||
if k == "join":
|
||||
(bots if x.get("bot") else humans).append(x["name"])
|
||||
elif k == "start": started = True
|
||||
elif k == "standIn":
|
||||
standing.add(x["name"]); stood.append((x.get("at", "")[11:16], x["name"], "to the clockwork"))
|
||||
elif k == "reseat" and x["name"] in standing:
|
||||
standing.discard(x["name"]); stood.append((x.get("at", "")[11:16], x["name"], "back to a person"))
|
||||
elif k == "command":
|
||||
cmds += 1; last = x.get("at", last)
|
||||
steps.append((x.get("playerId"), x["command"].get("type"), x.get("at", "")))
|
||||
steps.append((x.get("playerId"), x["command"].get("type"), x.get("at", ""), x.get("playerId") in standing))
|
||||
elif k == "chat":
|
||||
last = x.get("at", last)
|
||||
if x["player"] in humans: chat.append((x.get("at", "")[11:16], x["player"], x["text"]))
|
||||
for h in humans:
|
||||
if h not in first_seen or ca < first_seen[h]: first_seen[h] = ca
|
||||
rooms.append(dict(id=meta["id"], created=ca, humans=humans, bots=bots, started=started, cmds=cmds, last=last, chat=chat, steps=steps))
|
||||
rooms.append(dict(id=meta["id"], created=ca, humans=humans, bots=bots, started=started, cmds=cmds, last=last, chat=chat, steps=steps, stood=stood))
|
||||
|
||||
today = sorted([r for r in rooms if r["created"].startswith(day)], key=lambda r: r["created"])
|
||||
names = sorted({h for r in today for h in r["humans"]})
|
||||
@@ -68,12 +73,13 @@ for r in today:
|
||||
if r["cmds"]:
|
||||
t0 = datetime.datetime.fromisoformat(r["created"].replace("Z", "+00:00")); t1 = datetime.datetime.fromisoformat(r["last"].replace("Z", "+00:00"))
|
||||
span = "%d min" % round((t1 - t0).total_seconds() / 60)
|
||||
human_cmds = [s for s in r["steps"] if s[0] in r["humans"]]
|
||||
human_cmds = [s for s in r["steps"] if s[0] in r["humans"] and not s[3]]
|
||||
last_human = ("last human move: %s %s at %s" % (human_cmds[-1][0], human_cmds[-1][1], human_cmds[-1][2][11:16])) if human_cmds else "no human move"
|
||||
state = "lobby only" if not r["started"] else ("started, no moves" if not r["cmds"] else "in play")
|
||||
print(" %s %s %s%s %s %d moves (%d human) %s %s" % (
|
||||
r["created"][11:16], r["id"], "+".join(r["humans"]), (" vs %d bot%s" % (len(r["bots"]), "" if len(r["bots"]) == 1 else "s")) if r["bots"] else "",
|
||||
state, r["cmds"], len(human_cmds), span, last_human))
|
||||
for at, who, what in r["stood"]: print(" %s %s's seat goes %s" % (at, who, what))
|
||||
for at, who, text in r["chat"]: print(" %s %s: %s" % (at, who, text))
|
||||
|
||||
# --- the desk ---
|
||||
|
||||
Reference in New Issue
Block a user