Improve mobile colony layout and movement and gene controls
This commit is contained in:
parent
17846a9d7a
commit
a291f43314
7 changed files with 421 additions and 47 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/primordial-soup",
|
||||
"version": "0.2.17",
|
||||
"version": "0.2.18",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "dist/engine.js",
|
||||
|
|
|
|||
|
|
@ -56,6 +56,42 @@ try {
|
|||
assert.ok(
|
||||
!(await page.locator("dialog").textContent()).includes("undefined"),
|
||||
);
|
||||
const filter = page.locator('[data-ui="filter-buyable"]');
|
||||
const show = async (state) => {
|
||||
await page.evaluate(
|
||||
(state) => e.emit("state", state),
|
||||
E.stripSecret(state, 0),
|
||||
);
|
||||
await page.waitForTimeout(30);
|
||||
};
|
||||
const checkFilteredPool = async (state) => {
|
||||
const expected = [
|
||||
...new Set(
|
||||
E.legalMoves(state)
|
||||
.filter((move) => ["buy", "exchange"].includes(move.type))
|
||||
.map((move) => move.gene),
|
||||
),
|
||||
].sort();
|
||||
assert.deepEqual(
|
||||
await page
|
||||
.locator(".shop-card")
|
||||
.evaluateAll((cards) =>
|
||||
cards
|
||||
.map((card) => card.dataset.tutorial.slice("gene-".length))
|
||||
.sort(),
|
||||
),
|
||||
expected,
|
||||
);
|
||||
assert.equal(await filter.getAttribute("aria-pressed"), "true");
|
||||
};
|
||||
await filter.click();
|
||||
await checkFilteredPool(s);
|
||||
assert.ok((await page.locator(".shop-card").count()) < 46);
|
||||
assert.deepEqual(
|
||||
await page.evaluate(() => moves),
|
||||
[],
|
||||
"filtering sends no game move",
|
||||
);
|
||||
const exchange = page
|
||||
.locator('[data-tutorial="gene-energy"] button')
|
||||
.filter({ hasText: "Exchange Highly Adaptable" });
|
||||
|
|
@ -64,11 +100,88 @@ try {
|
|||
// A real server response clears the pending UI request.
|
||||
const action = await page.evaluate(() => moves[0]);
|
||||
s = E.move(s, action, 0);
|
||||
await page.evaluate((state) => e.emit("state", state), E.stripSecret(s, 0));
|
||||
await show(s);
|
||||
await checkFilteredPool(s);
|
||||
await page.screenshot({
|
||||
path: `/tmp/soup-new-genes-shop-${width}.png`,
|
||||
fullPage: true,
|
||||
});
|
||||
// Eligibility includes stock and the age of an upgrade's prerequisite.
|
||||
s = prepared({
|
||||
genes: ["movement1"],
|
||||
bp: 5,
|
||||
phase: 2,
|
||||
task: { kind: "genes", p: 0 },
|
||||
});
|
||||
s.players[0].genes[0].round = s.round;
|
||||
s.players[1].genes = [{ id: "speed", round: 1 }];
|
||||
s.players[2].genes = [{ id: "speed", round: 1 }];
|
||||
await show(s);
|
||||
await checkFilteredPool(s);
|
||||
for (const gene of ["movement1", "movement2", "speed"])
|
||||
assert.equal(
|
||||
await page.locator(`[data-tutorial="gene-${gene}"]`).count(),
|
||||
0,
|
||||
);
|
||||
s.players[0].genes[0].round--;
|
||||
await show(s);
|
||||
await checkFilteredPool(s);
|
||||
assert.equal(
|
||||
await page.locator('[data-tutorial="gene-movement2"]').count(),
|
||||
1,
|
||||
);
|
||||
|
||||
// Free exchanges remain visible even without any BP.
|
||||
s = prepared({
|
||||
genes: ["adaptable"],
|
||||
bp: 0,
|
||||
phase: 2,
|
||||
task: { kind: "genes", p: 0 },
|
||||
});
|
||||
s.newGeneMarket = {
|
||||
available: ["adaptable", "energy"],
|
||||
_deck: [],
|
||||
revealedRound: 2,
|
||||
};
|
||||
await show(s);
|
||||
await checkFilteredPool(s);
|
||||
assert.ok(
|
||||
(await page
|
||||
.locator('[data-tutorial="gene-intelligence"] button')
|
||||
.count()) > 0,
|
||||
);
|
||||
|
||||
// Buying the last affordable gene updates the filter to a clear empty state.
|
||||
s = prepared({ bp: 2, phase: 2, task: { kind: "genes", p: 0 } });
|
||||
await show(s);
|
||||
await page.locator('[data-tutorial="gene-intelligence"] button').click();
|
||||
s = E.move(s, await page.evaluate(() => moves.at(-1)), 0);
|
||||
await show(s);
|
||||
await checkFilteredPool(s);
|
||||
assert.equal(await page.locator(".shop-card").count(), 0);
|
||||
assert.ok(
|
||||
await page
|
||||
.getByText("No genes available to buy.", { exact: true })
|
||||
.isVisible(),
|
||||
);
|
||||
await page.evaluate(() => e.emit("preferences", { locale: "fr" }));
|
||||
assert.equal(await filter.locator("span").textContent(), "Achetables");
|
||||
await filter.click();
|
||||
assert.equal(await filter.getAttribute("aria-pressed"), "false");
|
||||
assert.ok((await page.locator(".shop-card").count()) > 0);
|
||||
await page.screenshot({
|
||||
path: `/tmp/soup-gene-filter-${width}.png`,
|
||||
fullPage: true,
|
||||
});
|
||||
await filter.click();
|
||||
await page.evaluate(() => {
|
||||
e.emit("preferences", { locale: "en" });
|
||||
e.emit("player", {});
|
||||
});
|
||||
assert.equal(await filter.isDisabled(), true);
|
||||
assert.equal(await filter.getAttribute("aria-pressed"), "false");
|
||||
assert.ok((await page.locator(".shop-card").count()) > 0);
|
||||
await page.evaluate(() => e.emit("player", { index: 0 }));
|
||||
await page.getByRole("button", { name: "Close", exact: true }).click();
|
||||
// Hide other players' forecasts and exercise the food source picker.
|
||||
s = prepared({ genes: ["suction2"], task: { kind: "feeding", a: "0-1" } });
|
||||
|
|
@ -91,7 +204,7 @@ try {
|
|||
assert.deepEqual(errors, []);
|
||||
await page.close();
|
||||
console.log(
|
||||
`New genes ${width}: market, exchange, private forecast, toxins and suction controls passed`,
|
||||
`New genes ${width}: buyable filter, stock, prerequisites, free exchanges, translations, market, private forecast, toxins and suction controls passed`,
|
||||
);
|
||||
}
|
||||
const page = await browser.newPage();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const browser = await chromium.launch({
|
|||
executablePath: process.env.CHROMIUM_EXECUTABLE,
|
||||
});
|
||||
try {
|
||||
for (const width of [320, 390, 1400]) {
|
||||
for (const width of [320, 390, 1000, 1400]) {
|
||||
const page = await browser.newPage({ viewport: { width, height: 1000 } });
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
|
|
@ -35,7 +35,18 @@ try {
|
|||
/\+10/,
|
||||
);
|
||||
const swim = page.locator(".board-swim");
|
||||
const driftButton = page.locator(".board-drift");
|
||||
assert.ok(await swim.isVisible());
|
||||
assert.ok(await driftButton.isVisible());
|
||||
assert.equal(await page.getByRole("button", { name: /^Swim/ }).count(), 1);
|
||||
const swimBox = await swim.boundingBox(),
|
||||
driftBox = await driftButton.boundingBox();
|
||||
assert.ok(
|
||||
Math.abs(swimBox.y - driftBox.y) < 1,
|
||||
"Drift and Swim share a row",
|
||||
);
|
||||
assert.ok(driftBox.x + driftBox.width < swimBox.x, "Drift is beside Swim");
|
||||
assert.ok(swimBox.height >= 44 && driftBox.height >= 44);
|
||||
await page.screenshot({
|
||||
path: `/tmp/soup-swim-${width}.png`,
|
||||
fullPage: true,
|
||||
|
|
@ -43,7 +54,7 @@ try {
|
|||
assert.match(await swim.getAttribute("aria-label"), /1 biological point/);
|
||||
// A deterministic drift offers undo; cancelling uses the real protocol move.
|
||||
const drift = E.legalMoves(s).find((m) => m.type === "drift");
|
||||
await page.locator(`[data-cell="${drift.cell}"]`).click();
|
||||
await driftButton.click();
|
||||
assert.deepEqual(await page.evaluate(() => moves.at(-1)), drift);
|
||||
s = E.move(s, drift, 0);
|
||||
await show(s);
|
||||
|
|
@ -55,12 +66,110 @@ try {
|
|||
await show(s);
|
||||
assert.equal(E.logLength(s), 0);
|
||||
assert.ok(await swim.isVisible());
|
||||
// Direct board destinations remain usable alongside the new button.
|
||||
await page.locator(`[data-cell="${drift.cell}"]`).click();
|
||||
assert.deepEqual(await page.evaluate(() => moves.at(-1)), drift);
|
||||
s = E.move(s, drift, 0);
|
||||
await show(s);
|
||||
await page.locator("[data-undo]").click();
|
||||
s = E.move(s, { type: "undo" }, 0);
|
||||
await show(s);
|
||||
await swim.click();
|
||||
assert.deepEqual(await page.evaluate(() => moves.at(-1)), { type: "swim" });
|
||||
s = E.move(s, { type: "swim" }, 0);
|
||||
await show(s);
|
||||
assert.equal(await page.locator("[data-undo]").count(), 0);
|
||||
assert.ok(!(await swim.isVisible()));
|
||||
assert.ok(!(await driftButton.isVisible()));
|
||||
|
||||
// Free drift remains available when swimming is unaffordable, including
|
||||
// still currents and blocked destinations that leave the amoeba in place.
|
||||
for (const direction of [2, 0, 4]) {
|
||||
s = prepared({ bp: 0 });
|
||||
s.environment.direction = direction;
|
||||
await show(s);
|
||||
assert.ok(await driftButton.isVisible());
|
||||
assert.equal(await swim.count(), 0);
|
||||
const move = E.legalMoves(s).find((m) => m.type === "drift");
|
||||
if (move.cell === s.amoebas[0].cell)
|
||||
assert.match(await driftButton.textContent(), /Stay here/);
|
||||
await driftButton.click();
|
||||
assert.deepEqual(await page.evaluate(() => moves.at(-1)), move);
|
||||
}
|
||||
|
||||
// Rebound must preserve both legal destinations, without moving on open.
|
||||
s = prepared({ genes: ["rebound"] });
|
||||
s.amoebas[0].cell = 11;
|
||||
const rebounds = E.legalMoves(s).filter((m) => m.type === "drift");
|
||||
assert.equal(rebounds.length, 2);
|
||||
for (const [index, move] of rebounds.entries()) {
|
||||
await show(s);
|
||||
const before = await page.evaluate(() => moves.length);
|
||||
await driftButton.focus();
|
||||
await page.keyboard.press("Enter");
|
||||
assert.equal(await page.evaluate(() => moves.length), before);
|
||||
const destinations = page.locator(".board-drift-destinations button");
|
||||
assert.equal(await destinations.count(), 2);
|
||||
assert.ok(await destinations.nth(index).isVisible());
|
||||
await destinations.nth(index).click();
|
||||
assert.deepEqual(await page.evaluate(() => moves.at(-1)), move);
|
||||
}
|
||||
|
||||
s = prepared({ bp: 0, genes: ["streamline", "movement2"] });
|
||||
await show(s);
|
||||
assert.match(await swim.getAttribute("aria-label"), /free/);
|
||||
assert.equal(await swim.getAttribute("title"), "Swim: choose a direction.");
|
||||
await swim.click();
|
||||
assert.deepEqual(await page.evaluate(() => moves.at(-1)), { type: "swim" });
|
||||
s = E.move(s, { type: "swim" }, 0);
|
||||
await show(s);
|
||||
assert.equal(await page.locator(".board-actions:visible").count(), 0);
|
||||
|
||||
s = prepared({ genes: ["speed"], task: { kind: "speed", a: "0-1" } });
|
||||
await show(s);
|
||||
assert.equal(await page.getByRole("button", { name: /^Swim/ }).count(), 1);
|
||||
assert.equal(await driftButton.count(), 0);
|
||||
assert.match(await swim.textContent(), /Swim again.*Free/);
|
||||
assert.ok(
|
||||
await page
|
||||
.getByRole("button", { name: "Finish moving", exact: true })
|
||||
.isVisible(),
|
||||
);
|
||||
await swim.click();
|
||||
assert.deepEqual(await page.evaluate(() => moves.at(-1)), {
|
||||
type: "swim-again",
|
||||
});
|
||||
|
||||
s = prepared();
|
||||
for (const [locale, driftName, swimName] of [
|
||||
["fr", "Dériver", "Nager"],
|
||||
["de", "Treiben", "Schwimmen"],
|
||||
]) {
|
||||
await page.evaluate(
|
||||
(locale) => e.emit("preferences", { locale }),
|
||||
locale,
|
||||
);
|
||||
await show(s);
|
||||
assert.ok((await driftButton.textContent()).includes(driftName));
|
||||
assert.ok((await swim.textContent()).includes(swimName));
|
||||
assert.ok(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
),
|
||||
);
|
||||
await driftButton.click();
|
||||
assert.deepEqual(
|
||||
await page.evaluate(() => moves.at(-1)),
|
||||
E.legalMoves(s).find((m) => m.type === "drift"),
|
||||
);
|
||||
}
|
||||
await page.evaluate(() => {
|
||||
e.emit("preferences", { locale: "en" });
|
||||
e.emit("player", {});
|
||||
});
|
||||
await show(s);
|
||||
assert.equal(await page.locator(".board-actions:visible").count(), 0);
|
||||
await page.evaluate(() => e.emit("player", { index: 0 }));
|
||||
|
||||
// Empty phase entries hand over; a final purchase/placement keeps Done and Undo.
|
||||
for (const [phase, kind, bp, type] of [
|
||||
|
|
@ -176,7 +285,7 @@ try {
|
|||
assert.deepEqual(errors, []);
|
||||
await page.close();
|
||||
console.log(
|
||||
`Turn controls ${width}: swim, undo, dice boundary, automatic empty turns, final-action confirmation, income, six visible badges and colony gene colour passed`,
|
||||
`Turn controls ${width}: paired Drift/Swim, Rebound, free movement, Speed, translations, undo, dice boundary, automatic empty turns, final-action confirmation, income, six visible badges and colony gene colour passed`,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
.soup .soup-activity .journal-list {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
overscroll-behavior: contain;
|
||||
overscroll-behavior: auto;
|
||||
overflow-anchor: none;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #b7c5a6 transparent;
|
||||
|
|
|
|||
171
viewer/style.css
171
viewer/style.css
|
|
@ -308,34 +308,75 @@
|
|||
position: absolute;
|
||||
bottom: 5%;
|
||||
left: 1%;
|
||||
width: 20%;
|
||||
width: 22%;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
z-index: 9;
|
||||
}
|
||||
.board-actions[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.soup .board-swim {
|
||||
.board-actions > * {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
max-width: 180px;
|
||||
}
|
||||
.soup .board-actions .board-movement {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 5px 10px;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
min-height: 44px;
|
||||
padding: 10px;
|
||||
font-size: 15px;
|
||||
border-radius: 13px;
|
||||
min-height: 52px;
|
||||
height: 100%;
|
||||
padding: 8px 5px;
|
||||
font-size: 13px;
|
||||
border-radius: 12px;
|
||||
white-space: normal;
|
||||
text-align: center;
|
||||
}
|
||||
.board-swim-title {
|
||||
.board-movement-title {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
white-space: nowrap;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.board-swim-title svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
.board-movement-title svg {
|
||||
flex: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
.board-drift-choice {
|
||||
position: relative;
|
||||
}
|
||||
.board-drift-choice summary {
|
||||
list-style: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.board-drift-choice summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
.board-drift-choice[open] summary {
|
||||
border-color: var(--ink);
|
||||
}
|
||||
.board-drift-destinations {
|
||||
position: absolute;
|
||||
bottom: calc(100% + 8px);
|
||||
left: 0;
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
width: max-content;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 12px;
|
||||
background: var(--cream);
|
||||
box-shadow: 0 3px 12px #24433a33;
|
||||
}
|
||||
.soup .board-drift-destinations .action {
|
||||
min-height: 44px;
|
||||
}
|
||||
.soup .nutrients {
|
||||
bottom: 10%;
|
||||
|
|
@ -845,7 +886,7 @@
|
|||
min-height: 0;
|
||||
padding: 33px;
|
||||
overflow: auto;
|
||||
overscroll-behavior: contain;
|
||||
overscroll-behavior: auto;
|
||||
}
|
||||
.soup .close-modal {
|
||||
z-index: 2;
|
||||
|
|
@ -866,6 +907,23 @@
|
|||
margin: 5px 0 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pool-filters {
|
||||
display: flex;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.soup .pool-filters .action {
|
||||
flex: none;
|
||||
min-height: 44px;
|
||||
white-space: normal;
|
||||
}
|
||||
.pool-filters small {
|
||||
border-radius: 5px;
|
||||
padding: 2px 5px;
|
||||
background: #8faa7c33;
|
||||
}
|
||||
.pool-empty {
|
||||
padding: 24px 0;
|
||||
}
|
||||
.soup .pool-guide {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -1368,6 +1426,19 @@
|
|||
.soup .board-wrap {
|
||||
flex-direction: column;
|
||||
}
|
||||
.board-actions {
|
||||
position: relative;
|
||||
bottom: auto;
|
||||
left: auto;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
margin: 8px 0;
|
||||
}
|
||||
.soup .board-actions .board-movement {
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
}
|
||||
.soup .board {
|
||||
flex: none;
|
||||
}
|
||||
|
|
@ -1480,19 +1551,6 @@
|
|||
--amoeba-height: 14%;
|
||||
--amoeba-width: 13%;
|
||||
}
|
||||
.soup .board-swim {
|
||||
padding: 5px 3px;
|
||||
font-size: 11px;
|
||||
gap: 2px 5px;
|
||||
border-radius: 9px;
|
||||
}
|
||||
.board-swim-title {
|
||||
gap: 3px;
|
||||
}
|
||||
.board-swim-title svg {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
}
|
||||
.soup .current-compass {
|
||||
left: 39.5%;
|
||||
width: 21%;
|
||||
|
|
@ -1984,3 +2042,58 @@
|
|||
.practice-nav input[type="checkbox"] {
|
||||
accent-color: #527446;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.soup .colony-panel {
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
padding: 8px 5px;
|
||||
gap: 6px 12px;
|
||||
align-items: center;
|
||||
}
|
||||
.soup .colony-heading .eyebrow,
|
||||
.soup .colony-heading .bio-balance,
|
||||
.soup .colony-metrics {
|
||||
display: none;
|
||||
}
|
||||
.soup .colony-heading h2 {
|
||||
font-size: 14px;
|
||||
max-width: 110px;
|
||||
margin: 0;
|
||||
}
|
||||
.soup .gene-heading {
|
||||
gap: 8px;
|
||||
}
|
||||
.soup .gene-heading .text-button {
|
||||
min-height: 44px;
|
||||
}
|
||||
.soup .gene-list {
|
||||
grid-column: 1 / -1;
|
||||
grid-row: auto;
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
}
|
||||
.soup .gene-list .empty-genes {
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.soup .gene p {
|
||||
font-size: 11px;
|
||||
}
|
||||
.soup .amoeba-picker {
|
||||
grid-column: 1 / -1;
|
||||
grid-row: auto;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.soup .pond-bottom:has(.last-move:empty) {
|
||||
display: none;
|
||||
}
|
||||
.soup .pond-bottom {
|
||||
min-height: 0;
|
||||
padding: 4px 5px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ export const chapters = {
|
|||
"To try another direction, use Swim. It costs 1 BP (a biological point, shown by the flask). 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",
|
||||
"movement",
|
||||
),
|
||||
step(
|
||||
"destination",
|
||||
|
|
|
|||
59
viewer/ui.js
59
viewer/ui.js
|
|
@ -228,7 +228,7 @@ export function mountGame(
|
|||
target.append(root);
|
||||
root.innerHTML = `<header class="topbar"><div class="brand"><span>${amoeba("green", 0)}</span><div><h1 translate="no">primordial soup<span class="title-dot">.</span></h1><span class="byline" translate="no">DORIS MATTHÄUS & FRANK NESTEL</span></div></div><nav class="utilities" aria-label="Game options"><button class="quiet-button" data-ui="genes" aria-label="Genes" title="Gene pool">${icon("gene")}<span class="utility-label">Genes</span></button><button class="icon-button" data-ui="colony-symbols" aria-label="Color-blind mode" aria-pressed="${colonySymbols}" title="Color-blind mode: match colonies by symbol">${icon("colony-symbols")}</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="board-wrap"><div class="board" data-tutorial="board"><div class="pond-tools">${chat ? `<button class="quiet-button" data-ui="chat">${icon("chat")} Chat</button>` : ""}<button class="quiet-button" data-ui="journal">${icon("history")} Journal</button></div><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="board-actions" hidden></div><div class="current-compass" data-tutorial="current"><div class="environment-current"><span>CURRENT</span><div class="compass-arrow">➜</div><b class="compass-label"></b></div><div class="environment-ozone" role="img" tabindex="0" title="${OZONE_HELP}"><span class="ozone-value">${icon("ozone")}<strong class="ozone"></strong></span></div></div></div><div class="board-reference"><div class="game-progress"></div><aside class="soup-board-key" data-tutorial="scoring" aria-label="Scoring reference"></aside></div></div><div class="private-forecast" hidden></div><div class="pond-bottom"><div class="last-move" aria-live="polite"></div><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="board-wrap"><div class="board" data-tutorial="board"><div class="pond-tools">${chat ? `<button class="quiet-button" data-ui="chat">${icon("chat")} Chat</button>` : ""}<button class="quiet-button" data-ui="journal">${icon("history")} Journal</button></div><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"><div class="environment-current"><span>CURRENT</span><div class="compass-arrow">➜</div><b class="compass-label"></b></div><div class="environment-ozone" role="img" tabindex="0" title="${OZONE_HELP}"><span class="ozone-value">${icon("ozone")}<strong class="ozone"></strong></span></div></div></div><div class="board-actions" data-tutorial="movement" hidden></div><div class="board-reference"><div class="game-progress"></div><aside class="soup-board-key" data-tutorial="scoring" aria-label="Scoring reference"></aside></div></div><div class="private-forecast" hidden></div><div class="pond-bottom"><div class="last-move" aria-live="polite"></div><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><ol class="phase-steps" aria-label="Round phases"></ol></div><div class="action-buttons"></div></footer><div class="game-message" role="alert"></div>
|
||||
<div class="activity-slot"></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),
|
||||
|
|
@ -252,7 +252,8 @@ export function mountGame(
|
|||
modalKind,
|
||||
modalPlayer,
|
||||
oldTask,
|
||||
mealSource;
|
||||
mealSource,
|
||||
buyableOnly = false;
|
||||
const dialog = $("dialog");
|
||||
const activity = mountActivity($(".activity-slot"), {
|
||||
chat,
|
||||
|
|
@ -355,12 +356,26 @@ export function mountGame(
|
|||
return `<button class="amoeba-button ${selected === a.id ? "selected" : ""} ${t?.a === a.id ? "acting" : ""}" data-amoeba="${a.id}" aria-label="${esc(state.players[a.p].name)} amoeba #${a.n}, ${coordinate(a.cell)}${a.hp ? ", " + a.hp + " injuries" : ""}" aria-pressed="${selected === a.id}" style="--x:${(60 + (a.cell % 5) * 156 + 78 + dx) / 9}%;--y:${(55 + Math.floor(a.cell / 5) * 105 + 49 + dy) / 6.5}%;--scale:${scale};--delay:-${a.n * 0.7}s;--amoeba-paper:${colors[COLORS[a.p]].light};--amoeba-ink:${colors[COLORS[a.p]].stroke}">${amoeba(COLORS[a.p], a.n, colonyTraits(state.players[a.p].genes))}<span class="amoeba-number">${a.n}</span>${hp}</button>`;
|
||||
})
|
||||
.join("");
|
||||
const swimIndex = actions().findIndex((m) =>
|
||||
const movementActions = actions();
|
||||
const driftMoves = movementActions
|
||||
.map((move, index) => ({ move, index }))
|
||||
.filter(({ move }) => move.type === "drift");
|
||||
const swimIndex = movementActions.findIndex((m) =>
|
||||
["swim", "swim-again"].includes(m.type),
|
||||
);
|
||||
$(".board-actions").hidden = swimIndex < 0;
|
||||
const movementButtons = [];
|
||||
if (driftMoves.length) {
|
||||
const currentCell = state.amoebas.find((a) => a.id === t.a)?.cell;
|
||||
const driftTitle = `<span class="board-movement-title">${icon("arrow")} Drift</span><small>${driftMoves.length === 1 && driftMoves[0].move.cell === currentCell ? "Stay here" : "Free"}</small>`;
|
||||
// Rebound may offer two destinations; opening the chooser makes no move.
|
||||
movementButtons.push(
|
||||
driftMoves.length === 1
|
||||
? `<button class="action secondary board-movement board-drift" data-move="${driftMoves[0].index}" aria-label="Drift · free">${driftTitle}</button>`
|
||||
: `<details class="board-drift-choice"><summary role="button" class="action secondary board-movement board-drift" aria-label="Drift · free">${driftTitle}</summary><div class="board-drift-destinations">${driftMoves.map(({ move, index }) => `<button class="action secondary" data-move="${index}">${move.cell === currentCell ? "Stay here" : `<span>Drift</span><span translate="no">${coordinate(move.cell)}</span>`}</button>`).join("")}</div></details>`,
|
||||
);
|
||||
}
|
||||
if (swimIndex >= 0) {
|
||||
const again = actions()[swimIndex].type === "swim-again";
|
||||
const again = movementActions[swimIndex].type === "swim-again";
|
||||
const free =
|
||||
again || state.players[seat].genes.some((g) => g.id === "streamline");
|
||||
const title = again
|
||||
|
|
@ -368,9 +383,12 @@ export function mountGame(
|
|||
: state.players[seat].genes.some((g) => g.id === "movement2")
|
||||
? "Swim: choose a direction."
|
||||
: "Swim: roll for a direction.";
|
||||
$(".board-actions").innerHTML =
|
||||
`<button class="action primary board-swim" data-move="${swimIndex}" title="${title}" aria-label="${again ? "Swim again" : "Swim"} · ${free ? "free" : "1 biological point"}"><span class="board-swim-title">${icon("wave")} Swim</span><small>${free ? "Free" : bp(1)}</small></button>`;
|
||||
} else $(".board-actions").innerHTML = "";
|
||||
movementButtons.push(
|
||||
`<button class="action primary board-movement board-swim" data-move="${swimIndex}" title="${title}" aria-label="${again ? "Swim again" : "Swim"} · ${free ? "free" : "1 biological point"}"><span class="board-movement-title">${icon("wave")} ${again ? "Swim again" : "Swim"}</span><small>${free ? "Free" : bp(1)}</small></button>`,
|
||||
);
|
||||
}
|
||||
$(".board-actions").hidden = movementButtons.length === 0;
|
||||
$(".board-actions").innerHTML = movementButtons.join("");
|
||||
const direction = state.environment.direction;
|
||||
$(".board").dataset.current = ["west", "north", "east", "south", "still"][
|
||||
direction
|
||||
|
|
@ -441,6 +459,8 @@ export function mountGame(
|
|||
"exchange",
|
||||
"direction",
|
||||
"drift",
|
||||
"swim",
|
||||
"swim-again",
|
||||
"excrete",
|
||||
].includes(m.type) ||
|
||||
(m.type === "eat" && (m.source ?? "local") !== mealSource)
|
||||
|
|
@ -522,7 +542,20 @@ export function mountGame(
|
|||
if (!state) return;
|
||||
let html = "";
|
||||
if (modalKind === "genes") {
|
||||
const families = geneFamilies(genesInGame(state));
|
||||
const canShop =
|
||||
!state.closed &&
|
||||
seat !== undefined &&
|
||||
seat === state.actor &&
|
||||
state.tasks[0]?.kind === "genes";
|
||||
const buyable = new Set(
|
||||
state.moves
|
||||
.filter((move) => ["buy", "exchange"].includes(move.type))
|
||||
.map((move) => move.gene),
|
||||
);
|
||||
const filtering = buyableOnly && canShop;
|
||||
const families = geneFamilies(
|
||||
genesInGame(state).filter((gene) => !filtering || buyable.has(gene.id)),
|
||||
);
|
||||
const groups = [
|
||||
{
|
||||
title: "New genes",
|
||||
|
|
@ -539,7 +572,7 @@ export function mountGame(
|
|||
),
|
||||
},
|
||||
].filter((group) => group.families.length);
|
||||
html = `<div class="pool-header"><div><h2>Gene pool</h2><p>${canAct() && state.tasks[0].kind === "genes" ? `${bp(state.players[seat].bp)} to spend` : "Buy during phase 3"}</p></div><div class="pool-guide" role="img" tabindex="0" title="${OZONE_HELP}" aria-label="Ozone layer ${state.environment.ozone}. ${OZONE_HELP}">${icon("ozone")}<strong>${state.environment.ozone}</strong></div></div>${groups.map((group) => `<section class="pool-section ${group.extra ? "pool-section--new" : ""}" aria-label="${group.title}"><div class="pool-heading"><h3>${group.extra ? '<span class="new-gene-star" aria-hidden="true">★</span>' : icon("gene")}${group.title}</h3><span>${group.families.flat().filter((g) => !group.extra || isNewGene(g.id)).length} ${group.extra ? "revealed" : "types"}</span></div>${group.extra ? `<p class="market-status" title="Two new genes are revealed in phase 3, after the leader finishes buying.">${state.newGeneMarket.remaining} unrevealed · +2 per round</p>` : ""}<div class="shop-grid">${group.families.map((family) => `<div class="shop-family" style="--gene-count:${family.length}"${family.length > 1 ? ` role="group" aria-label="${esc(family.map((g) => g.name).join(" / "))}"` : ""}>${family.map(renderGeneCard).join("")}</div>`).join("")}</div></section>`).join("")}`;
|
||||
html = `<div class="pool-header"><div><h2>Gene pool</h2><p>${canAct() && state.tasks[0].kind === "genes" ? `${bp(state.players[seat].bp)} to spend` : "Buy during phase 3"}</p></div><div class="pool-guide" role="img" tabindex="0" title="${OZONE_HELP}" aria-label="Ozone layer ${state.environment.ozone}. ${OZONE_HELP}">${icon("ozone")}<strong>${state.environment.ozone}</strong></div></div><div class="pool-filters"><button class="action ${filtering ? "primary" : "secondary"}" data-ui="filter-buyable" aria-pressed="${filtering}" title="${canShop ? "Show only genes you can buy or exchange now." : "Buy during phase 3"}" ${canShop ? "" : "disabled"}><span>Buyable</span>${canShop ? `<small>${buyable.size}</small>` : ""}</button></div>${filtering && !families.length ? '<p class="pool-empty" role="status">No genes available to buy.</p>' : ""}${groups.map((group) => `<section class="pool-section ${group.extra ? "pool-section--new" : ""}" aria-label="${group.title}"><div class="pool-heading"><h3>${group.extra ? '<span class="new-gene-star" aria-hidden="true">★</span>' : icon("gene")}${group.title}</h3><span>${group.families.flat().filter((g) => !group.extra || isNewGene(g.id)).length} ${group.extra ? "revealed" : "types"}</span></div>${group.extra ? `<p class="market-status" title="Two new genes are revealed in phase 3, after the leader finishes buying.">${state.newGeneMarket.remaining} unrevealed · +2 per round</p>` : ""}<div class="shop-grid">${group.families.map((family) => `<div class="shop-family" style="--gene-count:${family.length}"${family.length > 1 ? ` role="group" aria-label="${esc(family.map((g) => g.name).join(" / "))}"` : ""}>${family.map(renderGeneCard).join("")}</div>`).join("")}</div></section>`).join("")}`;
|
||||
} 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">${renderScoring(player, false)}</div><p>Advanced genes count as two; Ray Protection counts as zero. Score every round. Skip occupied scores on the track.</p>`;
|
||||
|
|
@ -641,6 +674,12 @@ export function mountGame(
|
|||
dialog.close();
|
||||
return;
|
||||
}
|
||||
if (el.dataset.ui === "filter-buyable") {
|
||||
buyableOnly = !buyableOnly;
|
||||
renderModal();
|
||||
$('[data-ui="filter-buyable"]').focus({ preventScroll: true });
|
||||
return;
|
||||
}
|
||||
if (el.dataset.ui === "chat" || el.dataset.ui === "journal") {
|
||||
activity.open(el.dataset.ui);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue