Harden limited-log privacy and prepare optional variants release

This commit is contained in:
coyotte508 2026-10-28 19:19:07 +01:00
commit 3e01897b08
12 changed files with 197 additions and 14 deletions

View file

@ -3,7 +3,7 @@
## Repository and live status
- This is **Acquire**, in `boardgamers/mergers-game`; the BGS game id is `acquire`, version **1**.
- **The BGS game is public**, verified 27 October 2026. Preserve the live visibility and
- **The BGS game is public**, verified 28 October 2026. Preserve the live visibility and
unrelated metadata on updates. Fetch fresh metadata before publishing; this file is not a
substitute for checking the live configuration.
- `docs/admin/gameinfo.json` is a bootstrap template. Its `public: false` and blank artifact
@ -53,6 +53,9 @@ Use Node 24 and pnpm 11. Inspect the working tree before editing and preserve un
- Stock swaps are an optional house rule: Off / 3 / 5 / 7 / Unlimited. The per-turn limit is
shared across exchanges, separate from the three-share purchase allowance; prices apply
after all merger resolution. Keep the default Off.
- Two tiles per turn and limited game log are optional, default Off. Two-tile turns retain
private undo and one turn increment. Limited logs must filter both entries and BGS summaries;
four-hands spectators use the active player's window. Replay unlocks at game end.
## Setup options and player preferences

View file

