From a4faf61dd00902e67dadbbacc4148eb58e90f8fd Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Sat, 19 Sep 2026 12:34:48 +0200 Subject: [PATCH] Integrate BGS chat and a tabbed journal below the board --- README.md | 2 + viewer/activity.css | 248 +++++++++++++++++++++++++++++++++++++++++ viewer/activity.js | 181 ++++++++++++++++++++++++++++++ viewer/art.js | 1 + viewer/chat-preview.js | 112 +++++++++++++++++++ viewer/index.js | 5 + viewer/preview.js | 9 +- viewer/style.css | 6 + viewer/ui.js | 38 ++++--- 9 files changed, 587 insertions(+), 15 deletions(-) create mode 100644 viewer/activity.css create mode 100644 viewer/activity.js create mode 100644 viewer/chat-preview.js diff --git a/README.md b/README.md index 9cf8139..b4f2ab8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ pnpm dev Local practice: http://127.0.0.1:5221/ . Lessons start at `/?chapter=drift`. +Chat and journal preview: `/?chat=1`. This uses the BGS viewer protocol with local messages, unread notifications, mentions and send-failure controls; nothing is sent to other players. + ## Rules and implementation status Rules: [Z-Man English rulebook](https://cs.uwaterloo.ca/~dtompkin/archive/dtlib/base/Primordial%20Soup.pdf), [publisher's reference sheets](http://doris-frank.de/download/Ursuppe_Rules.pdf), and [publisher FAQ](http://doris-frank.de/UrsuppeFAQ.html). diff --git a/viewer/activity.css b/viewer/activity.css new file mode 100644 index 0000000..1ad712f --- /dev/null +++ b/viewer/activity.css @@ -0,0 +1,248 @@ +.pond-tools { + display: flex; + align-items: center; + gap: 14px; +} +.soup .activity-slot { + flex: none; + margin-top: 24px; +} +.soup-activity { + border: 1px solid var(--line); + border-radius: 14px; + background: var(--paper); + overflow: hidden; + font-size: 13px; + --activity-height: 320px; + --activity-padding: 12px; +} +.activity-header, +.activity-header [role="tablist"] { + display: flex; + align-items: center; + gap: 8px; +} +.activity-header { + justify-content: space-between; + padding: 10px 16px 0; + border-bottom: 1px solid var(--line); +} +.activity-header [role="tab"] { + display: inline-flex; + align-items: center; + gap: 7px; + padding: 10px 12px; + border-bottom: 3px solid transparent; + color: var(--muted); + font-weight: 600; +} +.activity-header [role="tab"][aria-selected="true"] { + color: var(--ink); + border-color: #8cb74a; +} +.activity-header svg, +.soup-chat-shortcut > svg { + width: 17px; + height: 17px; +} +.activity-back { + padding: 10px 4px; + white-space: nowrap; +} +.soup .chat-count, +.soup-chat-shortcut > span { + border-radius: 20px; + min-width: 20px; + padding: 1px 5px; + background: #dcebb9; + color: var(--ink); + font-size: 11px; + text-align: center; +} +.soup .soup-activity [hidden], +.soup .soup-chat-shortcut[hidden] { + display: none; +} +.activity-chat, +.activity-journal { + height: var(--activity-height); + padding: var(--activity-padding) 20px; +} +.soup-activity .bgs-game-chat { + height: 100%; + min-width: 0; +} +.soup-activity .chat-body { + height: calc(var(--activity-height) - 2 * var(--activity-padding)); + display: flex; + flex-direction: column; + gap: 8px; + min-width: 0; +} +.soup-activity .bgs-game-chat > summary { + display: none; +} +.soup-activity .chat-messages, +.soup .soup-activity .journal-list { + min-height: 0; + overflow: auto; + overscroll-behavior: contain; + overflow-anchor: none; + scrollbar-width: thin; + scrollbar-color: #b7c5a6 transparent; + padding: 0 6px 0 0; + margin: 0; +} +.soup-activity .chat-messages { + flex: 1; +} +.soup .soup-activity .journal-list { + height: 100%; + max-height: none; +} +.soup-activity article { + padding: 9px 0; + border-bottom: 1px solid var(--line); + white-space: pre-wrap; + overflow-wrap: anywhere; + line-height: 1.65; +} +.soup-activity article:last-child { + border-bottom: 0; +} +.soup-activity .chat-author { + display: inline-flex; + align-items: center; + vertical-align: middle; + gap: 6px; + padding: 0; + font-weight: 700; +} +.soup-activity .chat-portrait { + display: inline-block; + width: 23px; + height: 23px; +} +.soup-activity .chat-portrait svg { + width: 100%; + height: 100%; +} +.soup-activity time, +.soup-activity .chat-edited { + margin-left: 8px; + color: var(--muted); + font-size: 10px; + white-space: nowrap; +} +.soup-activity .chat-day { + display: flex; + align-items: center; + gap: 12px; + margin: 12px 0; +} +.soup-activity .chat-day::before, +.soup-activity .chat-day::after { + content: ""; + flex: 1; + border-top: 1px solid var(--line); +} +.soup-activity .chat-day time { + margin: 0; +} +.soup-activity .chat-composer { + display: flex; + align-items: center; + gap: 8px; +} +.soup-activity input { + flex: 1; + min-width: 0; + height: 40px; + border: 1px solid #c5d2b8; + border-radius: 9px; + background: var(--cream); + color: var(--ink); + font: inherit; + padding: 8px 12px; +} +.soup-activity .chat-composer > button { + padding: 10px 18px; + border: 1px solid #a4bb7d; + border-radius: 9px; + background: #dfedc4; + font-weight: 600; +} +.soup-activity .chat-suggestions { + display: flex; + gap: 6px; + flex-wrap: wrap; +} +.soup-activity .chat-suggestions button { + padding: 5px 8px; + border: 1px solid var(--line); + border-radius: 6px; +} +.soup-activity .chat-suggestions [aria-selected="true"] { + background: #dfedc4; +} +.soup-activity .chat-status { + color: #845538; + font-size: 12px; +} +.soup-activity .chat-suggestions:empty, +.soup-activity .chat-status:empty { + display: none; +} +.soup-activity article a, +.soup-activity .chat-mention { + color: var(--ink); + text-decoration: underline; +} +.soup-activity .chat-mention { + padding: 0; + font-weight: 600; +} +.soup-activity .chat-empty, +.soup-activity .journal-empty { + color: var(--muted); +} +.soup-chat-shortcut { + position: fixed; + left: max(16px, env(safe-area-inset-left)); + bottom: max(16px, env(safe-area-inset-bottom)); + z-index: 20; + display: flex; + align-items: center; + gap: 8px; + padding: 10px 15px; + border: 1px solid #809b62; + border-radius: 24px; + background: var(--dark); + color: var(--cream); + box-shadow: 0 3px 12px var(--shadow); + font-weight: 600; +} +@media (max-width: 760px) { + .soup-activity { + --activity-height: 300px; + --activity-padding: 10px; + } + .activity-header { + padding: 6px 8px 0; + gap: 4px; + } + .activity-header [role="tab"] { + padding: 10px 8px; + gap: 5px; + } + .activity-back { + font-size: 11px; + } + .activity-chat, + .activity-journal { + padding: 10px 12px; + } + .soup-activity input { + font-size: 16px; + } +} diff --git a/viewer/activity.js b/viewer/activity.js new file mode 100644 index 0000000..af84f0d --- /dev/null +++ b/viewer/activity.js @@ -0,0 +1,181 @@ +import { mountChat } from "@boardgamers/protocol/chat/dom"; +import { amoeba, colors, icon } from "./art.js"; +import { richText } from "./rich-text.js"; + +let sequence = 0; + +export function mountActivity(target, { chat, openPlayer, backToBoard } = {}) { + const id = `soup-activity-${++sequence}`; + const section = document.createElement("section"); + section.className = "soup-activity"; + section.setAttribute("aria-label", "Chat and journal"); + section.innerHTML = `
+ + +
+ + `; + const shortcut = document.createElement("button"); + shortcut.type = "button"; + shortcut.className = "soup-chat-shortcut"; + shortcut.hidden = true; + target.append(section, shortcut); + const tabs = [...section.querySelectorAll("[data-tab]")]; + const chatPanel = section.querySelector(".activity-chat"); + const journalPanel = section.querySelector(".activity-journal"); + const journal = journalPanel.querySelector("ol"); + const count = section.querySelector(".chat-count"); + let active = chat ? "chat" : "journal"; + let players = []; + let identity = ""; + let journalKey; + let following = true; + let journalFrame; + const events = new AbortController(); + const eventOptions = { signal: events.signal }; + + const chatView = + chat && + mountChat(chatPanel, { + chat, + styles: false, + openPlayer, + renderAuthor(message) { + const author = document.createElement( + message.playerIndex !== undefined && openPlayer ? "button" : "strong", + ); + author.className = "chat-author"; + const player = players[message.playerIndex]; + if (player && colors[player.color]) { + const portrait = document.createElement("span"); + portrait.className = "chat-portrait"; + portrait.innerHTML = amoeba(player.color); + author.append(portrait); + } + author.append( + document.createTextNode(message.author ?? player?.name ?? "Game"), + ); + if (author.tagName === "BUTTON") { + author.type = "button"; + author.onclick = () => openPlayer(message.playerIndex); + } + return author; + }, + }); + if (chatView) { + const body = document.createElement("div"); + body.className = "chat-body"; + body.append( + ...[...chatView.element.children].filter( + (child) => child.tagName !== "SUMMARY", + ), + ); + chatView.element.append(body); + } + + function followJournal() { + cancelAnimationFrame(journalFrame); + journalFrame = requestAnimationFrame(() => { + if (active === "journal" && following) + journal.scrollTop = journal.scrollHeight; + }); + } + function select(kind) { + active = kind === "chat" && chat ? "chat" : "journal"; + for (const tab of tabs) { + tab.setAttribute("aria-selected", String(tab.dataset.tab === active)); + tab.tabIndex = tab.dataset.tab === active ? 0 : -1; + } + chatPanel.hidden = active !== "chat"; + journalPanel.hidden = active !== "journal"; + chat?.setOpen(active === "chat"); + followJournal(); + } + function open(kind) { + select(kind); + section.scrollIntoView({ block: "center" }); + if (active === "chat") chatView.open(); + else journal.focus({ preventScroll: true }); + } + for (const tab of tabs) { + tab.addEventListener("click", () => select(tab.dataset.tab), eventOptions); + tab.addEventListener( + "keydown", + (event) => { + const shown = tabs.filter((item) => !item.hidden); + const index = shown.indexOf(tab); + const next = { + ArrowRight: (index + 1) % shown.length, + ArrowLeft: (index + shown.length - 1) % shown.length, + Home: 0, + End: shown.length - 1, + }[event.key]; + if (next === undefined) return; + event.preventDefault(); + select(shown[next].dataset.tab); + shown[next].focus(); + }, + eventOptions, + ); + } + section + .querySelector(".activity-back") + .addEventListener("click", backToBoard, eventOptions); + shortcut.addEventListener("click", () => open("chat"), eventOptions); + journal.addEventListener( + "scroll", + () => { + if (journal.clientHeight) + following = + journal.scrollHeight - journal.scrollTop - journal.clientHeight < 32; + }, + { ...eventOptions, passive: true }, + ); + + const unsubscribe = chat?.subscribe((snapshot) => { + const unread = snapshot.unreadIds.length; + count.hidden = !unread; + count.textContent = unread; + count.setAttribute("aria-label", `${unread} unread messages`); + shortcut.hidden = !unread; + shortcut.innerHTML = `${icon("chat")} Chat ${unread}`; + shortcut.setAttribute( + "aria-label", + `Open chat, ${unread} unread message${unread === 1 ? "" : "s"}`, + ); + }); + select(active); + return { + open, + update(state) { + players = state.players; + const nextIdentity = JSON.stringify( + players.map(({ name, color }) => [name, color]), + ); + if (nextIdentity !== identity) { + identity = nextIdentity; + chatView?.refresh(); + } + const lines = state.log.slice(-150); + const key = JSON.stringify(lines); + if (key === journalKey) return; + journalKey = key; + journal.innerHTML = + lines + .map( + (line) => + `
  • Round ${Number(line.round)}${richText(line.text)}
  • `, + ) + .join("") || '
  • No moves yet.
  • '; + followJournal(); + }, + destroy() { + events.abort(); + cancelAnimationFrame(journalFrame); + unsubscribe?.(); + chatView?.destroy(); + section.remove(); + shortcut.remove(); + }, + }; +} diff --git a/viewer/art.js b/viewer/art.js index 84fbb33..70822be 100644 --- a/viewer/art.js +++ b/viewer/art.js @@ -40,6 +40,7 @@ const iconPaths = { "sound-off": '', sound: '', history: '', + chat: '', spark: '', wave: '', arrow: '', diff --git a/viewer/chat-preview.js b/viewer/chat-preview.js new file mode 100644 index 0000000..9d87395 --- /dev/null +++ b/viewer/chat-preview.js @@ -0,0 +1,112 @@ +import * as E from "../engine/index.js"; +import { chatSegments } from "@boardgamers/protocol/chat"; +import { prepared } from "./tutorials.js"; + +export function mountChatPreview(nav) { + let state = prepared({ round: 3 }); + let sequence = 0; + let failNext = false; + let spectator = false; + const emitter = window.primordialSoup.launch("#game"); + const people = state.players.map((p, i) => ({ + id: String(i), + name: p.name, + playerIndex: i, + })); + const names = new Map(people.map((p) => [p.name, p.id])); + const status = document.createElement("span"); + status.setAttribute("role", "status"); + status.textContent = "Local chat · messages stay here"; + function message(playerIndex, text, ago = 0) { + return { + _id: (++sequence).toString(16).padStart(24, "0"), + type: "text", + author: state.players[playerIndex].name, + playerIndex, + text, + segments: chatSegments(text, names, true), + createdAt: new Date(Date.now() - ago).toISOString(), + }; + } + function permissions() { + emitter.emit("player", { index: spectator ? undefined : 0 }); + emitter.emit("chat:state", { + canSend: !spectator, + reason: spectator ? "not-a-player" : "", + mentions: people, + }); + } + emitter.on("chat:send", ({ text, requestId }) => { + setTimeout(() => { + if (failNext) { + failNext = false; + emitter.emit("chat:result", { + requestId, + ok: false, + error: "Could not send. Try again.", + }); + status.textContent = "Send failed; draft kept"; + } else { + emitter.emit("chat:appended", [message(0, text)]); + emitter.emit("chat:result", { requestId, ok: true }); + status.textContent = "Message sent locally"; + } + }, 300); + }); + emitter.on("chat:read", () => { + status.textContent = "Read receipt received locally"; + }); + emitter.on("player:clicked", ({ index }) => { + status.textContent = `Player link: ${state.players[index].name}`; + }); + emitter.on("move", (move) => { + state = E.move(state, move, 0); + emitter.emit("state", E.stripSecret(state)); + }); + const controls = [ + [ + "Receive message", + () => + emitter.emit("chat:appended", [ + message(1, "@You Ready for the next round?"), + ]), + ], + [ + "Fail next send", + () => { + failNext = true; + status.textContent = "Next send will fail locally"; + }, + ], + [ + "Toggle spectator", + () => { + spectator = !spectator; + permissions(); + }, + ], + ["Refresh position", () => emitter.emit("state", E.stripSecret(state))], + ]; + for (const [label, click] of controls) { + const button = document.createElement("button"); + button.textContent = label; + button.onclick = click; + nav.append(button); + } + nav.append(status); + permissions(); + emitter.emit("state", E.stripSecret(state)); + emitter.emit("chat:messages", [ + message(1, "Good luck, everyone!", 86400000), + message(2, "I like the little amoebas.", 86300000), + message(0, "Trying Movement I this time.", 86200000), + message(3, "@Maya The gene pool explains each ability.", 400000), + message(1, "Thanks! Saving some BP for division.", 300000), + message(2, "The current is going east this round.", 200000), + message( + 3, + "Rules: https://boardgamers.space/page/primordial-soup/rules", + 100000, + ), + ]); +} diff --git a/viewer/index.js b/viewer/index.js index f233f93..e45e87a 100644 --- a/viewer/index.js +++ b/viewer/index.js @@ -1,5 +1,6 @@ import "./style.css"; import { registerViewer } from "@boardgamers/protocol/viewer"; +import { ChatController } from "@boardgamers/protocol/chat"; import { createTutorial } from "@boardgamers/protocol/tutorial"; import { mountTutorialGuide } from "@boardgamers/protocol/tutorial/dom"; import { stripSecret } from "../engine/index.js"; @@ -53,7 +54,10 @@ registerViewer( "primordialSoup", (ctx) => { let pending, timeout; + const chat = new ChatController(); const ui = mountGame(ctx.target, { + chat, + onOpenPlayer: ctx.openPlayer, onMove: (m) => new Promise((resolve, reject) => { pending = { resolve, reject }; @@ -69,6 +73,7 @@ registerViewer( }), }); return { + chat, onPlayer(player) { ui.setPlayer(player.index); }, diff --git a/viewer/preview.js b/viewer/preview.js index 3d99c09..6b86fe0 100644 --- a/viewer/preview.js +++ b/viewer/preview.js @@ -3,9 +3,11 @@ import * as E from "../engine/index.js"; import { mountGame } from "./ui.js"; import { chapterMetadata, prepared } from "./tutorials.js"; import { mountLesson } from "./index.js"; +import { mountChatPreview } from "./chat-preview.js"; const params = new URLSearchParams(location.search), chapter = params.get("chapter"), appearance = params.get("appearance") === "genes", + chatPreview = params.has("chat"), target = document.querySelector("#game"), nav = document.querySelector("#preview-nav"); nav.className = "practice-nav"; @@ -13,7 +15,12 @@ nav.innerHTML = `Local previewPractice game { location.href = e.target.value ? `/?chapter=${e.target.value}` : "/"; }); -if (chapter) { +if (chatPreview) { + nav + .querySelectorAll("#new-three, #new-four") + .forEach((button) => button.remove()); + mountChatPreview(nav); +} else if (chapter) { const next = chapterMetadata[chapterMetadata.findIndex((c) => c.id === chapter) + 1]; await mountLesson(target, { diff --git a/viewer/style.css b/viewer/style.css index e2874b4..6044fbe 100644 --- a/viewer/style.css +++ b/viewer/style.css @@ -1,5 +1,6 @@ @import "./fonts.css"; @import "./prototype.css"; +@import "./activity.css"; .soup { min-height: 100dvh; padding-bottom: 18px; @@ -457,6 +458,11 @@ .soup .journal-list li { font-size: 13px; } +.rules-links { + display: flex; + flex-wrap: wrap; + gap: 12px 24px; +} .results-list { list-style: none; padding: 0; diff --git a/viewer/ui.js b/viewer/ui.js index 457f558..35b4cdc 100644 --- a/viewer/ui.js +++ b/viewer/ui.js @@ -28,9 +28,12 @@ import { sensitivity, evolutionPoints, } from "./rich-text.js"; +import { mountActivity } from "./activity.js"; import { pondArt } from "./pond.js"; export const RULES_URL = "https://s3.fr-par.scw.cloud/bgs-assets/assets/primordial-soup/rules-en/69e877694adc4a15/rules-en.pdf"; +export const SIMPLE_RULES_URL = + "https://boardgamers.space/page/primordial-soup/rules"; export const esc = (x) => String(x ?? "").replace( /[&<>"']/g, @@ -151,16 +154,16 @@ function instruction(s, seat) { } export function mountGame( target, - { onMove, onFullscreen, onOpenPlayer, practice = false } = {}, + { onMove, onFullscreen, onOpenPlayer, chat, practice = false } = {}, ) { const root = document.createElement("div"); root.className = "soup game-shell"; target.append(root); root.innerHTML = `
    ${amoeba("green", 0)}

    primordial soup.

    -
    A LITTLE LIFE IN A BIG SOUP
    CURRENT
    ➜
    Ozone
    +
    A LITTLE LIFE IN A BIG SOUP
    ${chat ? `` : ""}
    CURRENT
    ➜
    Ozone
    ROUND
    - `; +
    `; const $ = (q) => root.querySelector(q), $$ = (q) => [...root.querySelectorAll(q)]; let state, @@ -173,6 +176,16 @@ export function mountGame( modalKind, oldTask; const dialog = $("dialog"); + const activity = mountActivity($(".activity-slot"), { + chat, + openPlayer: onOpenPlayer, + backToBoard() { + $(".play-area").scrollIntoView({ block: "start" }); + $(chat ? '[data-ui="chat"]' : '[data-ui="journal"]').focus({ + preventScroll: true, + }); + }, + }); const canAct = () => !busy && !locked && @@ -199,6 +212,7 @@ export function mountGame( } function render() { if (!state) return; + activity.update(state); const t = state.tasks[0], taskKey = JSON.stringify(t), actor = state.actor; @@ -314,16 +328,7 @@ export function mountGame( else if (modalKind === "scoring") { const player = viewPlayer ?? seat ?? state.actor ?? 0; html = `

    Scoring each round

    Look up your living amoebas and your gene total, then add the two rows. These points belong to the whole colony.

    ${scoringLegend(colony(state, player).length, geneCount(state, player), state.players[player].color, false)}

    Advanced genes count as two; Ray Protection counts as zero. Score every round. Skip occupied scores on the track.

    `; - } else if (modalKind === "journal") - html = `LIFE IN THE SOUP

    Journal

      ${state.log - .slice(-150) - .reverse() - .map( - (l) => - `
    1. Round ${l.round}${richText(l.text)}
    2. `, - ) - .join("")}
    `; - else if (modalKind === "results") + } else if (modalKind === "results") html = `

    A little life goes a long way.

    ${esc(state.players[state.winner]?.name ?? "")} wins.

      ${state.players .map((p, i) => ({ ...p, index: i })) .sort((a, b) => b.score - a.score) @@ -340,7 +345,7 @@ export function mountGame( ) .join("")}`; } else - html = `HOW LIFE WORKS

      Welcome to the soup.

      Grow your population and evolve genes. At the end of each round, earn evolution points from your amoebas and genes. Advance along the evolution track, skipping occupied scores. When a colony reaches 42 points — or the last environment card is revealed — finish the round. The highest score wins.

      1 · Move & feed

      Lowest score first; amoebas act in number order. Drift with the current for free, or pay 1 BP to swim: roll a die for direction. 1 west, 2 north, 3 east, 4 south, 5 stay, 6 choose. A blocked move stays in place.

      Food & injuries

      Eat three nutrients, never your own colour. With four colonies, eat one of each other colour; with three, eat two of one and one of the other. After eating, excrete two nutrients of your own colour onto the same space. If you cannot eat, excrete nothing and take one injury instead.

      2 · Environment

      A new card sets the next current and ozone layer. If your mutation exceeds the ozone, pay the difference in BP or discard genes. No defects in round one.

      3 · New genes

      Highest score first. Buy as many genes as you can afford. Advanced genes replace a prerequisite owned since a previous round.

      4 · Cell division

      Receive 10 BP. Each new amoeba costs 6 BP and goes next to one of yours, without sharing your colour's space. With one amoeba, the second may go anywhere. With none, the first returns anywhere for free.

      5 · Survival

      Two injuries cause death, or three with Longevity. Return two food cubes of every colour to that space. Aggression happens after natural deaths.

      6 · Evolution points

      Your living amoebas and genes earn points automatically. See the scoring table on the board.

      Food supply

      There are 55 cubes of each colour. If the supply runs out, place only the cubes still available. Dead amoeba numbers may be used again.

      Read the original English rules (PDF) ↗

      `; + html = `HOW LIFE WORKS

      Welcome to the soup.

      Grow your population and evolve genes. At the end of each round, earn evolution points from your amoebas and genes. Advance along the evolution track, skipping occupied scores. When a colony reaches 42 points — or the last environment card is revealed — finish the round. The highest score wins.

      1 · Move & feed

      Lowest score first; amoebas act in number order. Drift with the current for free, or pay 1 BP to swim: roll a die for direction. 1 west, 2 north, 3 east, 4 south, 5 stay, 6 choose. A blocked move stays in place.

      Food & injuries

      Eat three nutrients, never your own colour. With four colonies, eat one of each other colour; with three, eat two of one and one of the other. After eating, excrete two nutrients of your own colour onto the same space. If you cannot eat, excrete nothing and take one injury instead.

      2 · Environment

      A new card sets the next current and ozone layer. If your mutation exceeds the ozone, pay the difference in BP or discard genes. No defects in round one.

      3 · New genes

      Highest score first. Buy as many genes as you can afford. Advanced genes replace a prerequisite owned since a previous round.

      4 · Cell division

      Receive 10 BP. Each new amoeba costs 6 BP and goes next to one of yours, without sharing your colour's space. With one amoeba, the second may go anywhere. With none, the first returns anywhere for free.

      5 · Survival

      Two injuries cause death, or three with Longevity. Return two food cubes of every colour to that space. Aggression happens after natural deaths.

      6 · Evolution points

      Your living amoebas and genes earn points automatically. See the scoring table on the board.

      Food supply

      There are 55 cubes of each colour. If the supply runs out, place only the cubes still available. Dead amoeba numbers may be used again.

      `; $(".modal-content").innerHTML = html; if (modalKind === "rules") { for (const text of $(".modal-content").querySelectorAll( @@ -410,6 +415,10 @@ export function mountGame( dialog.close(); return; } + if (el.dataset.ui === "chat" || el.dataset.ui === "journal") { + activity.open(el.dataset.ui); + return; + } if (el.dataset.ui === "fullscreen") { void toggleFullscreen(); return; @@ -442,6 +451,7 @@ export function mountGame( dialog.close(); }, destroy() { + activity.destroy(); dialog.close(); root.remove(); },