From 058432130628d00764663ecf819a9adc6793768d Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 8 Nov 2026 03:29:35 +0100 Subject: v5.0.0: protocol v5 and the browser frontend Protocol v5 replaces newline lines with bounded [u32 len][text] frames and REQ/RES/EVT envelopes. Requests carry correlation ids and the server replays the last 256 replies per connection, so a gateway retry cannot double-debit and a late reply cannot clobber a newer request. HELLO/PONG carry server time; crash rounds announce started_at and push coalesced 10 Hz ticks. Crash now commits sha256(seed) before a round and reveals the seed when it ends, so clients recompute the crash point. Adds the webd/ gateway: one blocking thread, one ClientCore and one pinned upstream TLS connection per session, an HttpOnly session cookie, takeover, and a 60-second grace window. The browser sends Command JSON and renders View JSON; it never speaks the game protocol or stores credentials. Adds the vanilla TypeScript browser app at /play/ (login, lobby, all four games, history, notices, crash verification), the nginx /play and /ws routes, and the headless DOM smoke test. webd and the app stay out of the TUI/GUI/server build graph. The client/server version moves to 5.0.0 in lockstep; v4 peers are refused at HELLO. --- web/play/src/history.ts | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 web/play/src/history.ts (limited to 'web/play/src/history.ts') diff --git a/web/play/src/history.ts b/web/play/src/history.ts new file mode 100644 index 0000000..9e7a564 --- /dev/null +++ b/web/play/src/history.ts @@ -0,0 +1,60 @@ +import type { View } from "./types"; +import { clear, formatTime, money, node, signedMoney } from "./dom"; + +function summary(record: any): string { + const details = record.details ?? {}; + switch (record.game) { + case "slots": + return String(details.win_type ?? "spin"); + case "roulette": + return `${details.number ?? "?"} ${details.color ?? ""}`.trim(); + case "blackjack": + return String(details.result ?? ""); + case "crash": { + const result = String(details.result ?? ""); + const point = details.crash_point; + return point === undefined || point === null ? result : `${result} @ ${Number(point).toFixed(2)}×`; + } + default: + return ""; + } +} + +export function renderHistory(root: HTMLElement, view: View): void { + clear(root); + const records: any[] = view.records ?? []; + if (records.length === 0) { + const empty = node("div", "board"); + empty.append( + node("h2", undefined, "No plays yet"), + node("p", "muted", "Your settled plays will appear here."), + ); + root.append(empty); + return; + } + + const wrap = node("div", "table-wrap"); + const table = node("table"); + const head = node("thead"); + const headRow = node("tr"); + for (const label of ["Time", "Game", "Bet", "Result", "Net", "Balance"]) { + headRow.append(node("th", undefined, label)); + } + head.append(headRow); + const body = node("tbody"); + for (const record of records) { + const row = node("tr"); + row.append(node("td", "mono", formatTime(String(record.at ?? "")))); + row.append(node("td", undefined, String(record.game ?? ""))); + row.append(node("td", "num", money(Number(record.bet ?? 0)))); + row.append(node("td", "muted", summary(record))); + const net = Number(record.winnings ?? 0) - Number(record.bet ?? 0); + const netCell = node("td", `num ${net > 0 ? "pos" : net < 0 ? "neg" : ""}`, net === 0 ? "0 Kr" : signedMoney(net)); + row.append(netCell); + row.append(node("td", "num", money(Number(record.balance_after ?? 0)))); + body.append(row); + } + table.append(head, body); + wrap.append(table); + root.append(wrap); +} -- cgit v1.2.3