@ywkrlerche/richardwho 1.0.53 → 1.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/krillionwho.js CHANGED
@@ -9,15 +9,16 @@
9
9
  "use strict";
10
10
 
11
11
  const ROUND_MS = 25000, PREROLL = 3, ROUNDS = 7, MIN_POOL = 8, DAILY_POOL = 20, PARTY_POOL = 12;
12
- const FUSE = 25000, FLOOR = 8000, BREAK = 3500, MAX_PLAYERS = 8, ROOM_LIFE = 3 * 3600e3;
13
- const DAILY_KEY = "rug-krillionwho", STATS_KEY = "rug-krillionwho-stats", NAME_KEY = "rug-chat-name", PACK_KEY = "rug-krillionwho-pack";
12
+ const FUSE = 25000, FLOOR = 8000, BREAK = 3500, PUFF_AT = 9000, MAX_PLAYERS = 8, ROOM_LIFE = 3 * 3600e3;
13
+ const DAILY_KEY = "rug-krillionwho", STATS_KEY = "rug-krillionwho-stats", NAME_KEY = "rug-chat-name", KW_NAME_KEY = "rug-krillionwho-name", PACK_KEY = "rug-krillionwho-pack";
14
14
  const ROOM_KEY = "rug-krillionwho-room", MY_ROOMS_KEY = "rug-krillionwho-rooms", SOUND_KEY = "rug-krillionwho-sound";
15
15
  const ROOM_LETTERS = "ABCDEFGHJKMNPQRSTUVWXYZ23456789"; // no I, L, O, 0 or 1: they get misread
16
16
  const MAX_DEPTH = 7000, S = 1.2; // the ocean is 7,000 m deep, drawn at 1.2 px per meter
17
17
  const LAUNCH = new Date(2026, 11, 2); // Dive #1
18
18
  const ZONES = [[0, "Sunlight Zone"], [200, "Twilight Zone"], [1000, "Midnight Zone"], [4000, "The Abyss"], [6000, "The Trench"]];
19
- const TIERS = { 0: ["Missed", "šŸ’Ø"], 10: ["Seaweed", "🌿"], 20: ["Minnow", "🐟"], 30: ["Reef fish", "🐠"], 40: ["Sea turtle", "🐢"], 50: ["Dolphin", "🐬"],
20
- 60: ["Shark", "🦈"], 70: ["Octopus", "šŸ™"], 80: ["Giant squid", "šŸ¦‘"], 90: ["Anglerfish", "šŸ®"], 100: ["Sea monster", "šŸ‰"] };
19
+ // How rare an answer was, from the obvious ones floating at the top to the deepest cuts
20
+ const TIERS = { 0: ["Missed", "šŸ’Ø"], 10: ["Plankton", "🦐"], 20: ["Common", "🐚"], 30: ["Schooler", "🐟"], 40: ["Uncommon", "🐠"], 50: ["Rare", "🐢"],
21
+ 60: ["Very rare", "🐬"], 70: ["Deep cut", "🦈"], 80: ["Ultra rare", "šŸ™"], 90: ["Abyssal", "šŸ¦‘"], 100: ["One of a kind", "šŸ‰"] };
21
22
  const BOT_NAMES = ["Bubbles", "Finn", "Coral", "Kelp", "Barnacle", "Pearl", "Captain Gill"];
22
23
 
23
24
  let ctx = null, root = null, BANK = null;
@@ -184,7 +185,7 @@
184
185
  while (n < STEPS.length && at >= STEPS[n]) n++;
185
186
  return (n + 1) * 10;
186
187
  }
187
- // From what people here have said: under 0.3% of answers is a sea monster
188
+ // From what people here have said: under 0.3% of answers is one of a kind
188
189
  const CUTS = [0.2, 0.12, 0.08, 0.05, 0.035, 0.022, 0.013, 0.007, 0.003];
189
190
  function sharePts(share) { for (let n = 0; n < CUTS.length; n++) if (share >= CUTS[n]) return (n + 1) * 10; return 100; }
190
191
  // The more answers a prompt has collected, the more they count (fully from 70 answers on)
@@ -295,6 +296,7 @@
295
296
  else if (name === "pass") n(480, 0, 0.12, { vol: 0.07, to: 1000, type: "triangle" });
296
297
  else if (name === "fuse") n(arg ? 1500 : 1050, 0, 0.03, { vol: 0.035 });
297
298
  else if (name === "pop") { this.noise(0, 0.55, { vol: 0.45, from: 3200, to: 200, q: 0.6 }); n(160, 0, 0.32, { type: "sine", vol: 0.28, to: 45 }); }
299
+ else if (name === "puff") { this.noise(0, 0.3, { vol: 0.16, from: 380, to: 2400, q: 1.4 }); n(200, 0, 0.28, { type: "sine", vol: 0.12, to: 640 }); } // swelling up
298
300
  else if (name === "win") [523, 659, 784, 1047, 784, 1047, 1319].forEach((f, i) => n(f, i * 0.11, 0.2, { vol: 0.08 }));
299
301
  else if (name === "lose") [392, 370, 349, 311].forEach((f, i) => n(f, i * 0.26, 0.3, { vol: 0.07, type: "sawtooth" }));
300
302
  else if (name === "done") [392, 523, 659, 784].forEach((f, i) => n(f, i * 0.12, 0.22, { vol: 0.07, type: "triangle" }));
@@ -304,14 +306,16 @@
304
306
  };
305
307
 
306
308
  // ---------- Pixel art ----------
307
- // Rows of letters, one per pixel ("." is empty), turned into an SVG; runs of one color become one rectangle
309
+ // Rows of letters, one per pixel ("." is empty), turned into an SVG; runs of one color become one rectangle.
310
+ // A color can name a class after it ("#fcd34d pY") so the CSS can recolor those pixels.
308
311
  function sprite(rows, colors, cls) {
309
312
  let rects = "";
310
313
  rows.forEach((row, y) => {
311
314
  for (let x = 0; x < row.length;) {
312
315
  let w = 1;
313
316
  while (x + w < row.length && row[x + w] === row[x]) w++;
314
- if (colors[row[x]]) rects += `<rect x="${x}" y="${y}" width="${w}" height="1" fill="${colors[row[x]]}"/>`;
317
+ const [fill, k] = (colors[row[x]] || "").split(" ");
318
+ if (fill) rects += `<rect x="${x}" y="${y}" width="${w}" height="1" fill="${fill}"${k ? ` class="${k}"` : ""}/>`;
315
319
  x += w;
316
320
  }
317
321
  });
@@ -399,14 +403,44 @@
399
403
  "GBBBBBBBBBBBBG",
400
404
  "GGGGGGGGGGGGGG",
401
405
  ], { G: "#f59e0b", B: "#78350f", y: "#fde68a" }, "kw-chest-art");
