From 405bc070fa1313c5cdb9464b7452945b503f75be Mon Sep 17 00:00:00 2001 From: Ian Massaro Date: Tue, 17 Nov 2026 23:27:47 -0500 Subject: [PATCH 1/6] Back Room: Tournaments panel (tournament.js) with brackets, featured events and the Tournament Champion ribbon Co-Authored-By: Claude Opus 5.5 --- e63334287a3deaa3/index.html | 1 + e63334287a3deaa3/miles.js | 88 +++- e63334287a3deaa3/tournament.js | 870 +++++++++++++++++++++++++++++++++ index.html | 1 + 4 files changed, 955 insertions(+), 5 deletions(-) create mode 100644 e63334287a3deaa3/tournament.js diff --git a/e63334287a3deaa3/index.html b/e63334287a3deaa3/index.html index 1b042bce..f5dc5835 100644 --- a/e63334287a3deaa3/index.html +++ b/e63334287a3deaa3/index.html @@ -959,6 +959,7 @@

Flickerwood

+ diff --git a/e63334287a3deaa3/miles.js b/e63334287a3deaa3/miles.js index 0a6fcc74..3a396320 100644 --- a/e63334287a3deaa3/miles.js +++ b/e63334287a3deaa3/miles.js @@ -29,6 +29,9 @@ * award: see "Earned awards" below), else 0; also takes a uid * crackerOf(result) a result's player's all-time Shell Crackers kills if they hold Top Cracker (the other earned * award: most Shell Crackers kills, CRACK_MIN or more), else 0; also takes a uid + * champOf(result) { u, g, t } a result's player's newest Tournament Champion win in the last 7 days (the third earned + * award, a Captain-run tournament in tournament.js), else null; also takes a uid. readChamps() reads + * the hall again; hallCap(uid) says whether a hall node under that uid is believed (a Captain's) * setTops(tops) leaderboard.js hands over the top three ({ all, week: [uid…] the firsts, allTie, weekTie, and * all2, all3, week2, week3: [uid…] the seconds and thirds; topOf's all and week are the place, 1 to 3; * and ace: [uid…], aceN: the Slipstream ace's holders and how many tracks they lead; crack: @@ -168,6 +171,10 @@ // the gold tags and the First Class pill). shellcrackers: { earned: true, n: 'Top Cracker', tip: 'Most Shell Crackers kills', disc: '#2B1A10', rim: '#FFC93C', band: 'linear-gradient(90deg,#FFF8E8,#FBE6B8)', ink: '#2B1A10', edge: '#8A5A33', icon: '' }, + // EARNED too, for 7 days: Tournament Champion, the winner of a Back Room tournament run by a Captain (tournament.js; + // see champOf below for who is believed). Deep violet and mint, clear of the gold tags and the tier pills: a cup. + champion: { earned: true, n: 'Tournament Champion', tip: 'Won a Back Room tournament run by a Captain', disc: '#1E1747', rim: '#7CF2D0', band: 'linear-gradient(90deg,#5B3FD1,#7B5CFF)', ink: '#fff', + icon: '' }, // Boostball's navy, blue and boost orange: the ball with a boost flame behind it. boostball: { n: 'Boostball star', tip: 'Awarded for dedication to Boostball', disc: '#0E1B3A', rim: '#FF8A1F', band: 'linear-gradient(90deg,#2F7BFF,#6AA6FF)', ink: '#fff', icon: '' } @@ -273,15 +280,16 @@ // First on the Miles board: the pill and its "#1" tags in one wrapper. Everyone else gets the pill alone, as before. // An award holder gets the same wrapper, with a ribbon for each award after the tags. // The earned awards (the Slipstream ace, then Top Cracker) come last, after any award that was given. - var top = null, aw = awardsOf(res), led = 0, cr = 0; - if (res && res.uid) { wantTops(); top = topOf(res.uid); led = aceOf(res); cr = crackerOf(res); } - if (!top && !aw.length && !led && !cr) return s; + var top = null, aw = awardsOf(res), led = 0, cr = 0, ch = null; + if (res && res.uid) { wantTops(); top = topOf(res.uid); led = aceOf(res); cr = crackerOf(res); wantChamps(); ch = champOf(res); } + if (!top && !aw.length && !led && !cr && !ch) return s; var w = document.createElement('span'); w.className = 'bra-tw'; w.appendChild(s); if (top && top.all) w.appendChild(topTag('all', top.all, top.allTie)); if (top && top.week) w.appendChild(topTag('week', top.week, top.weekTie)); aw.forEach(function (k) { w.appendChild(awardTag(k)); }); if (led) w.appendChild(awardTag('slipstream', 'Leads ' + led + ' Slipstream tracks')); if (cr) w.appendChild(awardTag('shellcrackers', 'Most Shell Crackers kills: ' + fmt(cr))); + if (ch) w.appendChild(awardTag('champion', ch.g + ', ' + champDay(ch.t))); fitSoon(w); return w; } @@ -494,6 +502,75 @@ var c = liveTops(); if (!c || !c.crackN) return 0; return idsOf(res).some(function (u) { return c.crack.indexOf(u) >= 0; }) ? c.crackN : 0; } + // ---- Tournament Champion (the third earned award, for 7 days) ---- + // tournament.js runs Back Room tournaments. When one run by a Captain ends, the Captain's own browser writes the result + // to rooms/tn-hall/players/, as cw/ = { u: winner's uid, n: name, g: game, t: when }. + // The shared database rules only let a browser write the node under its own signed-in uid, so a node under a uid in + // OWNERS can only have been written by that Captain, signed in with Google. Here only those nodes are believed: anything + // under any other uid (a player writing "I won" for themselves) is ignored, as is a win older than 7 days (CHAMP_DAYS) or + // dated in the future. One read of rooms/tn-hall/players at most every 5 minutes (CHAMP_TTL) while a badge is drawn, + // kept in this browser's localStorage (tn:champs) and shared by every tab; tournament.js asks for a fresh read + // (readChamps) right after it writes one. On localhost only, uids listed in localStorage tn:testcaps count as Captains + // too, for testing (see tournament.js); the live site never looks at that list. + var CHAMP_KEY = 'tn:champs', CHAMP_TTL = 5 * 60000, CHAMP_DAYS = 7, CHAMP_PATH = 'rooms/tn-hall/players'; + var champs = null, champsAsked = 0; + var LOCAL = /^(localhost|127\.0\.0\.1|\[::1\])$/.test(location.hostname); + function hallCap(u) { + if (isOwner(u)) return true; + if (!LOCAL) return false; + try { var l = JSON.parse(localStorage.getItem('tn:testcaps') || '[]'); return Array.isArray(l) && l.indexOf(u) >= 0; } catch (e) { return false; } + } + function champWin(t, now) { return typeof t === 'number' && isFinite(t) && t <= now + 5 * 60000 && now - t < CHAMP_DAYS * 86400000; } + // The hall's nodes (as read) into a list of wins { u, g, t }, believing only the Captains' nodes. + function champList(val, now) { + var out = []; + if (!val || typeof val !== 'object') return out; + Object.keys(val).forEach(function (k) { + var v = val[k], cw = v && typeof v === 'object' && v.cw; + if (!hallCap(k) || !cw || typeof cw !== 'object') return; + Object.keys(cw).slice(0, 60).forEach(function (id) { + var e = cw[id]; + if (!e || typeof e !== 'object' || !okUid(e.u) || !champWin(e.t, now)) return; + out.push({ u: e.u, g: typeof e.g === 'string' ? e.g.replace(/[<>]/g, '').slice(0, 40) : 'a tournament', t: e.t }); + }); + }); + return out.slice(0, 200); + } + function storedChamps() { + try { var o = JSON.parse(localStorage.getItem(CHAMP_KEY) || 'null'); return o && num(o.t) && Array.isArray(o.list) ? o : null; } catch (e) { return null; } + } + function champSig(c) { return c ? c.list.map(function (e) { return e.u + e.t; }).join() : ''; } + function takeChamps(c) { + var was = champSig(champs); champs = c; + if (champSig(champs) !== was) try { document.dispatchEvent(new CustomEvent('backroom:miles', { detail: { uid: '', tops: true } })); } catch (e) {} + } + function readChamps() { + champsAsked = Date.now(); + return waitParty().then(function (P) { return P.boot().then(function (b) { + return b.db.ref(CHAMP_PATH).once('value').then(function (s) { + var c = { t: Date.now(), list: champList(s.val(), P.now ? P.now() : Date.now()) }; + try { localStorage.setItem(CHAMP_KEY, JSON.stringify(c)); } catch (e) {} + takeChamps(c); return c.list; + }); + }); }).catch(function () { return champs ? champs.list : []; }); + } + function wantChamps() { + var now = Date.now(); + if ((champs && now - champs.t < CHAMP_TTL) || now - champsAsked < 60000 || document.visibilityState === 'hidden') return; + champsAsked = now; + setTimeout(readChamps, 0); + } + // The newest win (within 7 days) of anyone a result stands for, or null. Takes a result or a uid. + function champOf(res) { + if (!champs) return null; + var ids = idsOf(res), now = Date.now(), best = null; + champs.list.forEach(function (e) { if (ids.indexOf(e.u) >= 0 && champWin(e.t, now) && (!best || e.t > best.t)) best = e; }); + return best; + } + function champDay(t) { try { return new Date(t).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); } catch (e) { return ''; } } + champs = storedChamps(); + window.addEventListener('storage', function (e) { if (e.key === CHAMP_KEY) { var c = storedChamps(); if (c && (!champs || c.t > champs.t)) takeChamps(c); } }); + function wantTops() { var now = Date.now(); if ((tops && now - tops.t < TOPS_TTL) || now - topsAsked < TOPS_RETRY) return; @@ -611,7 +688,8 @@ Object.keys(AWARD_KINDS).filter(function (k) { return !AWARD_KINDS[k].earned; }).forEach(function (k) { gRow(l, [awardTag(k)], AWARD_KINDS[k].n, AWARD_KINDS[k].tip + '. Given by the Captains.'); }); Object.keys(AWARD_KINDS).filter(function (k) { return AWARD_KINDS[k].earned; }).forEach(function (k) { gRow(l, [awardTag(k)], AWARD_KINDS[k].n, k === 'slipstream' ? 'Earned: hold the fastest lap this season on more Slipstream tracks than anyone else, ' + ACE_MIN + ' or more at once. It moves to whoever takes the lead.' - : k === 'shellcrackers' ? 'Earned: have more Shell Crackers kills of all time than anyone else, ' + CRACK_MIN + ' or more. It moves to whoever takes the lead.' : AWARD_KINDS[k].tip + '.'); + : k === 'shellcrackers' ? 'Earned: have more Shell Crackers kills of all time than anyone else, ' + CRACK_MIN + ' or more. It moves to whoever takes the lead.' + : k === 'champion' ? 'Earned: win a Back Room tournament run by a Captain (a featured event, or one a Captain starts from their party). It shows for ' + CHAMP_DAYS + ' days.' : AWARD_KINDS[k].tip + '.'); }); d.appendChild(box); // A click on the dimmed area outside the window closes it. @@ -646,7 +724,7 @@ window.BackRoomMiles = { of: of, tierOf: tierOf, isOwner: isOwner, badge: badge, guide: guide, line: line, peek: peek, load: load, fmt: fmt, TIERS: TIERS, RULES: RULES, PATH: PATH, HOUR: HOUR, CAPTAIN: CAPTAIN, OWNERS: OWNERS.slice(), FOUNDER: FOUNDER, isFounder: isFounder, isVice: isVice, VICE_CAPTAIN: VICE_CAPTAIN, VICE_CAPTAINS: VICE_CAPTAINS.slice(), forget: function (uid) { if (uid) delete cache[uid]; else cache = {}; }, setTops: setTops, topOf: topOf, needTops: needTops, - awardsOf: awardsOf, aceOf: aceOf, ACE_MIN: ACE_MIN, crackerOf: crackerOf, CRACK_MIN: CRACK_MIN, AWARD_KINDS: JSON.parse(JSON.stringify(AWARD_KINDS)), AWARDS: JSON.parse(JSON.stringify(AWARDS)) }; + awardsOf: awardsOf, aceOf: aceOf, ACE_MIN: ACE_MIN, crackerOf: crackerOf, CRACK_MIN: CRACK_MIN, champOf: champOf, readChamps: readChamps, hallCap: hallCap, CHAMP_DAYS: CHAMP_DAYS, AWARD_KINDS: JSON.parse(JSON.stringify(AWARD_KINDS)), AWARDS: JSON.parse(JSON.stringify(AWARDS)) }; // Test hook for the automated checks; harmless in normal play. put: a result for a uid without a read. if (navigator.webdriver) window.__miles = { get tops() { return tops; }, get asked() { return topsAsked; }, get wanted() { return topsWanted; }, TOPS_KEY: TOPS_KEY, TOPS_TTL: TOPS_TTL, TOPS_KEEP: TOPS_KEEP, age: function (ms) { if (tops) tops.t -= ms; topsAsked = 0; }, clear: function () { tops = null; topsAsked = 0; topsWanted = false; try { localStorage.removeItem(TOPS_KEY); } catch (e) {} }, diff --git a/e63334287a3deaa3/tournament.js b/e63334287a3deaa3/tournament.js new file mode 100644 index 00000000..f90e0aff --- /dev/null +++ b/e63334287a3deaa3/tournament.js @@ -0,0 +1,870 @@ +/* + * Back Room tournaments: single-elimination brackets for the 1v1 online games, and featured events a Captain schedules. + * + * Loaded by the Back Room page (a ` right after `` (every Back Room game, the Back Room and phone pages, Hype Cycle Exchange, Boxed and the home page; not the admin page). `NameFilter.clean(name)` masks rude words at the start of a word after their first letter (`F***face`), the same way and with the same look-alike digits as `social.js`'s and `leaderboard.js`'s `mask`, and turns a name that hides one of the worst words some other way (`f.u.c.k`, `fuuuck`, `xfuckx`) into `Player`; clean names come back unchanged. On its own it cleans the name boxes the games use (`#name`, `#inName`, `#joinName`, `#hostName`, `#newName`, `#ptyName`, or any `input[data-name-filter]`, such as the Online name box) on load, on blur or change, and on any click, Enter or submit before the game's own handlers run, so Play, Join and Host always read a cleaned name; it doesn't change a name while it's being typed. `social.js`, `party.js`, `leaderboard.js` and `stats.js` also pass every name through it in their `cleanName`, so names other people already saved are masked where those panels show them. A new game gets it by using one of those ids for its name box (or `data-name-filter`) and adding the script tag. The word lists are stored in ROT13; the comment at the top of the file says how to add words, and which list also looks for words hidden inside names. -- `e63334287a3deaa3/social.js`: Online (Back Room). An Online panel under the Party panel lists everyone who has the Back Room open, by name plus a seat tag worked out from their uid (rows 1–40, seats A–F, like `Nico · 14C`), so two people with the same name can be told apart (seats can still repeat now and then; there are 240). Each person shows as Idle, in a party (and its size), or in a game. The name starts as the signed-in account's first name, else the saved party or game name, and can be changed in the panel (saved as `ol:name`). **One name everywhere:** `ol:name` is the player's name for the Online panel, the Party panel and the Leaderboards, in one order (`ol:name`, then the Google account's first name, then `party:name`, then a game's saved name) in `social.js`, `party.js` and `stats.js`. A rename in the Online box (or the Party panel's name box, which saves both keys) is written to the Online node and, while in a party, to the party node within half a second, so other people see it in about a second; `social.js` also sets just `n` on the player's leaderboard entry (`rooms/lb-all/players//n`, only if the entry exists, at most every 4 seconds; once after each page load too, so an entry left with an old name catches up), and fires `backroom:name` (`{uid, n, mine}`) on `document`, as it does when someone else's Online node changes name, so the Leaderboards rename that row at once without a new read. Other tabs follow through the `storage` event. Measured with two windows: before, a rename reached the other window's Online list in 0.8 s but never reached the Party panel (the party node kept `party:name`), and the leaderboard entry only changed the next time a game published (up to 60 s with a game open, never without one; the other window needed a Refresh after that); after, Online 0.9 s, Party 0.9 s, Leaderboards 1.2 s live and the entry in about 2 s. Game name boxes (`ss:name`, `shellcr-name` …) stay each game's own and don't rename you; party launches fill them with the one name. Hide me (`ol:hidden`) takes you off the list, and you can't chat while hidden. **Joinable games:** next to Hide me, **Let people join my games** (localStorage `ol:join`, `'0'` = off; on by default; saved with the account by account-nudge.js; also a "Let people join: On / Off" button in the Online drawer, for use over a game) lets anyone in the Back Room join the online game you're in, party or not. While it's on, you aren't hidden and you aren't in a party set to Private, your Online node carries `jg` (game key from party.js's `GAMES`), `jr` (room code after the game's prefix) and `jt` (when you got there, server time); they're removed when you leave the room or switch it off, and go stale with the node's heartbeat like everything else there. Single-player games and games not in party.js's `GAMES` are never advertised. **Finding the room:** the game runs in its own window (the home page's game layer, the phone page's frame, or party.js's layer on the Back Room page, where party games now open instead of replacing the page) and keeps its connection to itself (every game's `Net` sits inside the game's own function, so the page can't read it). So social.js lists the rooms the open game could be in: the room in the game's address (`#-`, which every party game sets when it joins a room by code), the room party.js launched it into, the code in its room box, and its Quick match rooms (`pub-1` to `pub-6`; Rumble Karts' `lobby` to `lobby-6`). It reads `rooms//players//ts` for each (one small read each) and takes the first that heard from you in the last 20 s; the found room is checked again every 4 s while the game is open, the others every 6 s until one matches. Not covered: Backrooms' Quick match (it pairs two players into a 1v1 room with no code), single-player modes, and a game opened in its own tab. Everyone in a joinable game gets a **Join** button on their row ("In Shell Crackers · Join", or **Queue** when the room is full and the game plays in rounds), from playingnow.js's checks (`window.BackRoomPlaying`); it opens the game in that room the same way Playing now does, and closes the drawer if it was open over a game. When someone's node starts advertising the room you're in after you got there, a small toast says "Ben joined your game" for 5 s (not for your own party, who arrive together; not for blocked or muted people). Tap someone to open their card: Request to chat, invite them to your party (one is created first if you're not in one; they get a Join / No thanks card and Join puts them in your party through party.js), or send them a room code (pick a game and a code; while you're in a game it fills in the room you're in). Private messages need a chat request first: the other person gets a toast and a card with Accept / Decline (and Block), and only once they accept can either side message the other; a message from someone who hasn't been accepted (an older client, say) is dropped, and that person's thread just says to request a chat or to accept theirs. A request runs out after 10 minutes if nobody answers, and then the requester can ask again (one open request per pair; at most one request per person every 10 minutes and ten in 10 minutes in all); a declined request shows "Declined" and can be repeated after the same 10 minutes. If both people request each other at once, that counts as a yes. Accepted pairs are kept in this browser (`ol:chats`, uid to time, at most 60) so you don't have to ask again every visit; End chat in the thread forgets the pair here and tells the other side, which forgets it too. Party invites and room codes aren't chat, so they don't need a request; the cabin chat is unchanged. **Parties:** people in the same party can message each other straight away, without the chat request (their card says so and has no Request to chat button); "the same party" comes from party.js's own member list (the `rooms/pt-` nodes, through `Party.members`), minus anyone on the current leader's kick list (`Party.out`), never from what someone writes in their Online node, so nobody can claim to be in your party. Outside a party, and once someone leaves or is removed, the request is needed again. Block, session block and mute work exactly as before (a blocked party member can't message you and is hidden). **Party chat:** a group chat for the party, opened from the Party chat button in the Online panel (shown while in a party), in the Party panel, in the people drawer, or in a game (see `gamechat.js`). Each message is sealed separately to every member who is in the party at that moment and online here (not to anyone you blocked), with the same ECDH + AES-GCM as private messages, and kept in your own node as `pc/` (the last 6 to each member, `{ i, t, b }`; inside: `{ f, to, k: 'g', c: party code, x: text }`); copies for people who leave the party are dropped, and the oldest copies are trimmed if the node would grow past 50,000 characters. The node also carries `av`, the player's edited avatar as a code (see `avatar.js`; absent if never edited), and `nt`, the colour of their name tile (`'t1:'` or `'t0'`, see `avatar.js`; absent if never chosen), which colours their card in the list and in the drawer. A browser only shows a party message that names its current party code and comes from someone on its current member list, so only the party can read the chat, and people who join later don't see earlier messages; everyone online can see that something was sent to whom and when, as with private messages. Blocked and muted people's party messages are hidden (like the cabin chat), the word filter and the shared rate limit (one message every 1.5 s, five in 10 s) apply, a party message from someone else shows a toast when no game is showing it, and party chat is never logged. Report in someone's private conversation also includes the last 20 party-chat messages (everyone's, marked `[party]`) when that person wrote in the party chat, and the confirm box says so. The party chat is kept for the tab in sessionStorage `ol:pchat` (`{ c: code, m: [...] }`, 80 messages) and starts empty in a new party. `window.BackRoomChat` (`state`, `recent`, `send`, `listen`, `seen`, `open`) lets the in-game chat inside a game's iframe read and send it through this page; it only hands out messages already checked, filtered and masked here. While a game is open, a Chat button next to Online in the game's top bar (shown while in a party with someone) opens the game's own chat box, or the Party chat drawer for a game without one. Deepword is in `GAMES` too (status "In Deepword", room codes), so its top bar gets these buttons. **Join party / Request to join:** when someone's party is Public (its leader's node carries `pp`, see party.js), the leader's row in the list has a Join party button ("Party full" at 8; a game's Join button takes its place while the party's game is joinable), the card of anyone in that party has Join party in place of Request to join, and their status reads "Public party of 3"; it joins through `Party.join(code, true)`, which refuses if the party has gone Private, is full, or its leader removed you in the last 10 minutes, and asks first if you'd be leaving a party of your own. Otherwise the card of someone in a party has Request to join, next to Invite to party. It sends a sealed `j` to that party's leader: to them if they lead it, otherwise to their leader when that person is online (the card says so and shows how it's going, with a button to open the leader's chat); if a `j` reaches someone who isn't the leader (their leader is offline, say), their browser answers `x` with `lead` and who the leader is, and the requester sees "Only the leader can accept — ask " with an Ask button when that leader is online. A leader with room gets a toast and a card with Let them in / Decline; Let them in sends `y` with the party code, and the requester gets a Join party button (toast and card) that joins through party.js, so a person who was kicked is still kept out by the party's own 10-minute rule; Decline sends `x`. A full party (8), someone who isn't the leader, or someone no longer in a party answers `x` straight away with the reason. One open request per party (per leader) at a time, 10 minutes to answer, a repeat only 10 minutes after a no, and the same ten-requests-in-10-minutes limit as chat requests; a `y` or `x` only counts when it answers a request this tab sent. Join-request state lives in the thread in sessionStorage (`jq`, `jx`, `jw`, `jc`, `jl`, `jln`, `jin`, `jnd`), like chat requests. Room invites only ever become the site's own invite links (`/#-`, Rumble Karts `/#`) built from a known game and a checked code, never a link someone typed, and opening one goes straight into that game's room. The cabin chat is one public chat for everyone online; it shows the last 30 minutes from people who are still here. Each cabin message is also saved, sealed, to Firestore `chatlog` for the admin page (see below). A Privacy link to `/privacy.html` sits at the bottom of the panel. Mute (`ol:mute`) hides someone's cabin-chat messages and silences their notifications; Block (`ol:block`) also hides them from the list and hides their messages, requests and invites; both are saved only in this browser. Block for this session does the same as Block but is kept in sessionStorage (`ol:sblock`), so it's forgotten when the tab closes; the Blocked section of the people view lists both, with "(this session)" on the latter, and Unblock clears either. While a game is open in the page's game layer (home page, phone page, or a party launch), an Online button in the game's top bar opens the same list, chats and invites, and the status shows "In "; a game opened by its card on the Back Room page opened directly leaves the page, so that person goes offline until they come back. Loaded like party.js: a ``, lists its actions in `Keybinds.create({game, actions: [{id, label, keys: ['KeyW', 'ArrowUp']}]})` (keys are `e.code` names, so they're physical keys on any layout; mouse buttons are `Mouse0`/`Mouse1`/`Mouse2` in games that pass `mouse: true`), checks input with `KB.is(action, e.code)` and `KB.held(action, keys)` instead of comparing key codes, and opens the panel from a Controls button with `KB.open()`. Changed keys are saved only in the player's browser, under localStorage `keybinds:` as `{v: 1, b: {action: [codes]}}` (only the actions that differ from the defaults; Reset to defaults removes the entry), and never go to Firebase. Esc is never rebindable. Elements with `data-kb="action"` show the current keys and update themselves. The panel takes each game's look from `--kb-*` CSS variables and the game's own button classes; the comment at the top of the file lists the options. To add it to a game, do the same, and keep text inputs (names, room codes, chat) returning before any key lookup. Touch controls don't go through key codes: each game's touch buttons feed its input directly (in Shell Crackers, Quarry and Backrooms they hold actions by id in `tAct`, which the game checks alongside `KB.held`), so they keep working whatever keys are bound, and the Change keys / Controls buttons are hidden in the touch layout (`body.touch`). - `e63334287a3deaa3/news.js`: What's new (Back Room). A slim strip under the page header, above the Party panel, on the Back Room page and the phone page (one ``) and calls `BackRoomElo.report({ id, won, opp: [{ u: uid, s }, { bot: 1, s }] })` once where its online match or round ends (search each game for `BackRoomElo`): `opp` is everyone you played against, not teammates, and `s` is your result against that one opponent (1 beat them or your team won, 0 lost, 0.5 drew), so team games give every opponent the same `s`, races and free-for-alls go by finishing place, Driftfall counts everyone already out as beaten and everyone still alive as a loss, Tumble Trials rates once per show (when you go out or the final ends), and in Chromaflage a seeker beats each hider that was found while a hider beats the seekers by staying hidden. The change is the usual Elo one (K 36 for the first 10 matches, then 24), averaged over the opponents and multiplied by the number of real opponents (×1 for one, 25% more for each extra, at most ×3); bots count as rated 1000, and a match with no real opponent isn't rated, so practice and bot-only rooms never move a rating. Everyone starts at 1000 and stays in 100–3000. `id` stops a match being rated twice (results screens can be drawn more than once). Storage: this browser's `elo:` (`{ r, g, wn, pk, uid }`) and the Realtime Database at `rooms/elo-/players/` (`n, c, x, z, h, ts` as the shared rules need, plus `r, g, wn, pk`), written by the player's own browser; on load the account's saved rating wins, and opponents' ratings are read from their nodes when a match is reported. So, like every Back Room stat, it is self-reported and not cheat-proof. It never signs in or makes a Firebase app itself (it uses the game's), and every call swallows its own errors, so it can't stop a game. After a rated match a small pill at the top shows the new rating and the change. stats.js reads `elo:` into the game's `elo` stat (the list of folders is next to `READ`), and leaderboard.js has an Elo board first for each of these games (for Slipstream, after its lap and record boards); as with Shell Crackers, the board keeps the best value it has seen, so it shows a player's highest rating. To rate another game: add the script tag and one `report` call, add its folder to the list in stats.js, and add the Elo row to its entry in leaderboard.js. +- `e63334287a3deaa3/elo.js`: ranked ratings (Elo), one per game, for the online games that end with a winner: Boostball, Rumble Karts, Backrooms 1v1–4v4, Driftfall, Slipstream, Turbo Trail, Tumble Trials, Chromaflage, Odd One Out, Puffer Party, Deepword's Brawl and Lokop. Shell Crackers keeps its own older rating (`shellcr-rank`, `rooms/sc-ratings`) and doesn't load this file; the maths here is the same as its. Each game loads it next to stats.js (``) and calls `BackRoomElo.report({ id, won, opp: [{ u: uid, s }, { bot: 1, s }] })` once where its online match or round ends (search each game for `BackRoomElo`): `opp` is everyone you played against, not teammates, and `s` is your result against that one opponent (1 beat them or your team won, 0 lost, 0.5 drew), so team games give every opponent the same `s`, races and free-for-alls go by finishing place, Driftfall counts everyone already out as beaten and everyone still alive as a loss, Tumble Trials rates once per show (when you go out or the final ends), and in Chromaflage a seeker beats each hider that was found while a hider beats the seekers by staying hidden. The change is the usual Elo one (K 36 for the first 10 matches, then 24), averaged over the opponents and multiplied by the number of real opponents (×1 for one, 25% more for each extra, at most ×3); bots count as rated 1000, and a match with no real opponent isn't rated, so practice and bot-only rooms never move a rating. Everyone starts at 1000 and stays in 100–3000. `id` stops a match being rated twice (results screens can be drawn more than once). Storage: this browser's `elo:` (`{ r, g, wn, pk, uid }`) and the Realtime Database at `rooms/elo-/players/` (`n, c, x, z, h, ts` as the shared rules need, plus `r, g, wn, pk`), written by the player's own browser; on load the account's saved rating wins, and opponents' ratings are read from their nodes when a match is reported. So, like every Back Room stat, it is self-reported and not cheat-proof. It never signs in or makes a Firebase app itself (it uses the game's), and every call swallows its own errors, so it can't stop a game. After a rated match a small pill at the top shows the new rating and the change. stats.js reads `elo:` into the game's `elo` stat (the list of folders is next to `READ`), and leaderboard.js has an Elo board first for each of these games (for Slipstream, after its lap and record boards); as with Shell Crackers, the board keeps the best value it has seen, so it shows a player's highest rating. To rate another game: add the script tag and one `report` call, add its folder to the list in stats.js, and add the Elo row to its entry in leaderboard.js. `report()` also posts `{ backroomMatch: 1, game, room, won }` to the page around the game (same origin only) for tournament.js; nothing else listens. - `e63334287a3deaa3/netsmooth.js`: smooth movement for other players in the online games. Updates over school Wi-Fi and Firebase arrive late and in bursts, so a game that moves someone to their newest update makes them lurch and stall, and one that shows them a fixed time in the past freezes them whenever an update is later than that. Each remote player gets a `NetSmooth.lag()`, which measures how late their updates really arrive and shows them just far enough in the past that the next one is almost always already here (about a tenth of a second on good Wi-Fi, more on bad, never more than 0.45 s), easing that delay so the timeline never jumps; `NetSmooth.sample()` draws them between the two updates around that moment and carries them on for up to 0.3 s if an update is late. Used by Shell Crackers, Backrooms 1v1–4v4, Hail Mary, Coil, Quarry, Chromaflage, Odd One Out, Spire, Turbo Trail, Escapade, Updraft, Driftfall and Blockstorm. Kartwheel, Slipstream, Boostball, Rumble Karts and Tumble Trials keep their own approach: cars, karts and racers are projected forward to the present from their speed, which matters more there than perfectly even motion. Settings were tuned with a simulation of good, school and bad Wi-Fi: compared with chasing the newest update, other players stall about a fifth as often and almost never lurch, for roughly a tenth of a second more delay. - `e63334287a3deaa3/autores.js`: automatic resolution for the 3D games, so they stay smooth on school laptops. Every three.js game except Quarry (which has its own version) loads it right after `three.min.js`. It watches the frame rate, and when frames drop below about 45 a second it makes every three.js renderer on the page draw at a lower resolution, a tenth at a time, down to half; when frames stay smooth it steps back up (more slowly towards a resolution that was too slow before, so it doesn't keep flipping). It multiplies whatever `setPixelRatio` the game asks for, so a game's own graphics setting still counts. The scale each game settles on is remembered in the browser (`localStorage` key `autores:`), so the next visit starts there. No game code calls it; it wraps `THREE.WebGLRenderer`. `AutoRes.scale` shows the current scale and `AutoRes.off()` turns it off for a visit. - `e63334287a3deaa3/account-nudge.js`: the sign-in nudge and account save (Back Room). Loaded on the Back Room page and the phone page (one `