Clarify soup lessons, identify genes and improve viewer presentation

This commit is contained in:
coyotte508 2026-09-19 10:55:17 +02:00
commit 839a0805b2
14 changed files with 304 additions and 38 deletions

View file

@ -0,0 +1,30 @@
"""Rebuild with: uv run --with fonttools --with brotli scripts/build-display-font.py"""
from pathlib import Path
from fontTools.ttLib import TTFont
assets = Path(__file__).resolve().parent.parent / "viewer" / "assets"
font = TTFont(assets / "font-4.ttf", recalcTimestamp=False)
# Upstream Lilita One has undersized glyph bounds that Firefox flags. Keep its
# outlines, but recalculate the bounds and rename this derivative per the OFL.
for glyph in font["glyf"].glyphs.values():
glyph.expand(font["glyf"])
glyph.recalcBounds(font["glyf"])
names = {
1: "Soup Display",
2: "Regular",
3: "Soup Display Regular 1.0",
4: "Soup Display Regular",
6: "SoupDisplay-Regular",
16: "Soup Display",
17: "Regular",
}
for record in font["name"].names:
if record.nameID in names:
record.string = names[record.nameID].encode(record.getEncoding())
font.flavor = "woff2"
font.save(assets / "soup-display.woff2")

View file

@ -16,7 +16,7 @@ await build({
format: "iife",
target: "es2022",
outfile: "dist/viewer.js",
loader: { ".ttf": "dataurl" },
loader: { ".ttf": "dataurl", ".woff2": "dataurl" },
minify: true,
});
await build({
@ -26,10 +26,10 @@ await build({
format: "esm",
target: "es2022",
outfile: "dist/preview.js",
loader: { ".ttf": "dataurl" },
loader: { ".ttf": "dataurl", ".woff2": "dataurl" },
minify: false,
});
await writeFile(
"dist/index.html",
'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Primordial Soup · Private playtest</title><link rel="stylesheet" href="preview.css"></head><body><div id="preview-nav"></div><div id="game"></div><script type="module" src="preview.js"></script></body></html>',
'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Primordial Soup</title><link rel="stylesheet" href="preview.css"></head><body><div id="preview-nav"></div><div id="game"></div><script type="module" src="preview.js"></script></body></html>',
);

View file

@ -21,5 +21,5 @@ createServer(async (req, res) => {
res.end("Not found");
}
}).listen(5221, "127.0.0.1", () =>
console.log("Primordial Soup private playtest: http://127.0.0.1:5221"),
console.log("Primordial Soup: http://127.0.0.1:5221"),
);

View file

@ -46,6 +46,7 @@ const iconPaths = {
'<path d="M11 5C4-2-3 14 5 19c4 3 5-3 7-3s3 6 7 3c8-5 1-21-6-14Z"/><circle cx="7" cy="11" r="2"/><circle cx="17" cy="11" r="2"/>',
shield:
'<path d="m12 2 9 4v7q-2 6-9 9-7-3-9-9V6Z"/><path d="m8 12 3 3 5-6"/>',
gene: '<path d="M7 3c0 8 10 10 10 18M17 3c0 8-10 10-10 18M7.5 5h9M9 9h6m-6 6h6m-7.5 4h9"/>',
undo: '<path d="M4 11a8 8 0 1 1 2 9M4 4v7h7"/>',
};
const icon = (name) =>

Binary file not shown.

View file

@ -27,9 +27,9 @@
src: url(./assets/font-3.ttf) format("truetype");
}
@font-face {
font-family: "Lilita One";
font-family: "Soup Display";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(./assets/font-4.ttf) format("truetype");
src: url(./assets/soup-display.woff2) format("woff2");
}

163
viewer/gene-art.js Normal file
View file