402
- const SPIKES = Array.from({ length: 14 }, (_, k) => {
403
- const a = (k / 14) * Math.PI * 2, b = a + 0.16, c = a - 0.16, P = (r, t) => `${(60 + r * Math.cos(t)).toFixed(1)},${(62 + r * Math.sin(t)).toFixed(1)}`;
404
- return `<polygon points="${P(35, b)} ${P(50, a)} ${P(35, c)}"/>`;
405
- }).join("");
406
- const PUFFER = `<svg class="kw-puff-art" viewBox="0 0 120 124" aria-hidden="true"><g class="kw-spikes">${SPIKES}</g>` +
407
- `<path d="M95 62l20-15v30z" class="kw-fin"/><circle cx="60" cy="62" r="38" class="kw-body"/><ellipse cx="60" cy="80" rx="25" ry="15" fill="#fff" opacity=".35"/>` +
408
- `<circle cx="46" cy="52" r="8" fill="#fff"/><circle cx="48" cy="53" r="4" fill="#111827"/><circle cx="74" cy="52" r="8" fill="#fff"/><circle cx="76" cy="53" r="4" fill="#111827"/>` +
409
- `<ellipse cx="61" cy="71" rx="5.5" ry="4.5" fill="#9a3412"/><path d="M33 34q-9-10-2-17q8 5 10 15z" class="kw-fin"/></svg>`;
406
+ // The pufferfish: a calm fish most of the time, then a spiky ball when its time runs low. Both sit on one 34Ɨ28 grid so
407
+ // the pixels line up when it puffs up, and the p… classes let the CSS turn it red as it heats up.
408
+ const PUFF_COLORS = { L: "#fff1a8 pL", Y: "#fcd34d pY", D: "#f59e0b pD", R: "#b45309 pR", W: "#fff7e6 pW", w: "#f2d7a6 pw", S: "#a16207 pS",
409
+ F: "#f97316 pF", f: "#fdba74 pf", T: "#c2410c pT", t: "#fb923c pt", m: "#fb923c pm", E: "#fff", h: "#fff", P: "#0f172a", O: "#5b2a0a", M: "#7c2d12", K: "#fb7185" };
410
+ const PUFFER = sprite([
411
+ "............t...t.................", "........t...T...T...t.............", "........T...TT.TT...T.............", "........TT.DDDDDDD.TT.............",
412
+ "....t....DDYYYYYYYDD....t.........", ".....TTDDYYYYYSYYYYYRRTT..........", ".....TDOOLLYYYYYYYSYYDRT..........", "..t..DOEEEOYSYYYYYYYYDDR..........",
413
+ "...TTOEEEEEOYYYYSYYYYSDR.....FF...", "...TDOPPPEEOYYYYYYYYYDDDR...FFF...", "....DOPhPEEOYYYYYYYYYDDDR..FFFfF..", "....DOPPPEEOYYYSYYYSYDDSR.FFfffF..",
414
+ "...DYYOEEEOYYYYYYYYYDDDDRRfffffF..", ".mmDYYYOOOYYYYYYYYYDDDDDRRFFFFFFF.", "mMMDYYYYYYYYYYYFYYYDDDSDRRffffffF.", "mMMwWWWWKKYYYYfFFYDDDDDRRRFFfffF..",
415
+ ".mm.wWWWWWWWWWWWWDDDDDDRR.FFFFFF..", "....wWWWWWWWWWWWWWWwwwwww..FfFFF..", "...TwWWWWWWWWWWWWWwwwwwww...FFF...", "...TTwWWWWWWWWWWWwwwwwww.....FF...",
416
+ "..t..wWWWWWWWWWwwwwwwwww..........", ".....TRWWWWWWwwwwwwwwwRT..........", ".....TTRRwwwwwwwwwwwRRTT..........", "....t....RRwwwwwwwRR....t.........",
417
+ "........TT.RRRRRRR.TT.............", "........T...TT.TT...T.............", "........t...T...T...t.............", "............t...t.................",
418
+ ], PUFF_COLORS, "kw-puff-art kw-puff-ball");
419
+ const PUFF_CALM = sprite([...Array(5).fill(".".repeat(34)),
420
+ ".................FF...............", "...............FFFf...............", "..........DDDDD.Fff...............", ".......DDSYYYYYSDRf...............",
421
+ ".....DDLLYYSYYYYYYRR..........FF..", "....DOOOLYYYYYYYYYSDR........FFFF.", "...DOEEEOYYYYSYYYYYDDR......FFffF.", "..DYPPhEOYYYYYYYSYYDSDRR...FFfffFF",
422
+ "..DYPPPEOYYYYYYYYYDDDDRRRRFffFFFFF", "..DYYOOOYYYYYYYYYDDDDRRRRRfffffffF", "mMwWWWWWWWWWYYYYDDDDDRRRRRFFFffffF", "m.wWWWWKWWWfFFFWWwwwwwww...FfFFFFF",
423
+ "...wWWWWWWWfFfFWwwwwww......FffFF.", "....wWWWWWWWfFwwwwwww........FffF.", ".....RRWWWwwwwwwwwRR..........FF..", ".......RRRwwwwwRRRF...............",
424
+ "..........RRRRR.FFF...............", "...............FFFF...............", ".................FF...............", ...Array(4).fill(".".repeat(34)),
425
+ ], PUFF_COLORS, "kw-puff-art kw-puff-calm");
426
+ // Puffer Party players: everyone at the table gets their own sea creature, floating in a bubble
427
+ const CRITTERS = [
428
+ sprite([".CC........CC.", "CcCC......CCcC", "CccC......CccC", ".CC..e..e..CC.", "..C..R..R..C..", "..CRRRRRRRRC..", "..RRRRRRRRRR..",
429
+ ".RRrrrrrrrrRR.", ".RRRRRRRRRRRR.", "..RRRRRRRRRR..", ".R.R.R..R.R.R.", "R.R.R....R.R.R"], { C: "#dc2626", c: "#fecaca", R: "#ef4444", r: "#fca5a5", e: "#1f0a14" }, "kw-critter"),
430
+ sprite([".....PPPP.....", "...PPPPPPPP...", "..PPpPPPPPPP..", "..PpPPPPPPPP..", "..PwePPPPweP..", "..PPPPPPPPPP..", "..PPPPPPPPPP..",
431
+ "...PPPPPPPP...", "..PP.PPPP.PP..", ".PP..P..P..PP.", ".P..PP..PP..P.", "P...P....P...P"], { P: "#a855f7", p: "#d8b4fe", w: "#fff", e: "#1e1b4b" }, "kw-critter"),
432
+ sprite(["....JJJJJJ....", "..JJjjjjjjJJ..", ".JjjjjjjjjjjJ.", ".JjwejjjjwejJ.", "JjjjjjjjjjjjjJ", "JJJJJJJJJJJJJJ",
433
+ ".t.t.t..t.t.t.", "..t.t..t..t.t.", ".t...t..t..t..", "..t....t....t."], { J: "#ec4899", j: "#f9a8d4", w: "#fff", e: "#500724", t: "#f472b6" }, "kw-critter"),
434
+ sprite(["......YYY.....", ".....YYYYY....", "YYYYYYeYYY....", ".....YYYYY....", "......YYYYy...", ".....YYYYYyy..", ".....yYYYYYy..",
435
+ "......YYYYYy..", ".......YYYY...", "........YYY...", ".........YY...", ".......Y..Y...", "........YY...."], { Y: "#facc15", y: "#fde68a", e: "#422006" }, "kw-critter"),
436
+ sprite(["....SSSSS.....", "..SSsSSsSS.KK.", ".SSsSSsSSsSKKe", ".SsSSsSSsSSKKK", "GGGGGGGGGGGG..", ".KK......KK...", "KK........KK.."],
437
+ { S: "#15803d", s: "#4ade80", G: "#bef264", K: "#86efac", e: "#052e16" }, "kw-critter"),
438
+ sprite([".....OOOOO....", ".O..OOWOOWOO..", ".OOOOOWOOWOeO.", ".OOOOOWOOWOOOO", ".O..OOWOOWOO..", ".....OOOOO...."], { O: "#f97316", W: "#fff", e: "#111827" }, "kw-critter"),
439
+ sprite([".........w.w..", "..........w...", ".....BBBBBB...", "B..BBBBBBBBBB.", "BBBBBBBBBBBeB.", ".BBBBbbbbbbbBB", "..BBBbbbbbbbB.", ".....BBBBBB..."],
440
+ { B: "#3b82f6", b: "#bfdbfe", w: "#93c5fd", e: "#0f172a" }, "kw-critter"),
441
+ sprite(["......D.......", ".....DD.......", "D...DDDDDDD...", "DD.DDDDDDDDDD.", ".DDDDDDDDDDeDD", "DD.DLLLLLLLLL.", "D....LLLLLL..."],
442
+ { D: "#64748b", L: "#e2e8f0", e: "#0f172a" }, "kw-critter"),
443
+ ];
410
444
 
