Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(play): tighten war-portal leaderboard counters and sniper-solvency edges
nirholasa562aa956cbf
diff --git a/api/_lib/sniper-solvency.js b/api/_lib/sniper-solvency.jsindex c49323257..49cb41c10 100644--- a/api/_lib/sniper-solvency.js+++ b/api/_lib/sniper-solvency.js@@ -160,6 +160,32 @@ export function summarizeFleetSolvency({ wallets, masterSol = null, minTradeLamp};}+/**+ * The worker's overall state, combining process liveness with fleet solvency.+ *+ * Precedence is the point of this function. A dead process outranks everything+ * (nothing else can be true). Solvency outranks the feed checks: "no wallet can+ * pay for a trade" is both more specific and more actionable than "the feed is+ * quiet", and it is the condition that went unreported for ten days. An+ * unmeasured fleet ('unknown') never downgrades anything — absence of a+ * measurement is not evidence of insolvency.+ *+ * Pure. Exported so the verdict is testable without a DB or a live worker.+ *+ * @param {object} p+ * @param {boolean} p.alive heartbeat within the freshness window+ * @param {boolean} p.feedLive worker reports its feed subscription up+ * @param {boolean} p.feedSilent no feed events past the watchdog window+ * @param {string} [p.solvencyState] from summarizeFleetSolvency().state+ * @returns {'down'|'starved'|'degraded'|'live'}+ */+export function deriveSniperState({ alive, feedLive, feedSilent, solvencyState = 'unknown' }) {+ if (!alive) return 'down';+ if (solvencyState === 'starved') return 'starved';+ if (feedSilent || !feedLive || solvencyState === 'degraded') return 'degraded';+ return 'live';+}+/*** One-line operator summary of a solvency snapshot. Shared by the worker's alert* body and the status page so both describe the same condition the same way.diff --git a/api/_lib/tts-gemini.js b/api/_lib/tts-gemini.jsindex 020d7e8f9..2c52ee04e 100644--- a/api/_lib/tts-gemini.js+++ b/api/_lib/tts-gemini.js@@ -23,6 +23,13 @@ import { pcmToWav } from './tts-nvidia.js';import { getGcpAccessToken } from './gcp-auth.js';import { env } from './env.js';+// Google's own SDKs accept either name for a Generative Language API key, and+// this workspace has historically used GOOGLE_API_KEY. Read both so a working+// key never sits in .env unused.+function geminiApiKey() {+ return env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY || null;+}+// Preview TTS models. Flash is the real-time lane; Pro is the quality lane.export const GEMINI_TTS_MODELS = [{@@ -97,14 +104,14 @@ function vertexLocation() {/** True when either rung can serve. Read per call so late-injected env works. */export function geminiTtsConfigured() {- return Boolean(process.env.GOOGLE_CLOUD_PROJECT || env.GEMINI_API_KEY);+ return Boolean(process.env.GOOGLE_CLOUD_PROJECT || geminiApiKey());}/** Which rungs are live, for the catalog endpoint's provider report. */export function geminiTtsLanes() {return {vertex: Boolean(process.env.GOOGLE_CLOUD_PROJECT),- apiKey: Boolean(env.GEMINI_API_KEY),+ apiKey: Boolean(geminiApiKey()),};}@@ -216,11 +223,12 @@ export async function synthesizeGeminiTts({}// ── Rung 2: Generative Language API key ──────────────────────────────────- if (!pcm && env.GEMINI_API_KEY) {+ const apiKey = geminiApiKey();+ if (!pcm && apiKey) {try {pcm = await callGemini({url: `https://generativelanguage.googleapis.com/v1beta/models/${modelId}:generateContent`,- headers: { 'x-goog-api-key': env.GEMINI_API_KEY },+ headers: { 'x-goog-api-key': apiKey },body,timeoutMs,});diff --git a/scripts/play-journey-audit.mjs b/scripts/play-journey-audit.mjsindex 49d28097a..26ef260b2 100644--- a/scripts/play-journey-audit.mjs+++ b/scripts/play-journey-audit.mjs@@ -210,6 +210,9 @@ async function tabTrapCheck(label, steps = 25) {if (sel) seen.add(sel);}console.log(at(), `[tab:${label}] ${steps} presses reached ${seen.size} distinct controls`);+ // Naming them is what separates "a modal is trapping focus, as designed"+ // from "the tab order is broken", which look identical as a bare count.+ for (const s of [...seen].slice(0, 12)) console.log(' ', s);return seen.size;}@@ -252,6 +255,18 @@ await noteState('lobby-loaded', () => ({await overflowScan('lobby');if (MOBILE) await touchScan('lobby');await focusSweep('lobby');++// The cold-open intro (src/game/play-intro.js) auto-shows once per browser and+// correctly traps focus while it is up. Measuring the lobby's own tab order+// means dismissing it first, or the trap check just re-reports the modal.+const introDismissed = await page.evaluate(() => {+ const skip = document.querySelector('.pi-close, .pi-btn-ghost');+ if (!skip) return false;+ skip.click();+ return true;+});+if (introDismissed) console.log(at(), '[dismissed] cold-open intro');+await page.waitForTimeout(600);await tabTrapCheck('lobby');// ── 2. search: a query with hits, then one with none ───────────────────────diff --git a/scripts/shots/results.json b/scripts/shots/results.jsondeleted file mode 100644index 69295b19d..000000000--- a/scripts/shots/results.json+++ /dev/null@@ -1,511 +0,0 @@-[- {- "kind": "upcoming",- "theme": "dark",- "label": "desktop",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "upcoming",- "chip": "Upcoming",- "name": "$THREE First Holders Meetup",- "clock": "1day02hours04minutes48seconds",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Doors open Saturday, August 8 at 11:41 AM UTC (UTC). Runs until 1:36 PM.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "upcoming",- "theme": "dark",- "label": "mobile",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened.",- "error: Failed to load resource: the server responded with a status of 500 (Internal Server Error)"- ],- "state": "upcoming",- "chip": "Upcoming",- "name": "$THREE First Holders Meetup",- "clock": "1day02hours04minutes53seconds",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Doors open Saturday, August 8 at 11:41 AM UTC (UTC). Runs until 1:36 PM.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "upcoming",- "theme": "dark",- "label": "narrow",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "upcoming",- "chip": "Upcoming",- "name": "$THREE First Holders Meetup",- "clock": "1day02hours04minutes55seconds",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Doors open Saturday, August 8 at 11:41 AM UTC (UTC). Runs until 1:36 PM.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "upcoming",- "theme": "light",- "label": "desktop",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened.",- "warning: [.WebGL-0x1a8c0240ac00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels"- ],- "state": "upcoming",- "chip": "Upcoming",- "name": "$THREE First Holders Meetup",- "clock": "1day02hours04minutes51seconds",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Doors open Saturday, August 8 at 11:41 AM UTC (UTC). Runs until 1:36 PM.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "upcoming",- "theme": "light",- "label": "mobile",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "upcoming",- "chip": "Upcoming",- "name": "$THREE First Holders Meetup",- "clock": "1day02hours04minutes55seconds",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Doors open Saturday, August 8 at 11:42 AM UTC (UTC). Runs until 1:37 PM.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "live",- "theme": "dark",- "label": "desktop",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened.",- "error: Failed to load resource: the server responded with a status of 404 (Not Found)"- ],- "state": "live",- "chip": "Live now",- "name": "$THREE First Holders Meetup",- "clock": "LIVEright now01:12:55left to join",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Running now until 10:50 AM (UTC).",- "liveHidden": false,- "liveNum": "(hidden)",- "liveTitle": "The doors are open",- "agendaRows": 5,- "nowRow": "Fortune's Folly wheel hournow",- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "live",- "theme": "dark",- "label": "mobile",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened.",- "error: Failed to load resource: the server responded with a status of 500 (Internal Server Error)",- "warning: [.WebGL-0x1a8c01868800]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels",- "warning: [.WebGL-0x1a8c01868800]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels",- "warning: [.WebGL-0x1a8c01868800]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels (this message will no longer repeat)"- ],- "state": "live",- "chip": "Live now",- "name": "$THREE First Holders Meetup",- "clock": "LIVEright now01:12:31left to join",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Running now until 10:50 AM (UTC).",- "liveHidden": false,- "liveNum": "(hidden)",- "liveTitle": "The doors are open",- "agendaRows": 5,- "nowRow": "Fortune's Folly wheel hournow",- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "live",- "theme": "dark",- "label": "narrow",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened.",- "error: Failed to load resource: the server responded with a status of 404 (Not Found)"- ],- "state": "live",- "chip": "Live now",- "name": "$THREE First Holders Meetup",- "clock": "LIVEright now01:12:49left to join",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Running now until 10:51 AM (UTC).",- "liveHidden": false,- "liveNum": "(hidden)",- "liveTitle": "The doors are open",- "agendaRows": 5,- "nowRow": "Fortune's Folly wheel hournow",- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "live",- "theme": "light",- "label": "desktop",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened.",- "error: Failed to load resource: the server responded with a status of 404 (Not Found)"- ],- "state": "live",- "chip": "Live now",- "name": "$THREE First Holders Meetup",- "clock": "LIVEright now01:12:51left to join",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Running now until 10:51 AM (UTC).",- "liveHidden": false,- "liveNum": "(hidden)",- "liveTitle": "The doors are open",- "agendaRows": 5,- "nowRow": "Fortune's Folly wheel hournow",- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "live",- "theme": "light",- "label": "mobile",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "live",- "chip": "Live now",- "name": "$THREE First Holders Meetup",- "clock": "LIVEright now01:12:54left to join",- "cta": "Join the $THREE world",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": false,- "when": "Running now until 10:51 AM (UTC).",- "liveHidden": false,- "liveNum": "(hidden)",- "liveTitle": "The doors are open",- "agendaRows": 5,- "nowRow": "Fortune's Folly wheel hournow",- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "ended",- "theme": "dark",- "label": "desktop",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "This event has ended",- "name": "$THREE First Holders Meetup",- "clock": "",- "cta": "Enter the world anyway",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": true,- "when": "It ran on Thursday, August 6, 2026. The world is still open, and the next event will show up here.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "ended",- "theme": "dark",- "label": "mobile",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "This event has ended",- "name": "$THREE First Holders Meetup",- "clock": "",- "cta": "Enter the world anyway",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": true,- "when": "It ran on Thursday, August 6, 2026. The world is still open, and the next event will show up here.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "ended",- "theme": "dark",- "label": "narrow",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "This event has ended",- "name": "$THREE First Holders Meetup",- "clock": "",- "cta": "Enter the world anyway",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": true,- "when": "It ran on Thursday, August 6, 2026. The world is still open, and the next event will show up here.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "ended",- "theme": "light",- "label": "desktop",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "This event has ended",- "name": "$THREE First Holders Meetup",- "clock": "",- "cta": "Enter the world anyway",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": true,- "when": "It ran on Thursday, August 6, 2026. The world is still open, and the next event will show up here.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "ended",- "theme": "light",- "label": "mobile",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "This event has ended",- "name": "$THREE First Holders Meetup",- "clock": "",- "cta": "Enter the world anyway",- "ctaHref": "/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three",- "calHidden": true,- "when": "It ran on Thursday, August 6, 2026. The world is still open, and the next event will show up here.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 5,- "scheduleHidden": false,- "hScroll": false- },- {- "kind": "none",- "theme": "dark",- "label": "desktop",- "errors": [- "error: Failed to load resource: the server responded with a status of 404 (Not Found)",- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "No event scheduled",- "name": "The world is open anyway.",- "clock": "",- "cta": "Enter the three.ws world",- "ctaHref": "/play",- "calHidden": true,- "when": "Follow the changelog to hear about the next one before it starts.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 0,- "scheduleHidden": true,- "hScroll": false- },- {- "kind": "none",- "theme": "dark",- "label": "mobile",- "errors": [- "error: Failed to load resource: the server responded with a status of 404 (Not Found)",- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "No event scheduled",- "name": "The world is open anyway.",- "clock": "",- "cta": "Enter the three.ws world",- "ctaHref": "/play",- "calHidden": true,- "when": "Follow the changelog to hear about the next one before it starts.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 0,- "scheduleHidden": true,- "hScroll": false- },- {- "kind": "none",- "theme": "dark",- "label": "narrow",- "errors": [- "error: Failed to load resource: the server responded with a status of 404 (Not Found)",- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "No event scheduled",- "name": "The world is open anyway.",- "clock": "",- "cta": "Enter the three.ws world",- "ctaHref": "/play",- "calHidden": true,- "when": "Follow the changelog to hear about the next one before it starts.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 0,- "scheduleHidden": true,- "hScroll": false- },- {- "kind": "none",- "theme": "light",- "label": "desktop",- "errors": [- "error: Failed to load resource: the server responded with a status of 404 (Not Found)",- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened."- ],- "state": "ended",- "chip": "No event scheduled",- "name": "The world is open anyway.",- "clock": "",- "cta": "Enter the three.ws world",- "ctaHref": "/play",- "calHidden": true,- "when": "Follow the changelog to hear about the next one before it starts.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 0,- "scheduleHidden": true,- "hScroll": false- },- {- "kind": "none",- "theme": "light",- "label": "mobile",- "errors": [- "error: WebSocket connection to 'wss://fantastic-space-orbit-xrrw6xrjxxjc977j-3000.app.github.dev/?token=GeEzFU7CM6dB' failed: Error during WebSocket handshake: Unexpected response code: 404",- "error: Failed to load resource: the server responded with a status of 404 (Not Found)",- "error: [vite] failed to connect to websocket (Error: WebSocket closed without opened.). ",- "pageerror: WebSocket closed without opened.",- "error: Failed to load resource: the server responded with a status of 500 (Internal Server Error)"- ],- "state": "ended",- "chip": "No event scheduled",- "name": "The world is open anyway.",- "clock": "",- "cta": "Enter the three.ws world",- "ctaHref": "/play",- "calHidden": true,- "when": "Follow the changelog to hear about the next one before it starts.",- "liveHidden": true,- "liveNum": "—",- "liveTitle": "In the world right now",- "agendaRows": 0,- "scheduleHidden": true,- "hScroll": false- },- {- "kind": "ics",- "file": "/workspaces/three.ws/scripts/shots/three-first-meetup.ics",- "note": "Calendar file downloaded. Open it to add the event."- },- {- "kind": "keyboard",- "tabsToCta": null- }-]\ No newline at end of filediff --git a/scripts/shots/three-first-meetup.ics b/scripts/shots/three-first-meetup.icsdeleted file mode 100644index fd3234a0c..000000000--- a/scripts/shots/three-first-meetup.ics+++ /dev/null@@ -1,23 +0,0 @@-BEGIN:VCALENDAR-VERSION:2.0-PRODID:-//three.ws//Live event//EN-CALSCALE:GREGORIAN-METHOD:PUBLISH-BEGIN:VEVENT-UID:[email protected]-DTSTAMP:20260807T094038Z-DTSTART:20260808T114531Z-DTEND:20260808T134031Z-SUMMARY:$THREE First Holders Meetup-DESCRIPTION:The first live gathering in the three.ws world. Drop in\, hang- out\, win prizes.\n11:45 AM - Doors open in the plaza\n12:05 PM - King of- the Totem showdown\n12:30 PM - Fortune's Folly wheel hour\n12:55 PM - Plaz- a dance-off\n1:30 PM - Fireworks finale\nJoin: http://localhost:3000/play?- coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=thr- ee-LOCATION:http://localhost:3000/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyD- CatJVJpump&name=three.ws&symbol=three-URL:http://localhost:3000/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJV- Jpump&name=three.ws&symbol=three-END:VEVENT-END:VCALENDARdiff --git a/src/game/coincommunities-ui.js b/src/game/coincommunities-ui.jsindex 088483dfe..758c4053c 100644--- a/src/game/coincommunities-ui.js+++ b/src/game/coincommunities-ui.js@@ -21,6 +21,7 @@ import { getMe } from '../account.js';import { threeMarkSvg } from '../shared/brand-mark.js';import { proxiedImageURL } from '../ipfs.js';import { log } from '../shared/log.js';+import { t, onLocaleChange } from './i18n-play.js';// localStorage throws in private mode and in third-party iframe contexts where// storage is blocked (the `?bg=transparent` embed). Guard every access so a@@ -1316,7 +1317,8 @@ export class CommunityUI {this.coinMono = el('span', { class: 'cc-coin-mono', 'aria-hidden': 'true', hidden: true, text: '' });this.coinName = el('div', { class: 'cc-coin-name', text: '' });this.coinSym = el('span', { class: 'cc-coin-sym', text: '' });- this.onlineCount = el('span', { text: '1 online' });+ this.onlineCount = el('span', { text: t('play.online', '{{n}} online', { n: 1 }) });+ this._online = 1;// Marks the gated Holders world so the player always knows which room they're// in and the floor they cleared. Hidden in the open General world.this.tierBadge = el('span', { class: 'cc-tier-badge', hidden: true });@@ -1339,10 +1341,11 @@ export class CommunityUI {}, [el('span', { class: 'cc-gate-cfg-ico', 'aria-hidden': 'true', text: '🔑' }), el('span', { class: 'cc-gate-cfg-text', text: 'Gate', 'data-i18n': 'play.gate' })]);// Open the cosmetics shop — browse + try cosmetics on your avatar live.this.shopBtn = el('button', {- class: 'cc-shop-btn', type: 'button', title: 'Cosmetics — try looks on your avatar',+ class: 'cc-shop-btn', type: 'button', title: 'Cosmetics: try looks on your avatar','aria-label': 'Open cosmetics shop',+ 'data-i18n-attr': 'title:play.shop_title;aria-label:play.shop_aria',onclick: () => this.h.onShop?.(),- }, [el('span', { class: 'cc-shop-btn-ico', 'aria-hidden': 'true', text: '🛍️' }), el('span', { class: 'cc-shop-btn-text', text: 'Shop' })]);+ }, [el('span', { class: 'cc-shop-btn-ico', 'aria-hidden': 'true', text: '🛍️' }), el('span', { class: 'cc-shop-btn-text', text: 'Shop', 'data-i18n': 'play.shop' })]);// Change avatar without leaving the world: opens the in-world switcher// drawer (saved avatars, quick picks, gallery, upload, creator). Touch// equivalent of the V hotkey.@@ -1354,14 +1357,15 @@ export class CommunityUI {}, [el('span', { class: 'cc-avatarbtn-ico', 'aria-hidden': 'true', text: '🧍' }), el('span', { class: 'cc-avatarbtn-text', text: 'Avatar', 'data-i18n': 'play.avatar' })]);// Open the "My Cosmetics" wardrobe — equip owned items, persists across worlds.this.wardrobeBtn = el('button', {- class: 'cc-wardrobe-btn', type: 'button', title: 'My Cosmetics — equip your owned looks',+ class: 'cc-wardrobe-btn', type: 'button', title: 'My Cosmetics: equip your owned looks','aria-label': 'Open my cosmetics wardrobe',+ 'data-i18n-attr': 'title:play.wardrobe_title;aria-label:play.wardrobe_aria',onclick: () => this.h.onWardrobe?.(),- }, [el('span', { class: 'cc-wardrobe-btn-ico', 'aria-hidden': 'true', text: '👗' }), el('span', { class: 'cc-wardrobe-btn-text', text: 'My Fits' })]);+ }, [el('span', { class: 'cc-wardrobe-btn-ico', 'aria-hidden': 'true', text: '👗' }), el('span', { class: 'cc-wardrobe-btn-text', text: 'My Fits', 'data-i18n': 'play.wardrobe' })]);// Open the Jobs Board (W08 hooking W05) — dailies, repeatable work, and// the co-op vault heist, the same board every quest-giver NPC opens.this.jobsBtn = el('button', {- class: 'cc-jobs-btn', type: 'button', title: 'Jobs Board — dailies, courier runs, and the vault heist',+ class: 'cc-jobs-btn', type: 'button', title: 'Jobs Board: dailies, courier runs, and the vault heist','aria-label': 'Open the jobs board','data-i18n-attr': 'title:play.jobs_title;aria-label:play.jobs_aria',onclick: () => this.h.onJobs?.(),@@ -1373,12 +1377,13 @@ export class CommunityUI {// mobile has no keyboard.this.friendsBadge = el('span', { class: 'cc-friends-badge', hidden: true });this.friendsBtn = el('button', {- class: 'cc-friends-btn', type: 'button', title: 'Friends — presence and messages (J)',+ class: 'cc-friends-btn', type: 'button', title: 'Friends: presence and messages (J)','aria-label': 'Open friends panel', 'aria-expanded': 'false',+ 'data-i18n-attr': 'title:play.friends_title;aria-label:play.friends_aria',onclick: () => this.h.onFriends?.(),}, [el('span', { class: 'cc-friends-btn-ico', 'aria-hidden': 'true', text: '👥' }),- el('span', { class: 'cc-friends-btn-text', text: 'Friends' }),+ el('span', { class: 'cc-friends-btn-text', text: 'Friends', 'data-i18n': 'play.friends' }),this.friendsBadge,]);const banner = el('div', { class: 'cc-coin-banner' }, [@@ -1401,8 +1406,9 @@ export class CommunityUI {this.buyBtn,]);- const leave = el('button', { class: 'cc-leave', onclick: () => this.h.onLeave() }, [- el('span', { text: '←' }), document.createTextNode('Communities'),+ const leave = el('button', { class: 'cc-leave', type: 'button', onclick: () => this.h.onLeave() }, [+ el('span', { 'aria-hidden': 'true', text: '←' }),+ el('span', { text: 'Communities', 'data-i18n': 'play.leave' }),]);this.statusText = el('span', { text: 'connecting…' });@@ -1425,11 +1431,12 @@ export class CommunityUI {// out. Polite (not assertive) so a busy room never talks over the player.this.chatLog = el('div', {class: 'cc-chat-log', role: 'log', 'aria-live': 'polite', 'aria-relevant': 'additions text',- 'aria-label': 'Chat messages',+ 'aria-label': 'Chat messages', 'data-i18n-attr': 'aria-label:play.chat_log_aria',});this.chatInput = el('input', {type: 'text', maxlength: '200', placeholder: 'Say something…','aria-label': 'Chat message',+ 'data-i18n-attr': 'placeholder:play.chat_placeholder;aria-label:play.chat_input_aria',onkeydown: (e) => {if (e.key === 'Enter') this._sendChat();else if (e.key === 'Escape') this.chatInput.blur();@@ -1441,19 +1448,20 @@ export class CommunityUI {const head = el('div', {class: 'cc-chat-head', role: 'button', tabindex: '0', 'aria-label': 'Toggle chat','aria-expanded': 'true', 'aria-controls': 'cc-chat-body',+ 'data-i18n-attr': 'aria-label:play.chat_toggle_aria',onclick: () => this.toggleChat(),onkeydown: (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); e.stopPropagation(); this.toggleChat(); } },}, [- el('span', { class: 'cc-chat-title' }, [el('span', { class: 'cc-chat-ico', text: '💬' }), document.createTextNode('Chat')]),+ el('span', { class: 'cc-chat-title' }, [el('span', { class: 'cc-chat-ico', 'aria-hidden': 'true', text: '💬' }), el('span', { text: 'Chat', 'data-i18n': 'play.chat' })]),this.chatUnread,this.chatChevron,]);this.chatBody = el('div', { class: 'cc-chat-body', id: 'cc-chat-body' }, [this.chatLog,- el('div', { class: 'cc-chat-input' }, [this.chatInput, el('button', { class: 'cc-chat-send', type: 'button', text: 'Send', onclick: () => this._sendChat() })]),+ el('div', { class: 'cc-chat-input' }, [this.chatInput, el('button', { class: 'cc-chat-send', type: 'button', text: 'Send', 'data-i18n': 'play.send', onclick: () => this._sendChat() })]),]);this.chatHead = head;- this.chat = el('div', { id: 'cc-chat', role: 'region', 'aria-label': 'Chat' }, [head, this.chatBody]);+ this.chat = el('div', { id: 'cc-chat', role: 'region', 'aria-label': 'Chat', 'data-i18n-attr': 'aria-label:play.chat' }, [head, this.chatBody]);// Default: collapsed on touch (small screens), open on desktop — unless the// user has expressed a preference before.const stored = lsGet('cc-chat-min');@@ -1461,17 +1469,18 @@ export class CommunityUI {this.toggleChat(stored != null ? stored === '1' : matchMedia('(pointer: coarse)').matches);const chat = this.chat;- this.emoteTray = el('div', { id: 'cc-emotes', role: 'toolbar', 'aria-label': 'Emotes' });+ this.emoteTray = el('div', { id: 'cc-emotes', role: 'toolbar', 'aria-label': 'Emotes', 'data-i18n-attr': 'aria-label:play.emotes' });// Reaction bar (R04): 6 emoji that broadcast a floating sprite above the sender's avatar.- this.reactionBar = el('div', { id: 'cc-reactions', role: 'toolbar', 'aria-label': 'Reactions' });+ this.reactionBar = el('div', { id: 'cc-reactions', role: 'toolbar', 'aria-label': 'Reactions', 'data-i18n-attr': 'aria-label:play.reactions' });// Spatial voice toggle. Off by default (no mic until the player opts in);// the icon + label reflect every state (connecting / live / muted / blocked).// The SVG carries its own mute slash, shown via the button's data-state.- this.voiceLabel = el('span', { class: 'cc-voice-label', text: 'Voice' });+ this.voiceLabel = el('span', { class: 'cc-voice-label', text: 'Voice', 'data-i18n': 'play.voice' });this.voiceBtn = el('button', {class: 'cc-voice', type: 'button', 'data-state': 'off',- 'aria-label': 'Voice chat', title: 'Join voice — talk to people near you',+ 'aria-label': 'Voice chat', title: 'Join voice: talk to people near you',+ 'data-i18n-attr': 'aria-label:play.voice_aria;title:play.voice_title',onclick: () => this.h.onVoiceToggle?.(),}, [el('span', { class: 'cc-voice-ico', html:@@ -1491,11 +1500,12 @@ export class CommunityUI {this.powerBtn = el('button', {class: 'cc-power-btn', type: 'button','aria-pressed': getPowerSaver() ? 'true' : 'false',- 'aria-label': 'Power saver', title: 'Power saver — 30fps + lighter rendering, for a cooler, quieter machine',+ 'aria-label': 'Power saver', title: 'Power saver: 30fps and lighter rendering, for a cooler, quieter machine',+ 'data-i18n-attr': 'aria-label:play.eco_aria;title:play.eco_title',onclick: () => setPowerSaver(this.powerBtn.getAttribute('aria-pressed') !== 'true'),}, [el('span', { class: 'cc-power-ico', 'aria-hidden': 'true', text: '⚡' }),- el('span', { class: 'cc-power-label', text: 'Eco' }),+ el('span', { class: 'cc-power-label', text: 'Eco', 'data-i18n': 'play.eco' }),]);onPowerSaverChange((on) => this.powerBtn.setAttribute('aria-pressed', on ? 'true' : 'false'));@@ -1522,37 +1532,45 @@ export class CommunityUI {this.zenBtn = el('button', {class: 'cc-zen-btn', type: 'button', 'aria-pressed': 'false','aria-label': 'Zen mode', title: 'Zen mode: hide every panel, just the world (Z)',+ 'data-i18n-attr': 'aria-label:play.zen_aria;title:play.zen_title',onclick: () => this.h.onZen?.(),}, [el('span', { class: 'cc-zen-ico', 'aria-hidden': 'true', text: '🧘' }),- el('span', { class: 'cc-zen-label', text: 'Zen' }),+ el('span', { class: 'cc-zen-label', text: 'Zen', 'data-i18n': 'play.zen' }),]);this.zenExit = el('button', {id: 'cc-zen-exit', type: 'button','aria-label': 'Show controls', title: 'Show controls (Z)',+ 'data-i18n-attr': 'aria-label:play.show_ui_aria;title:play.show_ui_title',onclick: () => this.h.onZen?.(),}, [el('span', { 'aria-hidden': 'true', html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" focusable="false">'+ '<path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12z"/><circle cx="12" cy="12" r="3"/>'+ '</svg>' }),- document.createTextNode('Show UI'),+ el('span', { text: 'Show UI', 'data-i18n': 'play.show_ui' }),]);document.body.appendChild(this.zenExit);// Dance floor button — hidden until the player steps onto the pad.- this.danceBtnLabel = el('span', { class: 'cc-dance-label', text: 'Dance' });+ this.danceBtnLabel = el('span', { class: 'cc-dance-label', text: 'Dance', 'data-i18n': 'play.dance' });this.danceBtn = el('button', {class: 'cc-dance-btn', type: 'button', hidden: true,'aria-label': 'Dance on the floor', title: 'Sync-dance with everyone on the floor',+ 'data-i18n-attr': 'aria-label:play.dance_aria;title:play.dance_title',onclick: () => this.h.onDance?.(),}, [el('span', { class: 'cc-dance-ico', 'aria-hidden': 'true', text: '🪩' }),this.danceBtnLabel,]);- const hint = el('div', { id: 'cc-hint', html:- '<kbd>W A S D</kbd> / drag-joystick to move · <kbd>drag</kbd> to look · scroll zoom · <kbd>Enter</kbd> chat · <kbd>Q</kbd> emotes · <kbd>I</kbd> inspect · <kbd>P</kbd> photo · <kbd>Z</kbd> zen' });+ const hint = el('div', {+ id: 'cc-hint', 'data-i18n-html': 'play.hint',+ // Duplicated by the canvas aria-label in pages/play.html, which is what a+ // screen reader reads; this strip is the sighted player's copy.+ 'aria-hidden': 'true',+ html: '<kbd>W A S D</kbd> / drag-joystick to move · <kbd>drag</kbd> to look · scroll zoom · <kbd>Enter</kbd> chat · <kbd>Q</kbd> emotes · <kbd>I</kbd> inspect · <kbd>P</kbd> photo · <kbd>Z</kbd> zen',+ });// Touch-only control surface: it has no keyboard equivalent to offer and// nothing a screen reader can act on, so it stays out of both trees.@@ -2703,7 +2721,17 @@ export class CommunityUI {}setStatus(state, error = null) {- const labels = { connecting: 'connecting…', online: 'connected', offline: 'reconnecting…', unavailable: 'multiplayer unavailable', failed: 'offline, tap to retry', denied: 'sign-in required', idle: 'idle' };+ this._statusState = state;+ this._statusError = error;+ const labels = {+ connecting: t('play.status_connecting', 'connecting…'),+ online: t('play.status_online', 'connected'),+ offline: t('play.status_offline', 'reconnecting…'),+ unavailable: t('play.status_unavailable', 'multiplayer unavailable'),+ failed: t('play.status_failed', 'offline, tap to retry'),+ denied: t('play.status_denied', 'sign-in required'),+ idle: t('play.status_idle', 'idle'),+ };// 'offline' is two different truths: a transient drop mid-reconnect (no// error) vs the client having exhausted its retries (community-net attaches// an error string). Telling a player "reconnecting…" forever after the@@ -2719,8 +2747,8 @@ export class CommunityUI {if (retryable) {this.statusPill.setAttribute('tabindex', '0');this.statusPill.setAttribute('role', 'button');- this.statusPill.setAttribute('aria-label', `Connection ${this.statusText.textContent}. Activate to reconnect.`);- this.statusPill.title = 'Reconnect';+ this.statusPill.setAttribute('aria-label', t('play.status_retry_aria', 'Connection {{state}}. Activate to reconnect.', { state: this.statusText.textContent }));+ this.statusPill.title = t('play.status_retry_title', 'Reconnect');} else {this.statusPill.removeAttribute('tabindex');this.statusPill.setAttribute('role', 'status');@@ -2738,7 +2766,10 @@ export class CommunityUI {this.pingText.setAttribute('data-grade', ms < 90 ? 'good' : ms < 200 ? 'ok' : 'bad');}- setOnline(n) { this.onlineCount.textContent = `${n} online`; }+ setOnline(n) {+ this._online = n;+ this.onlineCount.textContent = t('play.online', '{{n}} online', { n });+ }/** Persist the typed display name and, if connected, broadcast it live. */_commitName() {diff --git a/src/game/community-net.js b/src/game/community-net.jsindex 004c06f4d..e7ca07a1f 100644--- a/src/game/community-net.js+++ b/src/game/community-net.js@@ -111,6 +111,7 @@ export class CommunityNet {xpgain: new Set(), // ({skill, amount, xp, level, levelXp, nextXp})levelup: new Set(), // ({skill, level})notice: new Set(), // ({kind, text, ...}) — activity result toast (fish/eat/tool/full/quest)+ souvenir: new Set(), // ({id, name, slot, eventId, eventName}) — a live event just granted this account its free commemorative wearable (once, ever)// General store, bank/ATM & the $THREE boutique (W04).store: new Set(), // ({sell:[{item,label,price}], buy:[{item,qty,price,label}]})boutique: new Set(), // ({listings, owned, configured}) — premium cosmetics priced in $THREEdiff --git a/src/play/war.js b/src/play/war.jsindex 61d52a6d6..39abb3f63 100644--- a/src/play/war.js+++ b/src/play/war.js@@ -61,6 +61,7 @@ let phase = 'lobby';let ended = null; // { winner, reason, scoreA, scoreB, mvp }let labelEls = new Map();let sendTimer = 0;+let clockTimer = 0;let lastSent = { x: NaN, z: NaN, yaw: NaN, motion: '' };let attackCooldownUntil = 0;@@ -154,6 +155,10 @@ let attackCooldownUntil = 0;$('controls').hidden = false;sendTimer = setInterval(sendPose, 1000 / SEND_HZ);+ // The round clock is derived from `endsAt`, which only changes when the match+ // starts — so it has to be ticked locally or it would freeze between the+ // state patches that carry a score change.+ clockTimer = setInterval(tickClock, 500);addEventListener('beforeunload', () => { try { room?.leave(); } catch { /* closing anyway */ } });})();@@ -282,8 +287,16 @@ function renderScore(s) {$('name-them').textContent = factionLabel(s, cfg.side === 'a' ? 'b' : 'a');$('cap').textContent = s.scoreCap ? `first to ${s.scoreCap}` : '';+ tickClock();+}++function tickClock() {+ const s = room?.state;+ if (!s) return;+ if (s.phase === 'sudden_death') { $('clock').textContent = 'OT'; return; }+ if (s.phase === 'lobby') { $('clock').textContent = '—'; return; }const target = s.phase === 'countdown' ? s.countdownEndsAt : s.endsAt;- $('clock').textContent = s.phase === 'sudden_death' ? 'OT' : clock(target - Date.now());+ $('clock').textContent = clock(target - Date.now());}function renderVitals(f) {@@ -441,6 +454,7 @@ function fail(title, detail, action = 'Back to the world') {$('fail-back').textContent = action;$('fail').hidden = false;clearInterval(sendTimer);+ clearInterval(clockTimer);}// The room throws named errors; each one has a player-readable cause.@@ -474,12 +488,16 @@ function displayName() {return '';}+// The body the player picked in /play. The lobby also stores non-loadable values+// there (a locally-staged guest avatar that was never uploaded), so only a real+// URL or site path is carried into the arena; anything else takes the default rig+// rather than putting an unloadable body on the field.function savedAvatar() {+ let stored = '';try {- return localStorage.getItem(AVATAR_KEY) || FALLBACK_AVATAR;- } catch {- return FALLBACK_AVATAR;- }+ stored = localStorage.getItem(AVATAR_KEY) || '';+ } catch { /* storage disabled */ }+ return /^https?:\/\//i.test(stored) || stored.startsWith('/') ? stored : FALLBACK_AVATAR;}function clock(ms) {diff --git a/tests/event-leaderboard.test.js b/tests/event-leaderboard.test.jsindex 723b6fb6c..3694fa590 100644--- a/tests/event-leaderboard.test.js+++ b/tests/event-leaderboard.test.js@@ -46,6 +46,16 @@ describe('applyEventRun', () => {expect(rec.cash).toBe(0);expect(rec.lastAt).toBe(0);});++ // A real epoch-ms stamp is past 2^31, so a bitwise coercion anywhere on this+ // path silently zeroes it and the "earlier finisher wins" tiebreak stops+ // working. Caught in a live run where every row came back with lastAt: 0.+ it('keeps a real epoch-millisecond timestamp intact', () => {+ const now = Date.UTC(2026, 7, 8, 17, 30, 0); // ~1.786e12, well past 2^31+ const rec = applyEventRun(emptyEventRecord('acct-1'), { missionId: 'm', gold: 220, at: now });+ expect(rec.lastAt).toBe(now);+ expect(normalizeEventRecord(rec).lastAt).toBe(now);+ });});describe('normalizeEventRecord', () => {diff --git a/tests/play-counters.test.js b/tests/play-counters.test.jsnew file mode 100644index 000000000..da47baaf0--- /dev/null+++ b/tests/play-counters.test.js@@ -0,0 +1,74 @@+// The cash counters are two lists in two files that must stay identical.+//+// The general store and the bank/ATM are the only cash actions that used to have+// no proximity check: the server priced every trade correctly but never asked+// where the player stood, so a crafted client could bank its purse from the+// middle of a fight and never risk a coin to a death drop. Closing that meant the+// server needs the counter positions, and those positions already existed on the+// client (src/game/world-zones.js, where the NPCs are placed).+//+// Two copies of a coordinate is exactly the drift that produces "the shop refuses+// to serve me while I'm standing in it", so this suite pins them equal. If a stall+// moves on the client, this fails here rather than in a player's face.++import { describe, it, expect } from 'vitest';++const {+ VENDOR_STALLS, ATMS, COUNTER_REACH, vendorInRange, atmInRange,+} = await import('../multiplayer/src/world-features.js');+const { spawnsOfType } = await import('../src/game/world-zones.js');++const at = (list, id) => list.find((n) => n.id === id);++describe('counter positions mirror the client spawn table exactly', () => {+ it('every vendor stall the client places has a server-side counter at the same point', () => {+ const clientStalls = spawnsOfType('vendor');+ expect(clientStalls.length).toBeGreaterThan(0);+ expect(VENDOR_STALLS.length).toBe(clientStalls.length);+ for (const stall of clientStalls) {+ const server = at(VENDOR_STALLS, stall.id);+ expect(server, `no server counter for client stall ${stall.id}`).toBeTruthy();+ expect([server.x, server.z]).toEqual([stall.x, stall.z]);+ }+ });++ it('every ATM the client places has a server-side counter at the same point', () => {+ const clientAtms = spawnsOfType('atm');+ expect(clientAtms.length).toBeGreaterThan(0);+ expect(ATMS.length).toBe(clientAtms.length);+ for (const atm of clientAtms) {+ const server = at(ATMS, atm.id);+ expect(server, `no server counter for client ATM ${atm.id}`).toBeTruthy();+ expect([server.x, server.z]).toEqual([atm.x, atm.z]);+ }+ });+});++describe('counter reach', () => {+ it('covers a player standing on the NPC that opened the panel', () => {+ for (const stall of VENDOR_STALLS) expect(vendorInRange(stall.x, stall.z)).toBeTruthy();+ for (const atm of ATMS) expect(atmInRange(atm.x, atm.z)).toBeTruthy();+ });++ // The NPC's own walk-up prompt fires at 5m, so the counter has to reach past+ // that or a player who takes one step back mid-trade gets refused.+ it('reaches further than the 5m NPC prompt that opens the panel', () => {+ expect(COUNTER_REACH).toBeGreaterThan(5);+ const stall = VENDOR_STALLS[0];+ expect(vendorInRange(stall.x + 6, stall.z)).toBeTruthy();+ });++ it('does not reach across the world, which is the whole point', () => {+ const stall = VENDOR_STALLS[0];+ expect(vendorInRange(stall.x + COUNTER_REACH + 2, stall.z)).toBeNull();+ // Spawn is 60m+ from either stall, so a player at spawn is not at a counter.+ expect(vendorInRange(0, 0)).toBeNull();+ // The ATM sits at (0,-30): far enough from spawn that banking is a walk.+ expect(atmInRange(0, 0)).toBeNull();+ });++ it('the store and the bank are separate counters, not one shared spot', () => {+ for (const atm of ATMS) expect(vendorInRange(atm.x, atm.z)).toBeNull();+ for (const stall of VENDOR_STALLS) expect(atmInRange(stall.x, stall.z)).toBeNull();+ });+});