@ -0,0 +1,163 @@
import { amoeba } from "./art.js";
const creature = (
x = 16,
y = 8,
size = 86,
variant = 0,
feature = "",
color = "green",
) =>
amoeba(color, variant, feature).replace(
"<svg viewBox=",
`<svg x="${x}" y="${y}" width="${size}" height="${size}" viewBox=`,
);
const cube = (x, y, color = "#e99b8a", size = 12) =>
`<rect x="${x}" y="${y}" width="${size}" height="${size}" rx="3" fill="${color}" stroke="#64785a" stroke-width="1.6"/><path d="m${x + 3} ${y + 3}h${size - 6}" stroke="#fff" stroke-opacity=".65" stroke-width="2" stroke-linecap="round"/>`;
const die = (x, y, dots) =>
`<g transform="translate(${x} ${y})"><rect width="23" height="23" rx="5" fill="#fffbed" stroke="#688464" stroke-width="1.8"/>${dots.map(([x, y]) => `<circle cx="${x}" cy="${y}" r="2" fill="#52734c"/>`).join("")}</g>`;
const arrows = (path, color = "#668f72") =>
`<path d="${path}" fill="none" stroke="${color}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>`;
export function geneArt(id) {
let art;
switch (id) {
case "movement1":
art =
creature(16, 0, 85, 1, "movement") +
die(28, 71, [
[6, 6],
[17, 17],
]) +
die(66, 71, [
[6, 6],
[17, 6],
[6, 17],
[17, 17],
]);
break;
case "movement2":
art =
creature(16, 4, 86, 1, "movement") +
'<circle cx="89" cy="73" r="19" fill="#fffbed" stroke="#668f72" stroke-width="2"/>' +
arrows(
"M89 59v28m-14-14h28m-18-10 4-4 4 4m6 6 4 4-4 4m-14 6 4 4 4-4m-14-14-4 4 4 4",
);
break;
case "streamline":
art =
arrows(
"M7 29c24-22 62-22 102 0M6 77c27 23 74 18 106-3M4 54h15m84-2h12",
"#71aaa1",
) +
creature(20, 7, 83, 2, "movement") +
arrows("m100 18 10 11-14 1m5 38 11 7-12 6", "#71aaa1");
break;
case "speed":
art =
arrows("M3 29h27M0 46h21M5 65h23", "#9bb28c") +
creature(26, 8, 86, 2, "movement") +
'<path d="m87 55-19 23h13l-5 20 24-27H87l6-16Z" fill="#f3d279" stroke="#a58740" stroke-width="1.6"/>';
break;
case "division":
art =
'<path d="M43 63q17-18 34-1" fill="none" stroke="#b4d16d" stroke-width="18"/>' +
creature(0, 15, 73, 1) +
creature(52, 24, 66, 2) +
arrows("M43 10h-9l-5 8m45-8h9l5 8", "#8aa16c");
break;
case "spores":
art =
creature(22, 20, 77, 0) +
creature(2, 0, 35, 1) +
creature(85, 5, 29, 2) +
creature(92, 68, 24, 0) +
'<g fill="#b8d76c" stroke="#729550" stroke-width="1"><circle cx="68" cy="9" r="4"/><circle cx="10" cy="63" r="3"/><circle cx="102" cy="46" r="4"/></g>';
break;
case "intelligence":
art =
creature(16, 14, 86, 0) +
'<g fill="none" stroke="#667757" stroke-width="2.7"><rect x="42" y="41" width="19" height="17" rx="5"/><rect x="62" y="40" width="19" height="17" rx="5"/><path d="M61 47h2m-27-2h6m39-1h5"/></g><path d="M72 13c0-13 19-13 19 0 0 6-5 6-5 12h-9c0-6-5-6-5-12Z" fill="#ffe89b" stroke="#ad9b4d" stroke-width="1.7"/><path d="M78 29h7m-16-21-4-2m28 2 4-2m-16-8v-4" stroke="#ad9b4d" stroke-width="2" stroke-linecap="round"/>';
break;
case "defense":
art =
creature(15, 8, 85, 2) +
'<circle cx="86" cy="69" r="25" fill="#c69567" stroke="#876447" stroke-width="3"/><path d="M74 49v40m12-44v47m12-42v38" stroke="#aa7b52" stroke-width="2"/><circle cx="86" cy="69" r="9" fill="#e9dfba" stroke="#887e61" stroke-width="2"/>';
break;
case "armor":
art =
creature(14, 9, 89, 2, "shield") +
'<path d="M34 38C32 0 83 0 87 36l-20-5-4 8-7-8Z" fill="#c9d5cc" stroke="#647d71" stroke-width="2"/><path d="M60 11v19m-19-3 10-9" stroke="#f6fcf5" stroke-width="4" stroke-linecap="round"/>';
break;
case "escape":
art =
arrows("M5 76q-5-35 25-45m-10-3 11 2-3 12", "#a0b496") +
creature(30, 2, 78, 1, "movement") +
arrows("M44 83q38 17 64-12m-3 13 4-14-15 1", "#8bab91");
break;
case "substitution":
art =
creature(21, 0, 76, 2) +
cube(11, 76) +
cube(65, 74, "#8eb8d5") +
cube(85, 74, "#8eb8d5") +
arrows("M33 80h22m-5-5 5 5-5 5M57 92H34m5-4-5 4 5 4");
break;
case "ray":
art =
'<circle cx="16" cy="17" r="9" fill="#f3d279"/><path d="M16 2V0M1 17h-4m7-12-4-4m24 4 4-4m-3 26 4 4" stroke="#d5b557" stroke-width="2"/>' +
creature(24, 20, 76, 0) +
'<path d="M26 33Q58-15 94 30l-17-2-9 8-14-6-11 8Z" fill="#a2c7b5" stroke="#5d8f7b" stroke-width="2"/><path d="M59 17q-3 58 6 51m-6-51L43 38m16-21 18 11" fill="none" stroke="#5d8f7b" stroke-width="2"/>';
break;
case "tentacle":
art =
'<path d="M38 65C4 71-4 27 15 28s11 18 3 13M83 64c31 15 41-14 29-23-11-6-13 9-5 8" fill="none" stroke="#85ad57" stroke-width="9" stroke-linecap="round"/>' +
creature(19, 7, 84, 1) +
cube(8, 20, "#8eb8d5") +
cube(96, 35, "#eed17c");
break;
case "holding":
art =
creature(0, 10, 79, 0) +
creature(60, 24, 54, 1, "", "blue") +
'<g fill="none" stroke="#708d78" stroke-width="4"><rect x="49" y="71" width="19" height="12" rx="6" transform="rotate(-24 49 71)"/><rect x="61" y="69" width="19" height="12" rx="6" transform="rotate(-24 61 69)"/></g>';
break;
case "longevity":
art =
creature(14, 8, 87, 0) +
'<rect x="31" y="64" width="26" height="12" rx="4" fill="#f3dca7" stroke="#b69f6f" stroke-width="1.4" transform="rotate(25 44 70)"/><path d="M44 67v6m-3-3h6" stroke="#bc9471"/><path d="M92 38s-20-12-16-24c3-7 13-6 16 1 4-7 15-7 16 1 2 10-16 22-16 22Z" fill="#e49c8c" stroke="#a56860" stroke-width="2"/>';
break;
case "frugality":
art =
creature(16, 4, 86, 1, "food") +
'<ellipse cx="42" cy="83" rx="25" ry="9" fill="#fff8e6" stroke="#b9b68c" stroke-width="2"/>' +
cube(35, 69, "#8eb8d5");
break;
case "struggle":
art =
creature(16, 6, 87, 2) +
'<g fill="none" stroke="#899d8f" stroke-width="3" stroke-linecap="round"><path d="M15 50v40M8 38v12q7 8 14 0V38m-7 0v13M102 37v53m0-53q-15 12 0 24"/></g><path d="M53 63q8 10 17-1" fill="#835548" stroke="#56713f" stroke-width="1.5"/>';
break;
case "parasitism":
art =
creature(0, 17, 75, 0) +
creature(64, 29, 50, 1, "", "red") +
'<path d="m46 64 11 8h20V49" fill="none" stroke="#b89862" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><circle cx="87" cy="25" r="12" fill="#efdb89" stroke="#ac9954" stroke-width="2"/><path d="M85 18h4m-3 0v6l-4 6h10l-4-6v-6" fill="none" stroke="#978847" stroke-width="1.6"/>';
break;
case "persistence":
art =
arrows(
"M15 60C-5 6 78-9 105 29m-2-14 3 15-15 1M105 44c24 51-51 67-79 37m0 13V80h14",
"#86a26b",
) + creature(24, 17, 72, 1);
break;
case "aggression":
art =
creature(16, 4, 86, 0, "spines") +
'<path d="M24 48C4 38 0 59 8 68l15 2 8-11Z" fill="#de9380" stroke="#ab6f5c" stroke-width="2"/><path d="M94 47c20-10 24 11 16 20l-15 2-8-11Z" fill="#de9380" stroke="#ab6f5c" stroke-width="2"/><path d="m11 68 12 2m74-1 10-2" stroke="#f2c7a5" stroke-width="6"/>';
break;
default:
art = creature();
}
return `<svg class="gene-illustration" viewBox="0 0 120 100" aria-hidden="true">${art}</svg>`;
}