@ -1,10 +1,20 @@
# Acquire — 26 October 2026
# Acquire — 28 October 2026
BGS registration: `acquire`, version `1`. Engine `0.0.4`, viewer `0.0.17`.
BGS registration: `acquire`, version `1`. Engine `0.0.5`, viewer `0.0.18`.
Source: <https://github.com/boardgamers/mergers-game>. The live game is now public; preserve its current visibility when updating.
## Validation
- [MikeIsom's PR #1](https://github.com/boardgamers/mergers-game/pull/1) adds two optional
setup checkboxes, both default Off: two tiles per turn (hands of 8) and limited game log.
The shortened labels requested in review are included. Two-tile rules cover founding/merger
restrictions, bank tiles, dead-tile replacement, skipped placements, dropped players and replay.
Follow-up fixes prevent BGS turn summaries from exposing hidden history, give four-hands
spectators the active player's log window, and lock replay throughout limited-log play.
Regression tests cover those privacy boundaries plus repeated two-tile revisions without
growing saved history or awarding duplicate time. Browser checks exercise both variants,
mobile layouts, all 17 locales, light/dark themes and replay after the full log is revealed.
- Optional stock swaps default to Off, with 3/5/7/Unlimited shares per turn shared across exchanges.
Only active chains may swap 1:1 at current prices after all mergers, respecting bank stock,
holdings and cash. Normal three-share purchases remain separate. Engine checks cover allowance
@ -46,8 +56,8 @@ Source: <https://github.com/boardgamers/mergers-game>. The live game is now publ
requests, hidden-information masking, replay, bank mode, four-hands, teams and dropped players.
Desktop/phone checks exercise repeated undo, saved-state refreshes, final history and clock totals.
- `pnpm check`: formatting, lint, TypeScript/Svelte checks, 222 engine tests,
66 viewer/tutorial tests, and the production build. Two pre-existing lint warnings
- `pnpm check`: formatting, lint, TypeScript/Svelte checks, 242 engine tests,
67 viewer/tutorial tests, and the production build. Two pre-existing lint warnings
remain (an unused test import and Svelte's `bind:this` assignment).
- Protocol diagnostics: all eight required engine methods; full core/chat/replay
viewer coverage, preferences, avatars and theme handlers. Protocol `0.10.0` is the

View file

@ -1,7 +1,7 @@
# Publishing Acquire on boardgamers.space
Acquire is already registered as game **`acquire`**, BGS version **`1`**, and is **public**
(verified 27 October 2026). Routine updates must preserve that visibility and the existing
(verified 28 October 2026). Routine updates must preserve that visibility and the existing
configuration. Start with [AGENTS.md](../AGENTS.md) for repository checks and compatibility
requirements, and [admin/release-check.md](admin/release-check.md) for the latest release record.
@ -146,8 +146,9 @@ do not replace other declarations from an old local snapshot.
Current declaration sources are in [admin/gameinfo.json](admin/gameinfo.json):
- Six options: public holdings, team play, two-player mode, automatic ending, end size,
and **Stock swap: Off / 3 / 5 / 7 / Unlimited**, default Off.
- Setup options include public holdings, team play, two-player mode, automatic ending, end size,
**Stock swap: Off / 3 / 5 / 7 / Unlimited**, two tiles per turn and limited game log.
Stock swaps, two tiles per turn and limited logs default Off.
- The **sound** preference, default on, also honoring BGS's global sound setting.
- Three interactive tutorial chapters: founding, mergers and scoring.

View file

@ -1,6 +1,6 @@
{
"name": "acquire-engine",
"version": "0.0.4",
"version": "0.0.5",
"description": "Acquire rules engine for boardgamers.space",
"license": "AGPL-3.0-only",
"files": [

View file

@ -6,6 +6,7 @@ import { logWindowStart } from "./limited-log.js";
import { applyMove, currentSeat } from "./moves.js";
import { normalizeOptions } from "./options.js";
import { initGame } from "./setup.js";
import { simpleLine } from "./simple.js";
import type { GameState, LogEntry } from "./types.js";
const LIMITED = { limitedLog: true };
@ -84,6 +85,26 @@ test("§13 limitedLog: a merger in progress stays fully visible to every dispose
assert.ok(disposals > 0, "the game reached a stock disposal");
});
test("§13 limitedLog: visible turn summaries cannot reveal an earlier hidden turn", () => {
const state = initGame(4, LIMITED, "summary-window");
playUntil(state, lcg(2), (s) => s.turn > 14 && s.phase === "place");
for (const player of [0, 1, 2, 3, undefined]) {
const start = logWindowStart(state, player);
assert.ok(start > 0);
const view = wrapper.stripSecret(state, player);
assert.equal(view.log[start - 1]!.type, "hidden");
const slice = wrapper.logSlice(state, { player, start, end: start }).log;
assert.equal(slice[0]!.simple, simpleLine(state, state.log[start]!));
}
});
test("§13 limitedLog: four-hands spectators use both seats of the active player", () => {
const state = initGame(2, { ...LIMITED, twoPlayerMode: "fourHands" }, "spectator-window");
playUntil(state, lcg(2), (s) => s.turn > 14 && s.phase === "place");
const owner = state.seatOwner[state.activeSeat]!;
assert.deepEqual(wrapper.stripSecret(state).log, wrapper.stripSecret(state, owner).log);
});
test("§13 limitedLog: the whole log is revealed once the game ends", () => {
const state = initGame(3, LIMITED, "revealed");
playUntil(state, lcg(3));

View file

@ -14,7 +14,7 @@ export function logWindowStart(state: GameState, player: number | undefined): nu
if (!state.options.limitedLog || state.ended) {
return 0;
}
const own = player === undefined ? [state.activeSeat] : seatsOf(state, player);
const own = seatsOf(state, player ?? state.seatOwner[state.activeSeat]);
let current = true;
for (let index = state.log.length - 1; index >= 0; index--) {
const entry = state.log[index]!;

View file

@ -58,6 +58,9 @@ export function simpleLineAt(state: GameState, index: number): string {
export function turnSummary(state: GameState, index: number): string {
let start = index - 1;
while (start >= 0 && state.log[start]!.type !== "turn") {
if (state.log[start]!.type === "hidden") {
return simpleLine(state, state.log[index]!);
}
start--;
}
if (start < 0) {

View file

@ -239,6 +239,7 @@ test("§15 twoTiles: both placements can be drafted privately before committing"
options: TWO_TILES,
});
const player = 0;
const original = structuredClone(state);
const draft = wrapper.move(
state,
{ type: "turn", from: state.log.length, moves: [place("5E"), place("9I")] },
@ -247,6 +248,22 @@ test("§15 twoTiles: both placements can be drafted privately before committing"
assert.equal(draft.phase, "buy");
assert.deepEqual(draft.tentative, { player, from: state.log.length });
assert.equal(wrapper.toSave(draft), undefined);
assert.deepEqual(wrapper.timeIncrements(draft), [0, 0, 0]);
for (let revision = 0; revision < 3; revision++) {
const revised = wrapper.move(state, { type: "turn", from: state.log.length, moves: [place("9I")] }, player);
assert.equal(revised.phase, "place");
assert.equal(wrapper.toSave(revised), undefined);
assert.deepEqual(wrapper.timeIncrements(revised), [0, 0, 0]);
assert.deepEqual(state, original);
}
const committed = wrapper.move(
state,
{ type: "turn", from: state.log.length, moves: [place("5E"), place("9I"), buy] },
player
);
assert.equal(wrapper.toSave(committed), committed);
assert.deepEqual(wrapper.timeIncrements(committed), [1, 0, 0]);
assert.equal(committed.log.filter((entry) => entry.type === "move").length, 3);
});
test("§14.7 twoTiles games replay exactly", () => {

View file

@ -4,7 +4,7 @@ import { applyMove, currentSeat, dropPlayerSeats } from "./src/moves.js";
import { replayGame } from "./src/replay.js";
import { playerRankings, playerScores } from "./src/scoring.js";
import { initGame } from "./src/setup.js";
import { simpleLine, simpleLineAt } from "./src/simple.js";
import { simpleLineAt } from "./src/simple.js";
import type { GameState, LogEntry } from "./src/types.js";
import { seatsOf, viewFor } from "./src/view.js";
@ -85,10 +85,12 @@ export function logSlice(
const start = Math.max(0, options?.start ?? 0);
const end = options?.end ?? data.log.length - 1;
const log = visibleLog(data, options?.player);
// Summaries must use the same filtered history: a visible turn can follow hidden moves.
const shown = { ...data, log };
return {
log: log.slice(start, end + 1).map((entry, i) => ({
...entry,
simple: entry.type === "hidden" ? simpleLine(data, entry) : simpleLineAt(data, start + i),
simple: simpleLineAt(shown, start + i),
})),
...(data.tentative && data.tentative.player === options?.player
? { preview: stripSecret(data, options.player) }

View file

@ -1,6 +1,6 @@
{
"name": "acquire-viewer",
"version": "0.0.17",
"version": "0.0.18",
"private": true,
"description": "Browser viewer for Acquire on boardgamers.space",
"license": "AGPL-3.0-only",

View file

@ -64,6 +64,9 @@ export class ViewerStore {
private display(state: GameState): void {
this.state = state;
if (!this.replayable) {
this.replayAt = undefined;
}
this.selected = undefined;
this.sending = false;
this.undoCount = this.draft.count;
@ -108,7 +111,7 @@ export class ViewerStore {
}
/** With a limited log (rules.md §13), replay waits until the game ends and the log is whole. */
replayable = $derived(!this.state?.log.some((entry) => entry.type === "hidden"));
replayable = $derived(!this.state?.options.limitedLog || this.state.ended);
/** The replay range BGS shows in its controls: setup done, up to the live position. */
replayRange(): { start: number; end: number } {

View file

@ -104,6 +104,129 @@ try {
assert.equal(report.diagnostics.compatible, true);
assert.equal(report.diagnostics.recommended.percent, 100);
// The two-tile variant keeps both placements private until buying or a commit boundary.
for (const width of [1280, 390, 320]) {
await page.setViewportSize({ width, height: 900 });
await open("players=3&hotseat=0&view=0&twoTiles=1&limitedLog=1");
await page.evaluate((state) => {
const { parseTile, allTiles } = window.acquireDev.rules;
state.options.twoTiles = true;
state.options.limitedLog = true;
state.board[parseTile("1C")] = "loose";
state.seats[0].hand = ["2A", "3A", "2C", "5E", "7E", "9E", "7G", "9G"].map(parseTile);
const held = new Set(state.seats.flatMap((seat) => seat.hand));
state.pool = allTiles().filter((tile) => state.board[tile] === null && !held.has(tile));
window.acquireDev.load(state);
}, preparedPosition("founding"));
await settle();
assert.equal(await page.locator("section.hand .tile").count(), 8);
const original = await page.evaluate(() => JSON.stringify(window.acquireDev.state));
await page.locator(".board").getByRole("button", { name: "Place 2A", exact: true }).click();
await page.locator(".choices button").filter({ hasText: "Tower" }).click();
await settle();
assert.match(await page.locator(".status").innerText(), /second tile/);
assert.equal(await page.locator("table.buy").count(), 0);
assert.equal(await page.locator("section.hand .tile.paused").count(), 1);
assert.equal(await page.locator(".board").getByRole("button", { name: "Place 2C", exact: true }).count(), 0);
for (const theme of ["light", "dark"]) {
await page.evaluate((value) => window.acquireDev.emitter.emit("theme", { dark: value === "dark" }), theme);
for (const locale of locales) {
await preferences({ locale });
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1));
assert.ok((await page.locator("section.hand .tile-notes").innerText()).length > 5);
}
await preferences({ locale: "en" });
await page.screenshot({ path: fileURLToPath(new URL(`two-tiles-${theme}-${width}.png`, output)) });
}
for (let revision = 0; revision < 3; revision++) {
await page.locator(".board").getByRole("button", { name: "Place 3A", exact: true }).click();
await page.waitForSelector("table.buy");
assert.equal(await page.evaluate(() => JSON.stringify(window.acquireDev.state)), original);
await page.getByRole("button", { name: "Undo", exact: true }).click();
await settle();
assert.match(await page.locator(".status").innerText(), /second tile/);
}
await page.locator(".board").getByRole("button", { name: "Place 3A", exact: true }).click();
await page.waitForSelector("table.buy");
await page.locator(".panel .primary").click();
await page.waitForFunction(() => window.acquireDev.state.turn === 2);
assert.deepEqual(
await page.evaluate(() => ({
moves: window.acquireDev.state.log.filter((entry) => entry.type === "move").length,
increments: window.acquireDev.engine.timeIncrements(window.acquireDev.state),
hand: window.acquireDev.state.seats[0].hand.length,
})),
{ moves: 4, increments: [1, 0, 0], hand: 8 }
);
}
report.scenarios.push(
"two-tile placement limits, 17 locales/both themes/phone layouts, repeated undo and one turn increment"
);
// Limited logs never enter replay during play, including before the first hidden entry.
for (const mode of ["players=4", "players=2&twoPlayerMode=fourHands"]) {
await open(`${mode}&twoTiles=1&limitedLog=1&hotseat=0&view=0`);
for (const later of [false, true]) {
if (later) {
await page.evaluate(() => {
const { rules, state, load } = window.acquireDev;
for (let i = 0; state.turn < 15 && i < 300; i++) {
const moves = rules.legalMoves(state).filter((move) => move.type !== "announce");
rules.applyMove(state, moves[i % moves.length], rules.currentSeat(state));
}
load(state);
});
}
const count = mode.startsWith("players=4") ? 4 : 2;
for (let viewer = 0; viewer <= count; viewer++) {
await page.evaluate(
(player) => {
const { engine, emitter, state } = window.acquireDev;
const index = player ?? undefined;
emitter.emit("player", { index });
emitter.emit("state", engine.stripSecret(state, index));
},
viewer === count ? null : viewer
);
await settle();
const board = await page.locator(".board").first().innerText();
const hands = await page.locator("section.hand").count();
await page.evaluate(() => {
const { emitter } = window.acquireDev;
emitter.emit("replay:start");
emitter.emit("replay:to", 0);
});
await settle();
assert.equal(await page.locator(".board").first().innerText(), board);
assert.equal(await page.locator("section.hand").count(), hands);
await page.evaluate(() => window.acquireDev.emitter.emit("replay:end"));
}
}
await page.evaluate(() => {
const { rules, state, load } = window.acquireDev;
for (let i = 0; !state.ended && i < 2000; i++) {
const moves = rules.legalMoves(state);
rules.applyMove(
state,
moves.find((move) => move.type === "announce") ?? moves[i % moves.length],
rules.currentSeat(state)
);
}
load(state);
});
await settle();
assert.equal(await page.evaluate(() => window.acquireDev.state.ended), true);
assert.equal(await page.locator(".log li.hidden").count(), 0);
const endedBoard = await page.locator(".board").first().innerText();
await page.evaluate(() => {
window.acquireDev.emitter.emit("replay:start");
window.acquireDev.emitter.emit("replay:to", 0);
});
await settle();
assert.notEqual(await page.locator(".board").first().innerText(), endedBoard);
}
report.scenarios.push("limited log: players/four hands/spectators, live replay lock and full replay after game end");
// Optional swaps are private drafts, with one shared allowance and separate purchases.
for (const width of [1280, 390, 320]) {
await page.setViewportSize({ width, height: 900 });