Add an in-board scoring reference and clarify colony scoring

This commit is contained in:
coyotte508 2026-09-19 11:59:59 +02:00
commit 6a0507fd3f
6 changed files with 154 additions and 29 deletions

View file

@ -15,13 +15,15 @@ test("tutorials and journal use the board's nutrient colours and quantities", ()
test("resource references support written quantities, negative amounts and injuries", () => {
const html = richText(
"Two injuries, an injury, 2 mutation sensitivity and −1 BP.",
"Two injuries, an injury, 2 mutation sensitivity, −1 BP, two evolution points and 1 EP.",
);
for (const label of [
"2 injuries",
"1 injury",
"2 mutation sensitivity",
"-1 biological points",
"2 evolution points",
"1 evolution point",
]) {
assert.ok(html.includes(`aria-label="${label}"`));
}

View file

@ -15,6 +15,13 @@ export const injury = (n) =>
amount("injury", n, `${n} ${n === 1 ? "injury" : "injuries"}`, "injury");
export const sensitivity = (n) =>
amount("mutation", n, `${n} mutation sensitivity`, "sun");
export const evolutionPoints = (n) =>
amount(
"evolution",
n,
`${n} evolution point${Number(n) === 1 ? "" : "s"}`,
"spark",
);
const numbers = {
a: 1,
@ -33,7 +40,7 @@ const numbers = {
const quantity = `(?:[−-]?\\d+|${Object.keys(numbers).join("|")})`;
const colours = { green: 0, coral: 1, red: 1, blue: 2, gold: 3, yellow: 3 };
const resource = new RegExp(
`(?<!\\w)(?:(?<foodCount>${quantity}) (?<colour>green|coral|red|blue|gold|yellow) (?:nutrients?|(?:food )?cubes?|ones?)|(?<bp>${quantity}) BP|(?<injury>${quantity}) injur(?:y|ies)|(?<mutation>${quantity}) mutation(?: sensitivity)?)\\b`,
`(?<!\\w)(?:(?<foodCount>${quantity}) (?<colour>green|coral|red|blue|gold|yellow) (?:nutrients?|(?:food )?cubes?|ones?)|(?<bp>${quantity}) BP|(?<injury>${quantity}) injur(?:y|ies)|(?<evolution>${quantity}) (?:evolution points?|EP)|(?<mutation>${quantity}) mutation(?: sensitivity)?)\\b`,
"gi",
);
const count = (value) =>
@ -52,7 +59,9 @@ export function richText(text) {
? bp(count(g.bp))
: g.injury
? injury(count(g.injury))
: sensitivity(count(g.mutation));
: g.evolution
? evolutionPoints(count(g.evolution))
: sensitivity(count(g.mutation));
offset = match.index + match[0].length;
}
return result + geneText(text.slice(offset));

23
viewer/scoring-legend.js Normal file
View file

@ -0,0 +1,23 @@
import { populationPoints, genePoints } from "../engine/catalog.js";
import { amoeba, icon } from "./art.js";
import { evolutionPoints } from "./rich-text.js";
const counts = [2, 3, 4, 5, 6, 7];
const bucket = (n) => Math.max(2, Math.min(7, n));
export function scoringLegend(population, genes, color, expandable = true) {
const row = (label, symbol, current, points) =>
`<tr><th scope="row" title="${label}" aria-label="${label}">${symbol}</th>${counts
.map(
(n) =>
`<td${bucket(current) === n ? ' class="current"' : ""}>${points(n)}</td>`,
)
.join("")}</tr>`;
const populationScore = populationPoints(population);
const geneScore = genePoints(genes);
return `<table class="scoring-table"><caption>${expandable ? `<button class="scoring-help" data-ui="scoring" aria-label="Show scoring reference">${icon("spark")} Each round</button>` : `${icon("spark")} Each round`}</caption><thead><tr><th scope="col" aria-label="Number owned">#</th>${counts
.map((n) => `<th scope="col">${n === 2 ? "≤2" : n === 7 ? "7+" : n}</th>`)
.join(
"",
)}</tr></thead><tbody>${row("Living amoebas", amoeba(color), population, populationPoints)}${row("Genes used for scoring", icon("gene"), genes, genePoints)}</tbody></table><div class="scoring-total" title="Population points + gene points = total for this colony">${populationScore} + ${geneScore} = ${evolutionPoints(populationScore + geneScore)}</div><small class="scoring-finish">Finish the round at ${evolutionPoints(42)}.</small>`;
}

View file

@ -160,25 +160,88 @@
position: absolute;
left: 1%;
top: 9%;
width: 19%;
width: 21%;
display: flex;
flex-direction: column;
align-items: center;
color: #8a9e77;
color: #617653;
text-align: center;
gap: 5px;
gap: 6px;
font-size: 11px;
}
.soup-board-key > span {
font-size: 9px;
letter-spacing: 2px;
.scoring-table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
font-variant-numeric: tabular-nums;
}
.soup-board-key > b {
font: 48px "Soup Display";
.scoring-table caption {
margin-bottom: 6px;
font-weight: 600;
}
.soup-board-key > small {
.scoring-table caption svg {
display: inline-block;
vertical-align: middle;
width: 15px;
height: 15px;
}
.scoring-table th,
.scoring-table td {
padding: 2px 1px;
text-align: center;
}
.scoring-table thead {
font-size: 10px;
color: #78896b;
}
.scoring-table th[scope="row"] svg {
width: 16px;
height: 16px;
margin: auto;
}
.scoring-table td.current {
background: #dfeac9;
border-radius: 4px;
color: #38532c;
font-weight: 700;
}
.scoring-total {
display: flex;
gap: 4px;
align-items: center;
font-weight: 600;
}
.scoring-finish {
font-size: 10px;
line-height: 1.5;
}
.scoring-help {
display: inline-flex;
align-items: center;
gap: 3px;
padding: 0;
font: inherit;
color: inherit;
}
.scoring-help:hover {
text-decoration: underline;
}
.scoring-detail {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
max-width: 420px;
margin: 20px auto;
font-size: 16px;
}
.scoring-detail .scoring-table th,
.scoring-detail .scoring-table td {
padding: 8px 3px;
}
.scoring-detail .scoring-table thead {
font-size: 14px;
}
.soup .pond-bottom {
margin: 0;
min-height: 32px;
@ -641,14 +704,26 @@
.soup .injury {
font-size: 8px;
}
.soup-board-key > span {
font-size: 6px;
letter-spacing: 1px;
.soup-board-key {
font-size: 7px;
gap: 4px;
}
.soup-board-key > b {
font-size: 31px;
.soup-board-key .scoring-table thead {
font-size: 7px;
}
.soup-board-key > small {
.soup-board-key .scoring-table caption {
margin-bottom: 2px;
}
.soup-board-key .scoring-table caption svg,
.soup-board-key .scoring-table th[scope="row"] svg {
width: 11px;
height: 11px;
}
.soup-board-key .scoring-table th,
.soup-board-key .scoring-table td {
padding: 2px 1px;
}
.soup-board-key .scoring-finish {
font-size: 7px;
}
.soup .pond-bottom {

View file

@ -336,18 +336,18 @@ export const chapters = {
(s) => !E.amoeba(s, "0-2"),
only("done"),
"board",
"The amoeba with two injuries died; the one with one injury survived.",
"The amoeba with two injuries died and left two nutrients of every colour, if available. The one with one injury survived.",
),
step(
"scoring",
"Four survivors earn two evolution points",
"A dead amoeba leaves two nutrients of every colour, if available. Your four survivors earn 2 evolution points. Genes can add more. Scoring starts with the leader, and occupied scores are jumped over without using a step.",
"Score the whole colony each round",
"Every colony scores at the end of every round, even if no amoeba died. Look up your number of living amoebas in the scoring legend beside the board. Four amoebas give your whole colony 2 evolution points. Add the gene row separately: here you have no genes, so the total is 2 + 0 = 2 evolution points. The star marks evolution points.",
undefined,
undefined,
"colonies",
"scoring",
),
],
"Population scoring: 0–2 / 3 / 4 / 5 / 6 / 7 amoebas → 0 / 1 / 2 / 4 / 5 / 6 evolution points. Gene scoring: 0–2 / 3 / 4 / 5 / 6+ genes → 0 / 1 / 2 / 3 / 4 evolution points. Finish the round when someone reaches 42 points or the last environment card is drawn; highest score wins.",
"Population scoring: 0–2 / 3 / 4 / 5 / 6 / 7 amoebas → 0 / 1 / 2 / 4 / 5 / 6 evolution points. Gene scoring: 0–2 / 3 / 4 / 5 / 6+ genes → 0 / 1 / 2 / 3 / 4 evolution points. Score from the leader down, skipping occupied spaces. Finish the round when someone reaches 42 points or the last environment card is drawn; highest score wins.",
),
"movement-genes": config(
"movement-genes",

View file

@ -18,8 +18,16 @@ import {
import { amoeba, icon, colors, colonyTraits } from "./art.js";
import { geneArt } from "./gene-art.js";
import { geneSummary } from "./gene-summary.js";
import { scoringLegend } from "./scoring-legend.js";
import { geneIcon, geneLabel } from "./gene-label.js";
import { richText, food, bp, injury, sensitivity } from "./rich-text.js";
import {
richText,
food,
bp,
injury,
sensitivity,
evolutionPoints,
} from "./rich-text.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";
@ -148,9 +156,9 @@ 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><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("gene")} 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 POINTS</span><b>42</b><small>Finish the round<br>when a colony reaches 42 points.</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>
<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><aside class="soup-board-key" data-tutorial="scoring" aria-label="Scoring reference"></aside></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>
<dialog><button class="close-modal icon-button" data-ui="close" aria-label="Close">×</button><div class="modal-content"></div></dialog>`;
const $ = (q) => root.querySelector(q),
@ -203,6 +211,11 @@ export function mountGame(
selected = a?.id;
const shown = viewPlayer ?? seat ?? actor ?? 0,
pl = state.players[shown];
$(".soup-board-key").innerHTML = scoringLegend(
colony(state, shown).length,
geneCount(state, shown),
pl.color,
);
$(".players").style.gridTemplateColumns =
`repeat(${state.players.length},1fr)`;
$(".players").innerHTML = state.players
@ -255,7 +268,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, colonyTraits(pl.genes))}</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 ? injury(a.hp) : "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">${geneIcon(g.id)}</span><span class="gene-text"><strong>${GENE[g.id].name}</strong><p>${richText(geneSummary(g.id, state.players.length))}</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 points earned at the end of the round with the current amoebas and genes">${icon("spark")} <strong>+${evolution(state, shown)}</strong> evolution points</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, colonyTraits(pl.genes))}</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 ? injury(a.hp) : "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">${geneIcon(g.id)}</span><span class="gene-text"><strong>${GENE[g.id].name}</strong><p>${richText(geneSummary(g.id, state.players.length))}</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 points earned at the end of the round with the current amoebas and genes">${evolutionPoints(`+${evolution(state, shown)}`)}</span></div>`;
$(".round-number").textContent = state.round || "—";
$(".phase-label").textContent = state.finished
? "Game complete"
@ -268,7 +281,7 @@ export function mountGame(
`<span title="${i + 1}. ${p}" class="${typeof state.phase === "number" && i <= state.phase ? "active" : ""}"></span>`,
).join("");
$(".action-buttons").innerHTML =
`${canAct() && t.kind === "genes" ? '<button class="action primary" data-ui="genes">' + icon("spark") + " Evolve genes</button>" : ""}${actions()
`${canAct() && t.kind === "genes" ? '<button class="action primary" data-ui="genes">' + icon("gene") + " Evolve genes</button>" : ""}${actions()
.map((m, i) =>
["place", "divide", "buy", "direction", "drift"].includes(m.type)
? ""
@ -298,7 +311,10 @@ export function mountGame(
return `<article class="shop-card" data-tutorial="gene-${g.id}"><div class="shop-art">${geneArt(g.id)}</div><div class="shop-body"><h3>${g.name}</h3><span class="gene-price">${bp(g.cost)} · ${sensitivity(g.mutation)} · ${remaining} left</span><p>${richText(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" : bp(g.cost)}</span>`}</div></article>`;
})
.join("")}</div>`;
else if (modalKind === "journal")
else if (modalKind === "scoring") {
const player = viewPlayer ?? seat ?? state.actor ?? 0;
html = `<h2>Scoring each round</h2><p>Look up your living amoebas and your gene total, then add the two rows. These points belong to the whole colony.</p><div class="scoring-detail">${scoringLegend(colony(state, player).length, geneCount(state, player), state.players[player].color, false)}</div><p>Advanced genes count as two; Ray Protection counts as zero. Score every round, even if no amoeba died. Skip occupied scores on the track.</p>`;
} else if (modalKind === "journal")
html = `<span class="eyebrow">LIFE IN THE SOUP</span><h2>Journal</h2><ol class="journal-list">${state.log
.slice(-150)
.reverse()