Seats are banked in a cookie the server sets, and a lost seat comes back by name to the address it was last used from
A seat lived in the browser's storage alone, and Safari clears that after a week away, or at a word from the person on another device. Now every seat taken is banked as well in an HttpOnly cookie the server writes, which such clearing leaves alone, and the wallet takes its seats back from the bank on arrival. For a browser that lost even the cookie, the ledger notes the address each seat was last used from, as a salted hash, at most once in ten minutes, and a name given in the lobby or from the gallery gets its seats back from the same address, with a new token; where the address differs, two people at the table share it, or the host gave the seat to the clockwork, the table is only counted, and the host's phrase or the keeper's link is the way back. A name refused as taken is looked for the same way before the refusal shows. The keeper's script finds a name across tables. The seat endpoints answer only this site's own pages, under a limit of their own. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CCLa2PaEeCj8njQZSWGqHx
This commit is contained in:
1 parent
dbc02a8d8f
commit
ecfee5d9c2
8 files changed
+388
-7
No files matched your search
@@ -152,3 +152,38 @@ describe("a player's own transfer phrase", () => {
|
||||
expect(claimed).toEqual({ roomId: room.id, name: "Bo", token: bo, reseated: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe("a seat a browser lost", () => {
|
||||
it("notes the address a seat is used from, once per change and not on its heels, and gives the seat back to that address by name", () => {
|
||||
const { room, bo } = playing();
|
||||
rooms.noteSeen(room, "Bo", "home");
|
||||
rooms.noteSeen(room, "Bo", "home");
|
||||
rooms.noteSeen(room, "Bo", "office");
|
||||
expect(room.addrs.get("Bo")).toBe("home");
|
||||
expect(rooms.findSeats("bo", "away", room.id)).toEqual({ seated: [], elsewhere: 1 });
|
||||
const found = rooms.findSeats("bo", "home", room.id);
|
||||
expect(found.elsewhere).toBe(0);
|
||||
expect(found.seated.map((s) => [s.roomId, s.name])).toEqual([[room.id, "Bo"]]);
|
||||
expect(rooms.seatOfToken(room, found.seated[0]!.token)).toBe("Bo");
|
||||
expect(rooms.seatOfToken(room, bo)).toBeNull();
|
||||
// Given a new token, the seat is noted afresh at once.
|
||||
rooms.noteSeen(room, "Bo", "office");
|
||||
expect(room.addrs.get("Bo")).toBe("office");
|
||||
});
|
||||
|
||||
it("only counts the table when another person at it shares the address, or the clockwork stands in, or the game is finished", () => {
|
||||
const { room, ann, bo } = playing();
|
||||
rooms.noteSeen(room, "Bo", "home");
|
||||
rooms.noteSeen(room, "Ann", "home");
|
||||
expect(rooms.findSeats("Bo", "home", room.id)).toEqual({ seated: [], elsewhere: 1 });
|
||||
expect(rooms.findSeats("Dee", "home", room.id)).toEqual({ seated: [], elsewhere: 0 });
|
||||
expect(rooms.seatOfToken(room, bo)).toBe("Bo");
|
||||
rooms.noteSeen(room, "Ann", "office");
|
||||
rooms.standIn(room, "Ann", "Bo");
|
||||
expect(rooms.findSeats("Bo", "home", room.id)).toEqual({ seated: [], elsewhere: 1 });
|
||||
expect(rooms.tablesForKeeper("bo").filter((t) => t.roomId === room.id)).toMatchObject([{ roomId: room.id, name: "Bo", standIn: true, players: ["Ann", "Cy"] }]);
|
||||
expect(rooms.seatOfToken(room, ann)).toBe("Ann");
|
||||
room.state!.phase = "finished";
|
||||
expect(rooms.findSeats("Cy", "home", room.id)).toEqual({ seated: [], elsewhere: 0 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user