From 2cfb5332f62d0b61e6cea66a8c8fb3d838ee1d9f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 06:54:05 -0700 Subject: [PATCH 01/12] Repeat tile placement confirmation under the hand on phones On narrow layouts the decision panel sits above the board, so confirming a tile chosen in the rack meant scrolling back up past the board. Extract the place confirmation into PlaceConfirm, used by the action panel and, below 700px, directly under the rack, where it scrolls into view when it opens. Co-Authored-By: Claude Opus 5.5 --- packages/viewer/src/App.svelte | 12 +++- packages/viewer/src/lib/ActionPanel.svelte | 31 +-------- packages/viewer/src/lib/PlaceConfirm.svelte | 72 +++++++++++++++++++++ 3 files changed, 86 insertions(+), 29 deletions(-) create mode 100644 packages/viewer/src/lib/PlaceConfirm.svelte diff --git a/packages/viewer/src/App.svelte b/packages/viewer/src/App.svelte index 4ce9658..721ad8c 100644 --- a/packages/viewer/src/App.svelte +++ b/packages/viewer/src/App.svelte @@ -5,6 +5,7 @@ import Chat from "./lib/Chat.svelte"; import Hand from "./lib/Hand.svelte"; import Log from "./lib/Log.svelte"; + import PlaceConfirm from "./lib/PlaceConfirm.svelte"; import Players from "./lib/Players.svelte"; import PriceTable from "./lib/PriceTable.svelte"; import Status from "./lib/Status.svelte"; @@ -30,7 +31,10 @@ /> {#if store.seats.length > 0 && store.replayAt === undefined} -
+
+ +
+
{/if}
@@ -70,6 +74,12 @@ .hand { grid-area: hand; } + /* Phones show the decision above the board: repeat the placement confirmation under the rack. */ + @media (min-width: 700px) { + .hand-confirm { + display: none; + } + } .market { grid-area: market; display: grid; diff --git a/packages/viewer/src/lib/ActionPanel.svelte b/packages/viewer/src/lib/ActionPanel.svelte index b21dd03..1c62946 100644 --- a/packages/viewer/src/lib/ActionPanel.svelte +++ b/packages/viewer/src/lib/ActionPanel.svelte @@ -7,22 +7,14 @@ merger, sharePrice, sharePurchaseLimit, - tileLabel, type ChainId, type Shares, } from "acquire-engine"; import ChainMark from "./ChainMark.svelte"; + import PlaceConfirm from "./PlaceConfirm.svelte"; import StockSwap from "./StockSwap.svelte"; import { mergerPreview } from "./mergerPreview"; - import { - adjustShares, - canBuy, - canDispose, - describePlacement, - disposalPresets, - nextDefunctChoices, - ofType, - } from "./decisions"; + import { adjustShares, canBuy, canDispose, disposalPresets, nextDefunctChoices, ofType } from "./decisions"; import { chainName } from "./format"; import type { ViewerStore } from "./store.svelte"; @@ -72,12 +64,6 @@ const price = (chain: ChainId) => sharePrice(chain, chainSize(game.board, chain)); const cost = $derived(Object.entries(shares).reduce((sum, [chain, n]) => sum + n * price(chain as ChainId), 0)); const total = $derived(Object.values(shares).reduce((sum, n) => sum + n, 0)); - - function placeSelected(): void { - if (store.selected !== undefined) { - store.send({ type: "place", tile: tileLabel(store.selected) }); - } - } {#if moves.length > 0 && !store.sending} @@ -115,18 +101,7 @@ {#if game.phase === "place"} {#if store.selected !== undefined} -

- {t("place.effect", { - tile: tileLabel(store.selected), - effect: describePlacement(game, store.selected, lang), - })} -

- - + {:else if legal("place")}

{t("place.choose")}

{/if} diff --git a/packages/viewer/src/lib/PlaceConfirm.svelte b/packages/viewer/src/lib/PlaceConfirm.svelte new file mode 100644 index 0000000..c13f45c --- /dev/null +++ b/packages/viewer/src/lib/PlaceConfirm.svelte @@ -0,0 +1,72 @@ + + +{#if tile !== undefined} +
+

{t("place.effect", { tile: tileLabel(tile), effect: describePlacement(store.state!, tile, store.lang) })}

+ + +
+{/if} + + From 5fbb6dce1694eea3f6647ff38c9f33de293e5a08 Mon Sep 17 00:00:00 2001 From: Mike Isom <103458985+MikeIsom@users.noreply.github.com> Date: Wed, 4 Nov 2026 06:56:52 -0700 Subject: [PATCH 02/12] Relax two-tiles-per-turn founding and merger limits A two-tile turn may now merge and then found, found and then merge two other chains, or merge twice. It still founds at most one chain, and the second tile cannot cause a merger involving the chain founded this turn. New two-tile games record twoTilesRelaxed in their options. Replay passes the init log's recorded options to normalizeOptions, so games created under the original limits keep them and replay exactly. The hand explains the new limit with hand.mergeFounded in all 17 catalogs. --- docs/admin/rules.md | 6 +- packages/engine/index.ts | 8 +- packages/engine/src/moves.ts | 13 +- packages/engine/src/options.ts | 14 +- packages/engine/src/replay.ts | 2 +- packages/engine/src/setup.ts | 16 +- packages/engine/src/two-tiles.spec.ts | 195 ++++++++++++++++++---- packages/engine/src/two-tiles.ts | 49 ++++-- packages/viewer/src/lib/Hand.svelte | 2 +- packages/viewer/src/lib/decisions.spec.ts | 11 +- packages/viewer/src/lib/decisions.ts | 13 +- packages/viewer/src/lib/locales/da.ts | 1 + packages/viewer/src/lib/locales/de.ts | 1 + packages/viewer/src/lib/locales/el.ts | 1 + packages/viewer/src/lib/locales/en.ts | 1 + packages/viewer/src/lib/locales/fa.ts | 1 + packages/viewer/src/lib/locales/fr.ts | 1 + packages/viewer/src/lib/locales/hi.ts | 1 + packages/viewer/src/lib/locales/it.ts | 1 + packages/viewer/src/lib/locales/ko.ts | 1 + packages/viewer/src/lib/locales/nl.ts | 1 + packages/viewer/src/lib/locales/pl.ts | 1 + packages/viewer/src/lib/locales/pt-BR.ts | 1 + packages/viewer/src/lib/locales/ro.ts | 1 + packages/viewer/src/lib/locales/ru.ts | 1 + packages/viewer/src/lib/locales/vi.ts | 1 + packages/viewer/src/lib/locales/zh-CN.ts | 1 + packages/viewer/src/lib/locales/zh-TW.ts | 1 + rules.md | 10 +- scripts/check-browser.mjs | 1 + 30 files changed, 287 insertions(+), 70 deletions(-) diff --git a/docs/admin/rules.md b/docs/admin/rules.md index 6a76981..b826a54 100644 --- a/docs/admin/rules.md +++ b/docs/admin/rules.md @@ -43,13 +43,15 @@ If the game uses **Two tiles per turn**, each player holds 8 tiles instead of 6 At the start of your turn, swap out any dead tiles. Then place your first tile and settle anything it causes, including a full merger with everyone's sell, trade or keep decisions, before placing your second. After both tiles, buy shares up to the game’s per-turn limit (3 by default) at the prices on the board, then draw back up to 8. -You may found only one chain per turn, and you can't found a chain and cause a merger in the same turn, in either order. You can cause two mergers, one with each tile. Example: your first tile merges Luxor into Tower, so your second tile can merge again or grow a chain, but it can't found a new one. +You may found only one chain per turn, and your second tile can't cause a merger involving the chain your first tile founded. Otherwise each tile follows the usual rules: you can merge and then found a chain, found a chain and then merge two other chains, or cause two mergers, one with each tile. Example: your first tile founds Worldwide, so your second tile can merge Luxor into Tower or grow Worldwide, but it can't found another chain or cause a merger involving Worldwide. You must play a second tile if any tile in your hand is legal after the first. If none is, go straight to buying. A tile that becomes dead during your turn, for example because your first tile made a chain safe, can't be your second tile; it's swapped out at the start of your next turn. You can announce the end of the game before your first tile, between your two tiles, or while buying, as long as an end condition holds at that moment. -In a two-player game, the bank's tiles are placed right after the merger that drew them, so between your two tiles if your first tile caused it. Mergers caused by the bank's tiles don't count toward your two mergers or the founding rule. If a player leaves, the game places their first two legal tiles for them. +Two-tile games started before this rule was relaxed keep the earlier limit: a turn can't both found a chain and cause a merger, in either order (mergers caused by the bank's tiles don't count). + +In a two-player game, the bank's tiles are placed right after the merger that drew them, so between your two tiles if your first tile caused it. If a player leaves, the game places their first two legal tiles for them. ## Mergers diff --git a/packages/engine/index.ts b/packages/engine/index.ts index 3f3986d..c80f20b 100644 --- a/packages/engine/index.ts +++ b/packages/engine/index.ts @@ -19,4 +19,10 @@ export * from "./src/replay.js"; export * from "./src/position.js"; export * from "./src/simple.js"; export { logWindowStart } from "./src/limited-log.js"; -export { blockedThisTurn, secondPlacementDue, turnPlacements } from "./src/two-tiles.js"; +export { + blockedThisTurn, + secondPlacementDue, + turnPlacements, + twoTileLimit, + type TwoTileLimit, +} from "./src/two-tiles.js"; diff --git a/packages/engine/src/moves.ts b/packages/engine/src/moves.ts index 1a10f8a..5ebb342 100644 --- a/packages/engine/src/moves.ts +++ b/packages/engine/src/moves.ts @@ -17,9 +17,15 @@ import { sharePrice } from "./prices.js"; import { canAnnounce, endGame } from "./scoring.js"; import { parseTile, tileLabel, type Tile } from "./tiles.js"; import { afterPlacement, endTurn, enterBuyPhase } from "./turn.js"; -import { blockedThisTurn } from "./two-tiles.js"; +import { twoTileLimit, type TwoTileLimit } from "./two-tiles.js"; import type { GameState, Move, Shares } from "./types.js"; +const TWO_TILE_LIMIT_ERRORS: Record = { + oneFounding: "A turn cannot found two chains", + mergeFounded: "A turn cannot merge the chain it founded", + foundOrMerge: "A turn cannot both found a chain and cause a merger", +}; + export function currentSeat(state: GameState): number | undefined { if (state.ended) { return undefined; @@ -88,8 +94,9 @@ export function sanitizeMove(state: GameState, raw: unknown, seat: number): Move if (tileLegality(state.board, tile) !== "playable") { throw new Error(`Tile ${tileLabel(tile)} cannot be played now`); } - if (blockedThisTurn(state, tile)) { - throw new Error("A turn cannot found two chains, or both found a chain and cause a merger"); + const limit = twoTileLimit(state, tile); + if (limit !== undefined) { + throw new Error(TWO_TILE_LIMIT_ERRORS[limit]); } return { type: "place", tile: tileLabel(tile) }; } diff --git a/packages/engine/src/options.ts b/packages/engine/src/options.ts index ded5bc5..315bc10 100644 --- a/packages/engine/src/options.ts +++ b/packages/engine/src/options.ts @@ -13,6 +13,11 @@ export interface GameOptions { sharesPerTurn?: 4 | 5; /** Omitted when off, like stockSwap. */ twoTiles?: true; + /** + * Set with twoTiles in games created under the relaxed founding/merger limits (rules.md + * §4.1). Two-tile games logged before them lack it and keep the original limits. + */ + twoTilesRelaxed?: true; /** Omitted when off, like stockSwap. */ limitedLog?: true; } @@ -37,11 +42,13 @@ const END_SIZES = [41, 31]; * Reads the creator's options defensively. BGS omits unticked checkboxes and always sends * selects (as strings), so a missing checkbox means false. Options are never rejected * (rules.md §3.5/§15): anything that does not apply, or has an unknown value, is ignored - * and reported so the log can say so. + * and reported so the log can say so. Replay passes the options `recorded` in the game's + * init log, so games created under an earlier rule revision rebuild with that revision. */ export function normalizeOptions( players: number, - raw: Record + raw: Record, + recorded?: Partial ): { options: GameOptions; ignored: IgnoredOption[] } { const options: GameOptions = { ...DEFAULT_OPTIONS }; const ignored: IgnoredOption[] = []; @@ -96,6 +103,9 @@ export function normalizeOptions( if (raw.twoTiles === true) { options.twoTiles = true; + if (recorded === undefined || recorded.twoTilesRelaxed === true) { + options.twoTilesRelaxed = true; + } } if (raw.limitedLog === true) { options.limitedLog = true; diff --git a/packages/engine/src/replay.ts b/packages/engine/src/replay.ts index d6f4684..3d9f597 100644 --- a/packages/engine/src/replay.ts +++ b/packages/engine/src/replay.ts @@ -15,7 +15,7 @@ export function replayGame(data: GameState, to: number = data.log.length): GameS if (!data.seed || first?.type !== "init") { throw new Error("Replay needs the full game state, including the seed"); } - const state = initGame(first.players, first.rawOptions, data.seed); + const state = initGame(first.players, first.rawOptions, data.seed, first.options); checkLog(state, data, 0); while (state.log.length < to) { const checked = state.log.length; diff --git a/packages/engine/src/setup.ts b/packages/engine/src/setup.ts index 49951ad..db31352 100644 --- a/packages/engine/src/setup.ts +++ b/packages/engine/src/setup.ts @@ -1,5 +1,5 @@ import { CHAIN_IDS, MAX_PLAYERS, MIN_PLAYERS, SHARES_PER_CHAIN, STARTING_CASH } from "./config.js"; -import { handSize, normalizeOptions, seatOwners } from "./options.js"; +import { handSize, normalizeOptions, seatOwners, type GameOptions } from "./options.js"; import { shuffle } from "./prng.js"; import { allTiles } from "./tiles.js"; import { drawTile, startTurn } from "./turn.js"; @@ -9,12 +9,20 @@ function sharesOf(count: number): Shares { return Object.fromEntries(CHAIN_IDS.map((chain) => [chain, count])) as Shares; } -/** Creates a game for `players` real players; fourHands gives each of them two seats. */ -export function initGame(players: number, rawOptions: Record, seed: string): GameState { +/** + * Creates a game for `players` real players; fourHands gives each of them two seats. Replay + * passes the init log's `recorded` options to keep the rules the game was created with. + */ +export function initGame( + players: number, + rawOptions: Record, + seed: string, + recorded?: Partial +): GameState { if (!Number.isInteger(players) || players < MIN_PLAYERS || players > MAX_PLAYERS) { throw new Error(`Acquire needs ${MIN_PLAYERS} to ${MAX_PLAYERS} players`); } - const { options, ignored } = normalizeOptions(players, rawOptions); + const { options, ignored } = normalizeOptions(players, rawOptions, recorded); const seatOwner = seatOwners(players, options); const seats = seatOwner.length; const state: GameState = { diff --git a/packages/engine/src/two-tiles.spec.ts b/packages/engine/src/two-tiles.spec.ts index 349178f..b46e416 100644 --- a/packages/engine/src/two-tiles.spec.ts +++ b/packages/engine/src/two-tiles.spec.ts @@ -4,6 +4,7 @@ import * as wrapper from "../wrapper.js"; import { legalMoves } from "./legal.js"; import { applyMove, currentSeat, dropPlayerSeats } from "./moves.js"; import { normalizeOptions } from "./options.js"; +import { blockedThisTurn, turnPlacements, twoTileLimit } from "./two-tiles.js"; import { positionAt } from "./position.js"; import { initGame } from "./setup.js"; import { turnSummary } from "./simple.js"; @@ -82,41 +83,61 @@ test("§15 twoTiles: the second tile is skipped when none is playable", () => { assert.deepEqual(placeable(state), []); }); -test("§15 twoTiles: after founding, a tile that would found or merge is blocked; growing is allowed", () => { - const state = scenario({ - board: { ...chainAt("tower", ["1E", "2E"]), ...chainAt("luxor", ["4E", "5E"]), "8A": "loose", "1A": "loose" }, - hands: [["9A", "3E", "6E", "2A"], ["12C"], ["12E"]], - poolOnly: true, - options: TWO_TILES, - }); - assert.deepEqual(placeable(state), ["9A", "3E", "6E", "2A"]); - play(state, 0, place("9A")); - play(state, 0, { type: "found", chain: "american" }); - assert.deepEqual(placeable(state), ["6E"]); - for (const tile of ["3E", "2A"]) { - assert.throws(() => applyMove(state, place(tile), 0), /cannot found two chains/); - } - play(state, 0, place("6E")); - assert.equal(state.phase, "buy"); -}); +// Two pairs of chains to merge, and loose tiles to found a chain next to. +const LIMITS_BOARD = { + ...chainAt("tower", ["1A", "2A"]), + ...chainAt("luxor", ["4A", "5A"]), + ...chainAt("american", ["1E", "2E"]), + ...chainAt("festival", ["4E", "5E"]), + "8G": "loose", + "1I": "loose", +} as const; -test("§15 twoTiles: a turn may cause two mergers, but not a merger and a founding", () => { +test("§4.1 twoTiles: a merger with the first tile, then a founding with the second, is allowed", () => { const state = scenario({ - board: { - ...chainAt("tower", ["1A", "2A"]), - ...chainAt("luxor", ["4A", "5A"]), - ...chainAt("american", ["1E", "2E"]), - ...chainAt("festival", ["4E", "5E"]), - "8G": "loose", - }, - hands: [["3A", "3E", "9G"], ["12C"], ["12E"]], + board: LIMITS_BOARD, + hands: [["3A", "9G"], ["12C"], ["12E"]], poolOnly: true, options: TWO_TILES, }); play(state, 0, place("3A")); play(state, 0, { type: "survivor", chain: "tower" }); assert.equal(state.phase, "place"); - assert.deepEqual(placeable(state), ["3E"], "9G would found a chain after a merger"); + assert.deepEqual(placeable(state), ["9G"]); + play(state, 0, place("9G")); + play(state, 0, { type: "found", chain: "worldwide" }); + assert.equal(state.phase, "buy"); + play(state, 0, buy); + assert.equal(turnSummary(state, state.log.length - 1), "Player 1 merged Luxor into Tower, founded Worldwide"); +}); + +test("§4.1 twoTiles: a founding with the first tile, then a merger of two other chains, is allowed", () => { + const state = scenario({ + board: LIMITS_BOARD, + hands: [["9G", "3A", "3E"], ["12C"], ["12E"]], + poolOnly: true, + options: TWO_TILES, + }); + play(state, 0, place("9G")); + play(state, 0, { type: "found", chain: "worldwide" }); + assert.deepEqual(placeable(state), ["3A", "3E"]); + play(state, 0, place("3E")); + play(state, 0, { type: "survivor", chain: "american" }); + assert.equal(state.phase, "buy"); + play(state, 0, buy); + assert.equal(turnSummary(state, state.log.length - 1), "Player 1 founded Worldwide, merged Festival into American"); +}); + +test("§4.1 twoTiles: a merger, then another merger, is allowed", () => { + const state = scenario({ + board: LIMITS_BOARD, + hands: [["3A", "3E", "9G"], ["12C"], ["12E"]], + poolOnly: true, + options: TWO_TILES, + }); + play(state, 0, place("3A")); + play(state, 0, { type: "survivor", chain: "tower" }); + assert.deepEqual(placeable(state), ["3E", "9G"]); play(state, 0, place("3E")); play(state, 0, { type: "survivor", chain: "american" }); assert.equal(state.phase, "buy"); @@ -127,16 +148,53 @@ test("§15 twoTiles: a turn may cause two mergers, but not a merger and a foundi ); }); -test("§15 twoTiles: a founding first rules out a merger with the second tile", () => { +test("§4.1 twoTiles: a turn cannot found two chains; growing the new chain is allowed", () => { const state = scenario({ - board: { ...chainAt("tower", ["1A", "2A"]), ...chainAt("luxor", ["4A", "5A"]), "8G": "loose" }, - hands: [["9G", "3A"], ["12C"], ["12E"]], + board: LIMITS_BOARD, + hands: [["9G", "2I", "10G"], ["12C"], ["12E"]], poolOnly: true, options: TWO_TILES, }); play(state, 0, place("9G")); - play(state, 0, { type: "found", chain: "american" }); - assert.deepEqual(placeable(state), [], "3A would merge after a founding"); + play(state, 0, { type: "found", chain: "worldwide" }); + assert.equal(twoTileLimit(state, t("2I")), "oneFounding"); + assert.throws(() => applyMove(state, place("2I"), 0), /cannot found two chains/); + assert.deepEqual(placeable(state), ["10G"]); + play(state, 0, place("10G")); + assert.equal(state.phase, "buy"); +}); + +test("§4.1 twoTiles: the second tile cannot merge the chain founded this turn", () => { + // 9G founds a chain with 8G; 7G would then merge it with Imperial. + const state = scenario({ + board: { ...LIMITS_BOARD, ...chainAt("imperial", ["6G", "6H"]) }, + hands: [["9G", "7G", "3A"], ["12C"], ["12E"]], + poolOnly: true, + options: TWO_TILES, + }); + assert.equal(twoTileLimit(state, t("7G")), undefined); + play(state, 0, place("9G")); + play(state, 0, { type: "found", chain: "worldwide" }); + assert.equal(twoTileLimit(state, t("7G")), "mergeFounded"); + assert.equal(twoTileLimit(state, t("3A")), undefined); + assert.throws(() => applyMove(state, place("7G"), 0), /cannot merge the chain it founded/); + assert.deepEqual(placeable(state), ["3A"]); + play(state, 0, place("3A")); + play(state, 0, { type: "survivor", chain: "luxor" }); + play(state, 0, buy); + assert.equal(twoTileLimit(state, t("7G")), undefined, "the limit ends with the turn"); +}); + +test("§4.1 twoTiles: the second tile is skipped when only a merger with the new chain remains", () => { + const state = scenario({ + board: { ...LIMITS_BOARD, ...chainAt("imperial", ["6G", "6H"]) }, + hands: [["9G", "7G"], ["12C"], ["12E"]], + poolOnly: true, + options: TWO_TILES, + }); + play(state, 0, place("9G")); + play(state, 0, { type: "found", chain: "worldwide" }); + assert.deepEqual(placeable(state), []); assert.equal(state.phase, "buy"); }); @@ -275,3 +333,76 @@ test("§14.7 twoTiles games replay exactly", () => { } assert.deepEqual(wrapper.replay(state), state); }); + +/** Two-tile games created before the relaxed limits have no `twoTilesRelaxed` option. */ +function legacy(state: GameState): GameState { + delete state.options.twoTilesRelaxed; + const init = state.log[0]; + if (init?.type === "init") { + delete init.options.twoTilesRelaxed; + } + return state; +} + +test("§4.1 twoTiles: new games record the relaxed limits; replay keeps a game's own revision", () => { + assert.equal(normalizeOptions(3, TWO_TILES).options.twoTilesRelaxed, true); + assert.equal("twoTilesRelaxed" in normalizeOptions(3, {}).options, false); + assert.equal("twoTilesRelaxed" in normalizeOptions(3, TWO_TILES, { twoTiles: true }).options, false); + assert.equal(normalizeOptions(3, TWO_TILES, { twoTiles: true, twoTilesRelaxed: true }).options.twoTilesRelaxed, true); + assert.equal("twoTilesRelaxed" in normalizeOptions(3, {}, { twoTilesRelaxed: true }).options, false); +}); + +test("§4.1 twoTiles in games created before the relaxed limits: no founding and merger in one turn", () => { + const foundThenMerge = legacy( + scenario({ + board: LIMITS_BOARD, + hands: [["9G", "3A", "12A"], ["12C"], ["12E"]], + poolOnly: true, + options: TWO_TILES, + }) + ); + play(foundThenMerge, 0, place("9G")); + play(foundThenMerge, 0, { type: "found", chain: "worldwide" }); + assert.equal(twoTileLimit(foundThenMerge, t("3A")), "foundOrMerge"); + assert.throws(() => applyMove(foundThenMerge, place("3A"), 0), /cannot both found a chain and cause a merger/); + assert.deepEqual(placeable(foundThenMerge), ["12A"]); + + const mergeThenFound = legacy( + scenario({ board: LIMITS_BOARD, hands: [["3A", "9G", "3E"], ["12C"], ["12E"]], poolOnly: true, options: TWO_TILES }) + ); + play(mergeThenFound, 0, place("3A")); + play(mergeThenFound, 0, { type: "survivor", chain: "tower" }); + assert.equal(twoTileLimit(mergeThenFound, t("9G")), "foundOrMerge"); + assert.deepEqual(placeable(mergeThenFound), ["3E"], "two mergers are still allowed"); +}); + +test("§4.1 twoTiles in games created before the relaxed limits: bank-caused mergers do not count", () => { + const state = legacy( + scenario({ board: LIMITS_BOARD, hands: [["12A", "9G"], ["12C"], ["12E"]], poolOnly: true, options: TWO_TILES }) + ); + play(state, 0, place("12A")); + state.log.push({ type: "merger", seat: 0, tile: t("3A"), sizes: { tower: 2, luxor: 2 }, byBank: true }); + assert.equal(turnPlacements(state).merged, false); + assert.equal(twoTileLimit(state, t("9G")), undefined); + state.log.push({ type: "merger", seat: 0, tile: t("3E"), sizes: { american: 2, festival: 2 } }); + assert.equal(turnPlacements(state).merged, true); + assert.equal(twoTileLimit(state, t("9G")), "foundOrMerge"); +}); + +test("§14.7 twoTiles games created before the relaxed limits replay under them", () => { + const state = legacy(initGame(3, TWO_TILES, "legacy-two-tiles")); + let differs = false; + for (let i = 0; i < 400 && !state.ended; i++) { + if (state.phase === "place") { + const relaxed = { ...state, options: { ...state.options, twoTilesRelaxed: true as const } }; + differs ||= state.seats[state.activeSeat]!.hand.some( + (tile) => blockedThisTurn(state, tile) && !blockedThisTurn(relaxed, tile) + ); + } + const moves = legalMoves(state).filter((move) => move.type !== "announce"); + play(state, currentSeat(state)!, moves[(i * 7919) % moves.length]!); + } + assert.ok(differs, "the game reaches a turn where the original limits block a tile"); + assert.equal("twoTilesRelaxed" in state.options, false); + assert.deepEqual(wrapper.replay(structuredClone(state)), state); +}); diff --git a/packages/engine/src/two-tiles.ts b/packages/engine/src/two-tiles.ts index fe90707..9f7c620 100644 --- a/packages/engine/src/two-tiles.ts +++ b/packages/engine/src/two-tiles.ts @@ -1,10 +1,25 @@ import { placementEffect } from "./board.js"; +import type { ChainId } from "./config.js"; import type { Tile } from "./tiles.js"; import type { GameState } from "./types.js"; -/** What the active seat's placements have done so far this turn, read from the log. */ -export function turnPlacements(state: GameState): { placed: number; founded: boolean; merged: boolean } { - const result = { placed: 0, founded: false, merged: false }; +/** + * Why rules.md §15 twoTiles rules out a tile this turn: `oneFounding` (a second founding), + * `mergeFounded` (a merger involving the chain founded this turn), or, in games created + * under the original limits, `foundOrMerge` (a founding and a merger in one turn). + */ +export type TwoTileLimit = "oneFounding" | "mergeFounded" | "foundOrMerge"; + +/** + * What the active seat's placements have done so far this turn, read from the log: how many + * tiles it placed, the chain it founded (if any) and whether it caused a merger. + */ +export function turnPlacements(state: GameState): { placed: number; founded: ChainId | null; merged: boolean } { + const result: { placed: number; founded: ChainId | null; merged: boolean } = { + placed: 0, + founded: null, + merged: false, + }; for (let i = state.log.length - 1; i >= 0; i--) { const entry = state.log[i]!; if (entry.type === "turn") { @@ -13,7 +28,7 @@ export function turnPlacements(state: GameState): { placed: number; founded: boo if (entry.type === "move" && entry.move.type === "place") { result.placed++; } else if (entry.type === "founded") { - result.founded = true; + result.founded = entry.chain; } else if (entry.type === "merger" && !entry.byBank) { // rules.md §15 twoTiles: mergers caused by bank tiles do not count. result.merged = true; @@ -23,16 +38,30 @@ export function turnPlacements(state: GameState): { placed: number; founded: boo } /** - * rules.md §15 twoTiles: a turn founds at most one chain, and never both founds a chain and - * causes a merger. Whether `tile` is ruled out by what this turn's placements already did. + * rules.md §4.1: a turn founds at most one chain, and its second tile cannot merge the chain + * its first tile founded. Games created before the relaxed limits (no `twoTilesRelaxed`) + * also forbid founding and merging in the same turn, in either order. */ -export function blockedThisTurn(state: GameState, tile: Tile): boolean { +export function twoTileLimit(state: GameState, tile: Tile): TwoTileLimit | undefined { if (!state.options.twoTiles) { - return false; + return undefined; } const { founded, merged } = turnPlacements(state); - const effect = placementEffect(state.board, tile).kind; - return (effect === "found" && (founded || merged)) || (effect === "merge" && founded); + const effect = placementEffect(state.board, tile); + if (effect.kind === "found" && founded !== null) { + return "oneFounding"; + } + if (!state.options.twoTilesRelaxed) { + return (effect.kind === "found" && merged) || (effect.kind === "merge" && founded !== null) + ? "foundOrMerge" + : undefined; + } + return effect.kind === "merge" && founded !== null && effect.chains.includes(founded) ? "mergeFounded" : undefined; +} + +/** Whether `tile` is ruled out by what this turn's placements already did (rules.md §4.1). */ +export function blockedThisTurn(state: GameState, tile: Tile): boolean { + return twoTileLimit(state, tile) !== undefined; } /** rules.md §15 twoTiles: whether the active seat places another tile before buying. */ diff --git a/packages/viewer/src/lib/Hand.svelte b/packages/viewer/src/lib/Hand.svelte index a8b008a..00d28c6 100644 --- a/packages/viewer/src/lib/Hand.svelte +++ b/packages/viewer/src/lib/Hand.svelte @@ -85,7 +85,7 @@ {paused.map(tileLabel).join(", ")} — {t("hand.eighth")} {/if} - {#each ["oneFounding", "foundOrMerge"] as const as limit (limit)} + {#each ["oneFounding", "mergeFounded", "foundOrMerge"] as const as limit (limit)} {@const tiles = limited.filter((tile) => turnLimit(state, seat, tile) === limit)} {#if tiles.length}
  • diff --git a/packages/viewer/src/lib/decisions.spec.ts b/packages/viewer/src/lib/decisions.spec.ts index 30c29c1..53a0c2f 100644 --- a/packages/viewer/src/lib/decisions.spec.ts +++ b/packages/viewer/src/lib/decisions.spec.ts @@ -137,8 +137,15 @@ test("two-tile limits explain exactly the tiles the engine blocks this turn", () continue; } assert.ok(!placeable.includes(tileLabel(tile))); - const founding = placementEffect(state.board, tile).kind === "found"; - assert.equal(limit, founding && turnPlacements(state).founded ? "oneFounding" : "foundOrMerge"); + const effect = placementEffect(state.board, tile); + const { founded } = turnPlacements(state); + assert.ok(founded, "only a founding earlier this turn limits the second tile"); + if (effect.kind === "merge") { + assert.equal(limit, "mergeFounded"); + assert.ok(effect.chains.includes(founded)); + } else { + assert.deepEqual([effect.kind, limit], ["found", "oneFounding"]); + } assert.equal(turnLimit(state, (seat + 1) % 4, tile), undefined, "limits apply only to the active seat"); } const view = stripSecret(state, seat); diff --git a/packages/viewer/src/lib/decisions.ts b/packages/viewer/src/lib/decisions.ts index d05d2f0..364abcc 100644 --- a/packages/viewer/src/lib/decisions.ts +++ b/packages/viewer/src/lib/decisions.ts @@ -1,18 +1,18 @@ // Which choices the viewer offers. Validity always comes from the engine: these helpers only // filter and look up engine.legalMoves(), so no rule is re-implemented here. import { - blockedThisTurn, CHAIN_IDS, chainSize, currentSeat, legalMoves, placementEffect, - turnPlacements, + twoTileLimit, type ChainId, type GameState, type Move, type Shares, type Tile, + type TwoTileLimit, } from "acquire-engine"; import { chainName, type Lang } from "./format.ts"; @@ -49,13 +49,8 @@ export function describePlacement(state: GameState, tile: Tile, lang: Lang): str * Why `tile` in `seat`'s hand can't be placed this turn under the two-tiles limits * (rules.md §4.1), or undefined when they don't block it. */ -export function turnLimit(state: GameState, seat: number, tile: Tile): "oneFounding" | "foundOrMerge" | undefined { - if (seat !== state.activeSeat || state.ended || !blockedThisTurn(state, tile)) { - return undefined; - } - return placementEffect(state.board, tile).kind === "found" && turnPlacements(state).founded - ? "oneFounding" - : "foundOrMerge"; +export function turnLimit(state: GameState, seat: number, tile: Tile): TwoTileLimit | undefined { + return seat === state.activeSeat && !state.ended ? twoTileLimit(state, tile) : undefined; } function sameShares(a: Partial, b: Partial): boolean { diff --git a/packages/viewer/src/lib/locales/da.ts b/packages/viewer/src/lib/locales/da.ts index 9763fa5..ed02812 100644 --- a/packages/viewer/src/lib/locales/da.ts +++ b/packages/viewer/src/lib/locales/da.ts @@ -92,6 +92,7 @@ export const da: Catalog = { "hand.eighth": "kan ikke grundlægge en 8. kæde", "hand.deadNextTurn": "Udskiftes ved starten af din næste tur", "hand.oneFounding": "kan ikke grundlægge en kæde mere i denne tur", + "hand.mergeFounded": "kan ikke fusionere kæden, du grundlagde i denne tur", "hand.foundOrMerge": "kan ikke både grundlægge en kæde og fusionere i samme tur", "chains.label": "Hotelkæder", "chains.title": "Kæder", diff --git a/packages/viewer/src/lib/locales/de.ts b/packages/viewer/src/lib/locales/de.ts index 9d29e49..da1f95b 100644 --- a/packages/viewer/src/lib/locales/de.ts +++ b/packages/viewer/src/lib/locales/de.ts @@ -92,6 +92,7 @@ export const de: Catalog = { "hand.eighth": "keine 8. Kette möglich", "hand.deadNextTurn": "Werden zu Beginn deines nächsten Zuges ersetzt", "hand.oneFounding": "keine zweite Kettengründung in diesem Zug", + "hand.mergeFounded": "keine Fusion mit der in diesem Zug gegründeten Kette", "hand.foundOrMerge": "nicht Gründung und Fusion im selben Zug", "chains.label": "Hotelketten", "chains.title": "Ketten", diff --git a/packages/viewer/src/lib/locales/el.ts b/packages/viewer/src/lib/locales/el.ts index 18a7588..1f4deb6 100644 --- a/packages/viewer/src/lib/locales/el.ts +++ b/packages/viewer/src/lib/locales/el.ts @@ -92,6 +92,7 @@ export const el: Catalog = { "hand.eighth": "δεν ιδρύεται 8η αλυσίδα", "hand.deadNextTurn": "Αντικατάσταση στην αρχή του επόμενου γύρου σου", "hand.oneFounding": "δεν ιδρύεται δεύτερη αλυσίδα σε αυτόν τον γύρο", + "hand.mergeFounded": "όχι συγχώνευση της αλυσίδας που ιδρύθηκε σε αυτόν τον γύρο", "hand.foundOrMerge": "όχι ίδρυση αλυσίδας και συγχώνευση στον ίδιο γύρο", "chains.label": "Αλυσίδες ξενοδοχείων", "chains.title": "Αλυσίδες", diff --git a/packages/viewer/src/lib/locales/en.ts b/packages/viewer/src/lib/locales/en.ts index 24b24de..72bb38e 100644 --- a/packages/viewer/src/lib/locales/en.ts +++ b/packages/viewer/src/lib/locales/en.ts @@ -99,6 +99,7 @@ export const en = { "hand.eighth": "can't found an 8th chain", "hand.deadNextTurn": "Replaced at the start of your next turn", "hand.oneFounding": "can't found a second chain this turn", + "hand.mergeFounded": "can't merge the chain you founded this turn", "hand.foundOrMerge": "can't both found a chain and merge in one turn", // Chain and price tables diff --git a/packages/viewer/src/lib/locales/fa.ts b/packages/viewer/src/lib/locales/fa.ts index a6987d4..81e9da7 100644 --- a/packages/viewer/src/lib/locales/fa.ts +++ b/packages/viewer/src/lib/locales/fa.ts @@ -92,6 +92,7 @@ export const fa: Catalog = { "hand.eighth": "زنجیره‌ی هشتم ممکن نیست", "hand.deadNextTurn": "در آغاز نوبت بعدی شما جایگزین می‌شوند", "hand.oneFounding": "در این نوبت زنجیره‌ی دوم ممکن نیست", + "hand.mergeFounded": "ادغام زنجیره‌ای که در این نوبت تأسیس شد ممکن نیست", "hand.foundOrMerge": "تأسیس زنجیره و ادغام در یک نوبت ممکن نیست", "chains.label": "زنجیره‌های هتل", "chains.title": "زنجیره‌ها", diff --git a/packages/viewer/src/lib/locales/fr.ts b/packages/viewer/src/lib/locales/fr.ts index 58714c6..eef96ae 100644 --- a/packages/viewer/src/lib/locales/fr.ts +++ b/packages/viewer/src/lib/locales/fr.ts @@ -97,6 +97,7 @@ export const fr: Catalog = { "hand.eighth": "impossible de fonder une 8e chaîne", "hand.deadNextTurn": "Remplacement au début de votre prochain tour", "hand.oneFounding": "impossible de fonder une deuxième chaîne ce tour-ci", + "hand.mergeFounded": "impossible de fusionner la chaîne fondée ce tour-ci", "hand.foundOrMerge": "impossible de fonder une chaîne et de fusionner dans le même tour", "chains.label": "Chaînes d’hôtels", "chains.title": "Chaînes", diff --git a/packages/viewer/src/lib/locales/hi.ts b/packages/viewer/src/lib/locales/hi.ts index a50fb98..f4b95e7 100644 --- a/packages/viewer/src/lib/locales/hi.ts +++ b/packages/viewer/src/lib/locales/hi.ts @@ -91,6 +91,7 @@ export const hi: Catalog = { "hand.eighth": "8वीं श्रृंखला स्थापित नहीं हो सकती", "hand.deadNextTurn": "आपकी अगली बारी की शुरुआत में बदल दी जाएँगी", "hand.oneFounding": "इस बारी में दूसरी श्रृंखला स्थापित नहीं हो सकती", + "hand.mergeFounded": "इस बारी में स्थापित श्रृंखला का विलय नहीं हो सकता", "hand.foundOrMerge": "एक ही बारी में श्रृंखला स्थापित करना और विलय दोनों नहीं हो सकते", "chains.label": "होटल श्रृंखलाएँ", "chains.title": "श्रृंखलाएँ", diff --git a/packages/viewer/src/lib/locales/it.ts b/packages/viewer/src/lib/locales/it.ts index 2283e7b..a340711 100644 --- a/packages/viewer/src/lib/locales/it.ts +++ b/packages/viewer/src/lib/locales/it.ts @@ -96,6 +96,7 @@ export const it: Catalog = { "hand.eighth": "non si può fondare un'8ª catena", "hand.deadNextTurn": "Sostituite all'inizio del tuo prossimo turno", "hand.oneFounding": "non si può fondare una seconda catena in questo turno", + "hand.mergeFounded": "non si può fondere la catena fondata in questo turno", "hand.foundOrMerge": "non si può fondare una catena e fondere nello stesso turno", "chains.label": "Catene alberghiere", "chains.title": "Catene", diff --git a/packages/viewer/src/lib/locales/ko.ts b/packages/viewer/src/lib/locales/ko.ts index 147f95b..f605af6 100644 --- a/packages/viewer/src/lib/locales/ko.ts +++ b/packages/viewer/src/lib/locales/ko.ts @@ -92,6 +92,7 @@ export const ko: Catalog = { "hand.eighth": "8번째 체인은 세울 수 없음", "hand.deadNextTurn": "다음 차례가 시작될 때 교체됩니다", "hand.oneFounding": "이번 차례에 두 번째 체인은 세울 수 없음", + "hand.mergeFounded": "이번 차례에 세운 체인은 합병할 수 없음", "hand.foundOrMerge": "한 차례에 체인 설립과 합병을 모두 할 수 없음", "chains.label": "호텔 체인", "chains.title": "체인", diff --git a/packages/viewer/src/lib/locales/nl.ts b/packages/viewer/src/lib/locales/nl.ts index 27f6faa..667ccab 100644 --- a/packages/viewer/src/lib/locales/nl.ts +++ b/packages/viewer/src/lib/locales/nl.ts @@ -92,6 +92,7 @@ export const nl: Catalog = { "hand.eighth": "kan geen 8e keten stichten", "hand.deadNextTurn": "Worden aan het begin van je volgende beurt vervangen", "hand.oneFounding": "kan deze beurt geen tweede keten stichten", + "hand.mergeFounded": "kan de keten die je deze beurt stichtte niet laten fuseren", "hand.foundOrMerge": "kan niet in één beurt een keten stichten én fuseren", "chains.label": "Hotelketens", "chains.title": "Ketens", diff --git a/packages/viewer/src/lib/locales/pl.ts b/packages/viewer/src/lib/locales/pl.ts index 6859e82..b3be556 100644 --- a/packages/viewer/src/lib/locales/pl.ts +++ b/packages/viewer/src/lib/locales/pl.ts @@ -97,6 +97,7 @@ export const pl: Catalog = { "hand.eighth": "nie można założyć 8. sieci", "hand.deadNextTurn": "Wymiana na początku twojej następnej tury", "hand.oneFounding": "nie można założyć drugiej sieci w tej turze", + "hand.mergeFounded": "nie można połączyć sieci założonej w tej turze", "hand.foundOrMerge": "nie można w jednej turze założyć sieci i połączyć sieci", "chains.label": "Sieci hoteli", "chains.title": "Sieci", diff --git a/packages/viewer/src/lib/locales/pt-BR.ts b/packages/viewer/src/lib/locales/pt-BR.ts index c51152f..55ec4ee 100644 --- a/packages/viewer/src/lib/locales/pt-BR.ts +++ b/packages/viewer/src/lib/locales/pt-BR.ts @@ -96,6 +96,7 @@ export const ptBR: Catalog = { "hand.eighth": "não dá para fundar uma 8ª rede", "hand.deadNextTurn": "Substituição no início do seu próximo turno", "hand.oneFounding": "não dá para fundar uma segunda rede neste turno", + "hand.mergeFounded": "não dá para fundir a rede fundada neste turno", "hand.foundOrMerge": "não dá para fundar uma rede e fundir no mesmo turno", "chains.label": "Redes de hotéis", "chains.title": "Redes", diff --git a/packages/viewer/src/lib/locales/ro.ts b/packages/viewer/src/lib/locales/ro.ts index b9a5c83..e515a4e 100644 --- a/packages/viewer/src/lib/locales/ro.ts +++ b/packages/viewer/src/lib/locales/ro.ts @@ -97,6 +97,7 @@ export const ro: Catalog = { "hand.eighth": "nu se poate înființa un al 8-lea lanț", "hand.deadNextTurn": "Înlocuire la începutul turei tale următoare", "hand.oneFounding": "nu se poate înființa un al doilea lanț în această tură", + "hand.mergeFounded": "nu se poate face fuziunea lanțului înființat în această tură", "hand.foundOrMerge": "nu se poate înființa un lanț și face o fuziune în aceeași tură", "chains.label": "Lanțuri hoteliere", "chains.title": "Lanțuri", diff --git a/packages/viewer/src/lib/locales/ru.ts b/packages/viewer/src/lib/locales/ru.ts index 1befbc9..e25b442 100644 --- a/packages/viewer/src/lib/locales/ru.ts +++ b/packages/viewer/src/lib/locales/ru.ts @@ -97,6 +97,7 @@ export const ru: Catalog = { "hand.eighth": "нельзя основать 8-ю сеть", "hand.deadNextTurn": "Заменяются в начале вашего следующего хода", "hand.oneFounding": "нельзя основать вторую сеть за этот ход", + "hand.mergeFounded": "нельзя слить сеть, основанную в этот ход", "hand.foundOrMerge": "нельзя за один ход и основать сеть, и провести слияние", "chains.label": "Гостиничные сети", "chains.title": "Сети", diff --git a/packages/viewer/src/lib/locales/vi.ts b/packages/viewer/src/lib/locales/vi.ts index 31da1c9..5ae941a 100644 --- a/packages/viewer/src/lib/locales/vi.ts +++ b/packages/viewer/src/lib/locales/vi.ts @@ -92,6 +92,7 @@ export const vi: Catalog = { "hand.eighth": "không thể lập chuỗi thứ 8", "hand.deadNextTurn": "Được thay khi bắt đầu lượt sau của bạn", "hand.oneFounding": "không thể lập chuỗi thứ hai trong lượt này", + "hand.mergeFounded": "không thể sáp nhập chuỗi vừa lập trong lượt này", "hand.foundOrMerge": "không thể vừa lập chuỗi vừa sáp nhập trong cùng một lượt", "chains.label": "Chuỗi khách sạn", "chains.title": "Chuỗi", diff --git a/packages/viewer/src/lib/locales/zh-CN.ts b/packages/viewer/src/lib/locales/zh-CN.ts index cef1e6e..fe306d9 100644 --- a/packages/viewer/src/lib/locales/zh-CN.ts +++ b/packages/viewer/src/lib/locales/zh-CN.ts @@ -91,6 +91,7 @@ export const zhCN: Catalog = { "hand.eighth": "无法创立第 8 个连锁", "hand.deadNextTurn": "在你下一回合开始时更换", "hand.oneFounding": "本回合不能再创立第二个连锁", + "hand.mergeFounded": "不能合并本回合创立的连锁", "hand.foundOrMerge": "同一回合内不能既创立连锁又进行合并", "chains.label": "酒店连锁", "chains.title": "连锁", diff --git a/packages/viewer/src/lib/locales/zh-TW.ts b/packages/viewer/src/lib/locales/zh-TW.ts index 21274ed..04a45e3 100644 --- a/packages/viewer/src/lib/locales/zh-TW.ts +++ b/packages/viewer/src/lib/locales/zh-TW.ts @@ -91,6 +91,7 @@ export const zhTW: Catalog = { "hand.eighth": "無法創立第 8 個連鎖", "hand.deadNextTurn": "在你下一回合開始時更換", "hand.oneFounding": "本回合不能再創立第二個連鎖", + "hand.mergeFounded": "不能合併本回合創立的連鎖", "hand.foundOrMerge": "同一回合內不能既創立連鎖又進行合併", "chains.label": "飯店連鎖", "chains.title": "連鎖", diff --git a/rules.md b/rules.md index cf7343e..772dff3 100644 --- a/rules.md +++ b/rules.md @@ -81,9 +81,13 @@ drawing), and each turn places two tiles: 3. Place the second tile if any tile in hand is playable now; otherwise go straight to buying. A tile that became permanently unplayable during this turn cannot be placed and is replaced at the start of the seat's next turn. -4. A turn founds at most one chain, and never both founds a chain and causes a merger, in - either order. It may cause two mergers, one per tile. Mergers caused by bank tiles do - not count towards these limits. +4. A turn founds at most one chain, and the second tile cannot cause a merger involving the + chain the first tile founded (as survivor or defunct). Otherwise each tile follows the + usual rules: a merger may be followed by a founding or another merger, and a founding by + a merger of other chains. **[DECISION]** Games created before this revision (init + options without `twoTilesRelaxed`) keep the earlier limit, also when replayed: a turn + never both founds a chain and causes a merger, in either order, and mergers caused by + bank tiles do not count towards it. 5. Buy (§9, including §9.1 swaps) once, after both tiles, then draw back up to 8. The end may also be announced between the two tiles, if an end condition holds at that diff --git a/scripts/check-browser.mjs b/scripts/check-browser.mjs index 1fec20f..75cbb59 100644 --- a/scripts/check-browser.mjs +++ b/scripts/check-browser.mjs @@ -170,6 +170,7 @@ try { await page.evaluate((state) => { const { parseTile, allTiles } = window.acquireDev.rules; state.options.twoTiles = true; + state.options.twoTilesRelaxed = true; state.options.limitedLog = true; state.board[parseTile("1C")] = "loose"; state.seats[0].hand = ["2A", "3A", "2C", "5E", "7E", "9E", "7G", "9G"].map(parseTile); From 2ffadb9ae4ea1925a59addc6d91af9c2f9a642d0 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 06:58:56 -0700 Subject: [PATCH 03/12] Stack desktop panels in independent columns The desktop grid shared rows with the board, so the decision/hand column and the chains column stretched to the board's height and left large empty areas. Group the panels into columns that stack independently: board and players; decision, hand and chains; history and chat. Tablets keep the board and players beside the decision, hand and chains, with history and chat below. Phones place the panels individually as before. Co-Authored-By: Claude Opus 5.5 --- packages/viewer/src/App.svelte | 117 +++++++++++++++++++-------------- scripts/check-browser.mjs | 35 ++++++---- 2 files changed, 92 insertions(+), 60 deletions(-) diff --git a/packages/viewer/src/App.svelte b/packages/viewer/src/App.svelte index 721ad8c..fd82c74 100644 --- a/packages/viewer/src/App.svelte +++ b/packages/viewer/src/App.svelte @@ -18,35 +18,43 @@
    {#if store.state} {@const state = store.view!} +
    -
    - - -
    -
    - store.send({ type: "place", tile: tileLabel(tile) })} - /> -
    - {#if store.seats.length > 0 && store.replayAt === undefined} -
    - -
    +
    +
    + + +
    + {#if store.seats.length > 0 && store.replayAt === undefined} +
    + +
    +
    + {/if} +
    + +
    - {/if} -
    - -
    -
    - +
    +
    + store.send({ type: "place", tile: tileLabel(tile) })} + /> +
    +
    + +
    +
    +
    +
    + {#if !store.analysis} +
    + {/if}
    - {#if !store.analysis} -
    - {/if} -
    {:else}

    {store.lang.t("loading")}

    @@ -54,7 +62,7 @@
    diff --git a/scripts/check-browser.mjs b/scripts/check-browser.mjs index 1fec20f..542d6ac 100644 --- a/scripts/check-browser.mjs +++ b/scripts/check-browser.mjs @@ -668,7 +668,7 @@ try { await open(`players=4&moves=95&publicHoldings=1&theme=${theme}`); const geometry = await page.evaluate(() => { const main = document.querySelector("main"); - const column = document.querySelector(".layout > .board"); + const column = document.querySelector(".board-column > .board"); const frame = column.querySelector(".frame"); return { margin: getComputedStyle(document.body).margin, @@ -1028,17 +1028,28 @@ try { "desktop/phone undo, repeated private revisions, refresh, no undo network calls, one saved turn and one clock increment" ); - // The desktop used to stack every supporting panel in one tall sidebar. Check the rendered - // arrangement and height, not only horizontal overflow, before creating gallery images. + // The desktop used to stack every supporting panel in one tall sidebar, and later left empty + // areas beside the board. Each column now stacks its own panels; check the rendered arrangement. await page.setViewportSize({ width: 1280, height: 900 }); await open("players=4&moves=95&publicHoldings=1"); - const board = await page.locator(".layout > .board").boundingBox(); - const panels = await Promise.all( - [".players", ".history", ".conversation"].map((selector) => page.locator(`.layout > ${selector}`).boundingBox()) - ); - for (const panel of panels) { - assert.ok(panel.y >= board.y + board.height, "supporting panels sit below the board"); - assert.ok(Math.abs(panel.y - panels[0].y) < 1, "supporting panels share a desktop row"); + const box = (selector) => page.locator(`.layout ${selector}`).boundingBox(); + const columns = [ + [".board-column > .board", ".board-column > .players"], + [".turn-column > .controls", ".turn-column > .hand", ".turn-column > .market"], + [".talk-column > .history", ".talk-column > .conversation"], + ]; + let previousColumn; + for (const column of columns) { + const boxes = await Promise.all(column.map(box)); + for (const [index, panel] of boxes.entries()) { + assert.ok(Math.abs(panel.x - boxes[0].x) < 1, `${column[index]} stays in its column`); + if (index > 0) { + const gap = panel.y - (boxes[index - 1].y + boxes[index - 1].height); + assert.ok(gap >= 0 && gap < 40, `${column[index]} follows the panel above it without an empty area`); + } + } + assert.ok(!previousColumn || boxes[0].x > previousColumn.x + previousColumn.width, "desktop columns side by side"); + previousColumn = boxes[0]; } assert.ok((await page.locator("main").boundingBox()).height <= 900, "desktop game fits within 900px"); assert.equal(await page.locator(".log li").count(), 8); @@ -1046,7 +1057,7 @@ try { assert.ok((await page.locator(".log li").count()) > 100, "full history remains available"); await page.locator(".history button").click(); assert.equal(await page.locator(".log li").count(), 8); - report.scenarios.push("balanced desktop panels, compact recent history and expandable full log"); + report.scenarios.push("independent desktop columns, compact recent history and expandable full log"); for (const [name, params, width, height] of [ ["overview", "players=4&moves=95&publicHoldings=1", 1280, 900], @@ -1057,7 +1068,7 @@ try { for (const theme of ["light", "dark"]) { await open(`${params}&theme=${theme}`); const main = await page.locator("main").boundingBox(); - const hand = await page.locator(".layout > .hand").boundingBox(); + const hand = await page.locator(".turn-column > .hand").boundingBox(); // Desktop shows the whole compact layout. On phones frame the complete decision, board // and hand, without appending a long column of tables, chat and history to the image. const captureHeight = Math.ceil(width < 700 ? hand.y + hand.height + 12 : main.height); From defff1ab97efb628756a855eef718966bb3df80d Mon Sep 17 00:00:00 2001 From: Mike Isom <103458985+MikeIsom@users.noreply.github.com> Date: Wed, 4 Nov 2026 06:59:53 -0700 Subject: [PATCH 04/12] Add holdings visibility levels for cash and total share count Replace the public holdings checkbox with a holdingsVisibility select: private, cash, cashAndShareCount or public. publicHoldings: true keeps meaning full public, and normalized options store holdingsVisibility only at the two new levels, so historical init logs are unchanged. stripSecret shows opponents' exact cash from the cash level and adds a total shareCount at the share-count level while per-chain holdings stay hidden. Net worth and scores still need fully public holdings. The buy step may skip for lack of cash whenever cash is public. --- README.md | 2 +- docs/admin/gameinfo.json | 26 ++++- docs/admin/rules.md | 10 +- docs/registering.md | 2 +- packages/engine/src/hidden.spec.ts | 72 +++++++++---- packages/engine/src/net-worth.spec.ts | 15 +++ packages/engine/src/net-worth.ts | 5 +- packages/engine/src/options.spec.ts | 122 ++++++++++++++++++++++- packages/engine/src/options.ts | 43 +++++++- packages/engine/src/scoring.ts | 5 +- packages/engine/src/turn.spec.ts | 22 ++-- packages/engine/src/turn.ts | 8 +- packages/engine/src/types.ts | 5 + packages/engine/src/view.ts | 36 ++++++- packages/engine/src/wrapper.spec.ts | 19 ++++ packages/viewer/src/dev.ts | 4 +- packages/viewer/src/lib/Players.svelte | 14 ++- packages/viewer/src/lib/format.spec.ts | 11 ++ packages/viewer/src/lib/format.ts | 4 + packages/viewer/src/lib/locales/da.ts | 4 + packages/viewer/src/lib/locales/de.ts | 4 + packages/viewer/src/lib/locales/el.ts | 4 + packages/viewer/src/lib/locales/en.ts | 3 + packages/viewer/src/lib/locales/fa.ts | 4 + packages/viewer/src/lib/locales/fr.ts | 3 + packages/viewer/src/lib/locales/hi.ts | 3 + packages/viewer/src/lib/locales/it.ts | 3 + packages/viewer/src/lib/locales/ko.ts | 3 + packages/viewer/src/lib/locales/nl.ts | 3 + packages/viewer/src/lib/locales/pl.ts | 3 + packages/viewer/src/lib/locales/pt-BR.ts | 3 + packages/viewer/src/lib/locales/ro.ts | 3 + packages/viewer/src/lib/locales/ru.ts | 3 + packages/viewer/src/lib/locales/vi.ts | 3 + packages/viewer/src/lib/locales/zh-CN.ts | 3 + packages/viewer/src/lib/locales/zh-TW.ts | 3 + packages/viewer/src/lib/replay.spec.ts | 32 ++++++ packages/viewer/src/lib/replay.ts | 18 ++-- rules.md | 38 +++++-- 39 files changed, 489 insertions(+), 79 deletions(-) create mode 100644 packages/viewer/src/lib/replay.spec.ts diff --git a/README.md b/README.md index a0db386..1175785 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ as each player sees it. With hot seat on, it switches to whoever must act, so on play every seat. The toolbar plays random moves, jumps to the next merger, and switches player, theme and language. -URL parameters: `players=2..6`, `seed=...`, `publicHoldings=1`, `teamPlay=1`, `autoEnd=1`, +URL parameters: `players=2..6`, `seed=...`, `holdingsVisibility=cash` (or `cashAndShareCount`, `public`; legacy `publicHoldings=1`), `teamPlay=1`, `autoEnd=1`, `endSize=31`, `twoPlayerMode=fourHands`, `stockSwap=3` (or `5`, `7`, `unlimited`), `twoTiles=1`, `limitedLog=1`, `theme=light|dark`, `locale=de`, `moves=50` (random moves on load), `merger=1` (continue to the next merger). diff --git a/docs/admin/gameinfo.json b/docs/admin/gameinfo.json index 9aefc63..7b7511c 100644 --- a/docs/admin/gameinfo.json +++ b/docs/admin/gameinfo.json @@ -44,10 +44,28 @@ ], "options": [ { - "name": "publicHoldings", - "label": "Public holdings (everyone sees all stock and cash)", - "type": "checkbox", - "default": false + "name": "holdingsVisibility", + "label": "What players see of each other's cash and stock", + "type": "select", + "default": "private", + "items": [ + { + "name": "private", + "label": "Private (standard)" + }, + { + "name": "cash", + "label": "Cash only" + }, + { + "name": "cashAndShareCount", + "label": "Cash and total share count" + }, + { + "name": "public", + "label": "Everything (public holdings)" + } + ] }, { "name": "teamPlay", diff --git a/docs/admin/rules.md b/docs/admin/rules.md index 6a76981..fc78fbb 100644 --- a/docs/admin/rules.md +++ b/docs/admin/rules.md @@ -134,7 +134,13 @@ With two players, the bank also acts as a shareholder whenever bonuses are paid. ## What you can see -Your tiles are private. Unless the game was created with **public holdings**, each player's cash and shares are private too; the game log is public (unless the game uses a limited game log, below), so a careful player can work them out. +Your tiles are private. By default, each player's cash and shares are private too; the game log is public (unless the game uses a limited game log, below), so a careful player can work them out. The game's creator can make more visible: + +- **Cash only:** everyone's exact cash is shown. +- **Cash and total share count:** everyone's exact cash and how many shares they hold in total are shown, but not which chains they are in. +- **Everything (public holdings):** everyone's cash and shares are shown, along with an estimated net worth. + +Everything is shown once the game ends. ### Limited game log @@ -148,7 +154,7 @@ Because replaying the game would show the full history, replay is only available - **Two tiles per turn:** hands of 8 tiles and two tiles placed every turn (see above). - **Shares per turn:** buy up to 3 (standard), 4 or 5 shares in total per turn, independently of stock swaps. - **Stock swap:** optional 1:1 exchanges with the bank before buying; Off / 3 / 5 / 7 / Unlimited shares per turn (see above). -- **Public holdings:** everyone's cash and shares are visible. +- **What players see of each other's cash and stock:** private (standard), cash only, cash and total share count, or everything (see above). - **Team play** (4 players only): seats 1 and 3 play against seats 2 and 4; each team's money is added together at the end. - **Two-player mode:** *Bank as third shareholder* (above) or *Four hands*, where each player controls two seats in a normal four-seat game and the player with the single richest seat wins. - **End automatically when an end condition is met:** the game ends at the end of that turn, with no announcement. diff --git a/docs/registering.md b/docs/registering.md index 96b1125..9fba91f 100644 --- a/docs/registering.md +++ b/docs/registering.md @@ -146,7 +146,7 @@ do not replace other declarations from an old local snapshot. Current declaration sources are in [admin/gameinfo.json](admin/gameinfo.json): -- Setup options include public holdings, team play, two-player mode, automatic ending, end size, +- Setup options include holdings visibility (private / cash / cash and share count / public), team play, two-player mode, automatic ending, end size, **Shares per turn: 3 (standard) / 4 / 5**, **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. diff --git a/packages/engine/src/hidden.spec.ts b/packages/engine/src/hidden.spec.ts index c47fba9..ac4ccfa 100644 --- a/packages/engine/src/hidden.spec.ts +++ b/packages/engine/src/hidden.spec.ts @@ -8,7 +8,7 @@ import { parseTile } from "./tiles.js"; import { chainAt, scenario } from "./test/helpers.js"; import type { GameState, LogEntry } from "./types.js"; import { simpleLine } from "./simple.js"; -import { HIDDEN, seatsOf } from "./view.js"; +import { HIDDEN, seatsOf, visibilityNow } from "./view.js"; import * as wrapper from "../wrapper.js"; const OPTION_SETS: Record[] = [ @@ -17,8 +17,14 @@ const OPTION_SETS: Record[] = [ { teamPlay: true }, { twoPlayerMode: "fourHands" }, { twoPlayerMode: "fourHands", publicHoldings: true }, + { holdingsVisibility: "cash" }, + { holdingsVisibility: "cashAndShareCount" }, + { holdingsVisibility: "cashAndShareCount", teamPlay: true }, + { holdingsVisibility: "cashAndShareCount", twoPlayerMode: "fourHands" }, ]; +const totalShares = (shares: Record) => Object.values(shares).reduce((sum, count) => sum + count, 0); + function lcg(seed: number): () => number { let s = seed >>> 0; return () => { @@ -61,21 +67,24 @@ function viewers(state: GameState): (number | undefined)[] { /** The state with every field the viewer may not see replaced by a fixed marker, for comparison. */ function withoutSecrets(state: GameState, player: number | undefined): unknown { const own = seatsOf(state, player); - const holdingsPublic = state.options.publicHoldings || state.ended; + const level = visibilityNow(state); return { ...state, seed: "", rngCounter: 0, pool: state.pool.length, - seats: state.seats.map((seat, index) => - own.includes(index) - ? seat - : { - ...seat, - hand: seat.hand.length, - ...(holdingsPublic ? {} : { cash: "hidden", shares: "hidden" }), - } - ), + seats: state.seats.map((seat, index) => { + if (own.includes(index)) { + return seat; + } + const { shareCount: _, ...rest } = seat; + return { + ...rest, + hand: seat.hand.length, + ...(level === "private" ? { cash: "hidden" } : {}), + ...(level === "public" ? {} : { shares: "hidden" }), + }; + }), }; } @@ -91,7 +100,7 @@ test("§13 each viewer's state hides exactly the private fields and passes every for (const player of viewers(state)) { const view = wrapper.stripSecret(state, player); const own = seatsOf(state, player); - const holdingsPublic = state.options.publicHoldings || state.ended; + const level = visibilityNow(state); assert.equal(view.seed, "", "§13 the seed (which fixes the pool order) is never sent"); assert.equal(view.rngCounter, 0); @@ -111,16 +120,24 @@ test("§13 each viewer's state hides exactly the private fields and passes every seat.hand.every((tile) => tile === HIDDEN), "§13 other players' hands are private" ); - if (holdingsPublic) { - assert.equal(seat.cash, state.seats[index]!.cash); + if (level === "private") { + assert.equal(seat.cash, HIDDEN, "§13 other players' cash is private"); + } else { + assert.equal(seat.cash, state.seats[index]!.cash, "§13 cash is public above the private level"); + } + if (level === "public") { assert.deepEqual(seat.shares, state.seats[index]!.shares); } else { - assert.equal(seat.cash, HIDDEN, "§13 other players' cash is private"); assert.ok( CHAIN_IDS.every((chain) => seat.shares[chain] === HIDDEN), "§13 other players' stock is private" ); } + assert.equal( + seat.shareCount, + level === "cashAndShareCount" ? totalShares(state.seats[index]!.shares) : undefined, + "§13 only the share-count level adds the total" + ); }); const masked = withoutSecrets(view, player) as Record; @@ -154,14 +171,25 @@ test("§13 a viewer cannot tell apart games that differ only in what is hidden f const opponent = variant.seats[other]!; [opponent.hand[0], variant.pool[0]] = [variant.pool[0]!, opponent.hand[0]!]; } - if (!state.options.publicHoldings && !state.ended) { - variant.seats.forEach((seat, index) => { - if (!own.includes(index)) { - seat.cash += 100; - seat.shares.tower += 1; + const level = visibilityNow(state); + variant.seats.forEach((seat, index) => { + if (own.includes(index) || level === "public") { + return; + } + if (level === "private") { + seat.cash += 100; + } + if (level === "cashAndShareCount") { + // Only the split between chains is hidden: move one share elsewhere. + const from = CHAIN_IDS.find((chain) => seat.shares[chain] > 0); + if (from) { + seat.shares[from] -= 1; + seat.shares[from === "tower" ? "luxor" : "tower"] += 1; } - }); - } + } else { + seat.shares.tower += 1; + } + }); assert.deepEqual( JSON.stringify(wrapper.stripSecret(variant, player)), JSON.stringify(wrapper.stripSecret(state, player)), diff --git a/packages/engine/src/net-worth.spec.ts b/packages/engine/src/net-worth.spec.ts index 038b449..3c68f4a 100644 --- a/packages/engine/src/net-worth.spec.ts +++ b/packages/engine/src/net-worth.spec.ts @@ -77,6 +77,21 @@ test("private or masked holdings cannot reveal net worth through helpers or publ assert.deepEqual(total(state), [6000, 6000, 6000], "inactive shares have no liquidation value"); }); +test("§13 the cash and share-count levels show no net worth or scores during play", () => { + for (const holdingsVisibility of ["cash", "cashAndShareCount"]) { + const state = scenario({ + board: chainAt("tower", ["1A", "2A"]), + shares: [{ tower: 5 }, { tower: 2 }], + hands: [["12I"], ["11I"], ["10I"]], + options: { holdingsVisibility }, + }); + assert.equal(projectedNetWorth(state), undefined, holdingsVisibility); + assert.equal(projectedNetWorth(wrapper.stripSecret(state, 0)), undefined); + assert.equal(projectedNetWorth(wrapper.stripSecret(state)), undefined); + assert.deepEqual(wrapper.scores(state), [0, 0, 0]); + } +}); + test("bank-mode forecasts omit uncertain bonuses and are independent of secret hands and draws", () => { const state = scenario({ seats: 2, diff --git a/packages/engine/src/net-worth.ts b/packages/engine/src/net-worth.ts index c6bf936..8957f77 100644 --- a/packages/engine/src/net-worth.ts +++ b/packages/engine/src/net-worth.ts @@ -11,7 +11,10 @@ export interface NetWorth { total: number; } -/** Public liquidation estimate, without inspecting hands, future draws or random state. */ +/** + * Public liquidation estimate, without inspecting hands, future draws or random state. It needs + * per-chain holdings, so it exists only with fully public holdings or after the game. + */ export function projectedNetWorth(state: GameState): NetWorth[] | undefined { if (!state.ended && !state.options.publicHoldings) { return undefined; diff --git a/packages/engine/src/options.spec.ts b/packages/engine/src/options.spec.ts index 8a6100e..c07f76b 100644 --- a/packages/engine/src/options.spec.ts +++ b/packages/engine/src/options.spec.ts @@ -2,7 +2,8 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { endConditionHolds } from "./board.js"; import { applyMove } from "./moves.js"; -import { DEFAULT_OPTIONS, normalizeOptions } from "./options.js"; +import { legalMoves } from "./legal.js"; +import { DEFAULT_OPTIONS, PUBLIC_HOLDINGS_OVERRIDE, holdingsVisibility, normalizeOptions } from "./options.js"; import { sharePrice } from "./prices.js"; import { initGame } from "./setup.js"; import { chainAt, checkInvariants, row, scenario } from "./test/helpers.js"; @@ -206,3 +207,122 @@ test("§15 publicHoldings: everyone's cash and stock are visible, hands are not" assert.equal(view.seats[1]!.shares.tower, 2); assert.deepEqual(view.seats[1]!.hand, [-1]); }); + +test("§15 holdingsVisibility: missing and private keep the historical options, intermediate levels are stored", () => { + const normalized = (raw: Record) => normalizeOptions(3, raw); + for (const raw of [{}, { holdingsVisibility: "private" }]) { + assert.deepEqual(normalized(raw), { options: DEFAULT_OPTIONS, ignored: [] }); + } + for (const level of ["cash", "cashAndShareCount"] as const) { + const { options, ignored } = normalized({ holdingsVisibility: level }); + assert.deepEqual(options, { ...DEFAULT_OPTIONS, holdingsVisibility: level }); + assert.deepEqual(ignored, []); + assert.equal(holdingsVisibility(options), level); + } + // Full public is stored exactly as the legacy checkbox stores it. + const legacy = normalized({ publicHoldings: true }); + assert.deepEqual(legacy, { options: { ...DEFAULT_OPTIONS, publicHoldings: true }, ignored: [] }); + assert.deepEqual(normalized({ holdingsVisibility: "public" }), legacy); + assert.equal(holdingsVisibility(legacy.options), "public"); + assert.equal(holdingsVisibility(DEFAULT_OPTIONS), "private"); + assert.equal("holdingsVisibility" in initGame(3, { publicHoldings: true }, "legacy").options, false); +}); + +test("§15 holdingsVisibility: invalid values are ignored and logged, falling back to the checkbox", () => { + for (const value of ["everything", "Cash", true, 2, null]) { + const { options, ignored } = normalizeOptions(3, { holdingsVisibility: value }); + assert.deepEqual(options, DEFAULT_OPTIONS); + assert.deepEqual(ignored, [{ option: "holdingsVisibility", value, reason: "unknown value" }]); + assert.equal(normalizeOptions(3, { holdingsVisibility: value, publicHoldings: true }).options.publicHoldings, true); + } + assert.equal(normalizeOptions(3, { publicHoldings: "true" }).options.publicHoldings, false); +}); + +test("§15 holdingsVisibility: the legacy publicHoldings checkbox wins, and only a real conflict is logged", () => { + for (const level of ["private", "public"]) { + assert.deepEqual(normalizeOptions(3, { publicHoldings: true, holdingsVisibility: level }), { + options: { ...DEFAULT_OPTIONS, publicHoldings: true }, + ignored: [], + }); + } + for (const level of ["cash", "cashAndShareCount"]) { + const state = initGame(3, { publicHoldings: true, holdingsVisibility: level }, "conflict"); + assert.deepEqual(state.options, { ...DEFAULT_OPTIONS, publicHoldings: true }); + assert.deepEqual(ignoredLog(state), [ + { type: "optionIgnored", option: "holdingsVisibility", value: level, reason: PUBLIC_HOLDINGS_OVERRIDE }, + ]); + } +}); + +test("§13 holdingsVisibility cash: opponents' exact cash is visible, their stock is not", () => { + const state = scenario({ + board: chainAt("tower", ["1A", "2A"]), + hands: [["9G"], ["9I"], ["11I"]], + shares: [{ tower: 1 }, { tower: 2, luxor: 3 }], + cash: [6000, 4300, 5100], + options: { holdingsVisibility: "cash" }, + }); + for (const player of [0, undefined]) { + const view = wrapper.stripSecret(state, player); + assert.equal(view.seats[1]!.cash, 4300); + assert.equal(view.seats[2]!.cash, 5100); + assert.equal(view.seats[1]!.shares.tower, -1); + assert.equal(view.seats[1]!.shares.luxor, -1); + assert.equal("shareCount" in view.seats[1]!, false); + assert.deepEqual(view.seats[1]!.hand, [-1]); + } + assert.deepEqual(wrapper.stripSecret(state, 0).seats[0], state.seats[0], "your own seat is complete"); +}); + +test("§13 holdingsVisibility cashAndShareCount: exact cash and total shares, never the chains", () => { + const state = scenario({ + board: chainAt("tower", ["1A", "2A"]), + hands: [["9G"], ["9I"], ["11I"]], + // Kept shares of a chain not on the board still count. + shares: [{ tower: 1 }, { tower: 2, luxor: 3 }], + cash: [6000, 4300, 5100], + options: { holdingsVisibility: "cashAndShareCount" }, + }); + for (const player of [0, undefined]) { + const view = wrapper.stripSecret(state, player); + assert.equal(view.seats[1]!.cash, 4300); + assert.equal(view.seats[1]!.shareCount, 5); + assert.equal(view.seats[2]!.shareCount, 0); + assert.ok(Object.values(view.seats[1]!.shares).every((count) => count === -1)); + assert.deepEqual(view.seats[1]!.hand, [-1]); + } + const own = wrapper.stripSecret(state, 0).seats[0]!; + assert.deepEqual(own, state.seats[0], "your own seat is complete, without a share count"); + assert.deepEqual(legalMoves(wrapper.stripSecret(state, 0)), legalMoves(state)); +}); + +test("§13 holdingsVisibility: every level reveals everything once the game ends", () => { + for (const holdingsVisibility of ["cash", "cashAndShareCount"]) { + const state = scenario({ + board: chainAt("tower", ["1A", "2A", "3A", "4A", "5A", "6A", "7A", "8A", "9A", "10A", "11A"]), + hands: [["9G"], ["9I", "12A"], ["11G"]], + shares: [{}, { luxor: 3 }], + cash: [6000, 4100, 6000], + options: { holdingsVisibility }, + }); + applyMove(state, { type: "announce" }, 0); + applyMove(state, { type: "place", tile: "9G" }, 0); + applyMove(state, { type: "buy", shares: {} }, 0); + assert.equal(state.ended, true); + const seat = wrapper.stripSecret(state, 0).seats[1]!; + assert.equal(seat.cash, 4100); + assert.equal(seat.shares.luxor, 3); + assert.equal("shareCount" in seat, false); + } +}); + +test("§15 holdingsVisibility games replay identically", () => { + for (const holdingsVisibility of ["cash", "cashAndShareCount", "public"]) { + const state = initGame(4, { holdingsVisibility }, `replay-${holdingsVisibility}`); + for (let step = 1; !state.ended && step < 200; step++) { + const moves = legalMoves(state).filter((move) => move.type !== "announce"); + wrapper.move(state, moves[(step * 7919) % moves.length]!, wrapper.currentPlayer(state)!); + } + assert.deepEqual(wrapper.replay(structuredClone(state)), state); + } +}); diff --git a/packages/engine/src/options.ts b/packages/engine/src/options.ts index ded5bc5..3dcb7d3 100644 --- a/packages/engine/src/options.ts +++ b/packages/engine/src/options.ts @@ -2,7 +2,13 @@ import { END_SIZE, HAND_SIZE, MAX_BUY, TWO_TILE_HAND_SIZE } from "./config.js"; /** rules.md §15, after normalisation against the player count. */ export interface GameOptions { + /** Full public holdings (rules.md §13), also the highest holdingsVisibility level. */ publicHoldings: boolean; + /** + * Only the intermediate levels are stored: private and public remain publicHoldings + * false/true, preserving the init log of games created before this option. + */ + holdingsVisibility?: "cash" | "cashAndShareCount"; teamPlay: boolean; twoPlayerMode: "bank" | "fourHands"; autoEnd: boolean; @@ -33,6 +39,23 @@ export const DEFAULT_OPTIONS: GameOptions = { const END_SIZES = [41, 31]; +/** The optionIgnored reason when the legacy checkbox already makes holdings public. */ +export const PUBLIC_HOLDINGS_OVERRIDE = "publicHoldings makes all holdings public"; + +/** rules.md §13: how much of other players' holdings everyone sees, from least to most. */ +export const HOLDINGS_VISIBILITY = ["private", "cash", "cashAndShareCount", "public"] as const; +export type HoldingsVisibility = (typeof HOLDINGS_VISIBILITY)[number]; + +/** The holdings level during play; everything becomes public when the game ends. */ +export function holdingsVisibility(options: GameOptions): HoldingsVisibility { + return options.publicHoldings ? "public" : (options.holdingsVisibility ?? "private"); +} + +/** Whether exact cash is public, so decisions that depend only on cash may reveal it. */ +export function cashIsPublic(options: GameOptions): boolean { + return holdingsVisibility(options) !== "private"; +} + /** * Reads the creator's options defensively. BGS omits unticked checkboxes and always sends * selects (as strings), so a missing checkbox means false. Options are never rejected @@ -46,7 +69,25 @@ export function normalizeOptions( const options: GameOptions = { ...DEFAULT_OPTIONS }; const ignored: IgnoredOption[] = []; - options.publicHoldings = raw.publicHoldings === true; + // The legacy publicHoldings checkbox always means full public holdings and wins over the + // holdingsVisibility select. Only an intermediate level it overrides is reported: the + // select's default "private" is always sent. + let visibility: HoldingsVisibility = "private"; + if (HOLDINGS_VISIBILITY.includes(raw.holdingsVisibility as HoldingsVisibility)) { + visibility = raw.holdingsVisibility as HoldingsVisibility; + } else if (raw.holdingsVisibility !== undefined) { + ignored.push({ option: "holdingsVisibility", value: raw.holdingsVisibility, reason: "unknown value" }); + } + if (raw.publicHoldings === true) { + if (visibility === "cash" || visibility === "cashAndShareCount") { + ignored.push({ option: "holdingsVisibility", value: visibility, reason: PUBLIC_HOLDINGS_OVERRIDE }); + } + visibility = "public"; + } + options.publicHoldings = visibility === "public"; + if (visibility === "cash" || visibility === "cashAndShareCount") { + options.holdingsVisibility = visibility; + } options.autoEnd = raw.autoEnd === true; if (raw.teamPlay === true) { diff --git a/packages/engine/src/scoring.ts b/packages/engine/src/scoring.ts index ca37884..de281ea 100644 --- a/packages/engine/src/scoring.ts +++ b/packages/engine/src/scoring.ts @@ -81,7 +81,10 @@ export function playerRankings(state: GameState): number[] { return players.map((player) => (hasDropped(state, player) ? lastStayed + 1 : ranks[player]!)); } -/** rules.md §13: scores stay 0 during play while holdings are private. */ +/** + * rules.md §13: scores stay 0 during play unless holdings are fully public. Net worth needs + * per-chain holdings, so the cash and share-count levels keep 0 too. + */ export function playerScores(state: GameState): number[] { if (!state.ended && !state.options.publicHoldings) { return Array.from({ length: state.players }, () => 0); diff --git a/packages/engine/src/turn.spec.ts b/packages/engine/src/turn.spec.ts index 514bacb..cc5c494 100644 --- a/packages/engine/src/turn.spec.ts +++ b/packages/engine/src/turn.spec.ts @@ -241,16 +241,18 @@ test("§9.6 with private holdings the buy step is not skipped for lack of cash", assert.equal(state.activeSeat, 1); }); -test("§9.6 with public holdings the buy step is skipped when the player cannot afford any share", () => { - const state = scenario({ - board: chainAt("tower", ["1A", "2A"]), - hands: [["9G"], ["11G"]], - cash: [100], - options: { publicHoldings: true }, - }); - play(state, 0, place("9G")); - assert.equal(state.activeSeat, 1); - assert.equal(state.phase, "place"); +test("§9.6 with public cash the buy step is skipped when the player cannot afford any share", () => { + for (const options of [ + { publicHoldings: true }, + { holdingsVisibility: "public" }, + { holdingsVisibility: "cash" }, + { holdingsVisibility: "cashAndShareCount" }, + ]) { + const state = scenario({ board: chainAt("tower", ["1A", "2A"]), hands: [["9G"], ["11G"]], cash: [100], options }); + play(state, 0, place("9G")); + assert.equal(state.activeSeat, 1, JSON.stringify(options)); + assert.equal(state.phase, "place"); + } }); test("§9.6 the buy step is skipped when no chain is on the board", () => { diff --git a/packages/engine/src/turn.ts b/packages/engine/src/turn.ts index edb32e0..b4cfcee 100644 --- a/packages/engine/src/turn.ts +++ b/packages/engine/src/turn.ts @@ -1,6 +1,6 @@ import { activeChains, chainSize, playableTiles, tileLegality } from "./board.js"; import { AUTO_TURN_LIMIT } from "./config.js"; -import { handSize } from "./options.js"; +import { cashIsPublic, handSize } from "./options.js"; import { sharePrice } from "./prices.js"; import { canAnnounce, endConditionMet, endGame } from "./scoring.js"; import type { Tile } from "./tiles.js"; @@ -13,7 +13,7 @@ export function drawTile(state: GameState): Tile | undefined { /** * rules.md §9.6: whether the buy step has anything to offer. Only public facts count unless - * holdings are public, so skipping the step never reveals a player's cash. + * cash is public (holdings level cash or above), so skipping the step never reveals it. */ export function buyStepAvailable(state: GameState): boolean { const seat = state.seats[state.activeSeat]!; @@ -23,9 +23,9 @@ export function buyStepAvailable(state: GameState): boolean { if (state.options.stockSwap && active.length > 1 && active.some((chain) => state.bank[chain] > 0)) { return true; } - const cashIsPublic = state.options.publicHoldings; + const cashKnown = cashIsPublic(state.options); return activeChains(state.board).some( - (chain) => state.bank[chain] > 0 && (!cashIsPublic || sharePrice(chain, chainSize(state.board, chain)) <= seat.cash) + (chain) => state.bank[chain] > 0 && (!cashKnown || sharePrice(chain, chainSize(state.board, chain)) <= seat.cash) ); } diff --git a/packages/engine/src/types.ts b/packages/engine/src/types.ts index 4772ee1..4c37c52 100644 --- a/packages/engine/src/types.ts +++ b/packages/engine/src/types.ts @@ -11,6 +11,11 @@ export interface SeatState { name: string; cash: number; shares: Shares; + /** + * Only in a viewer's state at the cashAndShareCount holdings level (rules.md §13): another + * seat's total shares across all chains, while `shares` is hidden. + */ + shareCount?: number; hand: Tile[]; dropped: boolean; } diff --git a/packages/engine/src/view.ts b/packages/engine/src/view.ts index 4e75b0c..c362685 100644 --- a/packages/engine/src/view.ts +++ b/packages/engine/src/view.ts @@ -1,5 +1,6 @@ import { CHAIN_IDS } from "./config.js"; import { visibleLog } from "./limited-log.js"; +import { holdingsVisibility, type HoldingsVisibility } from "./options.js"; import type { GameState, Shares } from "./types.js"; /** Value sent in place of anything the viewer may not see. */ @@ -12,16 +13,41 @@ export function seatsOf(state: GameState, player: number | undefined): number[] return state.seatOwner.flatMap((owner, seat) => (owner === player ? [seat] : [])); } +/** The holdings level everyone sees now: all of them once the game has ended. */ +export function visibilityNow(state: GameState): HoldingsVisibility { + return state.ended ? "public" : holdingsVisibility(state.options); +} + +/** + * rules.md §13: another seat's cash and shares as shown at `level`. Below public, the + * per-chain holdings are hidden; cashAndShareCount adds their total as `shareCount`. + */ +export function maskHoldings( + holdings: { cash: number; shares: Shares }, + level: HoldingsVisibility +): { cash: number; shares: Shares; shareCount?: number } { + if (level === "public") { + return { cash: holdings.cash, shares: { ...holdings.shares } }; + } + return { + cash: level === "private" ? HIDDEN : holdings.cash, + shares: { ...HIDDEN_SHARES }, + ...(level === "cashAndShareCount" + ? { shareCount: Object.values(holdings.shares).reduce((sum, count) => sum + count, 0) } + : {}), + }; +} + /** * rules.md §13: the state as `player` may see it (undefined for a spectator). Hidden numbers * are replaced by HIDDEN so the shape stays the same. Hands and the pool order are always - * private; holdings and cash are private unless publicHoldings is on or the game has ended. - * With limitedLog, older log entries are replaced. The seed is removed because it determines - * the pool order. + * private; other seats' cash and holdings are shown as far as the holdings level allows + * (maskHoldings), and fully once the game has ended. With limitedLog, older log entries are + * replaced. The seed is removed because it determines the pool order. */ export function viewFor(state: GameState, player: number | undefined): GameState { const own = seatsOf(state, player); - const holdingsPublic = state.options.publicHoldings || state.ended; + const level = visibilityNow(state); return { ...structuredClone(state), seed: "", @@ -35,7 +61,7 @@ export function viewFor(state: GameState, player: number | undefined): GameState return { ...structuredClone(seat), hand: seat.hand.map(() => HIDDEN), - ...(holdingsPublic ? {} : { cash: HIDDEN, shares: { ...HIDDEN_SHARES } }), + ...maskHoldings(seat, level), }; }), }; diff --git a/packages/engine/src/wrapper.spec.ts b/packages/engine/src/wrapper.spec.ts index 11f9bc2..3a9d1e5 100644 --- a/packages/engine/src/wrapper.spec.ts +++ b/packages/engine/src/wrapper.spec.ts @@ -45,3 +45,22 @@ test("wrapper: setPlayerMetaData stores the player name", () => { const state = wrapper.setPlayerMetaData(wrapper.init(2, [], {}, "seed"), 1, { name: "Ada" }); assert.equal(state.seats[1]?.name, "Ada"); }); + +test("wrapper: BGS setup values for holdingsVisibility reach stripSecret, and scores stay private", () => { + for (const [raw, cash, shareCount] of [ + [{ holdingsVisibility: "private" }, -1, undefined], + [{ holdingsVisibility: "cash" }, 6000, undefined], + [{ holdingsVisibility: "cashAndShareCount" }, 6000, 0], + ] as const) { + const state = wrapper.init(3, [], raw, "seed"); + const opponent = wrapper.stripSecret(state, 0).seats[1]!; + assert.equal(opponent.cash, cash, JSON.stringify(raw)); + assert.equal(opponent.shareCount, shareCount); + assert.deepEqual(wrapper.scores(state), [0, 0, 0]); + } + for (const raw of [{ publicHoldings: true }, { holdingsVisibility: "public" }]) { + const state = wrapper.init(3, [], raw, "seed"); + assert.deepEqual(wrapper.stripSecret(state, 0).seats[1]!.shares, state.seats[1]!.shares); + assert.deepEqual(wrapper.scores(state), [6000, 6000, 6000]); + } +}); diff --git a/packages/viewer/src/dev.ts b/packages/viewer/src/dev.ts index 480a4f2..3087bba 100644 --- a/packages/viewer/src/dev.ts +++ b/packages/viewer/src/dev.ts @@ -1,7 +1,7 @@ // Local dev harness (not part of the BGS bundle): runs the real engine in the page, plays // random moves on request, and lets you view the game as any player or as a spectator. // URL parameters: players=2..6, seed=..., view=N, hotseat=0, theme=light|dark, locale=de, and any game option, e.g. publicHoldings=1, -// twoPlayerMode=fourHands, teamPlay=1, autoEnd=1, endSize=31. For reproducible screenshots: moves=N plays N random moves, +// holdingsVisibility=cash|cashAndShareCount|public, twoPlayerMode=fourHands, teamPlay=1, autoEnd=1, endSize=31. For reproducible screenshots: moves=N plays N random moves, // merger=1 then plays on to the next merger decision, bar=0 hides this toolbar. import * as rules from "acquire-engine"; import { currentSeat, legalMoves, type GameState } from "acquire-engine"; @@ -34,7 +34,7 @@ for (const key of ["publicHoldings", "teamPlay", "autoEnd", "twoTiles", "limited options[key] = true; } } -for (const key of ["twoPlayerMode", "endSize", "stockSwap", "sharesPerTurn"]) { +for (const key of ["holdingsVisibility", "twoPlayerMode", "endSize", "stockSwap", "sharesPerTurn"]) { const value = params.get(key); if (value) { options[key] = value; diff --git a/packages/viewer/src/lib/Players.svelte b/packages/viewer/src/lib/Players.svelte index 10dfe62..d4f33ab 100644 --- a/packages/viewer/src/lib/Players.svelte +++ b/packages/viewer/src/lib/Players.svelte @@ -30,7 +30,8 @@ {#each state.seats as seat, index (index)} {@const held = CHAIN_IDS.filter((chain) => seat.shares[chain] !== 0)} - {@const hidden = seat.cash === HIDDEN} + {@const cashHidden = seat.cash === HIDDEN} + {@const sharesHidden = CHAIN_IDS.some((chain) => seat.shares[chain] === HIDDEN)} {#if index === acting}▶{/if} @@ -47,10 +48,14 @@ >{store.lang.money(seat.cash)} {:else} - {store.lang.money(seat.cash)} + {store.lang.money(seat.cash)} {/if} - {#if hidden} + {#if sharesHidden && seat.shareCount !== undefined} + + {:else if sharesHidden} {t("hidden")} {:else if held.length === 0} {t("players.none")} @@ -149,4 +154,7 @@ .none { color: var(--ink-muted); } + .share-count { + font-variant-numeric: tabular-nums; + } diff --git a/packages/viewer/src/lib/format.spec.ts b/packages/viewer/src/lib/format.spec.ts index c63924f..4ad8048 100644 --- a/packages/viewer/src/lib/format.spec.ts +++ b/packages/viewer/src/lib/format.spec.ts @@ -64,3 +64,14 @@ test("player names cannot be mistaken for chain names, markup or formatting toke ); } }); + +test("a holdings level overridden by the legacy publicHoldings checkbox is explained, not called unknown", () => { + const state = initGame(3, { publicHoldings: true, holdingsVisibility: "cash" }, "override"); + const entry = state.log.find((e) => e.type === "optionIgnored")!; + assert.equal( + describeEntry(state, entry, langFor("en")), + "Option holdingsVisibility was ignored: publicHoldings already shows all holdings" + ); + const unknown = initGame(3, { holdingsVisibility: "some" }, "unknown").log.find((e) => e.type === "optionIgnored")!; + assert.equal(describeEntry(state, unknown, langFor("en")), "Option holdingsVisibility was ignored: unknown value"); +}); diff --git a/packages/viewer/src/lib/format.ts b/packages/viewer/src/lib/format.ts index bc5dd28..1c32808 100644 --- a/packages/viewer/src/lib/format.ts +++ b/packages/viewer/src/lib/format.ts @@ -1,6 +1,7 @@ import { CHAINS, HIDDEN, + PUBLIC_HOLDINGS_OVERRIDE, currentSeat, merger, secondPlacementDue, @@ -98,6 +99,9 @@ export function describeEntry( case "init": return t("log.init", { count: entry.players }); case "optionIgnored": { + if (entry.reason === PUBLIC_HOLDINGS_OVERRIDE) { + return t("log.optionIgnored.publicHoldings", { option: entry.option }); + } const count = entry.option === "teamPlay" ? 4 : entry.option === "twoPlayerMode" ? 2 : undefined; return count !== undefined && entry.reason.startsWith("only applies") ? t("log.optionIgnored.players", { option: entry.option, count }) diff --git a/packages/viewer/src/lib/locales/da.ts b/packages/viewer/src/lib/locales/da.ts index 9763fa5..de7b5a1 100644 --- a/packages/viewer/src/lib/locales/da.ts +++ b/packages/viewer/src/lib/locales/da.ts @@ -132,6 +132,10 @@ export const da: Catalog = { "players.turn": "tur", "players.left": "forladt", "players.none": "ingen", + "players.shareCount": { one: "{count} aktie", other: "{count} aktier" }, + "players.shareCountHint": "I alt på tværs af alle kæder; beholdningen pr. kæde er skjult", + "log.optionIgnored.publicHoldings": + "Indstillingen {option} blev ignoreret: publicHoldings viser allerede alle beholdninger", hidden: "skjult", "seat.name": "{name} (plads {seat})", "log.label": "Spillets log", diff --git a/packages/viewer/src/lib/locales/de.ts b/packages/viewer/src/lib/locales/de.ts index 9d29e49..3cdef7f 100644 --- a/packages/viewer/src/lib/locales/de.ts +++ b/packages/viewer/src/lib/locales/de.ts @@ -132,6 +132,10 @@ export const de: Catalog = { "players.turn": "am Zug", "players.left": "ausgeschieden", "players.none": "keine", + "players.shareCount": { one: "{count} Aktie", other: "{count} Aktien" }, + "players.shareCountHint": "Summe über alle Ketten; der Besitz je Kette ist verdeckt", + "log.optionIgnored.publicHoldings": + "Option {option} wurde ignoriert: publicHoldings zeigt bereits den gesamten Besitz", hidden: "verdeckt", "seat.name": "{name} (Platz {seat})", "log.label": "Spielprotokoll", diff --git a/packages/viewer/src/lib/locales/el.ts b/packages/viewer/src/lib/locales/el.ts index 18a7588..fde7090 100644 --- a/packages/viewer/src/lib/locales/el.ts +++ b/packages/viewer/src/lib/locales/el.ts @@ -132,6 +132,10 @@ export const el: Catalog = { "players.turn": "σειρά", "players.left": "αποχώρησε", "players.none": "καμία", + "players.shareCount": { one: "{count} μετοχή", other: "{count} μετοχές" }, + "players.shareCountHint": "Σύνολο σε όλες τις αλυσίδες· οι μετοχές ανά αλυσίδα είναι κρυφές", + "log.optionIgnored.publicHoldings": + "Η επιλογή {option} αγνοήθηκε: το publicHoldings δείχνει ήδη όλες τις μετοχές και τα μετρητά", hidden: "κρυφό", "seat.name": "{name} (θέση {seat})", "log.label": "Ημερολόγιο παιχνιδιού", diff --git a/packages/viewer/src/lib/locales/en.ts b/packages/viewer/src/lib/locales/en.ts index 24b24de..4c070f2 100644 --- a/packages/viewer/src/lib/locales/en.ts +++ b/packages/viewer/src/lib/locales/en.ts @@ -142,6 +142,9 @@ export const en = { "players.turn": "turn", "players.left": "left", "players.none": "none", + "players.shareCount": { one: "{count} share", other: "{count} shares" }, + "players.shareCountHint": "Total across all chains; holdings per chain are hidden", + "log.optionIgnored.publicHoldings": "Option {option} was ignored: publicHoldings already shows all holdings", hidden: "hidden", "seat.name": "{name} (seat {seat})", diff --git a/packages/viewer/src/lib/locales/fa.ts b/packages/viewer/src/lib/locales/fa.ts index a6987d4..fee5386 100644 --- a/packages/viewer/src/lib/locales/fa.ts +++ b/packages/viewer/src/lib/locales/fa.ts @@ -131,6 +131,10 @@ export const fa: Catalog = { "players.turn": "نوبت", "players.left": "رفته", "players.none": "هیچ", + "players.shareCount": { one: "{count} سهم", other: "{count} سهم" }, + "players.shareCountHint": "مجموع در همه‌ی زنجیره‌ها؛ سهام هر زنجیره پنهان است", + "log.optionIgnored.publicHoldings": + "گزینه‌ی {option} نادیده گرفته شد: publicHoldings از قبل همه‌ی دارایی‌ها را نشان می‌دهد", hidden: "پنهان", "seat.name": "{name} (جایگاه {seat})", "log.label": "گزارش بازی", diff --git a/packages/viewer/src/lib/locales/fr.ts b/packages/viewer/src/lib/locales/fr.ts index 58714c6..ff5a355 100644 --- a/packages/viewer/src/lib/locales/fr.ts +++ b/packages/viewer/src/lib/locales/fr.ts @@ -137,6 +137,9 @@ export const fr: Catalog = { "players.turn": "son tour", "players.left": "parti", "players.none": "aucune", + "players.shareCount": { one: "{count} action", many: "{count} actions", other: "{count} actions" }, + "players.shareCountHint": "Total sur toutes les chaînes ; le détail par chaîne est caché", + "log.optionIgnored.publicHoldings": "L’option {option} a été ignorée : publicHoldings montre déjà tous les avoirs", hidden: "caché", "seat.name": "{name} (place {seat})", "log.label": "Journal de la partie", diff --git a/packages/viewer/src/lib/locales/hi.ts b/packages/viewer/src/lib/locales/hi.ts index a50fb98..afdc03c 100644 --- a/packages/viewer/src/lib/locales/hi.ts +++ b/packages/viewer/src/lib/locales/hi.ts @@ -129,6 +129,9 @@ export const hi: Catalog = { "players.turn": "बारी", "players.left": "छोड़ गए", "players.none": "कोई नहीं", + "players.shareCount": { one: "{count} शेयर", other: "{count} शेयर" }, + "players.shareCountHint": "सभी श्रृंखलाओं में कुल; हर श्रृंखला के शेयर छिपे हैं", + "log.optionIgnored.publicHoldings": "विकल्प {option} अनदेखा किया गया: publicHoldings पहले से सारी होल्डिंग दिखाता है", hidden: "छिपा", "seat.name": "{name} (सीट {seat})", "log.label": "खेल का लॉग", diff --git a/packages/viewer/src/lib/locales/it.ts b/packages/viewer/src/lib/locales/it.ts index 2283e7b..9d81e9d 100644 --- a/packages/viewer/src/lib/locales/it.ts +++ b/packages/viewer/src/lib/locales/it.ts @@ -137,6 +137,9 @@ export const it: Catalog = { "players.turn": "turno", "players.left": "uscito", "players.none": "nessuna", + "players.shareCount": { one: "{count} azione", many: "{count} azioni", other: "{count} azioni" }, + "players.shareCountHint": "Totale su tutte le catene; il dettaglio per catena è nascosto", + "log.optionIgnored.publicHoldings": "Opzione {option} ignorata: publicHoldings mostra già tutte le partecipazioni", hidden: "nascosto", "seat.name": "{name} (posto {seat})", "log.label": "Registro della partita", diff --git a/packages/viewer/src/lib/locales/ko.ts b/packages/viewer/src/lib/locales/ko.ts index 147f95b..ee27b42 100644 --- a/packages/viewer/src/lib/locales/ko.ts +++ b/packages/viewer/src/lib/locales/ko.ts @@ -131,6 +131,9 @@ export const ko: Catalog = { "players.turn": "차례", "players.left": "나감", "players.none": "없음", + "players.shareCount": { other: "{count}주" }, + "players.shareCountHint": "모든 체인의 합계이며, 체인별 보유량은 비공개입니다", + "log.optionIgnored.publicHoldings": "{option} 옵션 무시됨: publicHoldings가 이미 모든 보유량을 공개함", hidden: "비공개", "seat.name": "{name} ({seat}번 자리)", "log.label": "게임 기록", diff --git a/packages/viewer/src/lib/locales/nl.ts b/packages/viewer/src/lib/locales/nl.ts index 27f6faa..87e2cce 100644 --- a/packages/viewer/src/lib/locales/nl.ts +++ b/packages/viewer/src/lib/locales/nl.ts @@ -132,6 +132,9 @@ export const nl: Catalog = { "players.turn": "beurt", "players.left": "vertrokken", "players.none": "geen", + "players.shareCount": { one: "{count} aandeel", other: "{count} aandelen" }, + "players.shareCountHint": "Totaal over alle ketens; het bezit per keten is verborgen", + "log.optionIgnored.publicHoldings": "Optie {option} genegeerd: publicHoldings toont al het volledige bezit", hidden: "verborgen", "seat.name": "{name} (plaats {seat})", "log.label": "Spelverslag", diff --git a/packages/viewer/src/lib/locales/pl.ts b/packages/viewer/src/lib/locales/pl.ts index 6859e82..a4f2a2d 100644 --- a/packages/viewer/src/lib/locales/pl.ts +++ b/packages/viewer/src/lib/locales/pl.ts @@ -136,6 +136,9 @@ export const pl: Catalog = { "players.turn": "tura", "players.left": "odszedł", "players.none": "brak", + "players.shareCount": { one: "{count} akcja", few: "{count} akcje", many: "{count} akcji", other: "{count} akcji" }, + "players.shareCountHint": "Suma we wszystkich sieciach; akcje poszczególnych sieci są ukryte", + "log.optionIgnored.publicHoldings": "Opcję {option} pominięto: publicHoldings już pokazuje wszystkie aktywa", hidden: "ukryte", "seat.name": "{name} (miejsce {seat})", "log.label": "Dziennik gry", diff --git a/packages/viewer/src/lib/locales/pt-BR.ts b/packages/viewer/src/lib/locales/pt-BR.ts index c51152f..14c14e7 100644 --- a/packages/viewer/src/lib/locales/pt-BR.ts +++ b/packages/viewer/src/lib/locales/pt-BR.ts @@ -136,6 +136,9 @@ export const ptBR: Catalog = { "players.turn": "vez", "players.left": "saiu", "players.none": "nenhuma", + "players.shareCount": { one: "{count} ação", many: "{count} ações", other: "{count} ações" }, + "players.shareCountHint": "Total em todas as redes; as ações de cada rede ficam ocultas", + "log.optionIgnored.publicHoldings": "A opção {option} foi ignorada: publicHoldings já mostra todos os ativos", hidden: "oculto", "seat.name": "{name} (lugar {seat})", "log.label": "Registro do jogo", diff --git a/packages/viewer/src/lib/locales/ro.ts b/packages/viewer/src/lib/locales/ro.ts index b9a5c83..013663e 100644 --- a/packages/viewer/src/lib/locales/ro.ts +++ b/packages/viewer/src/lib/locales/ro.ts @@ -137,6 +137,9 @@ export const ro: Catalog = { "players.turn": "la rând", "players.left": "a plecat", "players.none": "niciuna", + "players.shareCount": { one: "{count} acțiune", few: "{count} acțiuni", other: "{count} de acțiuni" }, + "players.shareCountHint": "Total în toate lanțurile; acțiunile pe fiecare lanț sunt ascunse", + "log.optionIgnored.publicHoldings": "Opțiunea {option} a fost ignorată: publicHoldings arată deja toate deținerile", hidden: "ascuns", "seat.name": "{name} (locul {seat})", "log.label": "Jurnalul jocului", diff --git a/packages/viewer/src/lib/locales/ru.ts b/packages/viewer/src/lib/locales/ru.ts index 1befbc9..973a26f 100644 --- a/packages/viewer/src/lib/locales/ru.ts +++ b/packages/viewer/src/lib/locales/ru.ts @@ -136,6 +136,9 @@ export const ru: Catalog = { "players.turn": "ход", "players.left": "вышел", "players.none": "нет", + "players.shareCount": { one: "{count} акция", few: "{count} акции", many: "{count} акций", other: "{count} акции" }, + "players.shareCountHint": "Всего по всем сетям; акции по сетям скрыты", + "log.optionIgnored.publicHoldings": "Опция {option} пропущена: publicHoldings уже показывает все активы", hidden: "скрыто", "seat.name": "{name} (место {seat})", "log.label": "Журнал игры", diff --git a/packages/viewer/src/lib/locales/vi.ts b/packages/viewer/src/lib/locales/vi.ts index 31da1c9..5e1b8dc 100644 --- a/packages/viewer/src/lib/locales/vi.ts +++ b/packages/viewer/src/lib/locales/vi.ts @@ -132,6 +132,9 @@ export const vi: Catalog = { "players.turn": "lượt", "players.left": "đã rời", "players.none": "không có", + "players.shareCount": { other: "{count} cổ phiếu" }, + "players.shareCountHint": "Tổng trên mọi chuỗi; số cổ phiếu của từng chuỗi được ẩn", + "log.optionIgnored.publicHoldings": "Bỏ qua tùy chọn {option}: publicHoldings đã hiển thị mọi tài sản", hidden: "ẩn", "seat.name": "{name} (ghế {seat})", "log.label": "Nhật ký ván chơi", diff --git a/packages/viewer/src/lib/locales/zh-CN.ts b/packages/viewer/src/lib/locales/zh-CN.ts index cef1e6e..8c2a3f6 100644 --- a/packages/viewer/src/lib/locales/zh-CN.ts +++ b/packages/viewer/src/lib/locales/zh-CN.ts @@ -129,6 +129,9 @@ export const zhCN: Catalog = { "players.turn": "回合", "players.left": "已离开", "players.none": "无", + "players.shareCount": { other: "{count} 股" }, + "players.shareCountHint": "所有连锁的合计;各连锁的持股不公开", + "log.optionIgnored.publicHoldings": "已忽略选项 {option}:publicHoldings 已公开全部持股", hidden: "隐藏", "seat.name": "{name}(座位 {seat})", "log.label": "游戏记录", diff --git a/packages/viewer/src/lib/locales/zh-TW.ts b/packages/viewer/src/lib/locales/zh-TW.ts index 21274ed..58a3c8f 100644 --- a/packages/viewer/src/lib/locales/zh-TW.ts +++ b/packages/viewer/src/lib/locales/zh-TW.ts @@ -129,6 +129,9 @@ export const zhTW: Catalog = { "players.turn": "回合", "players.left": "已離開", "players.none": "無", + "players.shareCount": { other: "{count} 股" }, + "players.shareCountHint": "所有連鎖的合計;各連鎖的持股不公開", + "log.optionIgnored.publicHoldings": "已忽略選項 {option}:publicHoldings 已公開全部持股", hidden: "隱藏", "seat.name": "{name}(座位 {seat})", "log.label": "遊戲紀錄", diff --git a/packages/viewer/src/lib/replay.spec.ts b/packages/viewer/src/lib/replay.spec.ts new file mode 100644 index 0000000..e518e45 --- /dev/null +++ b/packages/viewer/src/lib/replay.spec.ts @@ -0,0 +1,32 @@ +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { HIDDEN, initGame, legalMoves, applyMove, currentSeat, type GameState } from "acquire-engine"; +import { replayView } from "./replay.ts"; + +function played(options: Record): GameState { + const state = initGame(3, options, "replay-levels"); + for (let step = 1; step < 120 && !state.ended; step++) { + const moves = legalMoves(state).filter((move) => move.type !== "announce"); + applyMove(state, moves[(step * 7919) % moves.length]!, currentSeat(state)!); + } + return state; +} + +test("replay positions show other seats' holdings only as far as the holdings level allows", () => { + const at = (state: GameState) => state.log.length; + const cases: [Record, (seat: GameState["seats"][number]) => void][] = [ + [{}, (seat) => assert.equal(seat.cash, HIDDEN)], + [{ holdingsVisibility: "cash" }, (seat) => assert.ok(seat.cash > 0 && seat.shareCount === undefined)], + [{ holdingsVisibility: "cashAndShareCount" }, (seat) => assert.equal(typeof seat.shareCount, "number")], + ]; + for (const [options, check] of cases) { + const state = played(options); + const view = replayView(state, 0, at(state)); + check(view.seats[1]!); + assert.equal(view.seats[1]!.shares.tower, HIDDEN); + assert.deepEqual(view.seats[0]!.shares, state.seats[0]!.shares, "your own holdings are shown"); + assert.equal(view.seats[0]!.shareCount, undefined); + } + const open = played({ holdingsVisibility: "public" }); + assert.deepEqual(replayView(open, 0, at(open)).seats[1]!.shares, open.seats[1]!.shares); +}); diff --git a/packages/viewer/src/lib/replay.ts b/packages/viewer/src/lib/replay.ts index 4fa38c5..6e1253b 100644 --- a/packages/viewer/src/lib/replay.ts +++ b/packages/viewer/src/lib/replay.ts @@ -1,8 +1,6 @@ // BGS replay controls: the state to display at a log position, built from the engine's // positionAt (the public log replayed with the engine's own placement functions). -import { CHAIN_IDS, HIDDEN, positionAt, seatsOf, type GameState, type Shares } from "acquire-engine"; - -const HIDDEN_SHARES = Object.fromEntries(CHAIN_IDS.map((chain) => [chain, HIDDEN])) as Shares; +import { HIDDEN, maskHoldings, positionAt, seatsOf, visibilityNow, type GameState } from "acquire-engine"; /** The first replay position: the board after setup, at the start of the first turn. */ export function replayStart(state: GameState): number { @@ -11,24 +9,24 @@ export function replayStart(state: GameState): number { } /** - * The game as it stood after `at` log entries. Holdings show only where they are public now: - * public holdings, a finished game, or the viewer's own seats. Tiles in hand are never shown. + * The game as it stood after `at` log entries. Holdings show only as far as they are public now + * (the holdings level, or all of them in a finished game), except on the viewer's own seats. + * Tiles in hand are never shown. */ export function replayView(state: GameState, player: number | undefined, at: number): GameState { const position = positionAt(state, at); const own = seatsOf(state, player); - const holdingsPublic = state.options.publicHoldings || state.ended; + const level = visibilityNow(state); return { ...state, board: position.board, bank: position.bank, seats: state.seats.map((seat, index) => { const shown = position.seats[index]!; - const visible = holdingsPublic || own.includes(index); + const { shareCount: _, ...rest } = seat; return { - ...seat, - cash: visible ? shown.cash : HIDDEN, - shares: visible ? shown.shares : { ...HIDDEN_SHARES }, + ...rest, + ...maskHoldings(shown, own.includes(index) ? "public" : level), hand: Array.from({ length: shown.tiles }, () => HIDDEN), }; }), diff --git a/rules.md b/rules.md index cf7343e..5c512f0 100644 --- a/rules.md +++ b/rules.md @@ -220,10 +220,11 @@ can be renamed later without touching game logic. 5. Players can never sell stock except during merger disposal (§7.2) and final scoring (§11.2). There is no trading between players. 6. **[DECISION]** The buy step is skipped automatically only for public reasons: no chain - is on the board, or the bank has no shares left in any active chain. When - `publicHoldings` is off (§13), it is never skipped because the player cannot afford a - share, since that would reveal their cash; they get the step and may buy nothing. When - `publicHoldings` is on, it is also skipped when the player cannot afford any share. + is on the board, or the bank has no shares left in any active chain. While cash is + private (`holdingsVisibility` `private`, §13), it is never skipped because the player + cannot afford a share, since that would reveal their cash; they get the step and may buy + nothing. When cash is public (every other level), it is also skipped when the player + cannot afford any share. ### 9.1 Optional stock swaps (house rule) @@ -331,9 +332,22 @@ Each viewer must only receive information their player is entitled to. - **Always private:** each player's hand of tiles, and the order of the draw pool. - **Always public:** the board, chain names and sizes, current prices, and the number of shares left in the bank for each chain. -- **[DECISION] Game option `publicHoldings` (default: `false`):** When off, each player's - current share holdings and cash are visible only to that player. When on, they are - public. +- **[DECISION] Game option `holdingsVisibility` (default: `private`):** what everyone sees + of other players' current cash and share holdings during play. + - `private`: nothing; each player's cash and holdings are visible only to that player. + - `cash`: every player's exact cash is public; holdings stay private. + - `cashAndShareCount`: exact cash and each player's total number of shares across all + chains (including kept shares of chains not on the board) are public; how many shares + of each chain stays private. + - `public`: cash and every holding are public. + + The legacy checkbox `publicHoldings: true` means `public` and wins over the select; an + intermediate level it overrides is logged as ignored. Normalized options keep + `publicHoldings` (true only at `public`) and store `holdingsVisibility` only for `cash` + and `cashAndShareCount`, so games created before this option keep identical init logs. + Projected net worth and scores need per-chain holdings, so they are shown only at + `public` (below). Summary lines say how many shares a player kept in a merger only at + `public`. The log is the same at every level. - **[DECISION] The game log is public** unless `limitedLog` is on (below). It records every action: tile placements, stock purchases, bonuses paid, and each player's disposal choices. Only the *current* holdings and cash are hidden, even though they can be @@ -344,8 +358,9 @@ Each viewer must only receive information their player is entitled to. Setup entries (options, turn order) stay visible. Earlier entries are replaced by placeholders, keeping the log's length. The whole log is revealed when the game ends, and replay is only available after that. -- **[DECISION] Scores during play:** When `publicHoldings` is off, every player's score - is 0 until the game ends. When it is on, the score is projected net worth: cash, +- **[DECISION] Scores during play:** Unless holdings are `public`, every player's score + is 0 until the game ends, including at the `cash` and `cashAndShareCount` levels. At + `public`, the score is projected net worth: cash, current share sale values and majority/minority bonuses at current holdings (including ties and rounding). Future bonuses are excluded in two-player bank mode because the bank's holding is drawn only at payout. In-progress mergers never count paid bonuses @@ -379,8 +394,9 @@ switches on one engine, not as separate code paths. Defaults reproduce the stand | Option | Values | Default | Effect | |---|---|---|---| -| `publicHoldings` | true / false | false | See §13. When false, share holdings and cash are private. | -| `teamPlay` | true / false | false | Only applies with exactly 4 players. Seats 1 and 3 form one team, seats 2 and 4 the other. All rules are unchanged; at final scoring each team's cash is added together and the team with more wins. **[DECISION]** With `publicHoldings` off, teammates still cannot see each other's holdings. | +| `holdingsVisibility` | `private` / `cash` / `cashAndShareCount` / `public` | `private` | See §13. What everyone sees of other players' cash and holdings during play. | +| `publicHoldings` | true / false | false | Legacy checkbox, kept for existing games: true means `holdingsVisibility: public`. See §13. | +| `teamPlay` | true / false | false | Only applies with exactly 4 players. Seats 1 and 3 form one team, seats 2 and 4 the other. All rules are unchanged; at final scoring each team's cash is added together and the team with more wins. **[DECISION]** Below `public` holdings, teammates see each other's cash and holdings only as far as everyone does. | | `twoPlayerMode` | `bank` / `fourHands` | `bank` | Only has an effect with exactly 2 players. `bank` uses §12. `fourHands` runs a normal 4-seat game where each player controls two seats (player A has seats 1 and 3, player B has seats 2 and 4), with no bank shareholder. **[DECISION]** The player who controls the single richest seat wins; seats are not combined. | | `autoEnd` | true / false | false | When true, the game ends automatically at the end of the turn in which an end condition (§11.1) first holds, instead of waiting for an announcement. | | `sharesPerTurn` | 3 / 4 / 5 | 3 | Maximum shares purchased per turn in total across all active chains (house rule). Independent of stock swaps; see §9. | From 33cd27df1b0a1e1cff5ede683a50b24e22e804a3 Mon Sep 17 00:00:00 2001 From: Mike Isom <103458985+MikeIsom@users.noreply.github.com> Date: Wed, 4 Nov 2026 07:02:46 -0700 Subject: [PATCH 05/12] Add a hand size setup option independent of two tiles per turn handSize offers 6 (default), 8, 10 or 12 tiles, with or without twoTiles. Normalized options omit it at the legacy size (6, or 8 with twoTiles), so games created without it keep their init log and replay exactly; unknown values are ignored and logged. Setup, refills, dead-tile replacement and public positions all use the chosen size. The rack picks columns per hand size with container queries: one row where it fits, otherwise two even rows, and three rows of four for 12 tiles on the narrowest phones. --- docs/admin/gameinfo.json | 26 ++++++- docs/admin/rules.md | 11 +-- packages/engine/src/hand-size.spec.ts | 106 ++++++++++++++++++++++++++ packages/engine/src/options.spec.ts | 41 +++++++++- packages/engine/src/options.ts | 22 +++++- packages/viewer/src/dev.ts | 4 +- packages/viewer/src/lib/Hand.svelte | 45 ++++++++--- rules.md | 18 +++-- 8 files changed, 245 insertions(+), 28 deletions(-) create mode 100644 packages/engine/src/hand-size.spec.ts diff --git a/docs/admin/gameinfo.json b/docs/admin/gameinfo.json index 9aefc63..5e743c4 100644 --- a/docs/admin/gameinfo.json +++ b/docs/admin/gameinfo.json @@ -143,10 +143,34 @@ }, { "name": "twoTiles", - "label": "Two tiles per turn (hands of 8)", + "label": "Two tiles per turn", "type": "checkbox", "default": false }, + { + "name": "handSize", + "label": "Tiles in hand", + "type": "select", + "default": "6", + "items": [ + { + "name": "6", + "label": "6 (standard)" + }, + { + "name": "8", + "label": "8" + }, + { + "name": "10", + "label": "10" + }, + { + "name": "12", + "label": "12" + } + ] + }, { "name": "limitedLog", "label": "Limited game log (only last round)", diff --git a/docs/admin/rules.md b/docs/admin/rules.md index b826a54..ce4b51b 100644 --- a/docs/admin/rules.md +++ b/docs/admin/rules.md @@ -14,7 +14,7 @@ There are 7 hotel chains, in three price tiers: - **Medium:** Worldwide, American, Festival - **Major:** Imperial, Continental -Each chain has 25 shares. Everyone starts with $6,000 and a hand of 6 tiles. Before the game, each player places one tile from the pool; the lowest tile (by number, then letter) goes first, and play continues in seat order. +Each chain has 25 shares. Everyone starts with $6,000 and a hand of 6 tiles (or 8, 10 or 12 with the Tiles in hand option). Before the game, each player places one tile from the pool; the lowest tile (by number, then letter) goes first, and play continues in seat order. A chain of 11 or more tiles is **safe**: it can never be taken over. @@ -22,7 +22,7 @@ A chain of 11 or more tiles is **safe**: it can never be taken over. 1. **Place one tile** from your hand. 2. **Buy up to 3 shares** by default, in any active chains (optional; see Shares per turn below). -3. **Draw** back up to 6 tiles. +3. **Draw** back up to 6 tiles (or the game’s hand size). ### What a tile does @@ -39,9 +39,9 @@ A chain of 11 or more tiles is **safe**: it can never be taken over. ### Two tiles per turn -If the game uses **Two tiles per turn**, each player holds 8 tiles instead of 6 and places two tiles every turn. +If the game uses **Two tiles per turn**, each player places two tiles every turn. The number of tiles in hand is a separate option, so you can combine two tiles per turn with any hand size. (Two-tile games started before that option existed use hands of 8.) -At the start of your turn, swap out any dead tiles. Then place your first tile and settle anything it causes, including a full merger with everyone's sell, trade or keep decisions, before placing your second. After both tiles, buy shares up to the game’s per-turn limit (3 by default) at the prices on the board, then draw back up to 8. +At the start of your turn, swap out any dead tiles. Then place your first tile and settle anything it causes, including a full merger with everyone's sell, trade or keep decisions, before placing your second. After both tiles, buy shares up to the game’s per-turn limit (3 by default) at the prices on the board, then draw back up to your hand size. You may found only one chain per turn, and your second tile can't cause a merger involving the chain your first tile founded. Otherwise each tile follows the usual rules: you can merge and then found a chain, found a chain and then merge two other chains, or cause two mergers, one with each tile. Example: your first tile founds Worldwide, so your second tile can merge Luxor into Tower or grow Worldwide, but it can't found another chain or cause a merger involving Worldwide. @@ -147,7 +147,8 @@ Because replaying the game would show the full history, replay is only available ## Game options - **Limited game log:** the log shows only what happened since your last turn, until the game ends (see above). -- **Two tiles per turn:** hands of 8 tiles and two tiles placed every turn (see above). +- **Two tiles per turn:** two tiles placed every turn (see above). +- **Tiles in hand:** 6 (standard), 8, 10 or 12 tiles in each hand, with or without two tiles per turn. - **Shares per turn:** buy up to 3 (standard), 4 or 5 shares in total per turn, independently of stock swaps. - **Stock swap:** optional 1:1 exchanges with the bank before buying; Off / 3 / 5 / 7 / Unlimited shares per turn (see above). - **Public holdings:** everyone's cash and shares are visible. diff --git a/packages/engine/src/hand-size.spec.ts b/packages/engine/src/hand-size.spec.ts new file mode 100644 index 0000000..8128b11 --- /dev/null +++ b/packages/engine/src/hand-size.spec.ts @@ -0,0 +1,106 @@ +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { legalMoves } from "./legal.js"; +import { applyMove } from "./moves.js"; +import { positionAt } from "./position.js"; +import { initGame } from "./setup.js"; +import { chainAt, checkInvariants, row, scenario, t } from "./test/helpers.js"; +import type { GameState, Move } from "./types.js"; +import * as wrapper from "../wrapper.js"; + +const place = (tile: string): Move => ({ type: "place", tile }); +const buy: Move = { type: "buy", shares: {} }; + +function play(state: GameState, seat: number, move: Move): GameState { + applyMove(state, move, seat); + checkInvariants(state); + return state; +} + +test("§15 handSize: every seat is dealt the chosen hand in every mode and player count", () => { + for (const handSize of ["6", "8", "10", "12"]) { + for (const twoTiles of [false, true]) { + for (let players = 2; players <= 6; players++) { + const modes = players === 2 ? ["bank", "fourHands"] : ["bank"]; + for (const twoPlayerMode of modes) { + const state = initGame( + players, + { ...(twoTiles && { twoTiles }), ...(players === 4 && { teamPlay: true }), twoPlayerMode, handSize }, + `deal-${handSize}-${players}-${twoPlayerMode}-${twoTiles}` + ); + checkInvariants(state); + const size = Number(handSize); + assert.ok(state.seats.every((seat) => seat.hand.length === size)); + assert.ok(positionAt(state, state.log.length).seats.every((seat) => seat.tiles === size)); + const view = wrapper.stripSecret(state, 0); + assert.ok( + view.seats.every((seat) => seat.hand.length === size), + "masked hands keep their size" + ); + } + } + } + } + // Six hands of 12 plus six turn-order tiles still leave 30 of the 108 tiles to draw. + assert.equal(initGame(6, { handSize: "12" }, "deal-max").pool.length, 30); +}); + +test("§15 handSize: the hand refills to the chosen size after a turn", () => { + const hand = ["5E", "9G", "11G", "3I", "6I", "9I", "1G", "1I", "12A", "12C"]; + const state = scenario({ hands: [hand, ["12E"]], poolTop: ["12G", "12I"], options: { handSize: "10" } }); + play(state, 0, place("5E")); + assert.equal(state.seats[0]!.hand.length, 10); + assert.ok(state.seats[0]!.hand.includes(t("12G"))); + assert.ok(!state.seats[0]!.hand.includes(t("12I"))); +}); + +test("§15 handSize: dead tiles are replaced up to the chosen size", () => { + const state = scenario({ + board: { ...chainAt("tower", row("A", 1, 11)), ...chainAt("continental", row("C", 1, 11)) }, + hands: [["1B", "10G", "12E", "12G", "12I", "10I", "8I", "6I", "4I", "2I", "8G", "6G"], ["5E"]], + options: { handSize: "12" }, + }); + play(state, 0, place("10G")); + play(state, 0, buy); + assert.ok(state.removed.includes(t("1B"))); + assert.equal(state.seats[0]!.hand.length, 12); + assert.deepEqual(state.log.filter((entry) => entry.type === "drew").at(-1), { type: "drew", seat: 0, count: 2 }); +}); + +test("§15 handSize with twoTiles: both tiles are placed, then the hand refills to the chosen size", () => { + const state = scenario({ + board: chainAt("tower", ["1A", "2A"]), + hands: [["5E", "9I", "12A", "12C", "12E", "12G"], ["10C"], ["10E"]], + poolTop: ["7G", "7I"], + options: { twoTiles: true, handSize: "6" }, + }); + assert.equal(state.options.handSize, 6); + play(state, 0, place("5E")); + play(state, 0, place("9I")); + play(state, 0, buy); + assert.equal(state.seats[0]!.hand.length, 6); + assert.deepEqual(state.seats[0]!.hand.slice(-2), [t("7G"), t("7I")]); +}); + +/** Plays a random game to the end, checking invariants after every move, and replays it. */ +function playToEnd(players: number, options: Record, seed: string): GameState { + const state = wrapper.init(players, [], options, seed); + for (let step = 0; !state.ended; step++) { + assert.ok(step < 5000, `${seed} did not finish`); + const moves = legalMoves(state); + const others = moves.filter((move) => move.type !== "announce"); + const choices = others.length > 0 && step % 23 !== 0 ? others : moves; + wrapper.move(state, choices[(step * 7919) % choices.length]!, wrapper.currentPlayer(state)!); + checkInvariants(state); + } + assert.deepEqual(wrapper.replay(structuredClone(state)), state, `§14.7 ${seed} replays exactly`); + return state; +} + +test("§14.8 handSize 12: full games finish and replay with 6 players, two-player bank mode and four hands", () => { + playToEnd(6, { handSize: "12" }, "hand-12-six"); + playToEnd(6, { handSize: "12", twoTiles: true }, "hand-12-six-two-tiles"); + playToEnd(2, { handSize: "12", twoPlayerMode: "bank" }, "hand-12-bank"); + playToEnd(2, { handSize: "12", twoPlayerMode: "fourHands", twoTiles: true }, "hand-12-four-hands"); + playToEnd(4, { handSize: "10", teamPlay: true, publicHoldings: true }, "hand-10-teams"); +}); diff --git a/packages/engine/src/options.spec.ts b/packages/engine/src/options.spec.ts index 8a6100e..afef512 100644 --- a/packages/engine/src/options.spec.ts +++ b/packages/engine/src/options.spec.ts @@ -2,7 +2,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { endConditionHolds } from "./board.js"; import { applyMove } from "./moves.js"; -import { DEFAULT_OPTIONS, normalizeOptions } from "./options.js"; +import { DEFAULT_OPTIONS, handSize, normalizeOptions } from "./options.js"; import { sharePrice } from "./prices.js"; import { initGame } from "./setup.js"; import { chainAt, checkInvariants, row, scenario } from "./test/helpers.js"; @@ -93,6 +93,45 @@ test("§3.5 options are never rejected: unknown values are ignored and logged", assert.doesNotThrow(() => wrapper.init(2, [], { teamPlay: true, twoPlayerMode: "fourHands", endSize: 7 }, "x")); }); +test("§15 handSize: missing keeps the legacy hand of 6, or 8 with twoTiles, and leaves the init log unchanged", () => { + assert.equal("handSize" in normalizeOptions(3, {}).options, false); + assert.equal(handSize(normalizeOptions(3, {}).options), 6); + assert.equal("handSize" in normalizeOptions(3, { twoTiles: true }).options, false); + assert.equal(handSize(normalizeOptions(3, { twoTiles: true }).options), 8); + const init = initGame(3, {}, "no-hand-size").log[0] as Extract; + assert.deepEqual(init.options, DEFAULT_OPTIONS); +}); + +test("§15 handSize: every size is read as BGS sends it, alone or with twoTiles; the legacy size is omitted", () => { + for (const twoTiles of [false, true]) { + const legacy = twoTiles ? 8 : 6; + for (const size of [6, 8, 10, 12]) { + for (const sent of [String(size), size]) { + const { options, ignored } = normalizeOptions(3, { ...(twoTiles && { twoTiles }), handSize: sent }); + assert.deepEqual(ignored, []); + assert.equal(handSize(options), size); + assert.equal(options.handSize, size === legacy ? undefined : size); + assert.equal("handSize" in options, size !== legacy, `handSize ${sent} with twoTiles ${twoTiles}`); + } + } + } + assert.deepEqual(normalizeOptions(3, { handSize: "10" }).options, { ...DEFAULT_OPTIONS, handSize: 10 }); +}); + +test("§15 handSize: unknown values are ignored and logged, keeping the legacy size", () => { + for (const value of ["7", 7, "", "eight", "08", " 8", 6.5, 14, true, null, ["8"]]) { + for (const twoTiles of [false, true]) { + const state = initGame(3, { ...(twoTiles && { twoTiles }), handSize: value }, "bad-hand-size"); + assert.equal("handSize" in state.options, false); + assert.deepEqual( + ignoredLog(state).map((e) => [e.option, e.value, e.reason]), + [["handSize", value, "unknown value"]] + ); + assert.ok(state.seats.every((seat) => seat.hand.length === (twoTiles ? 8 : 6))); + } + } +}); + test("§15 endSize 31: a 31-tile chain meets the end condition; safe size and prices are unchanged", () => { const tiles = [...row("A", 1, 12), ...row("B", 1, 12), ...row("C", 1, 7)]; const board = scenario({ board: chainAt("tower", tiles), hands: [["9I"]] }).board; diff --git a/packages/engine/src/options.ts b/packages/engine/src/options.ts index 315bc10..4e371b5 100644 --- a/packages/engine/src/options.ts +++ b/packages/engine/src/options.ts @@ -13,6 +13,8 @@ export interface GameOptions { sharesPerTurn?: 4 | 5; /** Omitted when off, like stockSwap. */ twoTiles?: true; + /** Omitted at the legacy size (6, or 8 with twoTiles), so games created before it replay. */ + handSize?: 6 | 8 | 10 | 12; /** * Set with twoTiles in games created under the relaxed founding/merger limits (rules.md * §4.1). Two-tile games logged before them lack it and keep the original limits. @@ -37,6 +39,7 @@ export const DEFAULT_OPTIONS: GameOptions = { }; const END_SIZES = [41, 31]; +const HAND_SIZES = [6, 8, 10, 12, "6", "8", "10", "12"]; /** * Reads the creator's options defensively. BGS omits unticked checkboxes and always sends @@ -107,6 +110,16 @@ export function normalizeOptions( options.twoTilesRelaxed = true; } } + if (raw.handSize !== undefined) { + if (HAND_SIZES.includes(raw.handSize as number | string)) { + const size = Number(raw.handSize) as 6 | 8 | 10 | 12; + if (size !== legacyHandSize(options)) { + options.handSize = size; + } + } else { + ignored.push({ option: "handSize", value: raw.handSize, reason: "unknown value" }); + } + } if (raw.limitedLog === true) { options.limitedLog = true; } @@ -119,11 +132,16 @@ export function sharePurchaseLimit(options: GameOptions): number { return options.sharesPerTurn ?? MAX_BUY; } -/** rules.md §15 twoTiles: hands hold 8 tiles instead of 6. */ -export function handSize(options: GameOptions): number { +/** Games created before the handSize option hold 6 tiles, or 8 with twoTiles. */ +function legacyHandSize(options: GameOptions): number { return options.twoTiles ? TWO_TILE_HAND_SIZE : HAND_SIZE; } +/** rules.md §15 handSize: the number of tiles each seat draws up to. */ +export function handSize(options: GameOptions): number { + return options.handSize ?? legacyHandSize(options); +} + /** Internal seats per real player: fourHands gives each of the 2 players two seats. */ export function seatOwners(players: number, options: GameOptions): number[] { if (players === 2 && options.twoPlayerMode === "fourHands") { diff --git a/packages/viewer/src/dev.ts b/packages/viewer/src/dev.ts index 480a4f2..a527073 100644 --- a/packages/viewer/src/dev.ts +++ b/packages/viewer/src/dev.ts @@ -1,7 +1,7 @@ // Local dev harness (not part of the BGS bundle): runs the real engine in the page, plays // random moves on request, and lets you view the game as any player or as a spectator. // URL parameters: players=2..6, seed=..., view=N, hotseat=0, theme=light|dark, locale=de, and any game option, e.g. publicHoldings=1, -// twoPlayerMode=fourHands, teamPlay=1, autoEnd=1, endSize=31. For reproducible screenshots: moves=N plays N random moves, +// twoPlayerMode=fourHands, teamPlay=1, autoEnd=1, endSize=31, twoTiles=1, handSize=12. For reproducible screenshots: moves=N plays N random moves, // merger=1 then plays on to the next merger decision, bar=0 hides this toolbar. import * as rules from "acquire-engine"; import { currentSeat, legalMoves, type GameState } from "acquire-engine"; @@ -34,7 +34,7 @@ for (const key of ["publicHoldings", "teamPlay", "autoEnd", "twoTiles", "limited options[key] = true; } } -for (const key of ["twoPlayerMode", "endSize", "stockSwap", "sharesPerTurn"]) { +for (const key of ["twoPlayerMode", "endSize", "stockSwap", "sharesPerTurn", "handSize"]) { const value = params.get(key); if (value) { options[key] = value; diff --git a/packages/viewer/src/lib/Hand.svelte b/packages/viewer/src/lib/Hand.svelte index 00d28c6..7d7fed5 100644 --- a/packages/viewer/src/lib/Hand.svelte +++ b/packages/viewer/src/lib/Hand.svelte @@ -1,5 +1,5 @@ + + +

    + {label} + {t("players.cash")} + {#if cash.before !== cash.after}{money(cash.before)}→{/if}{money(cash.after)} + {#each shown as change (change.chain)} + + {#if change.before !== change.after}{change.before}→{/if}{change.after} + {/each} +

    + + diff --git a/packages/viewer/src/lib/locales/da.ts b/packages/viewer/src/lib/locales/da.ts index 9763fa5..3a5ee57 100644 --- a/packages/viewer/src/lib/locales/da.ts +++ b/packages/viewer/src/lib/locales/da.ts @@ -31,6 +31,7 @@ export const da: Catalog = { "panel.label": "Din beslutning", "panel.sending": "Sender…", "turn.undo": "Fortryd", + "turn.finalStep": "Fortryd er ikke muligt efter dette trin.", "announce.ask": "Afslut spillet efter denne tur?", "announce.confirm": "Meld afslutning", "announce.cancel": "Spil videre", @@ -47,10 +48,13 @@ export const da: Catalog = { "place.pass": "Fortsæt uden at lægge", "found.prompt": "Navngiv den nye kæde. Du får én gratis aktie.", "survivor.prompt": "Disse kæder er lige store og størst. Vælg, hvilken der overlever.", + "survivor.choose": "Vælg den overlevende kæde", + "survivor.confirm": "Bekræft: {survivor} overtager {defunct}", tiles: { one: "{count} brik", other: "{count} brikker" }, "order.prompt": "{survivor} overlever. Nogle opslugte kæder er lige store: vælg rækkefølgen, de afregnes i, fra første til sidste.", "order.confirm": "Bekræft rækkefølge", + "order.confirmChains": "Afvikl {chains} i denne rækkefølge", "order.reset": "Start forfra", "dispose.takenOver": "{defunct} bliver opslugt af {survivor}.", "dispose.holding": { one: "Du har {count} {chain}-aktie.", other: "Du har {count} {chain}-aktier." }, @@ -68,6 +72,16 @@ export const da: Catalog = { "dispose.tradeFewer": "Byt to færre", "dispose.tradeMore": "Byt to flere", "dispose.confirm": "Bekræft", + "dispose.choose": "Vælg først sælg, byt eller behold.", + "dispose.keepAll": "Behold alle", + "dispose.tradeRate": "2 {defunct} for 1 {survivor}", + "dispose.tradeNone": "Banken har ikke flere {chain}-aktier", + "dispose.tradeFew": "Bytte kræver mindst 2 aktier", + "dispose.after": "Efter dette valg", + "dispose.doSell": "sælg {count} for {amount}", + "dispose.doTrade": "byt {give} for {receive} {chain}", + "dispose.doKeep": "behold {count} {chain}", + "dispose.doKeepAll": "behold alle {count} {chain}", "buy.prompt": "Køb op til {limit} aktier. Priserne ligger fast i denne tur.", "buy.chain": "Kæde", "buy.price": "Pris", @@ -228,8 +242,7 @@ export const da: Catalog = { "Du ejer allerede 3 Tower-aktier. Én mere giver dig 4 for i alt $700 brugt.\n\nHver tur må du købe op til 3 nye aktier. Du kan også købe ingenting og spare pengene.", "tutorial.mergers.3": "Læg 8F mellem Worldwide og Festival. Begge har 2 brikker.", "tutorial.mergers.4": "Vælg Worldwide som den overlevende kæde.", - "tutorial.mergers.5": - "Du fik begge Festival-bonusser. Behold din Festival-aktie: Lad salg og bytte stå på 0, og bekræft.", + "tutorial.mergers.5": "Du fik begge Festival-bonusser. Behold din Festival-aktie: Vælg “Behold alle”, og bekræft.", "tutorial.mergers.6": "Vælg “Køb intet og afslut turen” for at afslutte den anden fusion.", "tutorial.mechanics.equalMerger": "Når de største kæder er lige store, vælger spilleren, der lægger den forbindende brik, den overlevende kæde. Antallet af aktier afgør ikke ligheden.\n\nHer har begge kæder 2 brikker. Du ejer den eneste Festival-aktie uden for banken.", diff --git a/packages/viewer/src/lib/locales/de.ts b/packages/viewer/src/lib/locales/de.ts index 9d29e49..da71181 100644 --- a/packages/viewer/src/lib/locales/de.ts +++ b/packages/viewer/src/lib/locales/de.ts @@ -31,6 +31,7 @@ export const de: Catalog = { "panel.label": "Deine Entscheidung", "panel.sending": "Wird gesendet…", "turn.undo": "Rückgängig", + "turn.finalStep": "Nach diesem Schritt ist Rückgängig nicht mehr möglich.", "announce.ask": "Das Spiel nach diesem Zug beenden?", "announce.confirm": "Spielende ankündigen", "announce.cancel": "Weiterspielen", @@ -47,10 +48,13 @@ export const de: Catalog = { "place.pass": "Ohne Legen weiter", "found.prompt": "Benenne die neue Kette. Du erhältst eine Gratisaktie.", "survivor.prompt": "Diese Ketten sind gleich groß und die größten. Wähle, welche bestehen bleibt.", + "survivor.choose": "Überlebende Kette wählen", + "survivor.confirm": "Bestätigen: {survivor} übernimmt {defunct}", tiles: { one: "{count} Plättchen", other: "{count} Plättchen" }, "order.prompt": "{survivor} bleibt bestehen. Einige übernommene Ketten sind gleich groß: Wähle die Reihenfolge, in der sie abgerechnet werden, von der ersten bis zur letzten.", "order.confirm": "Reihenfolge bestätigen", + "order.confirmChains": "{chains} in dieser Reihenfolge abwickeln", "order.reset": "Neu beginnen", "dispose.takenOver": "{defunct} wird von {survivor} übernommen.", "dispose.holding": { one: "Du besitzt {count} {chain}-Aktie.", other: "Du besitzt {count} {chain}-Aktien." }, @@ -68,6 +72,16 @@ export const de: Catalog = { "dispose.tradeFewer": "Zwei weniger tauschen", "dispose.tradeMore": "Zwei mehr tauschen", "dispose.confirm": "Bestätigen", + "dispose.choose": "Wähle zuerst Verkaufen, Tauschen oder Behalten.", + "dispose.keepAll": "Alle behalten", + "dispose.tradeRate": "2 {defunct} gegen 1 {survivor}", + "dispose.tradeNone": "Die Bank hat keine {chain}-Aktien mehr", + "dispose.tradeFew": "Zum Tauschen brauchst du mindestens 2 Aktien", + "dispose.after": "Nach dieser Wahl", + "dispose.doSell": "{count} für {amount} verkaufen", + "dispose.doTrade": "{give} gegen {receive} {chain} tauschen", + "dispose.doKeep": "{count} {chain} behalten", + "dispose.doKeepAll": "alle {count} {chain} behalten", "buy.prompt": "Kaufe bis zu {limit} Aktien. Die Preise gelten für den ganzen Zug.", "buy.chain": "Kette", "buy.price": "Preis", @@ -229,7 +243,7 @@ export const de: Catalog = { "tutorial.mergers.3": "Lege 8F zwischen Worldwide und Festival. Beide haben 2 Plättchen.", "tutorial.mergers.4": "Wähle Worldwide als überlebende Kette.", "tutorial.mergers.5": - "Du hast beide Festival-Boni erhalten. Behalte deine Festival-Aktie: Lass Verkauf und Tausch auf 0 und bestätige.", + "Du hast beide Festival-Boni erhalten. Behalte deine Festival-Aktie: Wähle „Alle behalten“ und bestätige.", "tutorial.mergers.6": "Wähle „Nichts kaufen und Zug beenden“, um die zweite Fusion abzuschließen.", "tutorial.mechanics.equalMerger": "Sind die größten Ketten gleich groß, wählt die Person, die das verbindende Plättchen legt, die überlebende Kette. Aktienzahlen entscheiden nicht.\n\nHier haben beide Ketten 2 Plättchen. Du besitzt die einzige Festival-Aktie außerhalb der Bank.", diff --git a/packages/viewer/src/lib/locales/el.ts b/packages/viewer/src/lib/locales/el.ts index 18a7588..53fe8fb 100644 --- a/packages/viewer/src/lib/locales/el.ts +++ b/packages/viewer/src/lib/locales/el.ts @@ -31,6 +31,7 @@ export const el: Catalog = { "panel.label": "Η απόφασή σου", "panel.sending": "Αποστολή…", "turn.undo": "Αναίρεση", + "turn.finalStep": "Μετά από αυτό το βήμα δεν υπάρχει αναίρεση.", "announce.ask": "Να τελειώσει το παιχνίδι μετά από αυτόν τον γύρο;", "announce.confirm": "Ανακοίνωση τέλους", "announce.cancel": "Συνέχεια παιχνιδιού", @@ -47,10 +48,13 @@ export const el: Catalog = { "place.pass": "Συνέχεια χωρίς τοποθέτηση", "found.prompt": "Ονόμασε τη νέα αλυσίδα. Παίρνεις μία δωρεάν μετοχή.", "survivor.prompt": "Αυτές οι αλυσίδες είναι ισόπαλες ως οι μεγαλύτερες. Διάλεξε ποια επιβιώνει.", + "survivor.choose": "Διάλεξε την αλυσίδα που επιβιώνει", + "survivor.confirm": "Επιβεβαίωση: η {survivor} απορροφά τη {defunct}", tiles: { one: "{count} πλακίδιο", other: "{count} πλακίδια" }, "order.prompt": "Η {survivor} επιβιώνει. Ορισμένες αλυσίδες που απορροφώνται έχουν το ίδιο μέγεθος: διάλεξε τη σειρά εκκαθάρισής τους, από την πρώτη ως την τελευταία.", "order.confirm": "Επιβεβαίωση σειράς", + "order.confirmChains": "Εκκαθάριση {chains} με αυτή τη σειρά", "order.reset": "Από την αρχή", "dispose.takenOver": "Η {defunct} απορροφάται από την {survivor}.", "dispose.holding": { one: "Έχεις {count} μετοχή {chain}.", other: "Έχεις {count} μετοχές {chain}." }, @@ -68,6 +72,16 @@ export const el: Catalog = { "dispose.tradeFewer": "Ανταλλαγή δύο λιγότερων", "dispose.tradeMore": "Ανταλλαγή δύο ακόμη", "dispose.confirm": "Επιβεβαίωση", + "dispose.choose": "Διάλεξε πρώτα πώληση, ανταλλαγή ή διατήρηση.", + "dispose.keepAll": "Διατήρηση όλων", + "dispose.tradeRate": "2 {defunct} για 1 {survivor}", + "dispose.tradeNone": "Η τράπεζα δεν έχει άλλες μετοχές {chain}", + "dispose.tradeFew": "Για ανταλλαγή χρειάζονται τουλάχιστον 2 μετοχές", + "dispose.after": "Μετά από αυτή την επιλογή", + "dispose.doSell": "πώληση {count} για {amount}", + "dispose.doTrade": "ανταλλαγή {give} για {receive} {chain}", + "dispose.doKeep": "διατήρηση {count} {chain}", + "dispose.doKeepAll": "διατήρηση και των {count} {chain}", "buy.prompt": "Αγόρασε έως {limit} μετοχές. Οι τιμές μένουν σταθερές σε αυτόν τον γύρο.", "buy.chain": "Αλυσίδα", "buy.price": "Τιμή", @@ -229,7 +243,7 @@ export const el: Catalog = { "tutorial.mergers.3": "Τοποθέτησε το 8F ανάμεσα στη Worldwide και τη Festival. Και οι δύο έχουν 2 πλακίδια.", "tutorial.mergers.4": "Επίλεξε τη Worldwide ως επιζώσα αλυσίδα.", "tutorial.mergers.5": - "Πήρες και τα δύο μπόνους της Festival. Κράτησε τη μετοχή Festival: άφησε πώληση και ανταλλαγή στο 0 και επιβεβαίωσε.", + "Πήρες και τα δύο μπόνους της Festival. Κράτησε τη μετοχή Festival: διάλεξε «Διατήρηση όλων» και επιβεβαίωσε.", "tutorial.mergers.6": "Επίλεξε «Καμία αγορά και τέλος σειράς» για να ολοκληρώσεις τη δεύτερη συγχώνευση.", "tutorial.mechanics.equalMerger": "Όταν οι μεγαλύτερες αλυσίδες ισοβαθμούν σε μέγεθος, ο παίκτης που τοποθετεί το συνδετικό πλακίδιο επιλέγει ποια επιβιώνει. Ο αριθμός μετοχών δεν λύνει την ισοπαλία.\n\nΕδώ και οι δύο έχουν 2 πλακίδια. Κατέχεις τη μοναδική μετοχή Festival εκτός τράπεζας.", diff --git a/packages/viewer/src/lib/locales/en.ts b/packages/viewer/src/lib/locales/en.ts index 24b24de..3e8a14a 100644 --- a/packages/viewer/src/lib/locales/en.ts +++ b/packages/viewer/src/lib/locales/en.ts @@ -36,6 +36,7 @@ export const en = { "panel.label": "Your decision", "panel.sending": "Sending…", "turn.undo": "Undo", + "turn.finalStep": "Undo isn’t available after this step.", "announce.ask": "End the game after this turn?", "announce.confirm": "Announce the end", "announce.cancel": "Keep playing", @@ -52,10 +53,13 @@ export const en = { "place.pass": "Continue without placing", "found.prompt": "Name the new chain. You receive one free share.", "survivor.prompt": "These chains are tied for largest. Choose which one survives.", + "survivor.choose": "Choose the surviving chain", + "survivor.confirm": "Confirm: {survivor} takes over {defunct}", tiles: { one: "{count} tile", other: "{count} tiles" }, "order.prompt": "{survivor} survives. Some defunct chains are the same size: choose the order they are resolved in, first to last.", "order.confirm": "Confirm order", + "order.confirmChains": "Resolve {chains} in this order", "order.reset": "Start over", "dispose.takenOver": "{defunct} is taken over by {survivor}.", "dispose.holding": { one: "You hold {count} {chain} share.", other: "You hold {count} {chain} shares." }, @@ -73,6 +77,16 @@ export const en = { "dispose.tradeFewer": "Trade two fewer", "dispose.tradeMore": "Trade two more", "dispose.confirm": "Confirm", + "dispose.choose": "Choose sell, trade or keep first.", + "dispose.keepAll": "Keep all", + "dispose.tradeRate": "2 {defunct} for 1 {survivor}", + "dispose.tradeNone": "The bank has no {chain} shares left", + "dispose.tradeFew": "Trading needs at least 2 shares", + "dispose.after": "After this choice", + "dispose.doSell": "sell {count} for {amount}", + "dispose.doTrade": "trade {give} for {receive} {chain}", + "dispose.doKeep": "keep {count} {chain}", + "dispose.doKeepAll": "keep all {count} {chain}", "buy.prompt": "Buy up to {limit} shares. Prices are fixed for this turn.", "buy.chain": "Chain", "buy.price": "Price", @@ -243,7 +257,7 @@ export const en = { "tutorial.mergers.3": "Place 8F between Worldwide and Festival. Both have 2 tiles.", "tutorial.mergers.4": "Choose Worldwide as the surviving chain.", "tutorial.mergers.5": - "You received both Festival bonuses. Keep your Festival share: leave sell and trade at 0, then confirm.", + "You received both Festival bonuses. Keep your Festival share: choose “Keep all”, then confirm.", "tutorial.mergers.6": "Choose “Buy nothing and end turn” to finish the second merger.", "tutorial.mechanics.equalMerger": "When the largest chains tie in size, the player placing the connecting tile chooses the survivor. Share counts do not break the tie.\n\nHere both chains have 2 tiles. You own Festival’s only share.", diff --git a/packages/viewer/src/lib/locales/fa.ts b/packages/viewer/src/lib/locales/fa.ts index a6987d4..2976fbe 100644 --- a/packages/viewer/src/lib/locales/fa.ts +++ b/packages/viewer/src/lib/locales/fa.ts @@ -31,6 +31,7 @@ export const fa: Catalog = { "panel.label": "تصمیم شما", "panel.sending": "در حال ارسال…", "turn.undo": "واگرد", + "turn.finalStep": "پس از این مرحله واگرد ممکن نیست.", "announce.ask": "بازی بعد از این نوبت تمام شود؟", "announce.confirm": "اعلام پایان", "announce.cancel": "ادامه‌ی بازی", @@ -47,10 +48,13 @@ export const fa: Catalog = { "place.pass": "ادامه بدون گذاشتن", "found.prompt": "برای زنجیره‌ی جدید نام انتخاب کنید. یک سهم رایگان می‌گیرید.", "survivor.prompt": "این زنجیره‌ها هم‌اندازه و بزرگ‌ترین‌اند. انتخاب کنید کدام بماند.", + "survivor.choose": "زنجیره‌ی ماندگار را انتخاب کنید", + "survivor.confirm": "تأیید: {survivor} زنجیره‌ی {defunct} را تصاحب می‌کند", tiles: { one: "{count} کاشی", other: "{count} کاشی" }, "order.prompt": "{survivor} می‌ماند. برخی زنجیره‌های ادغام‌شونده هم‌اندازه‌اند: ترتیب تسویه‌ی آن‌ها را از اول تا آخر انتخاب کنید.", "order.confirm": "تأیید ترتیب", + "order.confirmChains": "تسویه‌ی {chains} به همین ترتیب", "order.reset": "از نو", "dispose.takenOver": "{defunct} در {survivor} ادغام می‌شود.", "dispose.holding": { one: "شما {count} سهم {chain} دارید.", other: "شما {count} سهم {chain} دارید." }, @@ -68,6 +72,16 @@ export const fa: Catalog = { "dispose.tradeFewer": "دو تا کمتر معاوضه کن", "dispose.tradeMore": "دو تا بیشتر معاوضه کن", "dispose.confirm": "تأیید", + "dispose.choose": "ابتدا فروش، معاوضه یا نگه‌داشتن را انتخاب کنید.", + "dispose.keepAll": "نگه‌داشتن همه", + "dispose.tradeRate": "2 {defunct} به 1 {survivor}", + "dispose.tradeNone": "بانک دیگر سهم {chain} ندارد", + "dispose.tradeFew": "برای معاوضه دست‌کم 2 سهم لازم است", + "dispose.after": "پس از این انتخاب", + "dispose.doSell": "فروش {count} به {amount}", + "dispose.doTrade": "معاوضه‌ی {give} با {receive} {chain}", + "dispose.doKeep": "نگه‌داشتن {count} {chain}", + "dispose.doKeepAll": "نگه‌داشتن هر {count} {chain}", "buy.prompt": "حداکثر {limit} سهم بخرید. قیمت‌ها در این نوبت ثابت‌اند.", "buy.chain": "زنجیره", "buy.price": "قیمت", @@ -228,7 +242,7 @@ export const fa: Catalog = { "tutorial.mergers.3": "8F را بین Worldwide و Festival بگذارید. هر دو ۲ کاشی دارند.", "tutorial.mergers.4": "Worldwide را به‌عنوان زنجیرهٔ باقی‌مانده انتخاب کنید.", "tutorial.mergers.5": - "هر دو پاداش Festival را گرفتید. سهم Festival را نگه دارید: فروش و معاوضه را روی ۰ بگذارید و تأیید کنید.", + "هر دو پاداش Festival را گرفتید. سهم Festival را نگه دارید: «نگه‌داشتن همه» را انتخاب و تأیید کنید.", "tutorial.mergers.6": "برای پایان ادغام دوم، «چیزی نخر و نوبت را تمام کن» را انتخاب کنید.", "tutorial.mechanics.equalMerger": "وقتی بزرگ‌ترین زنجیره‌ها هم‌اندازه‌اند، بازیکنی که کاشی اتصال را می‌گذارد زنجیرهٔ باقی‌مانده را انتخاب می‌کند. تعداد سهام تساوی را نمی‌شکند.\n\nاینجا هر دو ۲ کاشی دارند. تنها سهم Festival خارج از بانک متعلق به شماست.", diff --git a/packages/viewer/src/lib/locales/fr.ts b/packages/viewer/src/lib/locales/fr.ts index 58714c6..b2b5154 100644 --- a/packages/viewer/src/lib/locales/fr.ts +++ b/packages/viewer/src/lib/locales/fr.ts @@ -32,6 +32,7 @@ export const fr: Catalog = { "panel.label": "Votre décision", "panel.sending": "Envoi…", "turn.undo": "Annuler", + "turn.finalStep": "Annuler ne sera plus possible après cette étape.", "announce.ask": "Terminer la partie après ce tour ?", "announce.confirm": "Annoncer la fin", "announce.cancel": "Continuer à jouer", @@ -48,10 +49,13 @@ export const fr: Catalog = { "place.pass": "Continuer sans poser", "found.prompt": "Nommez la nouvelle chaîne. Vous recevez une action gratuite.", "survivor.prompt": "Ces chaînes sont à égalité pour la plus grande. Choisissez celle qui survit.", + "survivor.choose": "Choisissez la chaîne survivante", + "survivor.confirm": "Confirmer : {survivor} absorbe {defunct}", tiles: { one: "{count} tuile", many: "{count} tuiles", other: "{count} tuiles" }, "order.prompt": "{survivor} survit. Certaines chaînes absorbées ont la même taille : choisissez l’ordre dans lequel elles sont réglées, de la première à la dernière.", "order.confirm": "Confirmer l’ordre", + "order.confirmChains": "Liquider {chains} dans cet ordre", "order.reset": "Recommencer", "dispose.takenOver": "{defunct} est absorbée par {survivor}.", "dispose.holding": { @@ -73,6 +77,16 @@ export const fr: Catalog = { "dispose.tradeFewer": "Échanger deux de moins", "dispose.tradeMore": "Échanger deux de plus", "dispose.confirm": "Confirmer", + "dispose.choose": "Choisissez d’abord vendre, échanger ou garder.", + "dispose.keepAll": "Tout garder", + "dispose.tradeRate": "2 {defunct} contre 1 {survivor}", + "dispose.tradeNone": "La banque n’a plus d’actions {chain}", + "dispose.tradeFew": "Il faut au moins 2 actions pour échanger", + "dispose.after": "Après ce choix", + "dispose.doSell": "vendre {count} pour {amount}", + "dispose.doTrade": "échanger {give} contre {receive} {chain}", + "dispose.doKeep": "garder {count} {chain}", + "dispose.doKeepAll": "garder les {count} {chain}", "buy.prompt": "Achetez jusqu’à {limit} actions. Les prix restent fixes pendant ce tour.", "buy.chain": "Chaîne", "buy.price": "Prix", @@ -248,7 +262,7 @@ export const fr: Catalog = { "tutorial.mergers.3": "Posez 8F entre Worldwide et Festival. Les deux ont 2 tuiles.", "tutorial.mergers.4": "Choisissez Worldwide comme chaîne survivante.", "tutorial.mergers.5": - "Vous avez reçu les deux primes Festival. Gardez votre action : laissez vente et échange à 0, puis confirmez.", + "Vous avez reçu les deux primes Festival. Gardez votre action : choisissez « Tout garder », puis confirmez.", "tutorial.mergers.6": "Choisissez « Ne rien acheter et terminer » pour conclure la deuxième fusion.", "tutorial.mechanics.equalMerger": "Quand les plus grandes chaînes ont la même taille, le joueur qui pose la tuile de liaison choisit la survivante. Le nombre d’actions ne départage pas l’égalité.\n\nIci, chaque chaîne a 2 tuiles. Vous possédez la seule action Festival en circulation.", diff --git a/packages/viewer/src/lib/locales/hi.ts b/packages/viewer/src/lib/locales/hi.ts index a50fb98..7e2709d 100644 --- a/packages/viewer/src/lib/locales/hi.ts +++ b/packages/viewer/src/lib/locales/hi.ts @@ -31,6 +31,7 @@ export const hi: Catalog = { "panel.label": "आपका निर्णय", "panel.sending": "भेजा जा रहा है…", "turn.undo": "पूर्ववत करें", + "turn.finalStep": "इस चरण के बाद पूर्ववत उपलब्ध नहीं होगा।", "announce.ask": "इस बारी के बाद खेल समाप्त करें?", "announce.confirm": "अंत की घोषणा करें", "announce.cancel": "खेलना जारी रखें", @@ -47,9 +48,12 @@ export const hi: Catalog = { "place.pass": "बिना रखे आगे बढ़ें", "found.prompt": "नई श्रृंखला का नाम चुनें। आपको एक मुफ़्त शेयर मिलेगा।", "survivor.prompt": "ये श्रृंखलाएँ सबसे बड़ी होने में बराबर हैं। चुनें कि कौन सी बचेगी।", + "survivor.choose": "बचने वाली श्रृंखला चुनें", + "survivor.confirm": "पुष्टि करें: {survivor}, {defunct} का अधिग्रहण करेगी", tiles: { one: "{count} टाइल", other: "{count} टाइलें" }, "order.prompt": "{survivor} बचती है। विलय होने वाली कुछ श्रृंखलाएँ एक ही आकार की हैं: पहली से आख़िरी तक, उनके निपटान का क्रम चुनें।", "order.confirm": "क्रम की पुष्टि करें", + "order.confirmChains": "{chains} को इसी क्रम में निपटाएँ", "order.reset": "फिर से शुरू करें", "dispose.takenOver": "{defunct} का {survivor} में विलय हो रहा है।", "dispose.holding": { one: "आपके पास {chain} का {count} शेयर है।", other: "आपके पास {chain} के {count} शेयर हैं।" }, @@ -67,6 +71,16 @@ export const hi: Catalog = { "dispose.tradeFewer": "दो कम बदलें", "dispose.tradeMore": "दो और बदलें", "dispose.confirm": "पुष्टि करें", + "dispose.choose": "पहले बेचना, बदलना या रखना चुनें।", + "dispose.keepAll": "सभी रखें", + "dispose.tradeRate": "2 {defunct} के बदले 1 {survivor}", + "dispose.tradeNone": "बैंक में {chain} के शेयर नहीं बचे", + "dispose.tradeFew": "अदला-बदली के लिए कम से कम 2 शेयर चाहिए", + "dispose.after": "इस चुनाव के बाद", + "dispose.doSell": "{amount} में {count} बेचें", + "dispose.doTrade": "{give} के बदले {receive} {chain} लें", + "dispose.doKeep": "{count} {chain} रखें", + "dispose.doKeepAll": "सभी {count} {chain} रखें", "buy.prompt": "अधिकतम {limit} शेयर खरीदें। इस बारी में कीमतें नहीं बदलतीं।", "buy.chain": "श्रृंखला", "buy.price": "कीमत", @@ -225,7 +239,7 @@ export const hi: Catalog = { "आपके पास पहले से Tower के 3 शेयर हैं। एक और खरीदने पर कुल 4 हो जाएँगे और कुल खर्च $700 होगा।\n\nहर बारी में आप अधिकतम 3 नए शेयर खरीद सकते हैं। आप कुछ न खरीदकर पैसे बचा भी सकते हैं।", "tutorial.mergers.3": "Worldwide और Festival के बीच 8F रखें। दोनों में 2 टाइल हैं।", "tutorial.mergers.4": "बचने वाली शृंखला के रूप में Worldwide चुनें।", - "tutorial.mergers.5": "आपको Festival के दोनों बोनस मिले। अपना Festival शेयर रखें: बिक्री और अदला-बदली 0 पर छोड़ें और पुष्टि करें।", + "tutorial.mergers.5": "आपको Festival के दोनों बोनस मिले। अपना Festival शेयर रखें: “सभी रखें” चुनें और पुष्टि करें।", "tutorial.mergers.6": "दूसरा विलय पूरा करने के लिए “कुछ न खरीदें और बारी समाप्त करें” चुनें।", "tutorial.mechanics.equalMerger": "जब सबसे बड़ी शृंखलाओं का आकार बराबर हो, तो जोड़ने वाली टाइल रखने वाला खिलाड़ी तय करता है कि कौन बचेगी। शेयरों की संख्या बराबरी नहीं तोड़ती।\n\nयहाँ दोनों में 2 टाइल हैं। बैंक के बाहर Festival का एकमात्र शेयर आपके पास है।", diff --git a/packages/viewer/src/lib/locales/it.ts b/packages/viewer/src/lib/locales/it.ts index 2283e7b..9fd3a49 100644 --- a/packages/viewer/src/lib/locales/it.ts +++ b/packages/viewer/src/lib/locales/it.ts @@ -31,6 +31,7 @@ export const it: Catalog = { "panel.label": "La tua decisione", "panel.sending": "Invio…", "turn.undo": "Annulla", + "turn.finalStep": "Dopo questo passo non potrai annullare.", "announce.ask": "Terminare la partita dopo questo turno?", "announce.confirm": "Annuncia la fine", "announce.cancel": "Continua a giocare", @@ -47,10 +48,13 @@ export const it: Catalog = { "place.pass": "Continua senza piazzare", "found.prompt": "Dai un nome alla nuova catena. Ricevi un'azione gratuita.", "survivor.prompt": "Queste catene sono le più grandi a pari merito. Scegli quale sopravvive.", + "survivor.choose": "Scegli la catena che sopravvive", + "survivor.confirm": "Conferma: {survivor} assorbe {defunct}", tiles: { one: "{count} tessera", many: "{count} tessere", other: "{count} tessere" }, "order.prompt": "{survivor} sopravvive. Alcune catene assorbite hanno la stessa dimensione: scegli l'ordine in cui vengono liquidate, dalla prima all'ultima.", "order.confirm": "Conferma l'ordine", + "order.confirmChains": "Liquida {chains} in quest’ordine", "order.reset": "Ricomincia", "dispose.takenOver": "{defunct} viene assorbita da {survivor}.", "dispose.holding": { @@ -72,6 +76,16 @@ export const it: Catalog = { "dispose.tradeFewer": "Scambiane due in meno", "dispose.tradeMore": "Scambiane due in più", "dispose.confirm": "Conferma", + "dispose.choose": "Scegli prima se vendere, scambiare o tenere.", + "dispose.keepAll": "Tieni tutto", + "dispose.tradeRate": "2 {defunct} per 1 {survivor}", + "dispose.tradeNone": "La banca non ha più azioni {chain}", + "dispose.tradeFew": "Per scambiare servono almeno 2 azioni", + "dispose.after": "Dopo questa scelta", + "dispose.doSell": "vendi {count} per {amount}", + "dispose.doTrade": "scambia {give} per {receive} {chain}", + "dispose.doKeep": "tieni {count} {chain}", + "dispose.doKeepAll": "tieni tutte le {count} {chain}", "buy.prompt": "Compra fino a {limit} azioni. I prezzi restano fissi in questo turno.", "buy.chain": "Catena", "buy.price": "Prezzo", @@ -252,7 +266,7 @@ export const it: Catalog = { "tutorial.mergers.3": "Piazza 8F tra Worldwide e Festival. Entrambe hanno 2 tessere.", "tutorial.mergers.4": "Scegli Worldwide come catena superstite.", "tutorial.mergers.5": - "Hai ricevuto entrambi i premi Festival. Conserva la tua azione Festival: lascia vendita e scambio a 0, poi conferma.", + "Hai ricevuto entrambi i premi Festival. Conserva la tua azione Festival: scegli “Tieni tutto”, poi conferma.", "tutorial.mergers.6": "Scegli “Non comprare e termina il turno” per concludere la seconda fusione.", "tutorial.mechanics.equalMerger": "Se le catene più grandi hanno la stessa dimensione, il giocatore che piazza la tessera di collegamento sceglie la superstite. Il numero di azioni non risolve la parità.\n\nQui entrambe hanno 2 tessere. Possiedi l’unica azione Festival fuori dalla banca.", diff --git a/packages/viewer/src/lib/locales/ko.ts b/packages/viewer/src/lib/locales/ko.ts index 147f95b..940b188 100644 --- a/packages/viewer/src/lib/locales/ko.ts +++ b/packages/viewer/src/lib/locales/ko.ts @@ -31,6 +31,7 @@ export const ko: Catalog = { "panel.label": "내 결정", "panel.sending": "보내는 중…", "turn.undo": "되돌리기", + "turn.finalStep": "이 단계 이후에는 되돌릴 수 없습니다.", "announce.ask": "이번 턴이 끝나면 게임을 끝낼까요?", "announce.confirm": "종료 선언", "announce.cancel": "계속 플레이", @@ -47,10 +48,13 @@ export const ko: Catalog = { "place.pass": "놓지 않고 계속하기", "found.prompt": "새 체인의 이름을 고르세요. 무료 주식 1주를 받습니다.", "survivor.prompt": "이 체인들이 가장 크고 크기가 같습니다. 살아남을 체인을 고르세요.", + "survivor.choose": "살아남을 체인을 고르세요", + "survivor.confirm": "확정: {survivor}이(가) {defunct}을(를) 인수", tiles: { other: "타일 {count}개" }, "order.prompt": "{survivor}이(가) 살아남습니다. 흡수되는 체인 중 크기가 같은 것이 있습니다. 처음부터 마지막까지 정산할 순서를 고르세요.", "order.confirm": "순서 확정", + "order.confirmChains": "{chains} 순서로 정리", "order.reset": "다시 고르기", "dispose.takenOver": "{survivor}이(가) {defunct}을(를) 흡수합니다.", "dispose.holding": { other: "{chain} 주식을 {count}주 가지고 있습니다." }, @@ -68,6 +72,16 @@ export const ko: Catalog = { "dispose.tradeFewer": "2주 덜 교환", "dispose.tradeMore": "2주 더 교환", "dispose.confirm": "확정", + "dispose.choose": "먼저 매도, 교환, 보유 중에서 고르세요.", + "dispose.keepAll": "모두 보유", + "dispose.tradeRate": "{defunct} 2주 → {survivor} 1주", + "dispose.tradeNone": "은행에 {chain} 주식이 없습니다", + "dispose.tradeFew": "교환하려면 2주 이상 필요합니다", + "dispose.after": "이 선택 후", + "dispose.doSell": "{count}주를 {amount}에 매도", + "dispose.doTrade": "{give}주를 {chain} {receive}주로 교환", + "dispose.doKeep": "{chain} {count}주 보유", + "dispose.doKeepAll": "{chain} {count}주 모두 보유", "buy.prompt": "주식을 최대 {limit}주까지 사세요. 이번 턴에는 가격이 바뀌지 않습니다.", "buy.chain": "체인", "buy.price": "가격", @@ -222,7 +236,7 @@ export const ko: Catalog = { "tutorial.mergers.3": "Worldwide와 Festival 사이에 8F를 놓으세요. 둘 다 2칸입니다.", "tutorial.mergers.4": "존속할 체인으로 Worldwide를 선택하세요.", "tutorial.mergers.5": - "Festival의 두 보너스를 모두 받았습니다. Festival 주식을 보유하세요. 판매와 교환을 0으로 두고 확인하세요.", + "Festival의 두 보너스를 모두 받았습니다. Festival 주식을 보유하세요. “모두 보유”를 고르고 확인하세요.", "tutorial.mergers.6": "“구매 없이 차례 종료”를 선택해 두 번째 합병을 마치세요.", "tutorial.mechanics.equalMerger": "가장 큰 체인들의 크기가 같으면 연결 타일을 놓은 플레이어가 존속할 체인을 고릅니다. 주식 수로 동률을 가리지 않습니다.\n\n여기서는 두 체인 모두 2칸입니다. 은행 밖의 유일한 Festival 주식을 당신이 갖고 있습니다.", diff --git a/packages/viewer/src/lib/locales/nl.ts b/packages/viewer/src/lib/locales/nl.ts index 27f6faa..7b6a43b 100644 --- a/packages/viewer/src/lib/locales/nl.ts +++ b/packages/viewer/src/lib/locales/nl.ts @@ -31,6 +31,7 @@ export const nl: Catalog = { "panel.label": "Jouw beslissing", "panel.sending": "Versturen…", "turn.undo": "Ongedaan maken", + "turn.finalStep": "Na deze stap is ongedaan maken niet meer mogelijk.", "announce.ask": "Het spel na deze beurt beëindigen?", "announce.confirm": "Einde aankondigen", "announce.cancel": "Verder spelen", @@ -47,10 +48,13 @@ export const nl: Catalog = { "place.pass": "Verder zonder te leggen", "found.prompt": "Geef de nieuwe keten een naam. Je krijgt één gratis aandeel.", "survivor.prompt": "Deze ketens zijn gelijk de grootste. Kies welke overleeft.", + "survivor.choose": "Kies de overlevende keten", + "survivor.confirm": "Bevestigen: {survivor} neemt {defunct} over", tiles: { one: "{count} tegel", other: "{count} tegels" }, "order.prompt": "{survivor} overleeft. Sommige overgenomen ketens zijn even groot: kies de volgorde waarin ze worden afgehandeld, van eerste tot laatste.", "order.confirm": "Volgorde bevestigen", + "order.confirmChains": "{chains} in deze volgorde afhandelen", "order.reset": "Opnieuw beginnen", "dispose.takenOver": "{defunct} wordt overgenomen door {survivor}.", "dispose.holding": { one: "Je hebt {count} {chain}-aandeel.", other: "Je hebt {count} {chain}-aandelen." }, @@ -68,6 +72,16 @@ export const nl: Catalog = { "dispose.tradeFewer": "Twee minder ruilen", "dispose.tradeMore": "Twee meer ruilen", "dispose.confirm": "Bevestigen", + "dispose.choose": "Kies eerst verkopen, ruilen of houden.", + "dispose.keepAll": "Alles houden", + "dispose.tradeRate": "2 {defunct} voor 1 {survivor}", + "dispose.tradeNone": "De bank heeft geen {chain}-aandelen meer", + "dispose.tradeFew": "Ruilen kan pas vanaf 2 aandelen", + "dispose.after": "Na deze keuze", + "dispose.doSell": "{count} verkopen voor {amount}", + "dispose.doTrade": "{give} ruilen voor {receive} {chain}", + "dispose.doKeep": "{count} {chain} houden", + "dispose.doKeepAll": "alle {count} {chain} houden", "buy.prompt": "Koop tot {limit} aandelen. De prijzen liggen vast tijdens deze beurt.", "buy.chain": "Keten", "buy.price": "Prijs", @@ -229,7 +243,7 @@ export const nl: Catalog = { "tutorial.mergers.3": "Leg 8F tussen Worldwide en Festival. Beide hebben 2 tegels.", "tutorial.mergers.4": "Kies Worldwide als overlevende keten.", "tutorial.mergers.5": - "Je hebt beide Festival-bonussen ontvangen. Houd je Festival-aandeel: laat verkopen en ruilen op 0 staan en bevestig.", + "Je hebt beide Festival-bonussen ontvangen. Houd je Festival-aandeel: kies ‘Alles houden’ en bevestig.", "tutorial.mergers.6": "Kies “Niets kopen en beurt beëindigen” om de tweede fusie af te ronden.", "tutorial.mechanics.equalMerger": "Als de grootste ketens even groot zijn, kiest de speler die de verbindende tegel legt welke overleeft. Het aantal aandelen beslist niet.\n\nHier hebben beide ketens 2 tegels. Jij bezit het enige Festival-aandeel buiten de bank.", diff --git a/packages/viewer/src/lib/locales/pl.ts b/packages/viewer/src/lib/locales/pl.ts index 6859e82..84e84ff 100644 --- a/packages/viewer/src/lib/locales/pl.ts +++ b/packages/viewer/src/lib/locales/pl.ts @@ -31,6 +31,7 @@ export const pl: Catalog = { "panel.label": "Twoja decyzja", "panel.sending": "Wysyłanie…", "turn.undo": "Cofnij", + "turn.finalStep": "Po tym kroku cofnięcie nie będzie możliwe.", "announce.ask": "Zakończyć grę po tej turze?", "announce.confirm": "Ogłoś koniec gry", "announce.cancel": "Graj dalej", @@ -47,10 +48,13 @@ export const pl: Catalog = { "place.pass": "Kontynuuj bez kładzenia", "found.prompt": "Nazwij nową sieć. Otrzymujesz jedną darmową akcję.", "survivor.prompt": "Te sieci są równie duże i największe. Wybierz, która przetrwa.", + "survivor.choose": "Wybierz sieć, która przetrwa", + "survivor.confirm": "Potwierdź: {survivor} przejmuje {defunct}", tiles: { one: "{count} płytka", few: "{count} płytki", many: "{count} płytek", other: "{count} płytki" }, "order.prompt": "{survivor} przetrwa. Niektóre przejmowane sieci są tej samej wielkości: wybierz kolejność ich rozliczenia, od pierwszej do ostatniej.", "order.confirm": "Potwierdź kolejność", + "order.confirmChains": "Rozlicz {chains} w tej kolejności", "order.reset": "Zacznij od nowa", "dispose.takenOver": "{survivor} przejmuje {defunct}.", "dispose.holding": { @@ -73,6 +77,16 @@ export const pl: Catalog = { "dispose.tradeFewer": "Wymień o dwie mniej", "dispose.tradeMore": "Wymień o dwie więcej", "dispose.confirm": "Potwierdź", + "dispose.choose": "Najpierw wybierz sprzedaż, wymianę lub zatrzymanie.", + "dispose.keepAll": "Zatrzymaj wszystkie", + "dispose.tradeRate": "2 {defunct} za 1 {survivor}", + "dispose.tradeNone": "Bank nie ma już akcji {chain}", + "dispose.tradeFew": "Do wymiany potrzeba co najmniej 2 akcji", + "dispose.after": "Po tym wyborze", + "dispose.doSell": "sprzedaj {count} za {amount}", + "dispose.doTrade": "wymień {give} na {receive} {chain}", + "dispose.doKeep": "zatrzymaj {count} {chain}", + "dispose.doKeepAll": "zatrzymaj wszystkie ({count}) {chain}", "buy.prompt": "Kup do {limit} akcji. Ceny nie zmieniają się w tej turze.", "buy.chain": "Sieć", "buy.price": "Cena", @@ -257,7 +271,7 @@ export const pl: Catalog = { "tutorial.mergers.3": "Połóż 8F między Worldwide a Festival. Obie sieci mają 2 płytki.", "tutorial.mergers.4": "Wybierz Worldwide jako sieć przejmującą.", "tutorial.mergers.5": - "Otrzymujesz obie premie Festival. Zachowaj akcję Festival: zostaw sprzedaż i wymianę na 0, a następnie potwierdź.", + "Otrzymujesz obie premie Festival. Zachowaj akcję Festival: wybierz „Zatrzymaj wszystkie”, a następnie potwierdź.", "tutorial.mergers.6": "Wybierz „Nic nie kupuj i zakończ turę”, aby zakończyć drugą fuzję.", "tutorial.mechanics.equalMerger": "Gdy największe sieci mają ten sam rozmiar, gracz kładący łączącą płytkę wybiera sieć przejmującą. Liczba akcji nie rozstrzyga remisu.\n\nTutaj obie mają 2 płytki. Posiadasz jedyną akcję Festival poza bankiem.", diff --git a/packages/viewer/src/lib/locales/pt-BR.ts b/packages/viewer/src/lib/locales/pt-BR.ts index c51152f..44a38ef 100644 --- a/packages/viewer/src/lib/locales/pt-BR.ts +++ b/packages/viewer/src/lib/locales/pt-BR.ts @@ -31,6 +31,7 @@ export const ptBR: Catalog = { "panel.label": "Sua decisão", "panel.sending": "Enviando…", "turn.undo": "Desfazer", + "turn.finalStep": "Desfazer não estará disponível depois desta etapa.", "announce.ask": "Encerrar o jogo depois deste turno?", "announce.confirm": "Anunciar o fim", "announce.cancel": "Continuar jogando", @@ -47,10 +48,13 @@ export const ptBR: Catalog = { "place.pass": "Continuar sem colocar", "found.prompt": "Dê nome à nova rede. Você recebe uma ação grátis.", "survivor.prompt": "Estas redes empatam como as maiores. Escolha qual sobrevive.", + "survivor.choose": "Escolha a rede sobrevivente", + "survivor.confirm": "Confirmar: {survivor} absorve {defunct}", tiles: { one: "{count} peça", many: "{count} peças", other: "{count} peças" }, "order.prompt": "A {survivor} sobrevive. Algumas redes absorvidas têm o mesmo tamanho: escolha a ordem em que são liquidadas, da primeira à última.", "order.confirm": "Confirmar a ordem", + "order.confirmChains": "Liquidar {chains} nesta ordem", "order.reset": "Recomeçar", "dispose.takenOver": "A {defunct} é absorvida pela {survivor}.", "dispose.holding": { @@ -72,6 +76,16 @@ export const ptBR: Catalog = { "dispose.tradeFewer": "Trocar duas a menos", "dispose.tradeMore": "Trocar duas a mais", "dispose.confirm": "Confirmar", + "dispose.choose": "Escolha primeiro vender, trocar ou manter.", + "dispose.keepAll": "Manter todas", + "dispose.tradeRate": "2 {defunct} por 1 {survivor}", + "dispose.tradeNone": "O banco não tem mais ações de {chain}", + "dispose.tradeFew": "Trocar exige pelo menos 2 ações", + "dispose.after": "Depois desta escolha", + "dispose.doSell": "vender {count} por {amount}", + "dispose.doTrade": "trocar {give} por {receive} {chain}", + "dispose.doKeep": "manter {count} {chain}", + "dispose.doKeepAll": "manter todas as {count} {chain}", "buy.prompt": "Compre até {limit} ações. Os preços ficam fixos neste turno.", "buy.chain": "Rede", "buy.price": "Preço", @@ -251,7 +265,7 @@ export const ptBR: Catalog = { "tutorial.mergers.3": "Coloque 8F entre Worldwide e Festival. Ambas têm 2 peças.", "tutorial.mergers.4": "Escolha Worldwide como a rede sobrevivente.", "tutorial.mergers.5": - "Você recebeu os dois bônus de Festival. Guarde sua ação de Festival: deixe venda e troca em 0 e confirme.", + "Você recebeu os dois bônus de Festival. Guarde sua ação de Festival: escolha “Manter todas” e confirme.", "tutorial.mergers.6": "Escolha “Não comprar e encerrar turno” para concluir a segunda fusão.", "tutorial.mechanics.equalMerger": "Quando as maiores redes empatam em tamanho, quem coloca a peça de ligação escolhe a sobrevivente. O número de ações não desempata.\n\nAqui, ambas têm 2 peças. Você tem a única ação de Festival fora do banco.", diff --git a/packages/viewer/src/lib/locales/ro.ts b/packages/viewer/src/lib/locales/ro.ts index b9a5c83..36de648 100644 --- a/packages/viewer/src/lib/locales/ro.ts +++ b/packages/viewer/src/lib/locales/ro.ts @@ -32,6 +32,7 @@ export const ro: Catalog = { "panel.label": "Decizia ta", "panel.sending": "Se trimite…", "turn.undo": "Anulează", + "turn.finalStep": "După acest pas nu mai poți anula.", "announce.ask": "Încheiem jocul după această tură?", "announce.confirm": "Anunță sfârșitul", "announce.cancel": "Continuă jocul", @@ -48,10 +49,13 @@ export const ro: Catalog = { "place.pass": "Continuă fără să plasezi", "found.prompt": "Numește lanțul nou. Primești o acțiune gratuită.", "survivor.prompt": "Aceste lanțuri sunt la egalitate ca cele mai mari. Alege care supraviețuiește.", + "survivor.choose": "Alege lanțul care supraviețuiește", + "survivor.confirm": "Confirmă: {survivor} preia {defunct}", tiles: { one: "{count} piesă", few: "{count} piese", other: "{count} de piese" }, "order.prompt": "{survivor} supraviețuiește. Unele lanțuri absorbite au aceeași mărime: alege ordinea în care sunt decontate, de la primul la ultimul.", "order.confirm": "Confirmă ordinea", + "order.confirmChains": "Rezolvă {chains} în această ordine", "order.reset": "Ia de la capăt", "dispose.takenOver": "{defunct} este preluat de {survivor}.", "dispose.holding": { @@ -73,6 +77,16 @@ export const ro: Catalog = { "dispose.tradeFewer": "Schimbă două mai puțin", "dispose.tradeMore": "Schimbă două în plus", "dispose.confirm": "Confirmă", + "dispose.choose": "Alege întâi vânzare, schimb sau păstrare.", + "dispose.keepAll": "Păstrează tot", + "dispose.tradeRate": "2 {defunct} pentru 1 {survivor}", + "dispose.tradeNone": "Banca nu mai are acțiuni {chain}", + "dispose.tradeFew": "Pentru schimb ai nevoie de cel puțin 2 acțiuni", + "dispose.after": "După această alegere", + "dispose.doSell": "vinde {count} pentru {amount}", + "dispose.doTrade": "schimbă {give} pentru {receive} {chain}", + "dispose.doKeep": "păstrează {count} {chain}", + "dispose.doKeepAll": "păstrează toate cele {count} {chain}", "buy.prompt": "Cumpără până la {limit} acțiuni. Prețurile rămân fixe în această tură.", "buy.chain": "Lanț", "buy.price": "Preț", @@ -252,7 +266,7 @@ export const ro: Catalog = { "tutorial.mergers.3": "Plasează 8F între Worldwide și Festival. Ambele au 2 plăcuțe.", "tutorial.mergers.4": "Alege Worldwide ca lanț supraviețuitor.", "tutorial.mergers.5": - "Ai primit ambele bonusuri Festival. Păstrează acțiunea Festival: lasă vânzarea și schimbul la 0, apoi confirmă.", + "Ai primit ambele bonusuri Festival. Păstrează acțiunea Festival: alege „Păstrează tot”, apoi confirmă.", "tutorial.mergers.6": "Alege „Nu cumpăra și încheie tura” pentru a termina a doua fuziune.", "tutorial.mechanics.equalMerger": "Când cele mai mari lanțuri au aceeași mărime, jucătorul care plasează plăcuța de legătură alege supraviețuitorul. Numărul de acțiuni nu departajează.\n\nAici ambele au 2 plăcuțe. Deții singura acțiune Festival aflată în afara băncii.", diff --git a/packages/viewer/src/lib/locales/ru.ts b/packages/viewer/src/lib/locales/ru.ts index 1befbc9..7ee9cce 100644 --- a/packages/viewer/src/lib/locales/ru.ts +++ b/packages/viewer/src/lib/locales/ru.ts @@ -31,6 +31,7 @@ export const ru: Catalog = { "panel.label": "Ваше решение", "panel.sending": "Отправка…", "turn.undo": "Отменить", + "turn.finalStep": "После этого шага отмена будет недоступна.", "announce.ask": "Закончить игру после этого хода?", "announce.confirm": "Объявить конец игры", "announce.cancel": "Продолжить игру", @@ -47,10 +48,13 @@ export const ru: Catalog = { "place.pass": "Продолжить без выкладки", "found.prompt": "Назовите новую сеть. Вы получаете одну бесплатную акцию.", "survivor.prompt": "Эти сети одинаково велики и крупнее остальных. Выберите, какая уцелеет.", + "survivor.choose": "Выберите уцелевшую сеть", + "survivor.confirm": "Подтвердить: {survivor} поглощает {defunct}", tiles: { one: "{count} фишка", few: "{count} фишки", many: "{count} фишек", other: "{count} фишки" }, "order.prompt": "{survivor} уцелеет. Некоторые поглощаемые сети одного размера: выберите порядок их расчёта, от первой до последней.", "order.confirm": "Подтвердить порядок", + "order.confirmChains": "Ликвидировать {chains} в этом порядке", "order.reset": "Начать заново", "dispose.takenOver": "{survivor} поглощает {defunct}.", "dispose.holding": { @@ -73,6 +77,16 @@ export const ru: Catalog = { "dispose.tradeFewer": "Обменять на две меньше", "dispose.tradeMore": "Обменять на две больше", "dispose.confirm": "Подтвердить", + "dispose.choose": "Сначала выберите: продать, обменять или оставить.", + "dispose.keepAll": "Оставить все", + "dispose.tradeRate": "2 {defunct} за 1 {survivor}", + "dispose.tradeNone": "В банке не осталось акций {chain}", + "dispose.tradeFew": "Для обмена нужно не меньше 2 акций", + "dispose.after": "После этого выбора", + "dispose.doSell": "продать {count} за {amount}", + "dispose.doTrade": "обменять {give} на {receive} {chain}", + "dispose.doKeep": "оставить {count} {chain}", + "dispose.doKeepAll": "оставить все {count} {chain}", "buy.prompt": "Купите до {limit} акций. Цены в этом ходе не меняются.", "buy.chain": "Сеть", "buy.price": "Цена", @@ -257,7 +271,7 @@ export const ru: Catalog = { "tutorial.mergers.3": "Разместите 8F между Worldwide и Festival. У обеих сетей по 2 плитки.", "tutorial.mergers.4": "Выберите Worldwide в качестве выжившей сети.", "tutorial.mergers.5": - "Вы получили обе премии Festival. Сохраните акцию Festival: оставьте продажу и обмен на 0 и подтвердите.", + "Вы получили обе премии Festival. Сохраните акцию Festival: выберите «Оставить все» и подтвердите.", "tutorial.mergers.6": "Выберите «Ничего не покупать и закончить ход», чтобы завершить второе слияние.", "tutorial.mechanics.equalMerger": "Если крупнейшие сети равны по размеру, игрок, разместивший соединяющую плитку, выбирает выжившую. Число акций не разрешает ничью.\n\nЗдесь у обеих сетей по 2 плитки. Вам принадлежит единственная акция Festival вне банка.", diff --git a/packages/viewer/src/lib/locales/vi.ts b/packages/viewer/src/lib/locales/vi.ts index 31da1c9..b2a289e 100644 --- a/packages/viewer/src/lib/locales/vi.ts +++ b/packages/viewer/src/lib/locales/vi.ts @@ -31,6 +31,7 @@ export const vi: Catalog = { "panel.label": "Quyết định của bạn", "panel.sending": "Đang gửi…", "turn.undo": "Hoàn tác", + "turn.finalStep": "Sau bước này sẽ không thể hoàn tác.", "announce.ask": "Kết thúc ván chơi sau lượt này?", "announce.confirm": "Tuyên bố kết thúc", "announce.cancel": "Tiếp tục chơi", @@ -47,10 +48,13 @@ export const vi: Catalog = { "place.pass": "Tiếp tục mà không đặt", "found.prompt": "Đặt tên cho chuỗi mới. Bạn nhận một cổ phiếu miễn phí.", "survivor.prompt": "Các chuỗi này lớn nhất và bằng nhau. Chọn chuỗi tồn tại.", + "survivor.choose": "Chọn chuỗi tồn tại", + "survivor.confirm": "Xác nhận: {survivor} thâu tóm {defunct}", tiles: { other: "{count} ô" }, "order.prompt": "{survivor} tồn tại. Một số chuỗi bị thâu tóm có cùng kích thước: chọn thứ tự thanh toán chúng, từ đầu đến cuối.", "order.confirm": "Xác nhận thứ tự", + "order.confirmChains": "Giải quyết {chains} theo thứ tự này", "order.reset": "Chọn lại", "dispose.takenOver": "{defunct} bị {survivor} thâu tóm.", "dispose.holding": { other: "Bạn có {count} cổ phiếu {chain}." }, @@ -68,6 +72,16 @@ export const vi: Catalog = { "dispose.tradeFewer": "Đổi bớt hai", "dispose.tradeMore": "Đổi thêm hai", "dispose.confirm": "Xác nhận", + "dispose.choose": "Hãy chọn bán, đổi hoặc giữ trước.", + "dispose.keepAll": "Giữ tất cả", + "dispose.tradeRate": "2 {defunct} lấy 1 {survivor}", + "dispose.tradeNone": "Ngân hàng đã hết cổ phiếu {chain}", + "dispose.tradeFew": "Cần ít nhất 2 cổ phiếu để đổi", + "dispose.after": "Sau lựa chọn này", + "dispose.doSell": "bán {count} được {amount}", + "dispose.doTrade": "đổi {give} lấy {receive} {chain}", + "dispose.doKeep": "giữ {count} {chain}", + "dispose.doKeepAll": "giữ cả {count} {chain}", "buy.prompt": "Mua tối đa {limit} cổ phiếu. Giá không đổi trong lượt này.", "buy.chain": "Chuỗi", "buy.price": "Giá", @@ -223,7 +237,7 @@ export const vi: Catalog = { "tutorial.mergers.3": "Đặt 8F giữa Worldwide và Festival. Cả hai đều có 2 ô.", "tutorial.mergers.4": "Chọn Worldwide làm chuỗi tồn tại.", "tutorial.mergers.5": - "Bạn đã nhận cả hai khoản thưởng Festival. Giữ cổ phiếu Festival: để bán và đổi ở 0 rồi xác nhận.", + "Bạn đã nhận cả hai khoản thưởng Festival. Giữ cổ phiếu Festival: chọn “Giữ tất cả” rồi xác nhận.", "tutorial.mergers.6": "Chọn “Không mua và kết thúc lượt” để hoàn tất vụ sáp nhập thứ hai.", "tutorial.mechanics.equalMerger": "Khi các chuỗi lớn nhất bằng nhau, người đặt ô nối chọn chuỗi tồn tại. Số cổ phiếu không quyết định kết quả hòa.\n\nỞ đây, mỗi chuỗi có 2 ô. Bạn giữ cổ phiếu Festival duy nhất ngoài ngân hàng.", diff --git a/packages/viewer/src/lib/locales/zh-CN.ts b/packages/viewer/src/lib/locales/zh-CN.ts index cef1e6e..ec45240 100644 --- a/packages/viewer/src/lib/locales/zh-CN.ts +++ b/packages/viewer/src/lib/locales/zh-CN.ts @@ -31,6 +31,7 @@ export const zhCN: Catalog = { "panel.label": "你的决定", "panel.sending": "正在发送…", "turn.undo": "撤销", + "turn.finalStep": "此步骤之后将无法撤销。", "announce.ask": "在本回合结束后结束游戏?", "announce.confirm": "宣布结束", "announce.cancel": "继续游戏", @@ -47,9 +48,12 @@ export const zhCN: Catalog = { "place.pass": "不放置,继续", "found.prompt": "为新连锁命名。你将获得一股免费股票。", "survivor.prompt": "这些连锁并列最大。请选择存续的连锁。", + "survivor.choose": "选择存续连锁", + "survivor.confirm": "确认:{survivor} 并购 {defunct}", tiles: { other: "{count} 块" }, "order.prompt": "{survivor} 存续。部分被吞并的连锁大小相同:请从先到后选择它们的结算顺序。", "order.confirm": "确认顺序", + "order.confirmChains": "按此顺序结算 {chains}", "order.reset": "重新选择", "dispose.takenOver": "{defunct} 被 {survivor} 吞并。", "dispose.holding": { other: "你持有 {count} 股 {chain}。" }, @@ -67,6 +71,16 @@ export const zhCN: Catalog = { "dispose.tradeFewer": "少换两股", "dispose.tradeMore": "多换两股", "dispose.confirm": "确认", + "dispose.choose": "请先选择出售、交换或保留。", + "dispose.keepAll": "全部保留", + "dispose.tradeRate": "2 股 {defunct} 换 1 股 {survivor}", + "dispose.tradeNone": "银行已没有 {chain} 股票", + "dispose.tradeFew": "交换至少需要 2 股", + "dispose.after": "此选择后", + "dispose.doSell": "以 {amount} 出售 {count} 股", + "dispose.doTrade": "用 {give} 股换 {receive} 股 {chain}", + "dispose.doKeep": "保留 {count} 股 {chain}", + "dispose.doKeepAll": "保留全部 {count} 股 {chain}", "buy.prompt": "最多购买 {limit} 股。本回合内价格不变。", "buy.chain": "连锁", "buy.price": "价格", @@ -219,7 +233,7 @@ export const zhCN: Catalog = { "你已有 3 股 Tower。再买 1 股后共有 4 股,总支出为 $700。\n\n每个回合都可以新购最多 3 股。你也可以不买,保留现金。", "tutorial.mergers.3": "在 Worldwide 和 Festival 之间放置 8F。两者都占 2 格。", "tutorial.mergers.4": "选择 Worldwide 作为存续连锁。", - "tutorial.mergers.5": "你已获得 Festival 的两项奖金。保留 Festival 股票:将出售和交换保持为 0,然后确认。", + "tutorial.mergers.5": "你已获得 Festival 的两项奖金。保留 Festival 股票:选择“全部保留”,然后确认。", "tutorial.mergers.6": "选择“不购买并结束回合”,完成第二次合并。", "tutorial.mechanics.equalMerger": "当最大的连锁规模相同时,由放置连接方块的玩家选择存续连锁。持股数量不能打破平局。\n\n这里两家都占 2 格。银行以外唯一的 Festival 股票在你手中。", diff --git a/packages/viewer/src/lib/locales/zh-TW.ts b/packages/viewer/src/lib/locales/zh-TW.ts index 21274ed..0fc7acb 100644 --- a/packages/viewer/src/lib/locales/zh-TW.ts +++ b/packages/viewer/src/lib/locales/zh-TW.ts @@ -31,6 +31,7 @@ export const zhTW: Catalog = { "panel.label": "你的決定", "panel.sending": "正在傳送…", "turn.undo": "復原", + "turn.finalStep": "此步驟之後將無法復原。", "announce.ask": "在本回合結束後結束遊戲?", "announce.confirm": "宣布結束", "announce.cancel": "繼續遊戲", @@ -47,9 +48,12 @@ export const zhTW: Catalog = { "place.pass": "不放置,繼續", "found.prompt": "為新連鎖命名。你將獲得一股免費股票。", "survivor.prompt": "這些連鎖並列最大。請選擇存續的連鎖。", + "survivor.choose": "選擇存續連鎖", + "survivor.confirm": "確認:{survivor} 併購 {defunct}", tiles: { other: "{count} 塊" }, "order.prompt": "{survivor} 存續。部分被併購的連鎖大小相同:請由先到後選擇它們的結算順序。", "order.confirm": "確認順序", + "order.confirmChains": "依此順序結算 {chains}", "order.reset": "重新選擇", "dispose.takenOver": "{defunct} 被 {survivor} 併購。", "dispose.holding": { other: "你持有 {count} 股 {chain}。" }, @@ -67,6 +71,16 @@ export const zhTW: Catalog = { "dispose.tradeFewer": "少換兩股", "dispose.tradeMore": "多換兩股", "dispose.confirm": "確認", + "dispose.choose": "請先選擇出售、交換或保留。", + "dispose.keepAll": "全部保留", + "dispose.tradeRate": "2 股 {defunct} 換 1 股 {survivor}", + "dispose.tradeNone": "銀行已沒有 {chain} 股票", + "dispose.tradeFew": "交換至少需要 2 股", + "dispose.after": "此選擇後", + "dispose.doSell": "以 {amount} 出售 {count} 股", + "dispose.doTrade": "以 {give} 股換 {receive} 股 {chain}", + "dispose.doKeep": "保留 {count} 股 {chain}", + "dispose.doKeepAll": "保留全部 {count} 股 {chain}", "buy.prompt": "最多購買 {limit} 股。本回合內價格不變。", "buy.chain": "連鎖", "buy.price": "價格", @@ -219,7 +233,7 @@ export const zhTW: Catalog = { "你已有 3 股 Tower。再買 1 股後共有 4 股,總支出為 $700。\n\n每個回合都可以新購最多 3 股。你也可以不買,保留現金。", "tutorial.mergers.3": "在 Worldwide 和 Festival 之間放置 8F。兩者都占 2 格。", "tutorial.mergers.4": "選擇 Worldwide 作為存續連鎖。", - "tutorial.mergers.5": "你已獲得 Festival 的兩項獎金。保留 Festival 股票:將出售與交換保持為 0,然後確認。", + "tutorial.mergers.5": "你已獲得 Festival 的兩項獎金。保留 Festival 股票:選擇「全部保留」,然後確認。", "tutorial.mergers.6": "選擇「不購買並結束回合」,完成第二次合併。", "tutorial.mechanics.equalMerger": "當最大的連鎖規模相同時,由放置連接方塊的玩家選擇存續連鎖。持股數量不能打破平手。\n\n這裡兩家都占 2 格。銀行以外唯一的 Festival 股票在你手中。", diff --git a/packages/viewer/src/lib/store.svelte.ts b/packages/viewer/src/lib/store.svelte.ts index 4cff27f..e8ede42 100644 --- a/packages/viewer/src/lib/store.svelte.ts +++ b/packages/viewer/src/lib/store.svelte.ts @@ -6,7 +6,7 @@ import { movesFor } from "./decisions"; import { langFor } from "./format"; import { isRightToLeft, type Locale } from "./i18n"; import { replayStart, replayView } from "./replay"; -import { TurnDraft } from "./turn-draft"; +import { moveOutcome, TurnDraft, type MoveOutcome } from "./turn-draft"; /** Context key: the store is given to every component at mount, for viewer-wide settings. */ export const STORE = Symbol("viewer-store"); @@ -119,6 +119,16 @@ export class ViewerStore { return { start: this.replayable ? replayStart(this.state!) : end, end }; } + /** Moves are private drafts that can be undone until a commit boundary. */ + get drafting(): boolean { + return !!(this.options.turnDrafts && this.state?.supportsTurnDrafts && !this.analysis); + } + + /** What sending `move` now would do to the private turn draft. */ + outcome(move: Move): MoveOutcome | undefined { + return this.state ? moveOutcome($state.snapshot(this.state), move, this.player) : undefined; + } + send(move: Move): void { if (this.sending || this.readOnly || this.replayAt !== undefined) { return; diff --git a/packages/viewer/src/lib/turn-draft.spec.ts b/packages/viewer/src/lib/turn-draft.spec.ts index 9af28a2..228b733 100644 --- a/packages/viewer/src/lib/turn-draft.spec.ts +++ b/packages/viewer/src/lib/turn-draft.spec.ts @@ -1,9 +1,20 @@ import assert from "node:assert/strict"; import { test } from "node:test"; -import { type Move } from "acquire-engine"; +import { + applyMove, + currentSeat, + draftCanContinue, + dropPlayerSeats, + initGame, + legalMoves, + parseTile, + tileLabel, + type GameState, + type Move, +} from "acquire-engine"; import * as engine from "acquire-engine/wrapper"; import { preparedPosition } from "../tutorial/lessons.ts"; -import { TurnDraft } from "./turn-draft.ts"; +import { currentTurnEntries, moveOutcome, reviewFor, TurnDraft, type MoveOutcome } from "./turn-draft.ts"; function setup() { const full = preparedPosition("founding"); @@ -81,3 +92,120 @@ test("new committed states and player changes close undo; repeated revisions sta draft.reset(); assert.equal(draft.base, undefined); }); + +function truth(full: GameState, move: Move, player: number): MoveOutcome { + const seat = currentSeat(full)!; + const after = applyMove(structuredClone(full), move, seat); + // A dropped player's automatic turn depends on their hidden hand and cash. + const automatic = after.log.slice(full.log.length).some((entry) => entry.type === "move" && entry.auto); + return { + commits: !draftCanContinue(full, after, player), + endsTurn: seat === full.activeSeat && (after.ended || after.turn !== full.turn), + endsGame: after.ended && !automatic, + }; +} + +test("commit boundaries predicted from a private view match the engine's draft boundaries", () => { + // The second twoTiles seed drops a player, whose later turns are played automatically. + const variants: [number, Record, string][] = [ + [4, {}, "a"], + [3, { twoTiles: true }, "a"], + [3, { twoTiles: true }, "drop"], + [3, { stockSwap: "3" }, "a"], + [2, {}, "a"], + [2, { twoPlayerMode: "fourHands", twoTiles: true }, "a"], + [4, { publicHoldings: true, autoEnd: true, endSize: "31" }, "a"], + [4, { limitedLog: true, stockSwap: "5" }, "a"], + [6, { sharesPerTurn: "5" }, "a"], + ]; + const seen = new Set(); + for (const [players, options, seed] of variants) { + const state = initGame(players, options, `outcome-${seed}`); + for (let step = 0; step < 400 && !state.ended; step++) { + if (seed === "drop" && step === 150) { + dropPlayerSeats(state, 2); + continue; + } + const seat = currentSeat(state)!; + const player = state.seatOwner[seat]!; + const view = engine.stripSecret(state, player); + const moves = legalMoves(state); + const buys = moves.filter((move) => move.type === "buy"); + const sample = [...moves.filter((move) => move.type !== "buy").slice(0, 3), buys[0], buys.at(-1)]; + for (const move of sample) { + if (!move) { + continue; + } + const expected = truth(state, move, player); + assert.deepEqual(moveOutcome(view, move, player), expected, `${players} ${JSON.stringify(options)} ${step}`); + seen.add(`${move.type}:${expected.commits}:${expected.endsTurn}:${expected.endsGame}`); + } + const choices = moves.filter((move) => move.type !== "announce" || step > 250); + applyMove(state, choices[(step * 7919) % choices.length]!, seat); + } + } + for (const kind of [ + "place:false:false:false", + "place:true:false:false", + "place:true:true:false", + "survivor:true:false:false", + "dispose:true:false:false", + "dispose:false:false:false", + "swap:false:false:false", + "announce:false:false:false", + "buy:true:true:false", + "buy:true:true:true", + ]) { + assert.ok(seen.has(kind), `covered ${kind}`); + } +}); + +const review = (view: GameState, move: Move, player: number, undoable: number) => + reviewFor(view, move, moveOutcome(view, move, player), undoable); + +test("only the turn's final step, or a placement that ends undo, asks for review", () => { + const full = preparedPosition("founding"); + const view = () => engine.stripSecret(full, 0); + assert.equal(review(view(), place, 0, 0), undefined, "placing a founding tile continues"); + applyMove(full, place, 0); + applyMove(full, found, 0); + assert.equal(review(view(), { type: "buy", shares: {} }, 0, 2), "end"); + assert.equal(review(view(), { type: "announce" }, 0, 2), undefined); + assert.deepEqual( + currentTurnEntries(view()).flatMap((entry) => (entry.type === "move" ? [entry.move.type] : [])), + ["place", "found"] + ); + + // A lone placement that ends the turn already has the placement confirmation. + const quiet = initGame(3, {}, "lone"); + const seat = quiet.activeSeat; + quiet.board.fill(null); + const tile = quiet.seats[seat]!.hand[0]!; + const lone: Move = { type: "place", tile: tileLabel(tile) }; + assert.equal(moveOutcome(engine.stripSecret(quiet, seat), lone, seat).endsTurn, true); + assert.equal(review(engine.stripSecret(quiet, seat), lone, seat, 0), undefined); + + // With two tiles, the second placement ends the turn after an earlier move. + const two = initGame(3, { twoTiles: true }, "two"); + two.board.fill(null); + const turnSeat = two.activeSeat; + two.seats[turnSeat]!.hand = ["1A", "5E", "9I"].map((label) => parseTile(label)!); + applyMove(two, { type: "place", tile: "1A" }, turnSeat); + const second: Move = { type: "place", tile: "5E" }; + assert.equal(two.phase, "place"); + assert.equal(moveOutcome(engine.stripSecret(two, turnSeat), second, turnSeat).endsTurn, true); + assert.equal(review(engine.stripSecret(two, turnSeat), second, turnSeat, 1), "end"); +}); + +test("a placement that pays merger bonuses after an undoable move warns before undo ends", () => { + const full = preparedPosition("mergers"); + full.options = { ...full.options, twoTiles: true }; + full.seats[0]!.hand = [parseTile("12I")!, parseTile("4A")!]; + applyMove(full, { type: "place", tile: "12I" }, 0); + const view = engine.stripSecret(full, 0); + const merge: Move = { type: "place", tile: "4A" }; + assert.deepEqual(moveOutcome(view, merge, 0), { commits: true, endsTurn: false, endsGame: false }); + assert.equal(review(view, merge, 0, 1), "commit"); + assert.equal(review(view, merge, 0, 0), undefined, "nothing to lose without undoable moves"); + assert.equal(moveOutcome(view, merge, undefined).commits, true, "spectators never act"); +}); diff --git a/packages/viewer/src/lib/turn-draft.ts b/packages/viewer/src/lib/turn-draft.ts index 2bce3dc..156bbb2 100644 --- a/packages/viewer/src/lib/turn-draft.ts +++ b/packages/viewer/src/lib/turn-draft.ts @@ -1,4 +1,69 @@ -import type { GameState, Move, TurnRequest } from "acquire-engine"; +import { applyMove, currentSeat, draftCanContinue, type GameState, type Move, type TurnRequest } from "acquire-engine"; + +/** What sending a move would do to the acting player's private turn draft. */ +export interface MoveOutcome { + /** Undo stops here: hidden information, another player's decision or the turn's end follows. */ + commits: boolean; + /** The acting seat's own turn passes on (tiles are drawn) or the game ends. */ + endsTurn: boolean; + /** Known to end the game; a dropped player's automatic turn afterwards is not foreseen. */ + endsGame: boolean; +} + +/** + * Predicts the commit boundary of `move` with the engine's own draftCanContinue, on a throwaway + * copy of the player's view. Everything that decides the boundary is visible to the acting + * player (merger plans and disposer lists, their own hand and cash, waiting bank tiles, end + * conditions); numbers derived from hidden values on the copy are discarded unseen. + */ +export function moveOutcome(view: GameState, move: Move, player: number | undefined): MoveOutcome { + const seat = currentSeat(view); + try { + if (seat === undefined || player === undefined) { + throw new Error("Not acting"); + } + const copy = structuredClone(view); + // Dropped players' automatic moves would use their hidden hands and cash; stopping before + // them still shows the boundary, since a move by another seat always commits. + copy.seats.forEach((other) => (other.dropped = false)); + const after = applyMove(copy, structuredClone(move), seat); + return { + commits: !draftCanContinue(view, after, player), + endsTurn: seat === view.activeSeat && (after.ended || after.turn !== view.turn), + endsGame: after.ended, + }; + } catch { + // Buying always ends the turn; anything else unexpected is treated as final. + return { commits: true, endsTurn: move.type === "buy", endsGame: false }; + } +} + +/** Log entries of the turn in progress: everything after its "turn" heading. */ +export function currentTurnEntries(state: GameState): GameState["log"] { + const start = state.log.map((entry) => entry.type).lastIndexOf("turn"); + return state.log.slice(start + 1); +} + +/** + * Which confirmation a move needs before it is sent: a turn summary when it ends the turn + * (except a lone placement, which has its own confirmation), or a final-step warning when a + * placement would make earlier undoable moves permanent. Merger decisions confirm in place. + */ +export function reviewFor( + view: GameState, + move: Move, + outcome: MoveOutcome, + undoable: number +): "end" | "commit" | undefined { + if (outcome.endsTurn) { + const seat = currentSeat(view); + const earlier = currentTurnEntries(view).some( + (entry) => entry.type === "move" && entry.seat === seat && !entry.auto + ); + return earlier || (move.type !== "place" && move.type !== "pass") ? "end" : undefined; + } + return outcome.commits && undoable > 0 && move.type === "place" ? "commit" : undefined; +} /** Only server-validated private views are cached; hidden holdings are never simulated here. */ export class TurnDraft { diff --git a/packages/viewer/src/lib/turn-summary.ts b/packages/viewer/src/lib/turn-summary.ts new file mode 100644 index 0000000..7c0c02b --- /dev/null +++ b/packages/viewer/src/lib/turn-summary.ts @@ -0,0 +1,78 @@ +// The acting seat's cash and shares after a move, for previews before it is sent. Only the +// acting seat's own numbers are used; nothing is inferred about hidden holdings. +import { + CHAIN_IDS, + chainSize, + currentSeat, + placementEffect, + sharePrice, + stockSwapCost, + parseTile, + type ChainId, + type GameState, + type Move, + type Shares, +} from "acquire-engine"; + +export interface Effect { + cash: number; + shares: Partial; +} + +/** The change `move` makes to the acting seat's cash and shares, or undefined when it pays bonuses. */ +export function moveEffect(state: GameState, move: Move): Effect | undefined { + const seat = currentSeat(state); + if (seat === undefined) { + return undefined; + } + const price = (chain: ChainId) => sharePrice(chain, chainSize(state.board, chain)); + switch (move.type) { + case "buy": { + const shares = Object.entries(move.shares) as [ChainId, number][]; + return { + cash: -shares.reduce((sum, [chain, count]) => sum + count * price(chain), 0), + shares: move.shares, + }; + } + case "swap": + return { + cash: -stockSwapCost(state, move.from, move.to, move.count), + shares: { [move.from]: -move.count, [move.to]: move.count }, + }; + case "dispose": { + const merger = state.merger!; + const defunct = merger.current!; + return { + cash: move.sell * sharePrice(defunct, merger.sizes[defunct]!), + shares: { [defunct]: -(move.sell + move.trade), [merger.survivor!]: move.trade / 2 }, + }; + } + case "found": + return { cash: 0, shares: state.bank[move.chain] > 0 ? { [move.chain]: 1 } : {} }; + case "place": + return placementEffect(state.board, parseTile(move.tile)!).kind === "merge" ? undefined : { cash: 0, shares: {} }; + case "pass": + case "announce": + return { cash: 0, shares: {} }; + case "survivor": + case "defunctOrder": + return undefined; + } +} + +export interface HoldingChange { + chain: ChainId; + before: number; + after: number; +} + +/** The acting seat's cash and every holding it has or gains, before and after `effect`. */ +export function holdingsAfter(state: GameState, effect: Effect) { + const seat = state.seats[currentSeat(state)!]!; + const shares: HoldingChange[] = CHAIN_IDS.flatMap((chain) => { + const before = seat.shares[chain]; + const after = before + (effect.shares[chain] ?? 0); + return before > 0 || after > 0 ? [{ chain, before, after }] : []; + }); + return { cash: { before: seat.cash, after: seat.cash + effect.cash }, shares }; +} diff --git a/scripts/check-browser.mjs b/scripts/check-browser.mjs index 1fec20f..3ee33f4 100644 --- a/scripts/check-browser.mjs +++ b/scripts/check-browser.mjs @@ -477,6 +477,9 @@ try { beforePreset, "presets wait for Confirm" ); + assert.equal(await page.locator(".panel button.primary").innerText(), "Trade 6 for 3 Imperial and keep 1 Festival"); + await page.locator(".keep-all").click(); + assert.equal(await page.locator(".panel button.primary").innerText(), "Keep all 7 Festival"); for (const locale of locales) { await preferences({ locale }); assert.ok( @@ -1132,11 +1135,15 @@ try { await page.getByRole("button", { name: "Buy one more Tower", exact: true }).click(); } else { await page.locator(".choices button").filter({ hasText: "Festival" }).click(); + await page.locator("main .panel button.primary").click(); await page.getByRole("alert").waitFor(); await page.locator(".choices button").filter({ hasText: "Worldwide" }).click(); + await page.locator("main .panel button.primary").click(); await page.waitForSelector('.acquire-tutorial[data-step="5"]'); assert.match(await page.locator(".guide").innerText(), /\$4,500/); - // Default 0/0 keeps the Festival share after both bonuses are paid. + // Keeping the Festival share is an explicit choice; Confirm waits for it. + assert.equal(await page.locator("main .panel button.primary").isDisabled(), true); + await page.locator(".keep-all").click(); await page.locator("main .panel button.primary").click(); await page.waitForSelector('.acquire-tutorial[data-step="6"]'); } @@ -1248,6 +1255,7 @@ try { ); if (chapter === "mergers") { await page.locator(".choices button").filter({ hasText: "Worldwide" }).click(); + await page.locator("main .panel .primary").click(); await page.waitForSelector('.acquire-tutorial[data-step="5"]'); } assert.ok( From 2bdb95f23d9635d4c071529d224bcaf71e3d1f59 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 07:26:03 -0700 Subject: [PATCH 08/12] Show a turn summary before the step that ends the turn When the next move would end the turn (the buy, or a placement or decision that passes the turn on), the viewer holds it back and shows this turn's moves in plain language from the log (placements and their effects, foundings, merger results and disposals, swaps), the pending move, the cash and shares it leaves, and why it is final: ending the turn draws new tiles, or the game ends and is scored. "End turn" sends it, "Back" returns to the choice, and Undo steps back through the private draft from the summary. Lines already saved before the last commit boundary are greyed. A placement that would make earlier undoable moves permanent (a two-tile turn whose second tile pays merger bonuses) gets the same review. A lone placement that ends the turn keeps only its own placement confirmation, and tutorials keep their single-step flow. Undo after the turn has committed is still impossible: the end-of-turn draw reveals the next tile. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 4 +- packages/viewer/src/lib/ActionPanel.svelte | 25 +---- packages/viewer/src/lib/Log.svelte | 27 +---- packages/viewer/src/lib/LogParts.svelte | 37 +++++++ packages/viewer/src/lib/TurnSummary.svelte | 111 +++++++++++++++++++ packages/viewer/src/lib/UndoButton.svelte | 33 ++++++ packages/viewer/src/lib/locales/da.ts | 7 ++ packages/viewer/src/lib/locales/de.ts | 7 ++ packages/viewer/src/lib/locales/el.ts | 7 ++ packages/viewer/src/lib/locales/en.ts | 7 ++ packages/viewer/src/lib/locales/fa.ts | 7 ++ packages/viewer/src/lib/locales/fr.ts | 7 ++ packages/viewer/src/lib/locales/hi.ts | 7 ++ packages/viewer/src/lib/locales/it.ts | 7 ++ packages/viewer/src/lib/locales/ko.ts | 7 ++ packages/viewer/src/lib/locales/nl.ts | 7 ++ packages/viewer/src/lib/locales/pl.ts | 7 ++ packages/viewer/src/lib/locales/pt-BR.ts | 7 ++ packages/viewer/src/lib/locales/ro.ts | 7 ++ packages/viewer/src/lib/locales/ru.ts | 7 ++ packages/viewer/src/lib/locales/vi.ts | 7 ++ packages/viewer/src/lib/locales/zh-CN.ts | 7 ++ packages/viewer/src/lib/locales/zh-TW.ts | 7 ++ packages/viewer/src/lib/store.svelte.ts | 37 ++++++- packages/viewer/src/lib/turn-summary.spec.ts | 76 +++++++++++++ packages/viewer/src/lib/turn-summary.ts | 95 +++++++++++++++- packages/viewer/src/viewer.ts | 6 +- scripts/check-browser.mjs | 22 ++++ 28 files changed, 541 insertions(+), 51 deletions(-) create mode 100644 packages/viewer/src/lib/LogParts.svelte create mode 100644 packages/viewer/src/lib/TurnSummary.svelte create mode 100644 packages/viewer/src/lib/UndoButton.svelte create mode 100644 packages/viewer/src/lib/turn-summary.spec.ts diff --git a/AGENTS.md b/AGENTS.md index 59b0fb9..1df9aa6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,7 +43,9 @@ Use Node 24 and pnpm 11. Inspect the working tree before editing and preserve un `toSave: undefined`; only the acting player receives the stripped preview. Revisions must not append saved history or award time. Commit boundaries include another player's decision, hidden information being revealed, draws and game end. Keep atomic moves working - for older viewers, tutorials and analysis. + for older viewers, tutorials and analysis. The viewer predicts each boundary by running the + engine's `draftCanContinue` on a throwaway copy of the player's own view (`moveOutcome`), so + the turn-ending step shows a turn summary first and merger decisions warn when undo stops. - Preserve two-player bank mode, four hands, team play and dropped-player behavior when changing rules. - Put new UI/log/tutorial text in all 17 catalogs under `packages/viewer/src/lib/locales/`. Keep chain names and tile coordinates unchanged. CMS text and setup labels have separate diff --git a/packages/viewer/src/lib/ActionPanel.svelte b/packages/viewer/src/lib/ActionPanel.svelte index 8d4e2c1..15e1f1b 100644 --- a/packages/viewer/src/lib/ActionPanel.svelte +++ b/packages/viewer/src/lib/ActionPanel.svelte @@ -15,6 +15,8 @@ import ChainMark from "./ChainMark.svelte"; import HoldingChange from "./HoldingChange.svelte"; import StockSwap from "./StockSwap.svelte"; + import TurnSummary from "./TurnSummary.svelte"; + import UndoButton from "./UndoButton.svelte"; import { mergerPreview } from "./mergerPreview"; import { adjustShares, @@ -129,21 +131,12 @@ } -{#if moves.length > 0 && !store.sending} +{#if store.reviewing} + +{:else if moves.length > 0 && !store.sending}
    {#if store.canUndo} - + {/if} {#if legal("announce")}
    @@ -491,12 +484,6 @@ font-variant-numeric: tabular-nums; } - .panel .undo { - display: flex; - align-items: center; - gap: 6px; - margin-inline-start: auto; - } .panel { background: var(--panel); padding: 10px 12px 12px; diff --git a/packages/viewer/src/lib/Log.svelte b/packages/viewer/src/lib/Log.svelte index 01c15d0..1270d2d 100644 --- a/packages/viewer/src/lib/Log.svelte +++ b/packages/viewer/src/lib/Log.svelte @@ -1,8 +1,7 @@ + +{#each parts as part} + {#if part.kind === "player" || part.kind === "chain"} + {@const color = + part.kind === "player" + ? playerColor(game.seatOwner[part.seat] ?? part.seat, store.appearance?.playerColors) + : CHAIN_STYLES[part.chain].fill} + {part.text} + {:else if part.kind === "money"}{part.text}{:else}{part.text}{/if} +{/each} + + diff --git a/packages/viewer/src/lib/TurnSummary.svelte b/packages/viewer/src/lib/TurnSummary.svelte new file mode 100644 index 0000000..7a5681e --- /dev/null +++ b/packages/viewer/src/lib/TurnSummary.svelte @@ -0,0 +1,111 @@ + + +
    +
    +

    {t("turn.summary")}

    + {#if store.canUndo}{/if} +
    +
      + {#each lines as line (line.key)} +
    1. + {/each} +
    + {#if mixed}

    {t("turn.finalLines")}

    {/if} + {#if holdings} + + {/if} +

    {note}

    +
    + + +
    +
    + + diff --git a/packages/viewer/src/lib/UndoButton.svelte b/packages/viewer/src/lib/UndoButton.svelte new file mode 100644 index 0000000..f45e8a7 --- /dev/null +++ b/packages/viewer/src/lib/UndoButton.svelte @@ -0,0 +1,33 @@ + + + + + diff --git a/packages/viewer/src/lib/locales/da.ts b/packages/viewer/src/lib/locales/da.ts index 3a5ee57..25c612c 100644 --- a/packages/viewer/src/lib/locales/da.ts +++ b/packages/viewer/src/lib/locales/da.ts @@ -31,7 +31,14 @@ export const da: Catalog = { "panel.label": "Din beslutning", "panel.sending": "Sender…", "turn.undo": "Fortryd", + "turn.summary": "Gennemse din tur", + "turn.end": "Afslut tur", + "turn.back": "Tilbage", + "turn.after": "Efter denne tur", + "turn.endNote": "Når turen afsluttes, trækkes nye brikker, så den kan ikke fortrydes.", + "turn.gameEnds": "Dette afslutter spillet: Slutbonusser udbetales, og alle aktier sælges.", "turn.finalStep": "Fortryd er ikke muligt efter dette trin.", + "turn.finalLines": "Grå linjer er endelige; Fortryd går tilbage gennem resten én ad gangen.", "announce.ask": "Afslut spillet efter denne tur?", "announce.confirm": "Meld afslutning", "announce.cancel": "Spil videre", diff --git a/packages/viewer/src/lib/locales/de.ts b/packages/viewer/src/lib/locales/de.ts index da71181..b5ee6b2 100644 --- a/packages/viewer/src/lib/locales/de.ts +++ b/packages/viewer/src/lib/locales/de.ts @@ -31,7 +31,14 @@ export const de: Catalog = { "panel.label": "Deine Entscheidung", "panel.sending": "Wird gesendet…", "turn.undo": "Rückgängig", + "turn.summary": "Zug überprüfen", + "turn.end": "Zug beenden", + "turn.back": "Zurück", + "turn.after": "Nach diesem Zug", + "turn.endNote": "Beim Beenden des Zugs werden neue Plättchen gezogen; das lässt sich nicht rückgängig machen.", + "turn.gameEnds": "Damit endet das Spiel: Schlussprämien werden gezahlt und alle Aktien verkauft.", "turn.finalStep": "Nach diesem Schritt ist Rückgängig nicht mehr möglich.", + "turn.finalLines": "Graue Zeilen sind endgültig; Rückgängig nimmt die übrigen Schritt für Schritt zurück.", "announce.ask": "Das Spiel nach diesem Zug beenden?", "announce.confirm": "Spielende ankündigen", "announce.cancel": "Weiterspielen", diff --git a/packages/viewer/src/lib/locales/el.ts b/packages/viewer/src/lib/locales/el.ts index 53fe8fb..069c509 100644 --- a/packages/viewer/src/lib/locales/el.ts +++ b/packages/viewer/src/lib/locales/el.ts @@ -31,7 +31,14 @@ export const el: Catalog = { "panel.label": "Η απόφασή σου", "panel.sending": "Αποστολή…", "turn.undo": "Αναίρεση", + "turn.summary": "Έλεγχος γύρου", + "turn.end": "Τέλος γύρου", + "turn.back": "Πίσω", + "turn.after": "Μετά από αυτόν τον γύρο", + "turn.endNote": "Με το τέλος του γύρου τραβιούνται νέα πλακίδια, οπότε δεν αναιρείται.", + "turn.gameEnds": "Έτσι τελειώνει το παιχνίδι: πληρώνονται τα τελικά μπόνους και πωλούνται όλες οι μετοχές.", "turn.finalStep": "Μετά από αυτό το βήμα δεν υπάρχει αναίρεση.", + "turn.finalLines": "Οι γκρίζες γραμμές είναι οριστικές· η Αναίρεση γυρίζει πίσω τις υπόλοιπες μία μία.", "announce.ask": "Να τελειώσει το παιχνίδι μετά από αυτόν τον γύρο;", "announce.confirm": "Ανακοίνωση τέλους", "announce.cancel": "Συνέχεια παιχνιδιού", diff --git a/packages/viewer/src/lib/locales/en.ts b/packages/viewer/src/lib/locales/en.ts index 3e8a14a..b1878b8 100644 --- a/packages/viewer/src/lib/locales/en.ts +++ b/packages/viewer/src/lib/locales/en.ts @@ -36,7 +36,14 @@ export const en = { "panel.label": "Your decision", "panel.sending": "Sending…", "turn.undo": "Undo", + "turn.summary": "Review your turn", + "turn.end": "End turn", + "turn.back": "Back", + "turn.after": "After this turn", + "turn.endNote": "Ending your turn draws new tiles, so it can’t be undone.", + "turn.gameEnds": "This ends the game: final bonuses are paid and all shares are sold.", "turn.finalStep": "Undo isn’t available after this step.", + "turn.finalLines": "Greyed lines are final; Undo steps back through the rest.", "announce.ask": "End the game after this turn?", "announce.confirm": "Announce the end", "announce.cancel": "Keep playing", diff --git a/packages/viewer/src/lib/locales/fa.ts b/packages/viewer/src/lib/locales/fa.ts index 2976fbe..4a3373a 100644 --- a/packages/viewer/src/lib/locales/fa.ts +++ b/packages/viewer/src/lib/locales/fa.ts @@ -31,7 +31,14 @@ export const fa: Catalog = { "panel.label": "تصمیم شما", "panel.sending": "در حال ارسال…", "turn.undo": "واگرد", + "turn.summary": "مرور نوبت", + "turn.end": "پایان نوبت", + "turn.back": "بازگشت", + "turn.after": "پس از این نوبت", + "turn.endNote": "با پایان نوبت کاشی‌های تازه کشیده می‌شوند، پس قابل واگرد نیست.", + "turn.gameEnds": "بازی تمام می‌شود: پاداش‌های پایانی پرداخت و همه‌ی سهام فروخته می‌شود.", "turn.finalStep": "پس از این مرحله واگرد ممکن نیست.", + "turn.finalLines": "خط‌های خاکستری قطعی‌اند؛ واگرد بقیه را یکی‌یکی برمی‌گرداند.", "announce.ask": "بازی بعد از این نوبت تمام شود؟", "announce.confirm": "اعلام پایان", "announce.cancel": "ادامه‌ی بازی", diff --git a/packages/viewer/src/lib/locales/fr.ts b/packages/viewer/src/lib/locales/fr.ts index b2b5154..5205204 100644 --- a/packages/viewer/src/lib/locales/fr.ts +++ b/packages/viewer/src/lib/locales/fr.ts @@ -32,7 +32,14 @@ export const fr: Catalog = { "panel.label": "Votre décision", "panel.sending": "Envoi…", "turn.undo": "Annuler", + "turn.summary": "Vérifier votre tour", + "turn.end": "Finir le tour", + "turn.back": "Retour", + "turn.after": "Après ce tour", + "turn.endNote": "Finir le tour pioche de nouvelles tuiles : impossible de l’annuler ensuite.", + "turn.gameEnds": "Cela termine la partie : les primes finales sont versées et toutes les actions vendues.", "turn.finalStep": "Annuler ne sera plus possible après cette étape.", + "turn.finalLines": "Les lignes grisées sont définitives ; Annuler revient sur les autres une à une.", "announce.ask": "Terminer la partie après ce tour ?", "announce.confirm": "Annoncer la fin", "announce.cancel": "Continuer à jouer", diff --git a/packages/viewer/src/lib/locales/hi.ts b/packages/viewer/src/lib/locales/hi.ts index 7e2709d..699155d 100644 --- a/packages/viewer/src/lib/locales/hi.ts +++ b/packages/viewer/src/lib/locales/hi.ts @@ -31,7 +31,14 @@ export const hi: Catalog = { "panel.label": "आपका निर्णय", "panel.sending": "भेजा जा रहा है…", "turn.undo": "पूर्ववत करें", + "turn.summary": "अपनी बारी जाँचें", + "turn.end": "बारी समाप्त करें", + "turn.back": "वापस", + "turn.after": "इस बारी के बाद", + "turn.endNote": "बारी समाप्त करने पर नई टाइलें ली जाती हैं, इसलिए इसे पूर्ववत नहीं किया जा सकता।", + "turn.gameEnds": "इससे खेल समाप्त होगा: अंतिम बोनस दिए जाएँगे और सभी शेयर बेचे जाएँगे।", "turn.finalStep": "इस चरण के बाद पूर्ववत उपलब्ध नहीं होगा।", + "turn.finalLines": "धूसर पंक्तियाँ अंतिम हैं; पूर्ववत बाकी को एक-एक करके वापस लेता है।", "announce.ask": "इस बारी के बाद खेल समाप्त करें?", "announce.confirm": "अंत की घोषणा करें", "announce.cancel": "खेलना जारी रखें", diff --git a/packages/viewer/src/lib/locales/it.ts b/packages/viewer/src/lib/locales/it.ts index 9fd3a49..d485f7c 100644 --- a/packages/viewer/src/lib/locales/it.ts +++ b/packages/viewer/src/lib/locales/it.ts @@ -31,7 +31,14 @@ export const it: Catalog = { "panel.label": "La tua decisione", "panel.sending": "Invio…", "turn.undo": "Annulla", + "turn.summary": "Rivedi il turno", + "turn.end": "Termina il turno", + "turn.back": "Indietro", + "turn.after": "Dopo questo turno", + "turn.endNote": "Terminando il turno si pescano nuove tessere, quindi non si può annullare.", + "turn.gameEnds": "Questo termina la partita: si pagano i premi finali e si vendono tutte le azioni.", "turn.finalStep": "Dopo questo passo non potrai annullare.", + "turn.finalLines": "Le righe grigie sono definitive; Annulla torna indietro sulle altre una alla volta.", "announce.ask": "Terminare la partita dopo questo turno?", "announce.confirm": "Annuncia la fine", "announce.cancel": "Continua a giocare", diff --git a/packages/viewer/src/lib/locales/ko.ts b/packages/viewer/src/lib/locales/ko.ts index 940b188..a35a8c7 100644 --- a/packages/viewer/src/lib/locales/ko.ts +++ b/packages/viewer/src/lib/locales/ko.ts @@ -31,7 +31,14 @@ export const ko: Catalog = { "panel.label": "내 결정", "panel.sending": "보내는 중…", "turn.undo": "되돌리기", + "turn.summary": "턴 확인", + "turn.end": "턴 끝내기", + "turn.back": "뒤로", + "turn.after": "이번 턴 후", + "turn.endNote": "턴을 끝내면 새 타일을 뽑으므로 되돌릴 수 없습니다.", + "turn.gameEnds": "게임이 끝납니다. 최종 보너스가 지급되고 모든 주식이 매도됩니다.", "turn.finalStep": "이 단계 이후에는 되돌릴 수 없습니다.", + "turn.finalLines": "회색 줄은 확정되었습니다. 되돌리기는 나머지를 하나씩 취소합니다.", "announce.ask": "이번 턴이 끝나면 게임을 끝낼까요?", "announce.confirm": "종료 선언", "announce.cancel": "계속 플레이", diff --git a/packages/viewer/src/lib/locales/nl.ts b/packages/viewer/src/lib/locales/nl.ts index 7b6a43b..42187f2 100644 --- a/packages/viewer/src/lib/locales/nl.ts +++ b/packages/viewer/src/lib/locales/nl.ts @@ -31,7 +31,14 @@ export const nl: Catalog = { "panel.label": "Jouw beslissing", "panel.sending": "Versturen…", "turn.undo": "Ongedaan maken", + "turn.summary": "Controleer je beurt", + "turn.end": "Beurt beëindigen", + "turn.back": "Terug", + "turn.after": "Na deze beurt", + "turn.endNote": "Bij het beëindigen van je beurt trek je nieuwe tegels, dus dit kan niet ongedaan worden gemaakt.", + "turn.gameEnds": "Dit beëindigt het spel: eindbonussen worden uitbetaald en alle aandelen verkocht.", "turn.finalStep": "Na deze stap is ongedaan maken niet meer mogelijk.", + "turn.finalLines": "Grijze regels zijn definitief; Ongedaan maken loopt de rest stap voor stap terug.", "announce.ask": "Het spel na deze beurt beëindigen?", "announce.confirm": "Einde aankondigen", "announce.cancel": "Verder spelen", diff --git a/packages/viewer/src/lib/locales/pl.ts b/packages/viewer/src/lib/locales/pl.ts index 84e84ff..d95befd 100644 --- a/packages/viewer/src/lib/locales/pl.ts +++ b/packages/viewer/src/lib/locales/pl.ts @@ -31,7 +31,14 @@ export const pl: Catalog = { "panel.label": "Twoja decyzja", "panel.sending": "Wysyłanie…", "turn.undo": "Cofnij", + "turn.summary": "Sprawdź swoją turę", + "turn.end": "Zakończ turę", + "turn.back": "Wstecz", + "turn.after": "Po tej turze", + "turn.endNote": "Zakończenie tury dobiera nowe płytki, więc nie da się jej cofnąć.", + "turn.gameEnds": "To kończy grę: zostaną wypłacone premie końcowe i sprzedane wszystkie akcje.", "turn.finalStep": "Po tym kroku cofnięcie nie będzie możliwe.", + "turn.finalLines": "Szare wiersze są ostateczne; Cofnij wycofuje pozostałe po kolei.", "announce.ask": "Zakończyć grę po tej turze?", "announce.confirm": "Ogłoś koniec gry", "announce.cancel": "Graj dalej", diff --git a/packages/viewer/src/lib/locales/pt-BR.ts b/packages/viewer/src/lib/locales/pt-BR.ts index 44a38ef..b2c1704 100644 --- a/packages/viewer/src/lib/locales/pt-BR.ts +++ b/packages/viewer/src/lib/locales/pt-BR.ts @@ -31,7 +31,14 @@ export const ptBR: Catalog = { "panel.label": "Sua decisão", "panel.sending": "Enviando…", "turn.undo": "Desfazer", + "turn.summary": "Revise seu turno", + "turn.end": "Encerrar turno", + "turn.back": "Voltar", + "turn.after": "Depois deste turno", + "turn.endNote": "Encerrar o turno compra novas peças, então não dá para desfazer.", + "turn.gameEnds": "Isto encerra o jogo: os bônus finais são pagos e todas as ações são vendidas.", "turn.finalStep": "Desfazer não estará disponível depois desta etapa.", + "turn.finalLines": "Linhas em cinza são definitivas; Desfazer volta pelas outras uma a uma.", "announce.ask": "Encerrar o jogo depois deste turno?", "announce.confirm": "Anunciar o fim", "announce.cancel": "Continuar jogando", diff --git a/packages/viewer/src/lib/locales/ro.ts b/packages/viewer/src/lib/locales/ro.ts index 36de648..4c70dbc 100644 --- a/packages/viewer/src/lib/locales/ro.ts +++ b/packages/viewer/src/lib/locales/ro.ts @@ -32,7 +32,14 @@ export const ro: Catalog = { "panel.label": "Decizia ta", "panel.sending": "Se trimite…", "turn.undo": "Anulează", + "turn.summary": "Verifică tura", + "turn.end": "Încheie tura", + "turn.back": "Înapoi", + "turn.after": "După această tură", + "turn.endNote": "Încheierea turei trage piese noi, deci nu mai poate fi anulată.", + "turn.gameEnds": "Aceasta încheie jocul: se plătesc bonusurile finale și se vând toate acțiunile.", "turn.finalStep": "După acest pas nu mai poți anula.", + "turn.finalLines": "Liniile gri sunt definitive; Anulează revine pas cu pas asupra celorlalte.", "announce.ask": "Încheiem jocul după această tură?", "announce.confirm": "Anunță sfârșitul", "announce.cancel": "Continuă jocul", diff --git a/packages/viewer/src/lib/locales/ru.ts b/packages/viewer/src/lib/locales/ru.ts index 7ee9cce..45c91fa 100644 --- a/packages/viewer/src/lib/locales/ru.ts +++ b/packages/viewer/src/lib/locales/ru.ts @@ -31,7 +31,14 @@ export const ru: Catalog = { "panel.label": "Ваше решение", "panel.sending": "Отправка…", "turn.undo": "Отменить", + "turn.summary": "Проверьте ход", + "turn.end": "Закончить ход", + "turn.back": "Назад", + "turn.after": "После этого хода", + "turn.endNote": "В конце хода берутся новые фишки, поэтому его нельзя отменить.", + "turn.gameEnds": "Это завершит игру: будут выплачены итоговые премии и проданы все акции.", "turn.finalStep": "После этого шага отмена будет недоступна.", + "turn.finalLines": "Серые строки окончательны; «Отменить» по одной откатывает остальные.", "announce.ask": "Закончить игру после этого хода?", "announce.confirm": "Объявить конец игры", "announce.cancel": "Продолжить игру", diff --git a/packages/viewer/src/lib/locales/vi.ts b/packages/viewer/src/lib/locales/vi.ts index b2a289e..2b334e8 100644 --- a/packages/viewer/src/lib/locales/vi.ts +++ b/packages/viewer/src/lib/locales/vi.ts @@ -31,7 +31,14 @@ export const vi: Catalog = { "panel.label": "Quyết định của bạn", "panel.sending": "Đang gửi…", "turn.undo": "Hoàn tác", + "turn.summary": "Xem lại lượt", + "turn.end": "Kết thúc lượt", + "turn.back": "Quay lại", + "turn.after": "Sau lượt này", + "turn.endNote": "Kết thúc lượt sẽ bốc ô mới nên không thể hoàn tác.", + "turn.gameEnds": "Ván đấu sẽ kết thúc: trả thưởng cuối và bán toàn bộ cổ phiếu.", "turn.finalStep": "Sau bước này sẽ không thể hoàn tác.", + "turn.finalLines": "Dòng màu xám đã cố định; Hoàn tác lùi lại từng bước cho phần còn lại.", "announce.ask": "Kết thúc ván chơi sau lượt này?", "announce.confirm": "Tuyên bố kết thúc", "announce.cancel": "Tiếp tục chơi", diff --git a/packages/viewer/src/lib/locales/zh-CN.ts b/packages/viewer/src/lib/locales/zh-CN.ts index ec45240..67c978d 100644 --- a/packages/viewer/src/lib/locales/zh-CN.ts +++ b/packages/viewer/src/lib/locales/zh-CN.ts @@ -31,7 +31,14 @@ export const zhCN: Catalog = { "panel.label": "你的决定", "panel.sending": "正在发送…", "turn.undo": "撤销", + "turn.summary": "查看本回合", + "turn.end": "结束回合", + "turn.back": "返回", + "turn.after": "本回合后", + "turn.endNote": "结束回合会抽取新板块,因此无法撤销。", + "turn.gameEnds": "游戏将结束:支付最终奖金并出售所有股票。", "turn.finalStep": "此步骤之后将无法撤销。", + "turn.finalLines": "灰色项目已确定;撤销会逐步撤回其余项目。", "announce.ask": "在本回合结束后结束游戏?", "announce.confirm": "宣布结束", "announce.cancel": "继续游戏", diff --git a/packages/viewer/src/lib/locales/zh-TW.ts b/packages/viewer/src/lib/locales/zh-TW.ts index 0fc7acb..deaf1b0 100644 --- a/packages/viewer/src/lib/locales/zh-TW.ts +++ b/packages/viewer/src/lib/locales/zh-TW.ts @@ -31,7 +31,14 @@ export const zhTW: Catalog = { "panel.label": "你的決定", "panel.sending": "正在傳送…", "turn.undo": "復原", + "turn.summary": "檢視本回合", + "turn.end": "結束回合", + "turn.back": "返回", + "turn.after": "本回合後", + "turn.endNote": "結束回合會抽取新圖塊,因此無法復原。", + "turn.gameEnds": "遊戲將結束:支付最終獎金並出售所有股票。", "turn.finalStep": "此步驟之後將無法復原。", + "turn.finalLines": "灰色項目已確定;復原會逐步撤回其餘項目。", "announce.ask": "在本回合結束後結束遊戲?", "announce.confirm": "宣布結束", "announce.cancel": "繼續遊戲", diff --git a/packages/viewer/src/lib/store.svelte.ts b/packages/viewer/src/lib/store.svelte.ts index e8ede42..69920a7 100644 --- a/packages/viewer/src/lib/store.svelte.ts +++ b/packages/viewer/src/lib/store.svelte.ts @@ -6,7 +6,14 @@ import { movesFor } from "./decisions"; import { langFor } from "./format"; import { isRightToLeft, type Locale } from "./i18n"; import { replayStart, replayView } from "./replay"; -import { moveOutcome, TurnDraft, type MoveOutcome } from "./turn-draft"; +import { moveOutcome, reviewFor, TurnDraft, type MoveOutcome } from "./turn-draft"; + +/** A move held back for confirmation: the end of the turn, or a step that ends undo. */ +export interface PendingReview { + move: Move; + kind: "end" | "commit"; + outcome: MoveOutcome; +} /** Context key: the store is given to every component at mount, for viewer-wide settings. */ export const STORE = Symbol("viewer-store"); @@ -53,13 +60,23 @@ export class ViewerStore { private readonly draft = new TurnDraft(); undoCount = $state(0); + /** The first log entry that Undo can still take back (earlier entries are final). */ + undoFrom = $state(0); + /** The move awaiting confirmation in the turn summary, if any. */ + review = $state(); + reviewing = $derived(this.review !== undefined && this.moves.length > 0 && !this.sending); canUndo = $derived( this.undoCount > 0 && !this.sending && !this.readOnly && !this.analysis && this.replayAt === undefined ); constructor( private readonly sendMove: (move: Move | TurnRequest) => boolean, - private readonly options: { turnDrafts?: boolean; onState?: (state: GameState) => void } = {} + private readonly options: { + turnDrafts?: boolean; + /** Confirm the end of each turn with a summary (off in tutorials, whose steps name each button). */ + reviewTurns?: boolean; + onState?: (state: GameState) => void; + } = {} ) {} private display(state: GameState): void { @@ -69,7 +86,9 @@ export class ViewerStore { } this.selected = undefined; this.sending = false; + this.review = undefined; this.undoCount = this.draft.count; + this.undoFrom = this.draft.base?.log.length ?? state.log.length; this.options.onState?.(state); } @@ -104,6 +123,7 @@ export class ViewerStore { if (!this.canUndo) { return; } + this.review = undefined; const previous = this.draft.undo(); if (previous) { this.display(previous); @@ -129,11 +149,22 @@ export class ViewerStore { return this.state ? moveOutcome($state.snapshot(this.state), move, this.player) : undefined; } - send(move: Move): void { + /** Sends a move, first holding back the end of the turn for its summary unless `confirmed`. */ + send(move: Move, confirmed = false): void { if (this.sending || this.readOnly || this.replayAt !== undefined) { return; } const action = $state.snapshot(move); + if (!confirmed && this.options.reviewTurns && this.state) { + const view = $state.snapshot(this.state); + const outcome = moveOutcome(view, action, this.player); + const kind = reviewFor(view, action, outcome, this.drafting ? this.undoCount : 0); + if (kind) { + this.review = { move: action, kind, outcome }; + return; + } + } + this.review = undefined; const request = this.options.turnDrafts && this.state?.supportsTurnDrafts && !this.analysis ? this.draft.begin(action) : action; this.sending = true; diff --git a/packages/viewer/src/lib/turn-summary.spec.ts b/packages/viewer/src/lib/turn-summary.spec.ts new file mode 100644 index 0000000..c70a469 --- /dev/null +++ b/packages/viewer/src/lib/turn-summary.spec.ts @@ -0,0 +1,76 @@ +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { applyMove, type Move } from "acquire-engine"; +import * as engine from "acquire-engine/wrapper"; +import { preparedPosition } from "../tutorial/lessons.ts"; +import { langFor } from "./format.ts"; +import { holdingsAfter, moveEffect, turnSummary } from "./turn-summary.ts"; + +const lang = langFor("en"); +const text = (lines: ReturnType) => + lines.map((line) => line.parts.map((part) => part.text).join("")); + +test("the turn summary lists this turn's moves, then the pending move and the cash it leaves", () => { + const full = preparedPosition("founding"); + const start = full.log.length; + applyMove(full, { type: "place", tile: "2A" }, 0); + const afterPlace = full.log.length; + applyMove(full, { type: "found", chain: "tower" }, 0); + const view = engine.stripSecret(full, 0); + const buy: Move = { type: "buy", shares: { tower: 2 } }; + + const lines = turnSummary(view, buy, lang, afterPlace); + assert.deepEqual(text(lines), [ + "Alex placed 2A", + "Alex founded Tower (2 tiles) and received a free share", + "Alex bought 2 Tower for $400", + ]); + assert.deepEqual( + lines.map((line) => [line.final, line.pending]), + [ + [true, false], + [false, false], + [false, true], + ] + ); + assert.ok(turnSummary(view, buy, lang, start).every((line) => !line.final)); + + const effect = moveEffect(view, buy)!; + assert.deepEqual(effect, { cash: -400, shares: { tower: 2 } }); + assert.deepEqual(holdingsAfter(view, effect), { + cash: { before: 6000, after: 5600 }, + shares: [{ chain: "tower", before: 1, after: 3 }], + }); +}); + +test("disposal and swap effects use the defunct sale price, the 2:1 trade and current prices", () => { + const full = preparedPosition("mergers"); + applyMove(full, { type: "place", tile: "4A" }, 0); + const view = engine.stripSecret(full, 0); + assert.equal(view.phase, "dispose"); + const dispose: Move = { type: "dispose", sell: 1, trade: 2 }; + assert.deepEqual(moveEffect(view, dispose), { cash: 200, shares: { luxor: -3, tower: 1 } }); + const after = holdingsAfter(view, moveEffect(view, dispose)!); + assert.equal(after.cash.after - after.cash.before, 200); + assert.deepEqual( + after.shares.map(({ chain, before, after }) => [chain, before, after]), + [ + ["tower", 0, 1], + ["luxor", 3, 0], + ["festival", 1, 1], + ] + ); + assert.equal( + text(turnSummary(view, dispose, lang, 0)).at(-1), + "Alex sold 1 Luxor share for $200 and traded 2 Luxor shares for 1 of the survivor" + ); + + // Merger moves pay bonuses that may depend on hidden holdings: no forecast. + const before = preparedPosition("mergers"); + assert.equal(moveEffect(engine.stripSecret(before, 0), { type: "place", tile: "4A" }), undefined); + assert.deepEqual(moveEffect(engine.stripSecret(before, 0), { type: "place", tile: "12I" }), { cash: 0, shares: {} }); + assert.deepEqual(moveEffect(view, { type: "swap", from: "tower", to: "luxor", count: 1 })?.shares, { + tower: -1, + luxor: 1, + }); +}); diff --git a/packages/viewer/src/lib/turn-summary.ts b/packages/viewer/src/lib/turn-summary.ts index 7c0c02b..7df3170 100644 --- a/packages/viewer/src/lib/turn-summary.ts +++ b/packages/viewer/src/lib/turn-summary.ts @@ -1,8 +1,10 @@ -// The acting seat's cash and shares after a move, for previews before it is sent. Only the -// acting seat's own numbers are used; nothing is inferred about hidden holdings. +// The turn summary shown before a move that ends the turn: this turn's log lines, the move +// about to be sent, and the acting seat's cash and shares afterwards. Only the acting seat's own +// numbers are used; nothing is inferred about hidden holdings. import { CHAIN_IDS, chainSize, + connectedLoose, currentSeat, placementEffect, sharePrice, @@ -10,9 +12,13 @@ import { parseTile, type ChainId, type GameState, + type LogEntry, type Move, type Shares, } from "acquire-engine"; +import { describePlacement } from "./decisions.ts"; +import { describeEntryParts, type Lang, type LogPart } from "./format.ts"; +import { currentTurnEntries } from "./turn-draft.ts"; export interface Effect { cash: number; @@ -76,3 +82,88 @@ export function holdingsAfter(state: GameState, effect: Effect) { }); return { cash: { before: seat.cash, after: seat.cash + effect.cash }, shares }; } + +export interface SummaryLine { + key: string; + parts: LogPart[]; + /** Already saved: Undo cannot take it back. */ + final: boolean; + /** The move that confirming will send. */ + pending: boolean; +} + +/** How the pending move will be logged, built from the same log entries and translations. */ +function pendingEntry(state: GameState, move: Move, seat: number): LogEntry | undefined { + switch (move.type) { + case "buy": { + const cost = -(moveEffect(state, move)?.cash ?? 0); + return { type: "bought", seat, shares: move.shares, cost }; + } + case "swap": + return { + type: "swapped", + seat, + from: move.from, + to: move.to, + count: move.count, + cost: stockSwapCost(state, move.from, move.to, move.count), + }; + case "dispose": { + const merger = state.merger!; + const chain = merger.current!; + return { + type: "disposed", + seat, + chain, + sold: move.sell, + traded: move.trade, + held: state.seats[seat]!.shares[chain] - move.sell - move.trade, + proceeds: move.sell * sharePrice(chain, merger.sizes[chain]!), + }; + } + case "pass": + return { type: "skipPlace", seat }; + case "announce": + return { type: "announced", seat }; + case "found": + return { + type: "founded", + seat, + chain: move.chain, + size: connectedLoose(state.board, state.pendingTile!).length, + bonus: state.bank[move.chain] > 0, + }; + default: + return { type: "move", seat, move }; + } +} + +/** This turn's lines, oldest first, ending with the move about to be sent. */ +export function turnSummary(state: GameState, move: Move, lang: Lang, undoFrom: number): SummaryLine[] { + const seat = currentSeat(state)!; + const start = state.log.length - currentTurnEntries(state).length; + const lines: SummaryLine[] = []; + state.log.slice(start).forEach((entry, offset) => { + const index = start + offset; + const parts = describeEntryParts(state, entry, lang); + if (parts) { + lines.push({ key: String(index), parts, final: index < undoFrom, pending: false }); + } + }); + const parts = + move.type === "place" + ? [ + { + kind: "text" as const, + text: lang.t("place.effect", { + tile: move.tile, + effect: describePlacement(state, parseTile(move.tile)!, lang), + }), + }, + ] + : describeEntryParts(state, pendingEntry(state, move, seat)!, lang); + if (parts) { + lines.push({ key: "pending", parts, final: false, pending: true }); + } + return lines; +} diff --git a/packages/viewer/src/viewer.ts b/packages/viewer/src/viewer.ts index 43c9739..a4212a1 100644 --- a/packages/viewer/src/viewer.ts +++ b/packages/viewer/src/viewer.ts @@ -16,7 +16,11 @@ export const viewer = registerViewer( style.textContent = themeCss(); document.head.append(style); const sounds = createActionSounds(target); - const store = new ViewerStore(move, { turnDrafts: true, onState: (state) => sounds.onState(state) }); + const store = new ViewerStore(move, { + turnDrafts: true, + reviewTurns: true, + onState: (state) => sounds.onState(state), + }); store.theme = initialTheme(); const app = mount(App, { target, props: { store }, context: new Map([[STORE, store]]) }); return { diff --git a/scripts/check-browser.mjs b/scripts/check-browser.mjs index 3ee33f4..ece3e62 100644 --- a/scripts/check-browser.mjs +++ b/scripts/check-browser.mjs @@ -149,6 +149,10 @@ try { .screenshot({ path: fileURLToPath(new URL(`purchase-limit-${limit}-${theme}.png`, output)) }); } await page.locator(".panel .primary").click(); + // The final step waits for the turn summary. + assert.match(await page.locator(".turn-summary").innerText(), /bought/); + assert.equal(await page.evaluate(() => window.acquireDev.state.turn), 1); + await page.locator(".turn-summary").getByRole("button", { name: "End turn", exact: true }).click(); await page.waitForFunction(() => window.acquireDev.state.turn === 2); assert.deepEqual( await page.evaluate(() => ({ @@ -208,6 +212,8 @@ try { await page.locator(".board").getByRole("button", { name: "Place 3A", exact: true }).click(); await page.waitForSelector("table.buy"); await page.locator(".panel .primary").click(); + assert.match(await page.locator(".turn-summary").innerText(), /placed 2A[\s\S]*placed 3A/); + await page.locator(".turn-summary").getByRole("button", { name: "End turn", exact: true }).click(); await page.waitForFunction(() => window.acquireDev.state.turn === 2); assert.deepEqual( await page.evaluate(() => ({ @@ -360,6 +366,11 @@ try { await page.getByRole("button", { name: "Buy one more Tower", exact: true }).click(); } await page.getByRole("button", { name: "Buy for $900 and end turn", exact: true }).click(); + assert.match( + await page.locator(".turn-summary").innerText(), + /swapped[\s\S]*swapped[\s\S]*bought 3 Tower for \$900/ + ); + await page.locator(".turn-summary").getByRole("button", { name: "End turn", exact: true }).click(); await page.waitForFunction(() => window.acquireDev.state.turn === 2); assert.deepEqual( await page.evaluate(() => ({ @@ -564,6 +575,7 @@ try { await page.waitForSelector("table.buy"); // Disposal remains an undoable private draft until this player finishes buying. await page.getByRole("button", { name: "Buy nothing and end turn", exact: true }).click(); + await page.locator(".turn-summary").getByRole("button", { name: "End turn", exact: true }).click(); await page.waitForFunction(() => window.acquireDev.state.turn === 2); const result = await page.evaluate(() => window.acquireDev.state.seats[0]); assert.equal(result.shares.tower, expectedTrade / 2); @@ -1012,6 +1024,16 @@ try { await page.waitForSelector("table.buy"); await page.screenshot({ path: fileURLToPath(new URL(`undo-${width}.png`, output)), fullPage: true }); await page.locator(".panel .primary").click(); + await page.locator(".turn-summary").getByRole("button", { name: "Back", exact: true }).click(); + await page.waitForSelector("table.buy"); + await page.locator(".panel .primary").click(); + await page.screenshot({ path: fileURLToPath(new URL(`turn-summary-${width}.png`, output)), fullPage: true }); + await page.locator(".turn-summary").getByRole("button", { name: "Undo", exact: true }).click(); + await page.waitForSelector(".choices"); + await page.locator(".choices button").filter({ hasText: "Luxor" }).click(); + await page.waitForSelector("table.buy"); + await page.locator(".panel .primary").click(); + await page.locator(".turn-summary").getByRole("button", { name: "End turn", exact: true }).click(); await page.waitForFunction(() => window.acquireDev.state.turn === 2); await settle(); assert.equal(await undo.count(), 0, "no undo after drawing and handing over"); From 84f84302b6be413e9d21217210b2122f5f2ca6c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 07:28:05 -0700 Subject: [PATCH 09/12] Clarify stock buying and swaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Buy panel: each chain row shows how many shares you own and what you will own after this purchase, and a disabled "+" now says why (none left in the bank, not enough cash, or the per-turn limit reached). Stock swap panel: the selects say "you have N" and "bank has N" instead of bare numbers, the quantity is a -/+ stepper with its maximum, the preview spells out both legs with their values and the net payment, a live line shows cash and both holdings after the swap, the confirm button states the exact exchange ("Swap 2 Tower for 2 Continental · Pay $800"), and an unavailable pair explains why (no swaps left, bank empty, not enough cash). Co-Authored-By: Claude Opus 5.5 --- packages/viewer/src/lib/ActionPanel.svelte | 41 +++++- packages/viewer/src/lib/StockSwap.svelte | 155 +++++++++++++++++---- packages/viewer/src/lib/locales/da.ts | 16 +++ packages/viewer/src/lib/locales/de.ts | 16 +++ packages/viewer/src/lib/locales/el.ts | 16 +++ packages/viewer/src/lib/locales/en.ts | 16 +++ packages/viewer/src/lib/locales/fa.ts | 16 +++ packages/viewer/src/lib/locales/fr.ts | 16 +++ packages/viewer/src/lib/locales/hi.ts | 16 +++ packages/viewer/src/lib/locales/it.ts | 16 +++ packages/viewer/src/lib/locales/ko.ts | 16 +++ packages/viewer/src/lib/locales/nl.ts | 16 +++ packages/viewer/src/lib/locales/pl.ts | 16 +++ packages/viewer/src/lib/locales/pt-BR.ts | 16 +++ packages/viewer/src/lib/locales/ro.ts | 16 +++ packages/viewer/src/lib/locales/ru.ts | 16 +++ packages/viewer/src/lib/locales/vi.ts | 16 +++ packages/viewer/src/lib/locales/zh-CN.ts | 16 +++ packages/viewer/src/lib/locales/zh-TW.ts | 16 +++ scripts/check-browser.mjs | 16 ++- 20 files changed, 448 insertions(+), 36 deletions(-) diff --git a/packages/viewer/src/lib/ActionPanel.svelte b/packages/viewer/src/lib/ActionPanel.svelte index 15e1f1b..f950235 100644 --- a/packages/viewer/src/lib/ActionPanel.svelte +++ b/packages/viewer/src/lib/ActionPanel.svelte @@ -123,6 +123,14 @@ const price = (chain: ChainId) => sharePrice(chain, chainSize(game.board, chain)); const cost = $derived(Object.entries(shares).reduce((sum, [chain, n]) => sum + n * price(chain as ChainId), 0)); const total = $derived(Object.values(shares).reduce((sum, n) => sum + n, 0)); + const cash = $derived(seat === undefined ? 0 : game.seats[seat]!.cash); + /** Why one more share of `chain` cannot be added, beyond the shared purchase limit. */ + function buyBlocked(chain: ChainId): string | undefined { + if (total >= buyLimit || canBuy(moves, adjustShares(shares, chain, 1))) { + return undefined; + } + return game.bank[chain] - (shares[chain] ?? 0) <= 0 ? t("buy.soldOut") : t("buy.cantAfford"); + } function placeSelected(): void { if (store.selected !== undefined) { @@ -425,8 +433,23 @@ {#each buyable as chain (chain)} {@const fewer = adjustShares(shares, chain, -1)} {@const more = adjustShares(shares, chain, 1)} + {@const own = game.seats[seat!]!.shares[chain]} + {@const why = buyBlocked(chain)} - + + + {#if own > 0 || shares[chain]} + {t("buy.owned")} + {#if shares[chain]}{own}→{/if}{own + (shares[chain] ?? 0)} + {/if} + {#if why}{why}{/if} + {money(price(chain))} {game.bank[chain]} @@ -456,8 +479,9 @@ count: total, limit: buyLimit, cost: money(cost), - cash: money(game.seats[seat!]!.cash - cost), + cash: money(cash - cost), })} + {#if total >= buyLimit}{t("buy.limitReached", { limit: buyLimit })}{/if}

    - -
    - - {selected ? cash : t("swap.unavailable")} + {t("swap.count")} +
    + + {max === 0 ? 0 : count} +
    + {#if max > 0}{t("swap.max", { count: max })}{/if}
    + {#if selected} +

    + + {t("swap.giveDetail", { + count: selected.count, + chain: chainName(from), + value: money(selected.count * priceOf(from)), + })} + + {t("swap.takeDetail", { + count: selected.count, + chain: chainName(to), + value: money(selected.count * priceOf(to)), + })} + {cash} +

    + {#if after} + + {/if} + {:else} +

    {blocked}

    + {/if} selected && store.send(selected)} + >{selected + ? t("swap.confirmExact", { count: selected.count, from: chainName(from), to: chainName(to), cash }) + : t("swap.confirm")} {:else} -

    {t("swap.unavailable")}

    +

    {remaining <= 0 ? t("swap.noneLeft") : t("swap.unavailable")}

    {/if} @@ -103,13 +178,18 @@ summary { cursor: pointer; font-weight: 600; + min-height: 32px; } small, - .note { + .note, + .why { color: var(--ink-muted); font-size: 13px; font-weight: 400; } + .why { + font-style: italic; + } p { margin: 8px 0; } @@ -124,8 +204,7 @@ font-size: 13px; min-width: 0; } - select, - input { + select { box-sizing: border-box; width: 100%; min-height: 44px; @@ -136,26 +215,44 @@ padding: 6px; } .swap-controls { - display: flex; - align-items: end; - gap: 12px; - margin: 10px 0; - } - .swap-controls label { - flex: 0 0 72px; - } - .exchange { display: flex; flex-wrap: wrap; align-items: center; - gap: 6px; - min-width: 0; + gap: 4px 12px; + margin: 10px 0 4px; } - .exchange strong { - flex-basis: 100%; + .count-label { + font-size: 13px; + } + .stepper { + display: inline-flex; + align-items: center; + gap: 4px; + } + .stepper button { + width: 44px; + padding: 0; + font-size: 18px; + } + .value { + display: inline-block; + min-width: 24px; + text-align: center; + font-weight: 600; + font-variant-numeric: tabular-nums; + } + .exchange { + display: grid; + gap: 4px; + min-width: 0; font-size: 14px; font-variant-numeric: tabular-nums; } + .leg { + display: flex; + align-items: center; + gap: 6px; + } button { min-height: 44px; padding: 6px 12px; @@ -166,6 +263,10 @@ } button:disabled { color: var(--ink-muted); + background: transparent; + } + .confirm { + text-align: start; } @media (max-width: 400px) { .chains { diff --git a/packages/viewer/src/lib/locales/da.ts b/packages/viewer/src/lib/locales/da.ts index 25c612c..4dfe526 100644 --- a/packages/viewer/src/lib/locales/da.ts +++ b/packages/viewer/src/lib/locales/da.ts @@ -13,6 +13,18 @@ export const da: Catalog = { "swap.receive": "Modtag {amount}", "swap.even": "Ingen prisforskel", "swap.unavailable": "Intet bytte muligt med dette antal, grænsen, aktierne og kontanterne.", + "swap.optionGive": "{chain} · du har {count} · {price}", + "swap.optionTake": "{chain} · banken har {count} · {price}", + "swap.fewer": "Byt én færre", + "swap.more": "Byt én mere", + "swap.max": "op til {count}", + "swap.giveDetail": "afgiv {count} {chain} ({value})", + "swap.takeDetail": "få {count} {chain} ({value})", + "swap.after": "Efter dette bytte", + "swap.confirmExact": "Byt {count} {from} for {count} {to} · {cash}", + "swap.noneLeft": "Ingen bytter tilbage denne tur.", + "swap.bankEmpty": "Banken har ingen {chain}-aktier.", + "swap.cash": "Ikke penge nok til prisforskellen.", "log.swapped": "{name} bytter {count} {from} for {count} {to} · {cash}", loading: "Indlæser spillet…", @@ -99,6 +111,10 @@ export const da: Catalog = { "buy.total": "{count} af {limit} aktier · pris {cost} · tilbage {cash}", "buy.nothing": "Køb intet og afslut turen", "buy.confirm": "Køb for {cost} og afslut turen", + "buy.owned": "Du ejer", + "buy.soldOut": "Ingen tilbage i banken", + "buy.cantAfford": "Ikke penge nok til én mere", + "buy.limitReached": "Grænsen er nået: {limit} aktier pr. tur.", "board.label": "Spilleplade", "board.empty": "{tile} tom", "board.loose": "{tile} enlig brik", diff --git a/packages/viewer/src/lib/locales/de.ts b/packages/viewer/src/lib/locales/de.ts index b5ee6b2..87f1138 100644 --- a/packages/viewer/src/lib/locales/de.ts +++ b/packages/viewer/src/lib/locales/de.ts @@ -13,6 +13,18 @@ export const de: Catalog = { "swap.receive": "{amount} erhalten", "swap.even": "Keine Preisdifferenz", "swap.unavailable": "Mit dieser Menge, dem Limit, Aktienbestand und Bargeld ist kein Tausch möglich.", + "swap.optionGive": "{chain} · du hast {count} · {price}", + "swap.optionTake": "{chain} · Bank hat {count} · {price}", + "swap.fewer": "Eine weniger tauschen", + "swap.more": "Eine mehr tauschen", + "swap.max": "bis zu {count}", + "swap.giveDetail": "{count} {chain} abgeben ({value})", + "swap.takeDetail": "{count} {chain} erhalten ({value})", + "swap.after": "Nach diesem Tausch", + "swap.confirmExact": "{count} {from} gegen {count} {to} tauschen · {cash}", + "swap.noneLeft": "In diesem Zug sind keine Tausche mehr übrig.", + "swap.bankEmpty": "Die Bank hat keine {chain}-Aktien.", + "swap.cash": "Nicht genug Geld für die Preisdifferenz.", "log.swapped": "{name} tauscht {count} {from} gegen {count} {to} · {cash}", loading: "Spiel wird geladen…", @@ -99,6 +111,10 @@ export const de: Catalog = { "buy.total": "{count} von {limit} Aktien · Kosten {cost} · Restgeld {cash}", "buy.nothing": "Nichts kaufen und Zug beenden", "buy.confirm": "Für {cost} kaufen und Zug beenden", + "buy.owned": "Im Besitz", + "buy.soldOut": "Die Bank hat keine mehr", + "buy.cantAfford": "Nicht genug Geld für eine weitere", + "buy.limitReached": "Limit erreicht: {limit} Aktien pro Zug.", "board.label": "Spielplan", "board.empty": "{tile} leer", "board.loose": "{tile} einzelnes Plättchen", diff --git a/packages/viewer/src/lib/locales/el.ts b/packages/viewer/src/lib/locales/el.ts index 069c509..77c26e4 100644 --- a/packages/viewer/src/lib/locales/el.ts +++ b/packages/viewer/src/lib/locales/el.ts @@ -13,6 +13,18 @@ export const el: Catalog = { "swap.receive": "Είσπραξη {amount}", "swap.even": "Χωρίς διαφορά τιμής", "swap.unavailable": "Δεν γίνεται ανταλλαγή με αυτή την ποσότητα, το όριο, τις μετοχές και τα μετρητά.", + "swap.optionGive": "{chain} · έχεις {count} · {price}", + "swap.optionTake": "{chain} · τράπεζα {count} · {price}", + "swap.fewer": "Ανταλλαγή μίας λιγότερης", + "swap.more": "Ανταλλαγή μίας ακόμη", + "swap.max": "έως {count}", + "swap.giveDetail": "δίνεις {count} {chain} ({value})", + "swap.takeDetail": "παίρνεις {count} {chain} ({value})", + "swap.after": "Μετά από αυτή την ανταλλαγή", + "swap.confirmExact": "Ανταλλαγή {count} {from} με {count} {to} · {cash}", + "swap.noneLeft": "Δεν απομένουν ανταλλαγές σε αυτόν τον γύρο.", + "swap.bankEmpty": "Η τράπεζα δεν έχει μετοχές {chain}.", + "swap.cash": "Δεν φτάνουν τα μετρητά για τη διαφορά τιμής.", "log.swapped": "{name}: ανταλλαγή {count} {from} με {count} {to} · {cash}", loading: "Φόρτωση παιχνιδιού…", @@ -99,6 +111,10 @@ export const el: Catalog = { "buy.total": "{count} από {limit} μετοχές · κόστος {cost} · υπόλοιπο {cash}", "buy.nothing": "Καμία αγορά και τέλος γύρου", "buy.confirm": "Αγορά για {cost} και τέλος γύρου", + "buy.owned": "Έχεις", + "buy.soldOut": "Δεν έμειναν στην τράπεζα", + "buy.cantAfford": "Δεν φτάνουν τα μετρητά για άλλη", + "buy.limitReached": "Έφτασες το όριο: {limit} μετοχές ανά γύρο.", "board.label": "Ταμπλό", "board.empty": "{tile} κενό", "board.loose": "{tile} μεμονωμένο πλακίδιο", diff --git a/packages/viewer/src/lib/locales/en.ts b/packages/viewer/src/lib/locales/en.ts index b1878b8..c5ce813 100644 --- a/packages/viewer/src/lib/locales/en.ts +++ b/packages/viewer/src/lib/locales/en.ts @@ -14,6 +14,18 @@ export const en = { "swap.receive": "Receive {amount}", "swap.even": "No cash difference", "swap.unavailable": "No swap available with this quantity, allowance, stock and cash.", + "swap.optionGive": "{chain} · you have {count} · {price}", + "swap.optionTake": "{chain} · bank has {count} · {price}", + "swap.fewer": "Swap one fewer", + "swap.more": "Swap one more", + "swap.max": "up to {count}", + "swap.giveDetail": "give {count} {chain} ({value})", + "swap.takeDetail": "get {count} {chain} ({value})", + "swap.after": "After this swap", + "swap.confirmExact": "Swap {count} {from} for {count} {to} · {cash}", + "swap.noneLeft": "No swaps left this turn.", + "swap.bankEmpty": "The bank has no {chain} shares.", + "swap.cash": "Not enough cash to pay the price difference.", "log.swapped": "{name} swapped {count} {from} for {count} {to} · {cash}", loading: "Loading game…", @@ -104,6 +116,10 @@ export const en = { "buy.total": "{count} of {limit} shares · cost {cost} · cash left {cash}", "buy.nothing": "Buy nothing and end turn", "buy.confirm": "Buy for {cost} and end turn", + "buy.owned": "You own", + "buy.soldOut": "None left in the bank", + "buy.cantAfford": "Not enough cash for another", + "buy.limitReached": "Limit reached: {limit} shares per turn.", // Board and hand "board.label": "Board", diff --git a/packages/viewer/src/lib/locales/fa.ts b/packages/viewer/src/lib/locales/fa.ts index 4a3373a..a9a4f9b 100644 --- a/packages/viewer/src/lib/locales/fa.ts +++ b/packages/viewer/src/lib/locales/fa.ts @@ -13,6 +13,18 @@ export const fa: Catalog = { "swap.receive": "دریافت {amount}", "swap.even": "بدون اختلاف قیمت", "swap.unavailable": "با این تعداد، سقف تعویض، سهام و وجه نقد، تعویض ممکن نیست.", + "swap.optionGive": "{chain} · دارید {count} · {price}", + "swap.optionTake": "{chain} · بانک {count} · {price}", + "swap.fewer": "یکی کمتر تعویض کن", + "swap.more": "یکی بیشتر تعویض کن", + "swap.max": "تا {count}", + "swap.giveDetail": "واگذاری {count} {chain} ({value})", + "swap.takeDetail": "دریافت {count} {chain} ({value})", + "swap.after": "پس از این تعویض", + "swap.confirmExact": "تعویض {count} {from} با {count} {to} · {cash}", + "swap.noneLeft": "در این نوبت تعویضی باقی نمانده است.", + "swap.bankEmpty": "بانک سهم {chain} ندارد.", + "swap.cash": "پول برای پرداخت اختلاف قیمت کافی نیست.", "log.swapped": "{name} تعداد {count} سهم {from} را با {count} سهم {to} تعویض کرد · {cash}", loading: "در حال بارگذاری بازی…", @@ -99,6 +111,10 @@ export const fa: Catalog = { "buy.total": "{count} از {limit} سهم · هزینه {cost} · باقی‌مانده {cash}", "buy.nothing": "چیزی نخر و نوبت را تمام کن", "buy.confirm": "خرید به {cost} و پایان نوبت", + "buy.owned": "دارایی شما", + "buy.soldOut": "در بانک نمانده", + "buy.cantAfford": "پول برای یکی دیگر کافی نیست", + "buy.limitReached": "به سقف رسیدید: {limit} سهم در هر نوبت.", "board.label": "صفحه‌ی بازی", "board.empty": "{tile} خالی", "board.loose": "{tile} کاشی تنها", diff --git a/packages/viewer/src/lib/locales/fr.ts b/packages/viewer/src/lib/locales/fr.ts index 5205204..c0819bd 100644 --- a/packages/viewer/src/lib/locales/fr.ts +++ b/packages/viewer/src/lib/locales/fr.ts @@ -14,6 +14,18 @@ export const fr: Catalog = { "swap.receive": "Recevoir {amount}", "swap.even": "Sans différence de prix", "swap.unavailable": "Échange impossible avec cette quantité, la limite, les actions et les fonds disponibles.", + "swap.optionGive": "{chain} · vous en avez {count} · {price}", + "swap.optionTake": "{chain} · banque : {count} · {price}", + "swap.fewer": "Échanger une de moins", + "swap.more": "Échanger une de plus", + "swap.max": "jusqu’à {count}", + "swap.giveDetail": "donner {count} {chain} ({value})", + "swap.takeDetail": "recevoir {count} {chain} ({value})", + "swap.after": "Après cet échange", + "swap.confirmExact": "Échanger {count} {from} contre {count} {to} · {cash}", + "swap.noneLeft": "Plus aucun échange possible ce tour.", + "swap.bankEmpty": "La banque n’a pas d’actions {chain}.", + "swap.cash": "Pas assez d’argent pour payer la différence de prix.", "log.swapped": "{name} échange {count} {from} contre {count} {to} · {cash}", loading: "Chargement de la partie…", @@ -104,6 +116,10 @@ export const fr: Catalog = { "buy.total": "{count} actions sur {limit} · coût {cost} · argent restant {cash}", "buy.nothing": "Ne rien acheter et finir le tour", "buy.confirm": "Acheter pour {cost} et finir le tour", + "buy.owned": "Vous avez", + "buy.soldOut": "Plus aucune en banque", + "buy.cantAfford": "Pas assez d’argent pour une de plus", + "buy.limitReached": "Limite atteinte : {limit} actions par tour.", "board.label": "Plateau", "board.empty": "{tile} vide", "board.loose": "{tile} tuile isolée", diff --git a/packages/viewer/src/lib/locales/hi.ts b/packages/viewer/src/lib/locales/hi.ts index 699155d..f244e8a 100644 --- a/packages/viewer/src/lib/locales/hi.ts +++ b/packages/viewer/src/lib/locales/hi.ts @@ -13,6 +13,18 @@ export const hi: Catalog = { "swap.receive": "{amount} लें", "swap.even": "कीमत में कोई अंतर नहीं", "swap.unavailable": "इस मात्रा, सीमा, शेयरों और नकद के साथ अदला-बदली उपलब्ध नहीं है।", + "swap.optionGive": "{chain} · आपके पास {count} · {price}", + "swap.optionTake": "{chain} · बैंक में {count} · {price}", + "swap.fewer": "एक कम बदलें", + "swap.more": "एक और बदलें", + "swap.max": "{count} तक", + "swap.giveDetail": "{count} {chain} दें ({value})", + "swap.takeDetail": "{count} {chain} लें ({value})", + "swap.after": "इस अदला-बदली के बाद", + "swap.confirmExact": "{count} {from} के बदले {count} {to} लें · {cash}", + "swap.noneLeft": "इस बारी में कोई अदला-बदली बाकी नहीं।", + "swap.bankEmpty": "बैंक में {chain} के शेयर नहीं हैं।", + "swap.cash": "कीमत का अंतर चुकाने के लिए नकद पर्याप्त नहीं।", "log.swapped": "{name} ने {count} {from} के बदले {count} {to} लिए · {cash}", loading: "खेल लोड हो रहा है…", @@ -98,6 +110,10 @@ export const hi: Catalog = { "buy.total": "{limit} में से {count} शेयर · लागत {cost} · बची नकदी {cash}", "buy.nothing": "कुछ न खरीदें और बारी समाप्त करें", "buy.confirm": "{cost} में खरीदें और बारी समाप्त करें", + "buy.owned": "आपके पास", + "buy.soldOut": "बैंक में नहीं बचे", + "buy.cantAfford": "एक और के लिए नकद पर्याप्त नहीं", + "buy.limitReached": "सीमा पूरी: हर बारी में {limit} शेयर।", "board.label": "बोर्ड", "board.empty": "{tile} खाली", "board.loose": "{tile} अकेली टाइल", diff --git a/packages/viewer/src/lib/locales/it.ts b/packages/viewer/src/lib/locales/it.ts index d485f7c..7ce9a2f 100644 --- a/packages/viewer/src/lib/locales/it.ts +++ b/packages/viewer/src/lib/locales/it.ts @@ -13,6 +13,18 @@ export const it: Catalog = { "swap.receive": "Ricevi {amount}", "swap.even": "Nessuna differenza di prezzo", "swap.unavailable": "Scambio impossibile con questa quantità, il limite, le azioni e il denaro disponibili.", + "swap.optionGive": "{chain} · ne hai {count} · {price}", + "swap.optionTake": "{chain} · banca {count} · {price}", + "swap.fewer": "Scambia un’azione in meno", + "swap.more": "Scambia un’azione in più", + "swap.max": "fino a {count}", + "swap.giveDetail": "cedi {count} {chain} ({value})", + "swap.takeDetail": "ricevi {count} {chain} ({value})", + "swap.after": "Dopo questo scambio", + "swap.confirmExact": "Scambia {count} {from} con {count} {to} · {cash}", + "swap.noneLeft": "Nessuno scambio rimasto in questo turno.", + "swap.bankEmpty": "La banca non ha azioni {chain}.", + "swap.cash": "Denaro insufficiente per la differenza di prezzo.", "log.swapped": "{name} scambia {count} {from} con {count} {to} · {cash}", loading: "Caricamento della partita…", @@ -103,6 +115,10 @@ export const it: Catalog = { "buy.total": "{count} di {limit} azioni · costo {cost} · restano {cash}", "buy.nothing": "Non comprare nulla e termina il turno", "buy.confirm": "Compra per {cost} e termina il turno", + "buy.owned": "Possiedi", + "buy.soldOut": "Nessuna in banca", + "buy.cantAfford": "Denaro insufficiente per un’altra", + "buy.limitReached": "Limite raggiunto: {limit} azioni per turno.", "board.label": "Tabellone", "board.empty": "{tile} vuota", "board.loose": "{tile} tessera isolata", diff --git a/packages/viewer/src/lib/locales/ko.ts b/packages/viewer/src/lib/locales/ko.ts index a35a8c7..d9f07ce 100644 --- a/packages/viewer/src/lib/locales/ko.ts +++ b/packages/viewer/src/lib/locales/ko.ts @@ -13,6 +13,18 @@ export const ko: Catalog = { "swap.receive": "{amount} 수령", "swap.even": "차액 없음", "swap.unavailable": "이 수량, 교환 한도, 주식 및 현금으로는 교환할 수 없습니다.", + "swap.optionGive": "{chain} · 보유 {count} · {price}", + "swap.optionTake": "{chain} · 은행 {count} · {price}", + "swap.fewer": "한 주 덜 교환", + "swap.more": "한 주 더 교환", + "swap.max": "최대 {count}", + "swap.giveDetail": "{chain} {count}주 제공 ({value})", + "swap.takeDetail": "{chain} {count}주 수령 ({value})", + "swap.after": "이 교환 후", + "swap.confirmExact": "{from} {count}주를 {to} {count}주로 교환 · {cash}", + "swap.noneLeft": "이번 턴에 남은 교환이 없습니다.", + "swap.bankEmpty": "은행에 {chain} 주식이 없습니다.", + "swap.cash": "가격 차이를 낼 현금이 부족합니다.", "log.swapped": "{name}: {from} {count}주를 {to} {count}주로 교환 · {cash}", loading: "게임을 불러오는 중…", @@ -99,6 +111,10 @@ export const ko: Catalog = { "buy.total": "{limit}주 중 {count}주 · 비용 {cost} · 남는 돈 {cash}", "buy.nothing": "사지 않고 턴 끝내기", "buy.confirm": "{cost}에 사고 턴 끝내기", + "buy.owned": "보유", + "buy.soldOut": "은행에 남은 주식 없음", + "buy.cantAfford": "한 주 더 살 현금 부족", + "buy.limitReached": "한도 도달: 턴당 {limit}주.", "board.label": "게임판", "board.empty": "{tile} 빈칸", "board.loose": "{tile} 따로 놓인 타일", diff --git a/packages/viewer/src/lib/locales/nl.ts b/packages/viewer/src/lib/locales/nl.ts index 42187f2..069cb05 100644 --- a/packages/viewer/src/lib/locales/nl.ts +++ b/packages/viewer/src/lib/locales/nl.ts @@ -13,6 +13,18 @@ export const nl: Catalog = { "swap.receive": "Ontvang {amount}", "swap.even": "Geen prijsverschil", "swap.unavailable": "Geen ruil mogelijk met dit aantal, de limiet, aandelen en contanten.", + "swap.optionGive": "{chain} · je hebt {count} · {price}", + "swap.optionTake": "{chain} · bank heeft {count} · {price}", + "swap.fewer": "Eén minder ruilen", + "swap.more": "Eén meer ruilen", + "swap.max": "tot {count}", + "swap.giveDetail": "geef {count} {chain} ({value})", + "swap.takeDetail": "krijg {count} {chain} ({value})", + "swap.after": "Na deze ruil", + "swap.confirmExact": "Ruil {count} {from} voor {count} {to} · {cash}", + "swap.noneLeft": "Geen ruilen meer over deze beurt.", + "swap.bankEmpty": "De bank heeft geen {chain}-aandelen.", + "swap.cash": "Niet genoeg geld voor het prijsverschil.", "log.swapped": "{name} ruilt {count} {from} voor {count} {to} · {cash}", loading: "Spel laden…", @@ -99,6 +111,10 @@ export const nl: Catalog = { "buy.total": "{count} van {limit} aandelen · kosten {cost} · over {cash}", "buy.nothing": "Niets kopen en beurt beëindigen", "buy.confirm": "Kopen voor {cost} en beurt beëindigen", + "buy.owned": "Je hebt", + "buy.soldOut": "Geen meer in de bank", + "buy.cantAfford": "Niet genoeg geld voor nog één", + "buy.limitReached": "Limiet bereikt: {limit} aandelen per beurt.", "board.label": "Spelbord", "board.empty": "{tile} leeg", "board.loose": "{tile} losse tegel", diff --git a/packages/viewer/src/lib/locales/pl.ts b/packages/viewer/src/lib/locales/pl.ts index d95befd..a1680e3 100644 --- a/packages/viewer/src/lib/locales/pl.ts +++ b/packages/viewer/src/lib/locales/pl.ts @@ -13,6 +13,18 @@ export const pl: Catalog = { "swap.receive": "Otrzymaj {amount}", "swap.even": "Bez dopłaty", "swap.unavailable": "Wymiana niemożliwa przy tej liczbie, limicie, akcjach i gotówce.", + "swap.optionGive": "{chain} · masz {count} · {price}", + "swap.optionTake": "{chain} · w banku {count} · {price}", + "swap.fewer": "Wymień jedną mniej", + "swap.more": "Wymień jedną więcej", + "swap.max": "maks. {count}", + "swap.giveDetail": "oddaj {count} {chain} ({value})", + "swap.takeDetail": "otrzymaj {count} {chain} ({value})", + "swap.after": "Po tej wymianie", + "swap.confirmExact": "Wymień {count} {from} na {count} {to} · {cash}", + "swap.noneLeft": "W tej turze nie zostały już wymiany.", + "swap.bankEmpty": "Bank nie ma akcji {chain}.", + "swap.cash": "Za mało gotówki na pokrycie różnicy cen.", "log.swapped": "{name} wymienia {count} {from} na {count} {to} · {cash}", loading: "Wczytywanie gry…", @@ -104,6 +116,10 @@ export const pl: Catalog = { "buy.total": "{count} z {limit} akcji · koszt {cost} · zostaje {cash}", "buy.nothing": "Nic nie kupuj i zakończ turę", "buy.confirm": "Kup za {cost} i zakończ turę", + "buy.owned": "Masz", + "buy.soldOut": "Brak w banku", + "buy.cantAfford": "Za mało gotówki na kolejną", + "buy.limitReached": "Osiągnięto limit: {limit} akcji na turę.", "board.label": "Plansza", "board.empty": "{tile} puste", "board.loose": "{tile} pojedyncza płytka", diff --git a/packages/viewer/src/lib/locales/pt-BR.ts b/packages/viewer/src/lib/locales/pt-BR.ts index b2c1704..919ded5 100644 --- a/packages/viewer/src/lib/locales/pt-BR.ts +++ b/packages/viewer/src/lib/locales/pt-BR.ts @@ -13,6 +13,18 @@ export const ptBR: Catalog = { "swap.receive": "Receber {amount}", "swap.even": "Sem diferença de preço", "swap.unavailable": "Troca indisponível com esta quantidade, limite, ações e dinheiro.", + "swap.optionGive": "{chain} · você tem {count} · {price}", + "swap.optionTake": "{chain} · banco tem {count} · {price}", + "swap.fewer": "Trocar uma a menos", + "swap.more": "Trocar uma a mais", + "swap.max": "até {count}", + "swap.giveDetail": "dar {count} {chain} ({value})", + "swap.takeDetail": "receber {count} {chain} ({value})", + "swap.after": "Depois desta troca", + "swap.confirmExact": "Trocar {count} {from} por {count} {to} · {cash}", + "swap.noneLeft": "Não restam trocas neste turno.", + "swap.bankEmpty": "O banco não tem ações de {chain}.", + "swap.cash": "Dinheiro insuficiente para pagar a diferença de preço.", "log.swapped": "{name} trocou {count} {from} por {count} {to} · {cash}", loading: "Carregando o jogo…", @@ -103,6 +115,10 @@ export const ptBR: Catalog = { "buy.total": "{count} de {limit} ações · custo {cost} · sobra {cash}", "buy.nothing": "Não comprar nada e encerrar o turno", "buy.confirm": "Comprar por {cost} e encerrar o turno", + "buy.owned": "Você tem", + "buy.soldOut": "Nenhuma no banco", + "buy.cantAfford": "Dinheiro insuficiente para mais uma", + "buy.limitReached": "Limite atingido: {limit} ações por turno.", "board.label": "Tabuleiro", "board.empty": "{tile} vazia", "board.loose": "{tile} peça isolada", diff --git a/packages/viewer/src/lib/locales/ro.ts b/packages/viewer/src/lib/locales/ro.ts index 4c70dbc..8f5ed5c 100644 --- a/packages/viewer/src/lib/locales/ro.ts +++ b/packages/viewer/src/lib/locales/ro.ts @@ -14,6 +14,18 @@ export const ro: Catalog = { "swap.receive": "Primești {amount}", "swap.even": "Fără diferență de preț", "swap.unavailable": "Schimb imposibil cu această cantitate, limită, stoc și numerar.", + "swap.optionGive": "{chain} · ai {count} · {price}", + "swap.optionTake": "{chain} · banca are {count} · {price}", + "swap.fewer": "Schimbă una mai puțin", + "swap.more": "Schimbă una în plus", + "swap.max": "până la {count}", + "swap.giveDetail": "dai {count} {chain} ({value})", + "swap.takeDetail": "primești {count} {chain} ({value})", + "swap.after": "După acest schimb", + "swap.confirmExact": "Schimbă {count} {from} pe {count} {to} · {cash}", + "swap.noneLeft": "Nu mai ai schimburi în această tură.", + "swap.bankEmpty": "Banca nu are acțiuni {chain}.", + "swap.cash": "Bani insuficienți pentru diferența de preț.", "log.swapped": "{name} schimbă {count} {from} pentru {count} {to} · {cash}", loading: "Se încarcă jocul…", @@ -104,6 +116,10 @@ export const ro: Catalog = { "buy.total": "{count} din {limit} acțiuni · cost {cost} · bani rămași {cash}", "buy.nothing": "Nu cumpăra nimic și încheie tura", "buy.confirm": "Cumpără cu {cost} și încheie tura", + "buy.owned": "Deții", + "buy.soldOut": "Banca nu mai are", + "buy.cantAfford": "Bani insuficienți pentru încă una", + "buy.limitReached": "Limită atinsă: {limit} acțiuni pe tură.", "board.label": "Tablă", "board.empty": "{tile} liber", "board.loose": "{tile} piesă izolată", diff --git a/packages/viewer/src/lib/locales/ru.ts b/packages/viewer/src/lib/locales/ru.ts index 45c91fa..64148eb 100644 --- a/packages/viewer/src/lib/locales/ru.ts +++ b/packages/viewer/src/lib/locales/ru.ts @@ -13,6 +13,18 @@ export const ru: Catalog = { "swap.receive": "Получить {amount}", "swap.even": "Без доплаты", "swap.unavailable": "Обмен невозможен с этим количеством, лимитом, запасом акций и наличными.", + "swap.optionGive": "{chain} · у вас {count} · {price}", + "swap.optionTake": "{chain} · в банке {count} · {price}", + "swap.fewer": "Обменять на одну меньше", + "swap.more": "Обменять на одну больше", + "swap.max": "до {count}", + "swap.giveDetail": "отдать {count} {chain} ({value})", + "swap.takeDetail": "получить {count} {chain} ({value})", + "swap.after": "После этого обмена", + "swap.confirmExact": "Обменять {count} {from} на {count} {to} · {cash}", + "swap.noneLeft": "Обменов в этом ходу больше нет.", + "swap.bankEmpty": "В банке нет акций {chain}.", + "swap.cash": "Не хватает денег на разницу в цене.", "log.swapped": "{name} обменивает {count} {from} на {count} {to} · {cash}", loading: "Загрузка игры…", @@ -104,6 +116,10 @@ export const ru: Catalog = { "buy.total": "{count} из {limit} акций · стоимость {cost} · останется {cash}", "buy.nothing": "Ничего не покупать и закончить ход", "buy.confirm": "Купить за {cost} и закончить ход", + "buy.owned": "У вас", + "buy.soldOut": "В банке не осталось", + "buy.cantAfford": "Не хватает денег на ещё одну", + "buy.limitReached": "Лимит достигнут: {limit} акций за ход.", "board.label": "Поле", "board.empty": "{tile} пусто", "board.loose": "{tile} одиночная фишка", diff --git a/packages/viewer/src/lib/locales/vi.ts b/packages/viewer/src/lib/locales/vi.ts index 2b334e8..d360d77 100644 --- a/packages/viewer/src/lib/locales/vi.ts +++ b/packages/viewer/src/lib/locales/vi.ts @@ -13,6 +13,18 @@ export const vi: Catalog = { "swap.receive": "Nhận {amount}", "swap.even": "Không chênh lệch tiền", "swap.unavailable": "Không thể đổi với số lượng, hạn mức, cổ phiếu và tiền mặt này.", + "swap.optionGive": "{chain} · bạn có {count} · {price}", + "swap.optionTake": "{chain} · ngân hàng có {count} · {price}", + "swap.fewer": "Đổi bớt một", + "swap.more": "Đổi thêm một", + "swap.max": "tối đa {count}", + "swap.giveDetail": "đưa {count} {chain} ({value})", + "swap.takeDetail": "nhận {count} {chain} ({value})", + "swap.after": "Sau lần đổi này", + "swap.confirmExact": "Đổi {count} {from} lấy {count} {to} · {cash}", + "swap.noneLeft": "Lượt này đã hết lần đổi.", + "swap.bankEmpty": "Ngân hàng không có cổ phiếu {chain}.", + "swap.cash": "Không đủ tiền trả phần chênh lệch giá.", "log.swapped": "{name} đổi {count} {from} lấy {count} {to} · {cash}", loading: "Đang tải ván chơi…", @@ -99,6 +111,10 @@ export const vi: Catalog = { "buy.total": "{count}/{limit} cổ phiếu · chi phí {cost} · còn lại {cash}", "buy.nothing": "Không mua và kết thúc lượt", "buy.confirm": "Mua với giá {cost} và kết thúc lượt", + "buy.owned": "Bạn có", + "buy.soldOut": "Ngân hàng đã hết", + "buy.cantAfford": "Không đủ tiền mua thêm", + "buy.limitReached": "Đã đạt giới hạn: {limit} cổ phiếu mỗi lượt.", "board.label": "Bàn chơi", "board.empty": "{tile} trống", "board.loose": "{tile} ô nằm riêng", diff --git a/packages/viewer/src/lib/locales/zh-CN.ts b/packages/viewer/src/lib/locales/zh-CN.ts index 67c978d..f0a235d 100644 --- a/packages/viewer/src/lib/locales/zh-CN.ts +++ b/packages/viewer/src/lib/locales/zh-CN.ts @@ -13,6 +13,18 @@ export const zhCN: Catalog = { "swap.receive": "收取 {amount}", "swap.even": "无价差", "swap.unavailable": "此数量、交换限额、股票与现金不足以完成交换。", + "swap.optionGive": "{chain} · 持有 {count} · {price}", + "swap.optionTake": "{chain} · 银行 {count} · {price}", + "swap.fewer": "少换一股", + "swap.more": "多换一股", + "swap.max": "最多 {count}", + "swap.giveDetail": "交出 {count} 股 {chain}({value})", + "swap.takeDetail": "取得 {count} 股 {chain}({value})", + "swap.after": "此交换后", + "swap.confirmExact": "用 {count} 股 {from} 换 {count} 股 {to} · {cash}", + "swap.noneLeft": "本回合已无交换次数。", + "swap.bankEmpty": "银行没有 {chain} 股票。", + "swap.cash": "现金不足以支付差价。", "log.swapped": "{name} 以 {count} 股 {from} 交换 {count} 股 {to} · {cash}", loading: "正在加载游戏…", @@ -98,6 +110,10 @@ export const zhCN: Catalog = { "buy.total": "{count}/{limit} 股 · 花费 {cost} · 剩余 {cash}", "buy.nothing": "不购买,结束回合", "buy.confirm": "花费 {cost} 购买并结束回合", + "buy.owned": "持有", + "buy.soldOut": "银行已无存股", + "buy.cantAfford": "现金不足以再买一股", + "buy.limitReached": "已达上限:每回合 {limit} 股。", "board.label": "游戏版图", "board.empty": "{tile} 空", "board.loose": "{tile} 单独板块", diff --git a/packages/viewer/src/lib/locales/zh-TW.ts b/packages/viewer/src/lib/locales/zh-TW.ts index deaf1b0..4d5631d 100644 --- a/packages/viewer/src/lib/locales/zh-TW.ts +++ b/packages/viewer/src/lib/locales/zh-TW.ts @@ -13,6 +13,18 @@ export const zhTW: Catalog = { "swap.receive": "收取 {amount}", "swap.even": "無價差", "swap.unavailable": "此數量、交換限額、股票與現金不足以完成交換。", + "swap.optionGive": "{chain} · 持有 {count} · {price}", + "swap.optionTake": "{chain} · 銀行 {count} · {price}", + "swap.fewer": "少換一股", + "swap.more": "多換一股", + "swap.max": "最多 {count}", + "swap.giveDetail": "交出 {count} 股 {chain}({value})", + "swap.takeDetail": "取得 {count} 股 {chain}({value})", + "swap.after": "此交換後", + "swap.confirmExact": "以 {count} 股 {from} 換 {count} 股 {to} · {cash}", + "swap.noneLeft": "本回合已無交換次數。", + "swap.bankEmpty": "銀行沒有 {chain} 股票。", + "swap.cash": "現金不足以支付差價。", "log.swapped": "{name} 以 {count} 股 {from} 交換 {count} 股 {to} · {cash}", loading: "正在載入遊戲…", @@ -98,6 +110,10 @@ export const zhTW: Catalog = { "buy.total": "{count}/{limit} 股 · 花費 {cost} · 剩餘 {cash}", "buy.nothing": "不購買,結束回合", "buy.confirm": "花費 {cost} 購買並結束回合", + "buy.owned": "持有", + "buy.soldOut": "銀行已無存股", + "buy.cantAfford": "現金不足以再買一股", + "buy.limitReached": "已達上限:每回合 {limit} 股。", "board.label": "遊戲圖板", "board.empty": "{tile} 空", "board.loose": "{tile} 單獨板塊", diff --git a/scripts/check-browser.mjs b/scripts/check-browser.mjs index ece3e62..f43fd52 100644 --- a/scripts/check-browser.mjs +++ b/scripts/check-browser.mjs @@ -324,8 +324,9 @@ try { window.acquireDev.load(state); }, preparedPosition("founding")); await page.locator(".stock-swap summary").click(); - await page.getByRole("spinbutton", { name: "Shares", exact: true }).fill("2"); + await page.getByRole("button", { name: "Swap one more", exact: true }).click(); assert.match(await page.locator(".exchange").innerText(), /Pay \$800/); + assert.match(await page.locator(".stock-swap .holding-change").innerText(), /\$6,000\s*→\s*\$5,200/); for (const theme of ["dark", "light"]) { await page.evaluate((theme) => window.acquireDev.emitter.emit("theme", { dark: theme === "dark" }), theme); for (const locale of locales) { @@ -334,17 +335,18 @@ try { await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), `stock swap ${locale} ${theme} ${width}px` ); - assert.equal(await page.locator(".stock-swap button").isEnabled(), true); + assert.equal(await page.locator(".stock-swap button.confirm").isEnabled(), true); } await preferences({ locale: "en" }); await page .locator(".panel") .screenshot({ path: fileURLToPath(new URL(`stock-swap-${theme}-${width}.png`, output)) }); } + await page.getByRole("button", { name: "Swap one fewer", exact: true }).click(); const original = await page.evaluate(() => JSON.stringify(window.acquireDev.state)); for (let revision = 0; revision < 3; revision++) { - await page.getByRole("spinbutton", { name: "Shares", exact: true }).fill("2"); - await page.getByRole("button", { name: "Swap shares", exact: true }).click(); + await page.getByRole("button", { name: "Swap one more", exact: true }).click(); + await page.getByRole("button", { name: "Swap 2 Tower for 2 Continental · Pay $800", exact: true }).click(); await page.waitForFunction(() => document.querySelector(".stock-swap summary")?.textContent.includes("1 left")); assert.equal( await page.evaluate(() => JSON.stringify(window.acquireDev.state)), @@ -354,13 +356,13 @@ try { await page.getByRole("button", { name: "Undo", exact: true }).click(); await page.waitForFunction(() => document.querySelector(".stock-swap summary")?.textContent.includes("3 left")); } - await page.getByRole("spinbutton", { name: "Shares", exact: true }).fill("2"); - await page.getByRole("button", { name: "Swap shares", exact: true }).click(); + await page.getByRole("button", { name: "Swap one more", exact: true }).click(); + await page.locator(".stock-swap button.confirm").click(); await page.waitForFunction(() => document.querySelector(".stock-swap summary")?.textContent.includes("1 left")); await page.getByLabel("Give (your stock)", { exact: true }).selectOption("continental"); await settle(); assert.match(await page.locator(".exchange").innerText(), /Receive \$400/); - await page.getByRole("button", { name: "Swap shares", exact: true }).click(); + await page.locator(".stock-swap button.confirm").click(); await page.waitForFunction(() => document.querySelector(".stock-swap summary")?.textContent.includes("0 left")); for (let i = 0; i < 3; i++) { await page.getByRole("button", { name: "Buy one more Tower", exact: true }).click(); From 9d76acba2160eed1556eda14bed169fab061cc87 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 07:32:12 -0700 Subject: [PATCH 10/12] Warn on the placement confirm when placing ends undo for the turn A placement that crosses a commit boundary mid-turn, such as a second tile whose merger pays bonuses, now shows the same note as the merger confirmations. --- packages/viewer/src/lib/PlaceConfirm.svelte | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/viewer/src/lib/PlaceConfirm.svelte b/packages/viewer/src/lib/PlaceConfirm.svelte index c13f45c..7cf1ab1 100644 --- a/packages/viewer/src/lib/PlaceConfirm.svelte +++ b/packages/viewer/src/lib/PlaceConfirm.svelte @@ -17,6 +17,11 @@ store.state?.phase === "place" && store.moves.length > 0 && !store.sending ? store.selected : undefined ); + // Placing can cross a commit boundary mid-turn (e.g. paying merger bonuses), ending undo. + const final = $derived( + tile !== undefined && store.drafting && !!store.outcome({ type: "place", tile: tileLabel(tile) })?.commits + ); + let row = $state(); // Bring the confirmation into view when it opens below a rack at the bottom of the screen. $effect(() => { @@ -37,6 +42,7 @@ >{t("place.button", { tile: tileLabel(tile) })} + {#if final}

    {t("turn.finalStep")}

    {/if}
    {/if} @@ -49,6 +55,11 @@ p { margin: 0 0 8px; } + .final-note { + margin: 4px 0 0; + font-size: 13px; + color: var(--ink-muted); + } button { margin-block: 4px; margin-inline: 0 8px; From 637cae325a94fee089cd93f439cffb99305b7889 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 07:39:48 -0700 Subject: [PATCH 11/12] Tighten desktop spacing so a merger decision fits one screen With the new disposal controls in the decision column, a merger at 1280x900 with touch-sized buttons ran 24px past the desktop gallery limit. Narrow the desktop column and market gaps and the disposal paragraph margins. --- packages/viewer/src/App.svelte | 5 ++++- packages/viewer/src/lib/ActionPanel.svelte | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/viewer/src/App.svelte b/packages/viewer/src/App.svelte index fd82c74..4fbd4c3 100644 --- a/packages/viewer/src/App.svelte +++ b/packages/viewer/src/App.svelte @@ -137,7 +137,10 @@ .column { display: flex; flex-direction: column; - gap: 16px; + gap: 12px; + } + .market { + gap: 8px; } .talk-column { grid-area: talk; diff --git a/packages/viewer/src/lib/ActionPanel.svelte b/packages/viewer/src/lib/ActionPanel.svelte index ee0e00c..ba9b7ec 100644 --- a/packages/viewer/src/lib/ActionPanel.svelte +++ b/packages/viewer/src/lib/ActionPanel.svelte @@ -492,6 +492,10 @@ /* The layout already separates these controls from the hand below. */ margin-bottom: 0; } + /* Keep a merger decision within one desktop screen, even with touch-sized buttons. */ + .panel.disposal > p { + margin-bottom: 4px; + } .panel p { margin: 0 0 8px; } From 2894388bab738c0d38e6f671c40a1f27139d2562 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 08:07:31 -0700 Subject: [PATCH 12/12] Fix stock swap panel crash when a default chain is off the board The redesigned swap panel priced its initial Tower/Continental pair before picking a real choice, so any buy step where the player held shares and either chain was off the board threw and left the viewer on "Loading game". Never price a chain off the board, and add a browser check for such a position. --- packages/viewer/src/lib/StockSwap.svelte | 6 +++++- scripts/check-browser.mjs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/viewer/src/lib/StockSwap.svelte b/packages/viewer/src/lib/StockSwap.svelte index 058ebe2..9c82432 100644 --- a/packages/viewer/src/lib/StockSwap.svelte +++ b/packages/viewer/src/lib/StockSwap.svelte @@ -43,7 +43,8 @@ const cash = $derived( cost === 0 ? t("swap.even") : t(cost > 0 ? "swap.pay" : "swap.receive", { amount: money(Math.abs(cost)) }) ); - const priceOf = (chain: ChainId) => sharePrice(chain, chainSize(game.board, chain)); + // Chains off the board have no price; they are never offered, but the defaults may name one. + const priceOf = (chain: ChainId) => (active.includes(chain) ? sharePrice(chain, chainSize(game.board, chain)) : 0); const after = $derived.by(() => { const effect = selected && moveEffect(game, selected); return effect ? holdingsAfter(game, effect) : undefined; @@ -53,6 +54,9 @@ if (remaining <= 0) { return t("swap.noneLeft"); } + if (!active.includes(from) || !active.includes(to)) { + return t("swap.unavailable"); + } if (game.bank[to] <= 0) { return t("swap.bankEmpty", { chain: chainName(to) }); } diff --git a/scripts/check-browser.mjs b/scripts/check-browser.mjs index 2d4ba79..ff5a9b9 100644 --- a/scripts/check-browser.mjs +++ b/scripts/check-browser.mjs @@ -390,6 +390,10 @@ try { window.acquireDev.load(state); }, preparedPosition("scoring")); assert.equal(await page.locator(".stock-swap").count(), 0, "off never adds UI to existing games"); + // A random buy step where the panel's default chains (Tower, Continental) are not both on the + // board: the swap panel must not price a chain off the board. + await open("players=4&moves=16&stockSwap=3"); + assert.equal(await page.locator(".stock-swap").count(), 1, "swaps render when a default chain is off the board"); report.scenarios.push( "stock swaps in 17 languages and both themes at 1280/390/320px, pay/receive previews, shared allowance, undo without saved history and a separate three-share purchase" );