27
viewer/gene-label.js Normal file
View file

@ -0,0 +1,27 @@
import { GENES, GENE } from "../engine/catalog.js";
import { icon } from "./art.js";
const escape = (text) =>
String(text).replace(
/[&<>"']/g,
(c) =>
({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[
c
],
);
export function geneLabel(id, name = GENE[id].name) {
return `<span class="gene-label" title="Gene · ${escape(GENE[id].text)}">${icon("gene")}<span>${escape(name)}</span></span>`;
}
const byName = Object.fromEntries(GENES.map((g) => [g.name, g.id]));
byName.Struggle = "struggle";
const pattern = new RegExp(
`\\b(${Object.keys(byName)
.sort((a, b) => b.length - a.length)
.join("|")})\\b`,
"g",
);
export function geneText(text) {
return escape(text).replace(pattern, (name) => geneLabel(byName[name], name));
}

View file

@ -4,6 +4,7 @@ import { createTutorial } from "@boardgamers/protocol/tutorial";
import { mountTutorialGuide } from "@boardgamers/protocol/tutorial/dom";
import { stripSecret } from "../engine/index.js";
import { chapters } from "./tutorials.js";
import { geneText } from "./gene-label.js";
import { mountGame } from "./ui.js";
export async function mountLesson(target, options) {
const chapter = chapters[options.chapter];
@ -33,7 +34,15 @@ export async function mountLesson(target, options) {
const removeGuide = mountTutorialGuide(ui.guide, tutorial, {
nextChapter: options.nextChapter,
});
const offLabels = tutorial.subscribe(() => {
for (const text of ui.guide.querySelectorAll(
".bgs-tutorial-body > p, .bgs-tutorial-feedback",
)) {
text.innerHTML = geneText(text.textContent);
}
});
return () => {
offLabels();
off();
removeGuide();
tutorial.destroy();

View file

@ -8,7 +8,7 @@ const params = new URLSearchParams(location.search),
target = document.querySelector("#game"),
nav = document.querySelector("#preview-nav");
nav.className = "practice-nav";
nav.innerHTML = `<span>Private local playtest</span><a href="/">Practice game</a><label>Learn <select aria-label="Tutorial chapter"><option value="">Choose a chapter</option>${chapterMetadata.map((c) => `<option value="${c.id}" ${c.id === chapter ? "selected" : ""}>${c.title}</option>`).join("")}</select></label>${chapter ? "" : '<button id="new-three">New 3-colony game</button><button id="new-four">New 4-colony game</button>'}`;
nav.innerHTML = `<span>Local preview</span><a href="/">Practice game</a><label>Learn <select aria-label="Tutorial chapter"><option value="">Choose a chapter</option>${chapterMetadata.map((c) => `<option value="${c.id}" ${c.id === chapter ? "selected" : ""}>${c.title}</option>`).join("")}</select></label>${chapter ? "" : '<button id="new-three">New 3-colony game</button><button id="new-four">New 4-colony game</button>'}`;
nav.querySelector("select").addEventListener("change", (e) => {
location.href = e.target.value ? `/?chapter=${e.target.value}` : "/";
});

View file

@ -88,7 +88,7 @@ button:active:not(:disabled) {
height: 52px;
}
.brand h1 {
font-family: "Lilita One", sans-serif;
font-family: "Soup Display", sans-serif;
font-size: 32px;
letter-spacing: -0.8px;
font-weight: 400;
@ -195,7 +195,7 @@ button:active:not(:disabled) {
display: flex;
align-items: center;
gap: 6px;
font-family: "Lilita One";
font-family: "Soup Display";
font-size: 26px;
}
.player-score svg {
@ -600,7 +600,7 @@ button:active:not(:disabled) {
letter-spacing: 1.6px;
}
.colony-heading h2 {
font-family: "Lilita One";
font-family: "Soup Display";
font-size: 27px;
font-weight: 400;
margin: 6px 0 0;
@ -852,7 +852,7 @@ button:active:not(:disabled) {
transform: rotate(180deg);
}
.round > strong {
font-family: "Lilita One";
font-family: "Soup Display";
font-size: 36px;
font-weight: 400;
}
@ -988,7 +988,7 @@ dialog::backdrop {
font-size: 23px;
}
dialog h2 {
font: 32px "Lilita One";
font: 32px "Soup Display";
margin: 5px 0 12px;
}
dialog p {

View file

@ -9,13 +9,8 @@
height: 74px;
flex: none;
}
.edition-tag {
.soup .utilities {
margin-left: auto;
color: #6e8166;
font-size: 11px;
padding: 4px 9px;
border: 1px solid #cdd8c1;
border-radius: 20px;
}
.utilities .quiet-button svg {
width: 16px;
@ -169,7 +164,7 @@
letter-spacing: 2px;
}
.soup-board-key > b {
font: 48px "Lilita One";
font: 48px "Soup Display";
}
.soup-board-key > small {
font-size: 10px;
@ -387,7 +382,7 @@
}
.results-list li > b {
margin-left: auto;
font: 30px "Lilita One";
font: 30px "Soup Display";
}
.tutorial-slot:empty {
display: none;
@ -539,9 +534,6 @@
.soup .brand > span {
width: 35px;
}
.edition-tag {
display: none;
}
.soup .players {
gap: 4px;
padding: 10px 0;
@ -800,3 +792,29 @@
margin: 6px 0;
}
}
.soup:fullscreen {
max-width: none;
overflow-y: auto;
background-color: #eff1e6;
}
.gene-label {
display: inline-flex;
align-items: center;
gap: 0.3em;
padding: 0.05em 0.45em;
border: 1px solid #b9cda1;
border-radius: 0.45em;
background: #edf3df;
color: #3f6038;
font:
600 0.92em / 1.5 "DM Sans",
sans-serif;
vertical-align: baseline;
white-space: nowrap;
}
.gene-label svg {
width: 1.05em;
height: 1.05em;
flex: none;
}

View file

@ -169,11 +169,11 @@ export const chapters = {
step(
"food",
"Eat other colours",
"With four colonies, an amoeba eats one nutrient of each other colour: coral, blue and gold. It never eats green. Use Eat below; it will leave two green nutrients for the others.",
"With four colonies, your green amoeba eats one nutrient of each other colour: coral, blue and gold. It never eats its own colour. After eating, it excretes two nutrients of its own colour onto the same space — two green cubes for your colony. Click Eat to see this happen.",
(s) => s.history.some((h) => h.move.type === "eat"),
only("eat"),
"actions",
"Your amoeba ate three nutrients and returned two green ones.",
"Your amoeba ate one coral, one blue and one gold nutrient, then excreted two green nutrients onto this space.",
),
],
"Each amoeba moves and then feeds. Drift follows the current for free; at a shore or the island, it stays in place. With three colonies, a meal is two cubes of one other colour and one of the remaining colour.",
@ -185,7 +185,7 @@ export const chapters = {
step(
"choose",
"A little effort",
"To try another direction, use Swim. It costs 1 biological point (BP). Without movement genes, a die chooses the direction: 1 west, 2 north, 3 east, 4 south, 5 stay, 6 choose.",
"To try another direction, use Swim. It costs 1 biological point (BP). Without a movement gene — an ability you can buy later in the game — a die chooses the direction: 1 west, 2 north, 3 east, 4 south, 5 stay, 6 choose.",
(s) => s.tasks[0]?.kind === "direction",
only("swim"),
"actions",
@ -201,7 +201,7 @@ export const chapters = {
step(
"eat",
"Movement comes before dinner",
"Feed using the ordinary Eat control. If the right food is unavailable, an amoeba eats nothing, leaves nothing and receives one injury.",
"Click Eat to consume the other colours and excrete two green nutrients onto this space. If the right food is unavailable, your amoeba eats nothing, excretes nothing and receives one injury.",
(s) =>
s.history.some(
(h) => h.move.type === "eat" || h.move.type === "starve",
@ -210,7 +210,7 @@ export const chapters = {
"actions",
),
],
"Movement I lets you choose between two dice. Movement II lets you choose a direction without rolling. Streamline removes the BP cost. Speed adds an optional second swim, then you feed once.",
"Later in the game, you can buy genes for your colony. The Movement I gene lets you choose between two dice; upgrading it to Movement II lets you choose a direction without rolling. Streamline and Speed are other genes you can acquire: one removes the BP cost, the other adds an optional second swim before feeding.",
),
division: config(
"division",

View file

@ -16,6 +16,8 @@ import {
amoeba as findAmoeba,
} from "../engine/index.js";
import { amoeba, icon, colors } from "./art.js";
import { geneArt } from "./gene-art.js";
import { geneLabel, geneText } from "./gene-label.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";
@ -72,7 +74,7 @@ export function moveLabel(m, s) {
case "pay-defect":
return `Pay ${m.amount} BP`;
case "discard":
return `Give up ${GENE[m.gene].name}`;
return `Give up ${geneLabel(m.gene)}`;
case "buy":
return `Evolve · ${GENE[m.gene].cost} BP`;
case "divide":
@ -146,7 +148,7 @@ export function mountGame(
const root = document.createElement("div");
root.className = "soup game-shell";
target.append(root);
root.innerHTML = `<header class="topbar"><div class="brand"><span>${amoeba("green", 0)}</span><div><h1>primordial soup<span class="title-dot">.</span></h1><span class="byline">DORIS MATTHÄUS & FRANK NESTEL</span></div></div><span class="edition-tag">Private playtest</span><nav class="utilities" aria-label="Game options"><button class="quiet-button" data-ui="genes">${icon("spark")} Genes</button><button class="icon-button" data-ui="rules" aria-label="How to play">${icon("help")}</button><button class="icon-button" data-ui="fullscreen" aria-label="Fullscreen">${icon("expand")}</button></nav></header>
root.innerHTML = `<header class="topbar"><div class="brand"><span>${amoeba("green", 0)}</span><div><h1>primordial soup<span class="title-dot">.</span></h1><span class="byline">DORIS MATTHÄUS & FRANK NESTEL</span></div></div><nav class="utilities" aria-label="Game options"><button class="quiet-button" data-ui="genes">${icon("spark")} Genes</button><button class="icon-button" data-ui="rules" aria-label="How to play">${icon("help")}</button><button class="icon-button" data-ui="fullscreen" aria-label="Fullscreen">${icon("expand")}</button></nav></header>
<div class="tutorial-slot"></div><section class="players" aria-label="The colonies" data-tutorial="colonies"></section>
<main class="play-area"><section class="pond-section" aria-label="Primordial soup board"><div class="pond-toolbar"><div><span class="eyebrow">A LITTLE LIFE IN A BIG SOUP</span><span class="pond-subtitle" id="turn-order"></span></div><button class="quiet-button" data-ui="journal">${icon("history")} Journal</button></div><div class="board-wrap"><div class="board" data-tutorial="board"><svg id="pond-art" viewBox="0 0 900 650" preserveAspectRatio="none" aria-hidden="true">${pondArt()}</svg><div class="cells"></div><div class="organisms"></div><div class="current-compass" data-tutorial="current"><span>CURRENT</span><div class="compass-arrow">➜</div><b class="compass-label"></b><small>Ozone <strong class="ozone"></strong></small></div><div class="soup-board-key"><span>EVOLUTION</span><b>42</b><small>Finish the round<br>when a colony reaches 42.</small></div></div></div><div class="pond-bottom"><span class="last-move" aria-live="polite"></span><span class="food-reserve" title="Food cubes remaining in the common supply"></span></div></section><aside class="colony-panel" data-tutorial="colony"></aside></main>
<footer class="turnbar" data-tutorial="actions"><div class="round"><span>ROUND</span><strong class="round-number"></strong></div><div class="turn-details"><div class="phase-label"></div><div class="phase-instruction" aria-live="polite"></div><div class="phase-dots"></div></div><div class="action-buttons"></div></footer><div class="game-message" role="alert"></div>
@ -253,7 +255,7 @@ export function mountGame(
$(".food-reserve").innerHTML =
`<small>Supply</small>${nutrients(state.supply)}`;
$(".colony-panel").innerHTML =
`<div class="colony-heading"><div><span class="eyebrow">${shown === seat ? "YOUR COLONY" : "THE COLONY"}</span><h2>${esc(pl.name)}</h2></div><div class="bio-balance" data-tutorial="bp" title="Biological points">${icon("bio")}<strong>${pl.bp}</strong><span>BP</span></div></div><div class="specimen"><div class="specimen-orbit"></div><div id="selected-portrait">${amoeba(pl.color, a?.n ?? 1)}</div><span class="specimen-coord">${a ? coordinate(a.cell) : "—"}</span></div><div class="specimen-heading"><h3>${a ? `Amoeba #${a.n}` : "Ready to grow"}</h3><span class="health ${a?.hp ? "hurt" : ""}">${a?.hp ? `${a.hp} ${a.hp === 1 ? "injury" : "injuries"}` : "Feeling great"}</span></div><div class="diet"><span>Food colours</span><div>${state.players.map((_, p) => (p !== shown ? food(p) : "")).join("")}</div></div>${positions.length ? `<label class="amoeba-picker">New amoeba <select aria-label="Amoeba number">${[...new Set(positions.map((m) => m.n))].map((n) => `<option value="${n}" ${n === number ? "selected" : ""}>#${n}</option>`).join("")}</select></label>` : ""}<div class="gene-heading"><h3>Genes <span>${geneCount(state, shown)}</span></h3><button class="text-button" data-ui="genes">${t?.kind === "genes" && canAct() ? "Evolve ↗" : "Gene pool ↗"}</button></div><div class="gene-list" data-tutorial="genes">${pl.genes.map((g) => `<button class="gene" data-gene="${g.id}"><span class="gene-art">${icon(g.id === "movement1" || g.id === "movement2" ? "wave" : g.id === "division" ? "divide" : g.id === "armor" || g.id === "defense" ? "shield" : "spark")}</span><span class="gene-text"><strong>${GENE[g.id].name}</strong><p>${GENE[g.id].points === 2 ? "Advanced gene" : "Colony adaptation"}</p></span><span class="gene-sensitivity" title="Mutation sensitivity">${icon("sun")}${GENE[g.id].mutation}</span></button>`).join("") || '<p class="empty-genes">No genes yet. New abilities evolve in phase 3.</p>'}</div><div class="colony-metrics"><span>${icon("sun")} <strong>${mutation(state, shown)}</strong> mutation</span><span title="Evolution before any further division or deaths">${icon("spark")} <strong>+${evolution(state, shown)}</strong> evolution</span></div>`;
`<div class="colony-heading"><div><span class="eyebrow">${shown === seat ? "YOUR COLONY" : "THE COLONY"}</span><h2>${esc(pl.name)}</h2></div><div class="bio-balance" data-tutorial="bp" title="Biological points">${icon("bio")}<strong>${pl.bp}</strong><span>BP</span></div></div><div class="specimen"><div class="specimen-orbit"></div><div id="selected-portrait">${amoeba(pl.color, a?.n ?? 1)}</div><span class="specimen-coord">${a ? coordinate(a.cell) : "—"}</span></div><div class="specimen-heading"><h3>${a ? `Amoeba #${a.n}` : "Ready to grow"}</h3><span class="health ${a?.hp ? "hurt" : ""}">${a?.hp ? `${a.hp} ${a.hp === 1 ? "injury" : "injuries"}` : "Feeling great"}</span></div><div class="diet"><span>Food colours</span><div>${state.players.map((_, p) => (p !== shown ? food(p) : "")).join("")}</div></div>${positions.length ? `<label class="amoeba-picker">New amoeba <select aria-label="Amoeba number">${[...new Set(positions.map((m) => m.n))].map((n) => `<option value="${n}" ${n === number ? "selected" : ""}>#${n}</option>`).join("")}</select></label>` : ""}<div class="gene-heading"><h3>Genes <span>${geneCount(state, shown)}</span></h3><button class="text-button" data-ui="genes">${t?.kind === "genes" && canAct() ? "Evolve ↗" : "Gene pool ↗"}</button></div><div class="gene-list" data-tutorial="genes">${pl.genes.map((g) => `<button class="gene" data-gene="${g.id}"><span class="gene-art">${icon("gene")}</span><span class="gene-text"><strong>${GENE[g.id].name}</strong><p>${GENE[g.id].points === 2 ? "Advanced gene" : "Colony adaptation"}</p></span><span class="gene-sensitivity" title="Mutation sensitivity">${icon("sun")}${GENE[g.id].mutation}</span></button>`).join("") || '<p class="empty-genes">No genes yet. New abilities evolve in phase 3.</p>'}</div><div class="colony-metrics"><span>${icon("sun")} <strong>${mutation(state, shown)}</strong> mutation</span><span title="Evolution before any further division or deaths">${icon("spark")} <strong>+${evolution(state, shown)}</strong> evolution</span></div>`;
$(".round-number").textContent = state.round || "—";
$(".phase-label").textContent = state.finished
? "Evolution complete"
@ -293,7 +295,7 @@ export function mountGame(
const moves = actions()
.map((m, i) => ({ m, i }))
.filter(({ m }) => m.type === "buy" && m.gene === g.id);
return `<article class="shop-card" data-tutorial="gene-${g.id}"><div class="shop-art">${amoeba("green", g.cost, g.id.includes("movement") ? "movement" : g.id === "armor" ? "shield" : g.id === "frugality" ? "food" : "")}</div><div class="shop-body"><h3>${g.name}</h3><span class="gene-price">${g.cost} BP · ${g.mutation} mutation · ${remaining} left</span><p>${g.text}</p>${g.base.length ? `<small>Trade in ${g.base.map((id) => GENE[id].name).join(" or ")}, owned since a previous round.</small>` : ""}${moves.map(({ m, i }) => actionButton(m, i)).join("") || `<span class="gene-unavailable">${state.players[seat ?? 0].genes.some((x) => x.id === g.id) ? "Already owned" : !remaining ? "All copies owned" : g.base.length ? "Requires an earlier gene" : `${g.cost} BP`}</span>`}</div></article>`;
return `<article class="shop-card" data-tutorial="gene-${g.id}"><div class="shop-art">${geneArt(g.id)}</div><div class="shop-body"><h3>${geneLabel(g.id)}</h3><span class="gene-price">${g.cost} BP · ${g.mutation} mutation · ${remaining} left</span><p>${geneText(g.text)}</p>${g.base.length ? `<small>Trade in ${g.base.map((id) => geneLabel(id)).join(" or ")}, owned since a previous round.</small>` : ""}${moves.map(({ m, i }) => actionButton(m, i)).join("") || `<span class="gene-unavailable">${state.players[seat ?? 0].genes.some((x) => x.id === g.id) ? "Already owned" : !remaining ? "All copies owned" : g.base.length ? "Requires an earlier gene" : `${g.cost} BP`}</span>`}</div></article>`;
})
.join("")}</div>`;
else if (modalKind === "journal")
@ -316,20 +318,39 @@ export function mountGame(
.join("")}</ol>`;
else if (GENE[modalKind]) {
const g = GENE[modalKind];
html = `<div class="gene-explainer-art">${amoeba("green", g.cost)}</div><span class="eyebrow">${g.points === 2 ? "ADVANCED GENE" : "COLONY GENE"}</span><h2>${g.name}</h2><p>${g.text}</p><p>${g.cost} BP · ${g.mutation} mutation · counts as ${g.points} gene${g.points === 1 ? "" : "s"} for evolution.</p><div class="action-buttons">${actions()
html = `<div class="gene-explainer-art">${geneArt(g.id)}</div><span class="eyebrow">${g.points === 2 ? "ADVANCED GENE" : "COLONY GENE"}</span><h2>${geneLabel(g.id)}</h2><p>${geneText(g.text)}</p><p>${g.cost} BP · ${g.mutation} mutation · counts as ${g.points} gene${g.points === 1 ? "" : "s"} for evolution.</p><div class="action-buttons">${actions()
.map((m, i) =>
m.type === "discard" && m.gene === g.id ? actionButton(m, i) : "",
)
.join("")}</div>`;
} else
html = `<span class="eyebrow">HOW LIFE WORKS</span><h2>Welcome to the soup.</h2><p>Grow your population and evolve genes. At the end of each round, advance along the evolution track. When a colony reaches 42 — or the last environment card is revealed — finish the round. The highest score wins.</p><p class="playtest-note">Private playtest: the exact printed environment-card distribution still needs verification. Full games currently use a provisional deck; tutorial positions are prepared.</p><div class="help-steps"><section><h3>1 · Move & feed</h3><p>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.</p></section><section><h3>Food & injuries</h3><p>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. Leave two of your own. If you cannot eat, take one injury instead.</p></section><section><h3>2 · Environment</h3><p>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.</p></section><section><h3>3 · New genes</h3><p>Highest score first. Buy as many genes as you can afford. Advanced genes replace a prerequisite owned since a previous round.</p></section><section><h3>4 · Cell division</h3><p>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.</p></section><section><h3>5 · Survival</h3><p>Two injuries cause death, or three with Longevity. Return two food cubes of every colour to that space. Aggression happens after natural deaths.</p></section><section><h3>6 · Evolution</h3><p>3 / 4 / 5 / 6 / 7 amoebas advance 1 / 2 / 4 / 5 / 6 spaces. 3 / 4 / 5 / 6+ genes add 1 / 2 / 3 / 4. Advanced genes count twice; Ray Protection does not count. Jump over occupied scores.</p></section><section><h3>Food supply</h3><p>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.</p></section></div><p><a href="${RULES_URL}" target="_blank" rel="noopener">Read the original English rules (PDF) ↗</a></p>`;
html = `<span class="eyebrow">HOW LIFE WORKS</span><h2>Welcome to the soup.</h2><p>Grow your population and evolve genes. At the end of each round, advance along the evolution track. When a colony reaches 42 — or the last environment card is revealed — finish the round. The highest score wins.</p><div class="help-steps"><section><h3>1 · Move & feed</h3><p>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.</p></section><section><h3>Food & injuries</h3><p>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.</p></section><section><h3>2 · Environment</h3><p>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.</p></section><section><h3>3 · New genes</h3><p>Highest score first. Buy as many genes as you can afford. Advanced genes replace a prerequisite owned since a previous round.</p></section><section><h3>4 · Cell division</h3><p>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.</p></section><section><h3>5 · Survival</h3><p>Two injuries cause death, or three with Longevity. Return two food cubes of every colour to that space. Aggression happens after natural deaths.</p></section><section><h3>6 · Evolution</h3><p>3 / 4 / 5 / 6 / 7 amoebas advance 1 / 2 / 4 / 5 / 6 spaces. 3 / 4 / 5 / 6+ genes add 1 / 2 / 3 / 4. Advanced genes count twice; Ray Protection does not count. Jump over occupied scores.</p></section><section><h3>Food supply</h3><p>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.</p></section></div><p><a href="${RULES_URL}" target="_blank" rel="noopener">Read the original English rules (PDF) ↗</a></p>`;
$(".modal-content").innerHTML = html;
if (modalKind === "rules") {
for (const text of $(".modal-content").querySelectorAll(
".help-steps p",
)) {
text.innerHTML = geneText(text.textContent);
}
}
}
function open(kind) {
modalKind = kind;
renderModal();
if (!dialog.open) dialog.showModal();
}
async function toggleFullscreen() {
$(".game-message").textContent = "";
try {
if (onFullscreen) await onFullscreen();
else if (document.fullscreenElement) await document.exitFullscreen();
else if (root.requestFullscreen) await root.requestFullscreen();
else throw new Error("Fullscreen is not available in this browser.");
} catch (error) {
$(".game-message").textContent =
error.message || "Fullscreen could not be opened.";
}
}
root.addEventListener("click", (e) => {
const el = e.target.closest("button");
if (!el) return;
@ -374,10 +395,7 @@ export function mountGame(
return;
}
if (el.dataset.ui === "fullscreen") {
if (onFullscreen) onFullscreen();
else if (!document.fullscreenElement)
root.requestFullscreen?.().catch(() => {});
else document.exitFullscreen?.().catch(() => {});
void toggleFullscreen();
return;
}
if (el.dataset.ui) open(el.dataset.ui);