411
445
  // ---------- The scene: one tall ocean, and a camera that moves down it ----------
412
446
  const sc = { H: 0, sky: 0, at: null };
@@ -610,10 +644,10 @@
610
644
  const name = String(raw || "").replace(/\s+/g, " ").trim();
611
645
  if (!name) return { error: "Pick a name first." };
612
646
  if ([...name].length > 16) return { error: "Names can be up to 16 characters." };
613
- if (/^ *richard *$/i.test(name)) return { error: "That name is taken." };
614
647
  return { name: ctx.maskSlurs(name) };
615
648
  }
616
- function myName() { return cleanName(ctx.store.get(NAME_KEY, "")).name || ""; }
649
+ // Your diver name is your own (any name, Richard included); it starts out as your chat name until you pick one here
650
+ function myName() { return cleanName(ctx.store.get(KW_NAME_KEY, "") || ctx.store.get(NAME_KEY, "")).name || ""; }
617
651
  function askName(then, why) {
618
652
  const have = myName();
619
653
  if (have) return then(have);
@@ -704,7 +738,7 @@
704
738
  }
705
739
  function menuSheet() {
706
740
  openSheet(`<p class="kw-sheet-title">MENU</p>
707
- <form class="kw-inline" data-form="rename" autocomplete="off"><input id="kw-name-in" maxlength="16" spellcheck="false" value="${esc(ctx.store.get(NAME_KEY, ""))}" placeholder="your diver name" aria-label="Your name"><button class="kw-btn ghost" type="submit">SAVE NAME</button></form>
741
+ <form class="kw-inline" data-form="rename" autocomplete="off"><input id="kw-name-in" maxlength="16" spellcheck="false" value="${esc(myName())}" placeholder="your diver name" aria-label="Your name"><button class="kw-btn ghost" type="submit">SAVE NAME</button></form>
708
742
  <p class="kw-note" id="kw-sheet-note" aria-live="polite"></p>
709
743
  <div class="kw-two"><button class="kw-btn ghost" type="button" data-act="howto">HOW TO PLAY</button><button class="kw-btn ghost" type="button" data-act="board">LEADERBOARD</button></div>
710
744
  <div class="kw-two"><button class="kw-btn ghost" type="button" data-act="sound">SOUND: ${sfx.on ? "ON" : "OFF"}</button><button class="kw-btn ghost" type="button" data-act="surface">BACK TO THE SURFACE</button></div>`);
@@ -760,11 +794,27 @@
760
794
  for (let i = 0; i < text.length; i++) { h = Math.imul(h ^ text.charCodeAt(i), 3432918353); h = (h << 13) | (h >>> 19); }
761
795
  return () => { h = Math.imul(h ^ (h >>> 16), 2246822507); h = Math.imul(h ^ (h >>> 13), 3266489909); h ^= h >>> 16; return (h >>> 0) / 4294967296; };
762
796
  }
763
- function pickDaily(date) { // the same 7 prompts for everyone: one per category, at most 2 per pack
764
- const rnd = seeded("krillionwho " + date);
765
- const pool = BANK.prompts.filter((p) => p.pool.length >= DAILY_POOL).sort((a, b) => (a.key < b.key ? -1 : 1));
766
- for (let i = pool.length - 1; i > 0; i--) { const j = Math.floor(rnd() * (i + 1)); [pool[i], pool[j]] = [pool[j], pool[i]]; }
767
- return spread(pool);
797
+ // The same 7 prompts for everyone: one per category, at most 2 per pack. Adding answers or prompts must never change a day
798
+ // people may already have played, so the first days (through FIRST_DAYS_END) draw from the prompts that existed then
799
+ // (FIRST_DAYS), exactly as the version they played on did. From then on every category gets its own repeatable score for
800
+ // the day, so each is as likely as any other however many prompts it has, and shows its own best-scoring prompt: a new
801
+ // prompt only takes over where it outscores its category's old ones, and a category with `since` (a date) waits until that day.
802
+ const FIRST_DAYS_END = "2026-12-05", FIRST_DAYS = new Set("animal,animal~bird,animal~fish,animal~ins,animal~mam,animal~rep,animal~sea,animal~starts-b,animal~starts-c,animal~starts-g,animal~starts-m,animal~starts-p,animal~starts-s,candy,capital,capital~af,capital~as,capital~eu,capital~eun,capital~na,capital~starts-b,car,cheese,color,color~starts-c,console,constellation,constellation~starts-c,country,country~af,country~as,country~eu,country~eun,country~ll,country~na,country~starts-s,dc,dinosaur,dinosaur~starts-s,disney,disney~pixar,disney~wdas,dog,dog~starts-b,dog~starts-c,dog~starts-s,element,element~rad,epl,fastfood,fruit,fruit~berry,fruit~cit,fruit~trop,game,game~board,game~card,game~starts-c,game~starts-s,greekgod,icecream,instrument,instrument~perc,instrument~starts-s,instrument~string,instrument~wind,mario,marvel,marvel~starts-m,marvel~starts-s,mcu,minecraft,mlb,nba,nfl,nhl,pasta,pizza,pokemon,pokemon~g1,pokemon~g2,pokemon~starts-m,pokemon~starts-p,pokemon~starts-s,potter,president,shakespeare,simpsons,smash,spongebob,sport,sport~oly,sport~starts-s,starwars,state,state-capital,vegetable,vegetable~root".split(","));
803
+ function pickDaily(date) {
804
+ const big = BANK.prompts.filter((p) => p.pool.length >= DAILY_POOL);
805
+ if (date <= FIRST_DAYS_END) {
806
+ const rnd = seeded("krillionwho " + date);
807
+ const pool = big.filter((p) => FIRST_DAYS.has(p.key)).sort((a, b) => (a.key < b.key ? -1 : 1));
808
+ for (let i = pool.length - 1; i > 0; i--) { const j = Math.floor(rnd() * (i + 1)); [pool[i], pool[j]] = [pool[j], pool[i]]; }
809
+ return spread(pool);
810
+ }
811
+ const score = (text) => seeded(`krillionwho ${date} ${text}`)(), best = new Map();
812
+ for (const p of big) {
813
+ if (p.cat.since && p.cat.since > date) continue;
814
+ const s = score(p.key), had = best.get(p.cat.id);
815
+ if (!had || s < had[0]) best.set(p.cat.id, [s, p]);
816
+ }
817
+ return spread([...best.values()].map(([, p]) => [score(`category ${p.cat.id}`), p]).sort((a, b) => a[0] - b[0]).map(([, p]) => p));
768
818
  }
769
819
  function spread(pool) {
770
820
  const out = [], cats = new Set(), packs = {};
@@ -775,12 +825,17 @@
775
825
  }
776
826
  return out;
777
827
  }
828
+ // Free play: each category as likely as any other however many prompts it has. Everything takes one prompt per category
829
+ // (at most 2 per pack); one pack takes each of its categories once, then more of their prompts if it has fewer than 7.
778
830
  function pickFree(pack) {
779
- const pool = BANK.prompts.filter((p) => p.pool.length >= PARTY_POOL && (pack === "all" || p.cat.pack === pack));
780
- for (let i = pool.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [pool[i], pool[j]] = [pool[j], pool[i]]; }
781
- if (pack === "all") return spread(pool);
782
- const out = [], cats = new Set();
783
- for (const p of pool) { if (!cats.has(p.cat.id) || pool.length < 30) { out.push(p.key); cats.add(p.cat.id); } if (out.length === ROUNDS) break; }
831
+ const shuffle = (a) => { for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; };
832
+ const pool = shuffle(BANK.prompts.filter((p) => p.pool.length >= PARTY_POOL && (pack === "all" || p.cat.pack === pack)));
833
+ const first = new Map();
834
+ for (const p of pool) if (!first.has(p.cat.id)) first.set(p.cat.id, p);
835
+ const picks = shuffle([...first.values()]);
836
+ if (pack === "all") return spread(picks);
837
+ const out = picks.slice(0, ROUNDS).map((p) => p.key);
838
+ for (const p of pool) { if (out.length >= ROUNDS) break; if (!out.includes(p.key)) out.push(p.key); }
784
839
  return out;
785
840
  }
786
841
  const promptFor = (key) => BANK.byKey.get(key) || BANK.prompts.find((p) => p.pool.length >= DAILY_POOL && p.cat.id === key.split("~")[0]) || BANK.prompts[0];
@@ -967,7 +1022,7 @@
967
1022
  const reveal = $("kw-reveal");
968
1023
  reveal.hidden = false;
969
1024
  reveal.innerHTML = (res.ok
970
- ? `<p class="kw-said">you said <b>${esc(res.entry.name)}</b>${res.entry.of ? ` <span class="kw-muted">(${esc(res.entry.of)})</span>` : ""} Ā· <span class="t${pts} kw-tierword">${emoji} ${tier.toLowerCase()}</span> Ā· ${fmtM(pts * 10)} deeper</p>` +
1025
+ ? `<p class="kw-said">you said <b class="kw-tc t${pts}">${esc(res.entry.name)}</b>${res.entry.of ? ` <span class="kw-muted">(${esc(res.entry.of)})</span>` : ""} Ā· <span class="t${pts} kw-tierword">${emoji} ${tier.toLowerCase()}</span> Ā· ${fmtM(pts * 10)} deeper</p>` +
971
1026
  (share !== null ? `<p class="kw-stat">${share < 0.01 ? "under 1%" : `${Math.round(share * 100)}%`} of divers here said that${pts >= 100 ? " Ā· one of a kind!" : ""}</p>` : pts >= 100 ? `<p class="kw-stat">one of a kind!</p>` : "")
972
1027
  : `<p class="kw-said miss">šŸ’Ø ${esc(whyText(res, raw, p))}</p>`) +
973
1028
  `<p class="kw-common">most said: ${topNames(p, counts).map(esc).join(" Ā· ")}</p>` +
@@ -1183,7 +1238,7 @@
1183
1238
  };
1184
1239
 
1185
1240
  const pp = { mode: null, code: null, me: null, room: null, ref: null, tick: 0, busy: false, plan: null, level: 1, bots: 3,
1186
- shownPop: 0, lastPass: 0, lastFuse: 0, listSig: "", screen: null, close: null, connected: null, overSeen: false };
1241
+ shownPop: 0, lastPass: 0, lastFuse: 0, listSig: "", screen: null, close: null, connected: null, overSeen: false, goneUntil: 0, hit: null };
1187
1242
  const ppNow = () => (pp.mode === "online" ? now() : Date.now());
1188
1243
  const personName = (id) => (pp.room && pp.room.players[id] ? ctx.maskSlurs(pp.room.players[id].name) : "Someone");
1189
1244
  function answerName(promptKey, key) {
@@ -1434,23 +1489,29 @@
1434
1489
  if (!box) return;
1435
1490
  if (pp.screen !== room.state) {
1436
1491
  pp.screen = room.state;
1492
+ box.dataset.state = room.state;
1437
1493
  box.innerHTML = ppShell(room.state);
1438
- if (room.state === "over" && !pp.overSeen) { pp.overSeen = true; sfx.play(room.winner === pp.me ? "win" : "lose"); }
1439
1494
  if (room.state !== "over") pp.overSeen = false;
1440
1495
  }
1441
1496
  const mine = room.host === pp.me, ids = PP.seats(room);
1442
- const head = $("kw-pp-head");
1497
+ const head = $("kw-pp-head"), lobby = room.state === "lobby";
1443
1498
  if (head) head.innerHTML = pp.mode === "bots" ? `<span class="kw-label">PUFFER PARTY Ā· VS THE COMPUTER</span>`
1444
- : `<span class="kw-label">PUFFER PARTY Ā· ROOM</span><button class="kw-code" type="button" data-act="pp-copy" title="Copy the code">${esc(pp.code)}</button>${room.pub ? `<span class="kw-tag">PUBLIC</span>` : ""}`;
1445
- const players = $("kw-pp-players");
1446
- if (players) players.innerHTML = ids.map((id) => {
1447
- const p = room.players[id], hold = room.round && room.round.holder === id;
1448
- const hearts = room.state === "lobby" ? "" : `<span class="kw-hearts">${"♄".repeat(p.lives)}<i>${"♄".repeat(Math.max(0, room.lives - p.lives))}</i></span>`;
1449
- return `<li class="${hold ? "hold" : ""} ${p.lives <= 0 && room.state !== "lobby" ? "out" : ""} ${p.on === false ? "off" : ""}">` +
1450
- `<span class="kw-pn">${id === room.host ? "šŸ‘‘ " : ""}${esc(ctx.maskSlurs(p.name))}${id === pp.me ? " <small>(you)</small>" : ""}</span>${hearts}` +
1451
- `${hold ? `<span class="kw-has">${PUFFER}</span>` : ""}</li>`;
1452
- }).join("");
1453
- if (room.state === "lobby") {
1499
+ : `<span class="kw-label">PUFFER PARTY Ā· ROOM</span>${lobby ? "" : `<button class="kw-code" type="button" data-act="pp-copy" title="Copy the code">${esc(pp.code)}</button>`}` +
1500
+ `${room.pub ? `<span class="kw-tag">PUBLIC</span>` : ""}${lobby ? `<span class="kw-count">${ids.length}/${MAX_PLAYERS} DIVERS</span>` : ""}`;
1501
+ // In an online lobby the room code gets its own big card, so it's easy to read out to friends
1502
+ const card = $("kw-pp-room");
1503
+ if (card) {
1504
+ card.hidden = pp.mode !== "online";
1505
+ if (pp.mode === "online" && card.dataset.code !== pp.code) {
1506
+ card.dataset.code = pp.code;
1507
+ card.innerHTML = `<p class="kw-label">ROOM CODE</p>
1508
+ <button class="kw-bigcode" type="button" data-act="pp-copy" title="Copy the code" aria-label="Room code ${esc([...pp.code].join(" "))}. Copy it">${[...pp.code].map((c) => `<b>${esc(c)}</b>`).join("")}</button>
1509
+ <p class="kw-muted">Friends open Puffer Party, type this code and press <b>JOIN</b>. Click the code to copy it.</p>`;
1510
+ }
1511
+ }
1512
+ ppSeats(room);
1513
+ const burst = ppPopped(room);
1514
+ if (lobby) {
1454
1515
  const here = ids.filter((id) => room.players[id].on !== false).length;
1455
1516
  const packs = [["all", "Everything"], ...BANK.packs].map(([id, label]) => `<option value="${id}"${room.pack === id ? " selected" : ""}>${esc(label)}</option>`).join("");
1456
1517
  $("kw-pp-setup").innerHTML = mine
@@ -1461,27 +1522,33 @@
1461
1522
  : `<label class="kw-check"><input type="checkbox" data-set="pub"${room.pub ? " checked" : ""}> Anyone can join with Quick play</label>`}`
1462
1523
  : `<p class="kw-muted">Pack: <b>${esc(packName(room.pack))}</b> Ā· Lives: <b>${room.lives}</b></p>`;
1463
1524
  $("kw-pp-go").innerHTML = mine
1464
- ? `<button class="kw-play small" type="button" data-act="pp-start"${here < 2 ? " disabled" : ""}>ā–¶ START ā—€</button>${here < 2 ? `<p class="kw-muted">Share the code <b>${esc(pp.code || "")}</b> so friends can join. You need at least 2 players.</p>` : ""}`
1525
+ ? `<button class="kw-play small" type="button" data-act="pp-start"${here < 2 ? " disabled" : ""}>ā–¶ START ā—€</button>${here < 2 ? `<p class="kw-muted">You need at least 2 players to start.</p>` : ""}`
1465
1526
  : `<p class="kw-muted">Waiting for the host to start…</p>`;
1466
1527
  } else if (room.state === "playing") ppGame(room);
1467
1528
  else {
1468
1529
  const w = room.winner;
1469
- $("kw-pp-win").innerHTML = `<span class="kw-trophy">šŸ†</span><h2>${w === pp.me ? "YOU WIN!" : `${esc(personName(w)).toUpperCase()} WINS!`}</h2>` +
1530
+ const win = $("kw-pp-win");
1531
+ win.innerHTML = `<span class="kw-trophy">šŸ†</span><h2>${w === pp.me ? "YOU WIN!" : `${esc(personName(w)).toUpperCase()} WINS!`}</h2>` +
1470
1532
  `<p class="kw-muted">${w === pp.me ? "Last diver standing." : "Better luck next time."}</p>`;
1533
+ if (!pp.overSeen) { // the last pufferfish bursts first, then the winner comes up
1534
+ pp.overSeen = true;
1535
+ win.classList.toggle("late", burst);
1536
+ setTimeout(() => sfx.play(w === pp.me ? "win" : "lose"), burst ? 1100 : 0);
1537
+ }
1471
1538
  $("kw-pp-go").innerHTML = mine ? `<button class="kw-play small" type="button" data-act="pp-again">ā–¶ PLAY AGAIN ā—€</button>` : `<p class="kw-muted">Waiting for the host to start another game…</p>`;
1472
1539
  }
1473
1540
  }
1541
+ // The table (everyone in a ring of bubbles around the pufferfish) on one side, the prompt and your answer on the other
1474
1542
  function ppShell(state) {
1475
1543
  const top = `<div class="kw-pp-top"><div id="kw-pp-head"></div><button class="kw-link" type="button" data-act="pp-leave">ā—€ LEAVE</button></div>`;
1476
- if (state === "lobby") return `<div class="kw-panel">${top}
1477
- <p class="kw-label">DIVERS</p><ul class="kw-pp-players" id="kw-pp-players"></ul>
1544
+ const table = (extra = "") => `<div class="kw-arena" id="kw-pp-stage"><ul class="kw-seats" id="kw-pp-seats"></ul>
1545
+ <div class="kw-pf" id="kw-pf"><div class="kw-puffer" id="kw-puffer" data-act="pp-poke">${PUFF_CALM}${PUFFER}</div></div>${extra}</div>`;
1546
+ if (state === "lobby") return `${top}${table()}<div class="kw-side"><div class="kw-panel kw-pp-room" id="kw-pp-room" hidden></div><div class="kw-panel kw-pp-lobby">
1478
1547
  <div class="kw-pp-setup" id="kw-pp-setup"></div><div id="kw-pp-go"></div>
1479
- <p class="kw-muted kw-rules">When the pufferfish comes to you, type an answer that fits the prompt to pass it on. The fuse keeps burning between turns, but nobody gets less than 8 seconds. No repeats. If it pops on you, you lose a life and a new prompt starts. A 100-point answer wins back a life.</p></div>`;
1480
- if (state === "playing") return `${top}<ul class="kw-pp-players row" id="kw-pp-players"></ul>
1481
- <div class="kw-pp-stage" id="kw-pp-stage">
1482
- <p class="kw-card-top" id="kw-pp-round"></p>
1483
- <h2 class="kw-prompt" id="kw-pp-prompt"></h2><p class="kw-hint" id="kw-pp-hint"></p>
1484
- <div class="kw-puffer" id="kw-puffer">${PUFFER}<span class="kw-pop-word">POP!</span></div>
1548
+ <p class="kw-muted kw-rules">When the pufferfish comes to you, type an answer that fits the prompt to pass it on. The fuse keeps burning between turns, but nobody gets less than 8 seconds. No repeats. If it pops on you, you lose a life and a new prompt starts. A 100-point answer wins back a life.</p></div></div>`;
1549
+ if (state === "playing") return `${top}${table()}<div class="kw-side">
1550
+ <div class="kw-panel kw-pp-ask"><p class="kw-card-top" id="kw-pp-round"></p><h2 class="kw-prompt" id="kw-pp-prompt"></h2><p class="kw-hint" id="kw-pp-hint"></p></div>
1551
+ <div class="kw-panel kw-pp-play">
1485
1552
  <p class="kw-pp-clock" id="kw-pp-clock"></p>
1486
1553
  <p class="kw-pp-turn" id="kw-pp-turn"></p>
1487
1554
  <form class="kw-answer" data-form="pp-answer" id="kw-pp-form" autocomplete="off">
@@ -1492,8 +1559,59 @@
1492
1559
  <p class="kw-note" id="kw-pp-msg" aria-live="polite"></p>
1493
1560
  <p class="kw-pp-last" id="kw-pp-last"></p>
1494
1561
  </div>
1495
- <div class="kw-panel kw-used"><p class="kw-label">ALREADY SAID</p><ul class="kw-chips" id="kw-pp-used"></ul></div>`;
1496
- return `<div class="kw-panel kw-pp-over">${top}<div class="kw-pp-win" id="kw-pp-win"></div><ul class="kw-pp-players" id="kw-pp-players"></ul><div id="kw-pp-go"></div></div>`;
1562
+ <div class="kw-panel kw-used"><p class="kw-label">ALREADY SAID</p><ul class="kw-chips" id="kw-pp-used"></ul></div></div>`;
1563
+ return `${top}${table(`<div class="kw-pp-win" id="kw-pp-win"></div>`)}<div class="kw-side"><div class="kw-panel kw-pp-over" id="kw-pp-go"></div></div>`;
1564
+ }
1565
+ // A different creature for everyone at the table: their seat's, or the next one nobody has
1566
+ function critters(room) {
1567
+ const out = {}, taken = new Set();
1568
+ for (const id of PP.seats(room)) {
1569
+ let c = (Math.max(1, room.players[id].seat || 1) - 1) % CRITTERS.length;
1570
+ while (taken.has(c)) c = (c + 1) % CRITTERS.length;
1571
+ taken.add(c);
1572
+ out[id] = c;
1573
+ }
1574
+ return out;
1575
+ }
1576
+ // Seats go round the table with you at the bottom; the rest follow in seat order. Seats are kept and moved, not rebuilt,
1577
+ // so the bubbles keep bobbing and slide when someone joins or leaves. An online lobby shows its open seats too.
1578
+ function ppSeats(room) {
1579
+ const box = $("kw-pp-seats");
1580
+ if (!box) return;
1581
+ const ids = PP.seats(room), at = ids.indexOf(pp.me), order = at > 0 ? [...ids.slice(at), ...ids.slice(0, at)] : ids;
1582
+ const lobby = room.state === "lobby", open = lobby && pp.mode === "online" ? Math.max(0, MAX_PLAYERS - ids.length) : 0;
1583
+ const n = order.length + open, look = critters(room), hold = room.state === "playing" && room.round ? room.round.holder : null;
1584
+ const spot = (k) => { const a = Math.PI / 2 + (k / n) * Math.PI * 2; return [50 + 37 * Math.cos(a), 50 + 35 * Math.sin(a)]; };
1585
+ const seen = new Set();
1586
+ const put = (key, k, cls, c, name, hearts) => {
1587
+ let li = [...box.children].find((x) => x.dataset.k === key);
1588
+ if (!li) {
1589
+ li = document.createElement("li");
1590
+ li.dataset.k = key;
1591
+ li.innerHTML = `<span class="kw-bub"></span><span class="kw-pn"></span><span class="kw-hearts"></span>`;
1592
+ li.style.setProperty("--d", `-${((box.children.length * 0.83) % 3.2).toFixed(2)}s`);
1593
+ box.appendChild(li);
1594
+ }
1595
+ seen.add(li);
1596
+ const [x, y] = spot(k), [bub, nm, ht] = li.children;
1597
+ li.className = `kw-seat ${cls}`;
1598
+ li.style.left = `${x.toFixed(2)}%`;
1599
+ li.style.top = `${y.toFixed(2)}%`;
1600
+ if (bub.dataset.c !== String(c)) { bub.dataset.c = c; bub.innerHTML = c >= 0 ? CRITTERS[c] : ""; }
1601
+ if (nm.dataset.v !== name) { nm.dataset.v = name; nm.innerHTML = name; }
1602
+ if (ht.dataset.v !== hearts) { ht.dataset.v = hearts; ht.innerHTML = hearts; }
1603
+ return [x, y];
1604
+ };
1605
+ pp.spots = {};
1606
+ order.forEach((id, k) => {
1607
+ const p = room.players[id], out = !lobby && p.lives <= 0;
1608
+ const cls = [id === pp.me && "me", id === hold && "hold", out && "out", p.on === false && "off", room.state === "over" && room.winner === id && "won",
1609
+ pp.hit && pp.hit.uid === id && Date.now() < pp.hit.until && "hit"].filter(Boolean).join(" ");
1610
+ const hearts = lobby ? "" : `${"♄".repeat(Math.max(0, p.lives))}<i>${"♄".repeat(Math.max(0, room.lives - p.lives))}</i>`;
1611
+ pp.spots[id] = put(id, k, cls, look[id], `${id === room.host ? "šŸ‘‘ " : ""}${esc(ctx.maskSlurs(p.name))}`, hearts);
1612
+ });
1613
+ for (let j = 0; j < open; j++) put(`open${j}`, order.length + j, "open", -1, "open", "");
1614
+ for (const li of [...box.children]) if (!seen.has(li)) li.remove();
1497
1615
  }
1498
1616
  function ppGame(room) {
1499
1617
  const r = room.round;
@@ -1502,44 +1620,98 @@
1502
1620
  $("kw-pp-round").textContent = `ROUND ${r.n} Ā· ${p ? packName(p.cat.pack).toUpperCase() : ""}`;
1503
1621
  $("kw-pp-prompt").textContent = p ? p.text : "…";
1504
1622
  $("kw-pp-hint").textContent = p ? p.hint : "";
1505
- const used = Object.entries(r.used || {});
1506
- $("kw-pp-used").innerHTML = used.length ? used.map(([k, who]) => `<li class="${who === pp.me ? "me" : ""}">${esc(answerName(r.key, k))}</li>`).join("") : `<li class="kw-muted">Nothing yet.</li>`;
1507
- const last = r.last;
1508
- $("kw-pp-last").innerHTML = last ? `${esc(personName(last.uid))} said <b>${esc(answerName(r.key, last.a))}</b> <span class="kw-tag t${last.pts}">+${last.pts}</span>${last.bonus ? " and won back a life! ♄" : ""}` : "";
1509
- if (last && last.at !== pp.lastPass) { pp.lastPass = last.at; sfx.play("pass"); }
1623
+ // every answer shows in the color of the rarity it got
1624
+ const used = Object.entries(r.used || {}), tierOf = (k) => { const i = p ? p.cat.entries.findIndex((e) => e.key === k) : -1; return i >= 0 ? listPts(p, i) : 0; };
1625
+ $("kw-pp-used").innerHTML = used.length ? used.map(([k, who]) => `<li class="tier t${tierOf(k)}${who === pp.me ? " me" : ""}">${esc(answerName(r.key, k))}</li>`).join("") : `<li class="kw-muted">Nothing yet.</li>`;
1626
+ const last = r.last, lastEl = $("kw-pp-last");
1627
+ lastEl.innerHTML = last ? `${last.uid === pp.me ? "You" : esc(personName(last.uid))} said <b class="kw-tc t${last.pts}">${esc(answerName(r.key, last.a))}</b> ` +
1628
+ `<span class="kw-tag t${last.pts}">${TIERS[last.pts] ? `${TIERS[last.pts][1]} ${TIERS[last.pts][0].toUpperCase()} ` : ""}+${last.pts}</span>${last.bonus ? " and won back a life! ♄" : ""}` : "";
1629
+ if (last && last.at !== pp.lastPass) { pp.lastPass = last.at; sfx.play("pass"); lastEl.classList.remove("fresh"); void lastEl.offsetWidth; lastEl.classList.add("fresh"); }
1510
1630
  const mineTurn = r.holder === pp.me;
1511
1631
  const input = $("kw-pp-input"), form = $("kw-pp-form");
1512
1632
  if (pp.close && (!mineTurn || pp.close.at !== r.at)) ppDropClose(); // the puffer moved on: the suggestion is stale
1513
1633
  if (mineTurn && form.hidden) sfx.play("go");
1514
1634
  form.hidden = !mineTurn;
1515
- if (mineTurn && document.activeElement !== input && ppNow() >= r.startsAt) input.focus();
1516
- if (room.pop && room.pop.at !== pp.shownPop && ppNow() - room.pop.at < 4000) { // someone just popped
1517
- pp.shownPop = room.pop.at;
1518
- const stage = $("kw-pp-stage");
1519
- stage.classList.remove("popped"); void stage.offsetWidth; stage.classList.add("popped");
1520
- sfx.play("pop");
1521
- const me = room.pop.uid === pp.me, lives = room.players[room.pop.uid] ? room.players[room.pop.uid].lives : 0;
1522
- ppSay(`šŸ’„ ${me ? "You" : personName(room.pop.uid)} ${me ? "lose" : "loses"} a life${lives <= 0 ? ` and ${me ? "are" : "is"} out` : ""}!`, false);
1523
- }
1635
+ if (mineTurn && document.activeElement !== input && ppNow() >= r.startsAt) { input.focus(); form.scrollIntoView({ block: "nearest" }); }
1524
1636
  ppClock(room, ppNow());
1525
1637
  }
1638
+ // Where the pufferfish hangs out: partway from the middle of the table toward someone's seat
1639
+ const near = (s) => [50 + (s[0] - 50) * 0.4, 50 + (s[1] - 50) * 0.4];
1640
+ // Someone's time ran out: the pufferfish bursts where it was, their bubble shakes, and a fresh one swims in after
1641
+ function ppPopped(room) {
1642
+ const pop = room.pop, arena = $("kw-pp-stage"), s = pp.spots && pop && pp.spots[pop.uid];
1643
+ if (!pop || pop.at === pp.shownPop) return false;
1644
+ pp.shownPop = pop.at;
1645
+ if (!arena || !s || ppNow() - pop.at > 4000) return false;
1646
+ const [x, y] = near(s), me = pop.uid === pp.me, lives = room.players[pop.uid] ? room.players[pop.uid].lives : 0;
1647
+ const colors = ["#ef4444", "#f97316", "#fbbf24", "#fde68a", "#fff7e6", "#b91c1c", "#fcd34d", "#c2410c"];
1648
+ let bits = "";
1649
+ for (let i = 0; i < 26; i++) {
1650
+ const a = (i / 26) * Math.PI * 2 + Math.random() * 0.4, d = 0.55 + Math.random() * 0.8;
1651
+ bits += `<i style="--x:${(Math.cos(a) * d).toFixed(2)};--y:${(Math.sin(a) * d).toFixed(2)};--r:${Math.round(Math.random() * 720 - 360)}deg;` +
1652
+ `--z:${(0.5 + Math.random() * 0.9).toFixed(2)};--c:${colors[i % colors.length]};--t:${(0.65 + Math.random() * 0.5).toFixed(2)}s"></i>`;
1653
+ }
1654
+ const boom = document.createElement("div");
1655
+ boom.className = "kw-boom";
1656
+ boom.style.left = `${x.toFixed(2)}%`;
1657
+ boom.style.top = `${y.toFixed(2)}%`;
1658
+ boom.innerHTML = `<span class="kw-boom-flash"></span><span class="kw-boom-ring"></span>${bits}<b class="kw-boom-word">POP!</b>`;
1659
+ const lost = document.createElement("b");
1660
+ lost.className = "kw-lost";
1661
+ lost.style.left = `${s[0].toFixed(2)}%`;
1662
+ lost.style.top = `${s[1].toFixed(2)}%`;
1663
+ lost.textContent = "āˆ’ā™„";
1664
+ arena.append(boom, lost);
1665
+ setTimeout(() => { boom.remove(); lost.remove(); }, 1800);
1666
+ arena.classList.remove("shake"); void arena.offsetWidth; arena.classList.add("shake");
1667
+ pp.goneUntil = Date.now() + 1500;
1668
+ pp.hit = { uid: pop.uid, until: Date.now() + 900 };
1669
+ const seat = [...$("kw-pp-seats").children].find((li) => li.dataset.k === pop.uid);
1670
+ if (seat) seat.classList.add("hit");
1671
+ const wrap = $("kw-pf");
1672
+ if (wrap) wrap.classList.add("gone");
1673
+ sfx.play("pop");
1674
+ ppSay(`šŸ’„ ${me ? "You" : personName(pop.uid)} ${me ? "lose" : "loses"} a life${lives <= 0 ? ` and ${me ? "are" : "is"} out` : ""}!`, false);
1675
+ return true;
1676
+ }
1677
+ // The pufferfish swims over toward whoever has it (facing them), and the ring round their bubble burns down with their time
1678
+ function ppAim(r, part) {
1679
+ const s = pp.spots && pp.spots[r.holder], wrap = $("kw-pf"), seats = $("kw-pp-seats");
1680
+ if (wrap && s) {
1681
+ const [x, y] = near(s);
1682
+ wrap.style.left = `${x.toFixed(2)}%`;
1683
+ wrap.style.top = `${y.toFixed(2)}%`;
1684
+ wrap.classList.toggle("right", s[0] > 52);
1685
+ }
1686
+ const seat = seats && [...seats.children].find((li) => li.dataset.k === r.holder);
1687
+ if (seat) seat.style.setProperty("--left", Math.max(0, Math.min(1, part)).toFixed(3));
1688
+ }
1689
+ // Calm while there's time; with under PUFF_AT left it puffs up into a spiky ball that swells, reddens and shakes until someone passes it or it pops
1690
+ function ppPuff(fish, heat, grown) {
1691
+ const puffed = heat > 0;
1692
+ if (puffed !== fish.classList.contains("puffed")) { fish.classList.toggle("puffed", puffed); if (puffed) sfx.play("puff"); }
1693
+ fish.classList.toggle("critical", heat > 0.6);
1694
+ fish.style.setProperty("--s", (puffed ? 1 + heat * 0.6 : 0.9 + grown * 0.15).toFixed(3));
1695
+ fish.style.setProperty("--heat", heat.toFixed(3));
1696
+ }
1526
1697
  function ppClock(room, t) {
1527
- const r = room.round, fish = $("kw-puffer");
1698
+ const r = room.round, fish = $("kw-puffer"), wrap = $("kw-pf");
1528
1699
  if (room.state !== "playing" || !r || !fish) return;
1700
+ if (wrap) wrap.classList.toggle("gone", Date.now() < pp.goneUntil);
1529
1701
  const turn = $("kw-pp-turn"), clock = $("kw-pp-clock"), mineTurn = r.holder === pp.me, input = $("kw-pp-input");
1530
1702
  if (t < r.startsAt) {
1531
1703
  clock.textContent = `next prompt in ${Math.ceil((r.startsAt - t) / 1000)}…`;
1532
1704
  turn.textContent = mineTurn ? "You start with the pufferfish. Get ready!" : `${personName(r.holder)} starts with the pufferfish.`;
1533
1705
  input.disabled = true;
1534
- fish.style.setProperty("--s", "0.85");
1535
- fish.style.setProperty("--heat", "0");
1706
+ ppPuff(fish, 0, 0);
1707
+ ppAim(r, 1);
1536
1708
  return;
1537
1709
  }
1538
1710
  input.disabled = !mineTurn;
1539
1711
  const left = Math.max(0, r.endsAt - t), span = Math.max(1, r.endsAt - Math.max(r.at, r.startsAt));
1540
- const grown = Math.min(1, 1 - left / Math.max(span, FLOOR)), heat = Math.min(1, Math.max(0, 1 - left / 9000));
1541
- fish.style.setProperty("--s", (0.85 + grown * 0.75).toFixed(3));
1542
- fish.style.setProperty("--heat", heat.toFixed(3));
1712
+ ppAim(r, left / span);
1713
+ const heat = Math.min(1, Math.max(0, 1 - left / PUFF_AT));
1714
+ ppPuff(fish, heat, Math.min(1, 1 - left / Math.max(span, FLOOR)));
1543
1715
  clock.textContent = `${(left / 1000).toFixed(1)}s`;
1544
1716
  clock.classList.toggle("hurry", left < 4000);
1545
1717
  if (left > 0 && Date.now() - pp.lastFuse > 650 - heat * 500) { pp.lastFuse = Date.now(); sfx.play("fuse", heat > 0.6 ? 1 : 0); } // the fuse ticks faster as it burns down
@@ -1552,7 +1724,7 @@
1552
1724
  if (e.target.id === "kw-modal") { closeSheet(); return; } // clicked outside a pop-up
1553
1725
  const b = e.target.closest("[data-act]");
1554
1726
  if (!b || !root.contains(b)) return;
1555
- const act = b.dataset.act, quiet = ["sound", "next", "close-yes", "pp-close-yes", "daily", "free", "past", "again"];
1727
+ const act = b.dataset.act, quiet = ["sound", "next", "close-yes", "pp-close-yes", "daily", "free", "past", "again", "pp-poke"];
1556
1728
  if (!quiet.includes(act)) sfx.play("click");
1557
1729
  if (act === "play") playSheet();
1558
1730
  else if (act === "howto") howSheet();
@@ -1578,6 +1750,12 @@
1578
1750
  else if (act === "pp-rejoin") askName((name) => ppJoin(ctx.store.get(ROOM_KEY, ""), name), "So the others know who's who.");
1579
1751
  else if (act === "pp-leave") ppLeave();
1580
1752
  else if (act === "pp-copy") navigator.clipboard?.writeText(pp.code).then(() => ctx.toast(`Room code ${pp.code} copied.`), () => {});
1753
+ else if (act === "pp-poke") { // poke the pufferfish while you wait and it puffs up for a moment
1754
+ if (!pp.room || pp.room.state !== "lobby" || b.classList.contains("puffed")) return;
1755
+ b.classList.add("puffed");
1756
+ sfx.play("puff");
1757
+ setTimeout(() => b.classList.remove("puffed"), 1400);
1758
+ }
1581
1759
  else if (act === "pp-start") ppDo((x, t) => PP.start(x, t, Math.random)).then((why) => { if (why) ppSay(ppNoteText(why), true); });
1582
1760
  else if (act === "pp-again") ppDo((x) => PP.reset(x));
1583
1761
  else if (act === "pp-close-yes" && pp.close) ppAnswer(pp.close.raw, confirmClose(pp.close.prompt, pp.close.res));
@@ -1606,7 +1784,8 @@
1606
1784
  else if (kind === "name" || kind === "rename") {
1607
1785
  const res = cleanName($("kw-name-in").value);
1608
1786
  if (res.error) return sheetNote(res.error, true);
1609
- ctx.store.set(NAME_KEY, res.name);
1787
+ ctx.store.set(KW_NAME_KEY, res.name); // KrillionWho's own, so a name the chat doesn't allow can't break chat
1788
+ if (!ctx.store.get(NAME_KEY, "") && !/^ *richard *$/i.test(res.name)) ctx.store.set(NAME_KEY, res.name); // chat can use it too, if chat has none yet
1610
1789
  sfx.play("click");
1611
1790
  if (kind === "rename") return sheetNote(`Saved: ${res.name}`);
1612
1791
  const then = afterName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywkrlerche/richardwho",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "Richards Unblocked Games",
5
5
  "license": "UNLICENSED",
6
6
  "files": [