From 3d31fd48b8e2720d52f10dd8aebdf42b77ccc436 Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Thu, 29 Oct 2026 21:17:50 +0100 Subject: [PATCH] Add configurable three, four or five share purchase limit --- AGENTS.md | 5 +- docs/admin/gameinfo.json | 20 +++ docs/admin/release-check.md | 17 ++- docs/admin/rules.md | 15 +- docs/registering.md | 5 +- packages/engine/package.json | 2 +- packages/engine/src/legal.ts | 12 +- packages/engine/src/moves.ts | 8 +- packages/engine/src/options.ts | 17 ++- packages/engine/src/purchase-limit.spec.ts | 157 +++++++++++++++++++++ packages/viewer/package.json | 2 +- packages/viewer/src/dev.ts | 2 +- packages/viewer/src/lib/ActionPanel.svelte | 11 +- packages/viewer/src/lib/StockSwap.svelte | 3 +- packages/viewer/src/lib/locales/da.ts | 6 +- packages/viewer/src/lib/locales/de.ts | 6 +- packages/viewer/src/lib/locales/el.ts | 6 +- packages/viewer/src/lib/locales/en.ts | 6 +- packages/viewer/src/lib/locales/fa.ts | 6 +- packages/viewer/src/lib/locales/fr.ts | 7 +- packages/viewer/src/lib/locales/hi.ts | 6 +- packages/viewer/src/lib/locales/it.ts | 6 +- packages/viewer/src/lib/locales/ko.ts | 6 +- packages/viewer/src/lib/locales/nl.ts | 6 +- packages/viewer/src/lib/locales/pl.ts | 6 +- packages/viewer/src/lib/locales/pt-BR.ts | 6 +- packages/viewer/src/lib/locales/ro.ts | 7 +- packages/viewer/src/lib/locales/ru.ts | 6 +- packages/viewer/src/lib/locales/vi.ts | 6 +- packages/viewer/src/lib/locales/zh-CN.ts | 6 +- packages/viewer/src/lib/locales/zh-TW.ts | 6 +- rules.md | 10 +- scripts/check-browser.mjs | 59 ++++++++ 33 files changed, 370 insertions(+), 79 deletions(-) create mode 100644 packages/engine/src/purchase-limit.spec.ts diff --git a/AGENTS.md b/AGENTS.md index c6b2b4c..59b0fb9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,7 @@ ## Repository and live status - This is **Acquire**, in `boardgamers/mergers-game`; the BGS game id is `acquire`, version **1**. -- **The BGS game is public**, verified 28 October 2026. Preserve the live visibility and +- **The BGS game is public**, verified 29 October 2026. Preserve the live visibility and unrelated metadata on updates. Fetch fresh metadata before publishing; this file is not a substitute for checking the live configuration. - `docs/admin/gameinfo.json` is a bootstrap template. Its `public: false` and blank artifact @@ -51,7 +51,8 @@ Use Node 24 and pnpm 11. Inspect the working tree before editing and preserve un - Honor BGS theme, sound, chat, replay and supporter player colors. Chain letters already identify chains independently of color. Ongoing hidden-information analysis is not enabled. - Stock swaps are an optional house rule: Off / 3 / 5 / 7 / Unlimited. The per-turn limit is - shared across exchanges, separate from the three-share purchase allowance; prices apply + shared across exchanges, separate from the purchase allowance (3 by default; `sharesPerTurn` + may raise it to 4 or 5); prices apply after all merger resolution. Keep the default Off. - Two tiles per turn and limited game log are optional, default Off. Two-tile turns retain private undo and one turn increment. Limited logs must filter both entries and BGS summaries; diff --git a/docs/admin/gameinfo.json b/docs/admin/gameinfo.json index 9ec321d..9b6bd02 100644 --- a/docs/admin/gameinfo.json +++ b/docs/admin/gameinfo.json @@ -94,6 +94,26 @@ } ] }, + { + "name": "sharesPerTurn", + "label": "Shares per turn", + "type": "select", + "default": "3", + "items": [ + { + "name": "3", + "label": "3 (standard)" + }, + { + "name": "4", + "label": "4" + }, + { + "name": "5", + "label": "5" + } + ] + }, { "name": "stockSwap", "label": "Stock swap (shares per turn, optional variant)", diff --git a/docs/admin/release-check.md b/docs/admin/release-check.md index a9cee24..2baf44a 100644 --- a/docs/admin/release-check.md +++ b/docs/admin/release-check.md @@ -1,10 +1,19 @@ -# Acquire — 28 October 2026 +# Acquire — 29 October 2026 -BGS registration: `acquire`, version `1`. Engine `0.0.5`, viewer `0.0.18`. +BGS registration: `acquire`, version `1`. Engine `0.0.6`, viewer `0.0.19`. Source: . The live game is now public; preserve its current visibility when updating. ## Validation +- **Shares per turn** offers 3 (standard), 4 or 5 total purchases across all chains. + Existing games and tutorial lessons retain 3. The allowance is separate from stock swaps, + founding gifts and merger exchanges, and applies once to a two-tile turn or four-hands seat. + Checks cover default/invalid setup values, legal moves and direct validation, bank/cash + limits, private drafts with one clock increment, and replay in bank/team/four-hands modes. + Purchase and swap prompts show the configured limit in all 17 viewer locales; browser + checks cover each limit, mixed-chain purchases, disabled excess purchases and phone layouts. + The BGS setup declaration uses English source labels; platform label translations are separate. + - [MikeIsom's PR #1](https://github.com/boardgamers/mergers-game/pull/1) adds two optional setup checkboxes, both default Off: two tiles per turn (hands of 8) and limited game log. The shortened labels requested in review are included. Two-tile rules cover founding/merger @@ -17,7 +26,7 @@ Source: . The live game is now publ - Optional stock swaps default to Off, with 3/5/7/Unlimited shares per turn shared across exchanges. Only active chains may swap 1:1 at current prices after all mergers, respecting bank stock, - holdings and cash. Normal three-share purchases remain separate. Engine checks cover allowance + holdings and cash. Normal purchases (3 by default, optionally 4 or 5) remain separate. Engine checks cover allowance resets, refunds, equal prices, bank/cash limits, malformed moves, merger timing, old replays, public replay reconstruction, four hands, private undo and one clock increment per turn. The compact pre-buy controls and public swap log are translated into all 17 languages. @@ -56,7 +65,7 @@ Source: . The live game is now publ requests, hidden-information masking, replay, bank mode, four-hands, teams and dropped players. Desktop/phone checks exercise repeated undo, saved-state refreshes, final history and clock totals. -- `pnpm check`: formatting, lint, TypeScript/Svelte checks, 242 engine tests, +- `pnpm check`: formatting, lint, TypeScript/Svelte checks, 248 engine tests, 67 viewer/tutorial tests, and the production build. Two pre-existing lint warnings remain (an unused test import and Svelte's `bind:this` assignment). - Protocol diagnostics: all eight required engine methods; full core/chat/replay diff --git a/docs/admin/rules.md b/docs/admin/rules.md index b0f4dc7..6a76981 100644 --- a/docs/admin/rules.md +++ b/docs/admin/rules.md @@ -21,7 +21,7 @@ A chain of 11 or more tiles is **safe**: it can never be taken over. ## Your turn 1. **Place one tile** from your hand. -2. **Buy up to 3 shares**, in any active chains (optional). +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. ### What a tile does @@ -41,7 +41,7 @@ A chain of 11 or more tiles is **safe**: it can never be taken over. If the game uses **Two tiles per turn**, each player holds 8 tiles instead of 6 and places two tiles every turn. -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 up to 3 shares 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 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. @@ -73,6 +73,13 @@ Then the survivor absorbs all the tiles. The names of the chains taken over are After placing, you may buy up to 3 shares in total, in one or more chains on the board. Prices depend on each chain's current size and stay fixed for the rest of your turn. You can't borrow, and you can't sell stock except in a merger or at the end. +### Optional purchase limit + +The **Shares per turn** setup option offers **3 (standard)**, **4** or **5**. This is the +total you may buy across all chains, once per turn, even when playing two tiles. Founding +gifts and shares received during mergers do not count. Cash and bank stock still limit +what you can buy. Choosing 4 or 5 is a house rule; existing games and tutorials keep 3. + ### Optional stock swaps If the game uses **Stock swap**, after your tile and any mergers are fully resolved you @@ -86,7 +93,8 @@ each cost $800. Reversing that exchange pays you $800. The setting is **Off** (default), **3**, **5**, **7** or **Unlimited** shares per turn. The allowance is shared across exchanges: giving three shares and receiving three uses -three of the allowance. You can still buy your usual **up to 3 shares** afterward. +three of the allowance. You can still buy up to the game’s **Shares per turn** limit +(**3** by default) afterward; the two allowances are independent. Swaps can be undone until you finish buying. This is an optional house rule. ## Price table @@ -138,6 +146,7 @@ Because replaying the game would show the full history, replay is only available - **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). +- **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. - **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. diff --git a/docs/registering.md b/docs/registering.md index 47d4354..96b1125 100644 --- a/docs/registering.md +++ b/docs/registering.md @@ -1,7 +1,7 @@ # Publishing Acquire on boardgamers.space Acquire is already registered as game **`acquire`**, BGS version **`1`**, and is **public** -(verified 28 October 2026). Routine updates must preserve that visibility and the existing +(verified 29 October 2026). Routine updates must preserve that visibility and the existing configuration. Start with [AGENTS.md](../AGENTS.md) for repository checks and compatibility requirements, and [admin/release-check.md](admin/release-check.md) for the latest release record. @@ -147,7 +147,8 @@ 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, - **Stock swap: Off / 3 / 5 / 7 / Unlimited**, two tiles per turn and limited game log. + **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. - The **sound** preference, default on, also honoring BGS's global sound setting. - Three interactive tutorial chapters: founding, mergers and scoring. diff --git a/packages/engine/package.json b/packages/engine/package.json index b54b637..cf7c9cb 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -1,6 +1,6 @@ { "name": "acquire-engine", - "version": "0.0.5", + "version": "0.0.6", "description": "Acquire rules engine for boardgamers.space", "license": "AGPL-3.0-only", "files": [ diff --git a/packages/engine/src/legal.ts b/packages/engine/src/legal.ts index 2bb87e9..eda0f60 100644 --- a/packages/engine/src/legal.ts +++ b/packages/engine/src/legal.ts @@ -1,12 +1,13 @@ import { activeChains } from "./board.js"; -import { CHAIN_IDS, MAX_BUY, type ChainId } from "./config.js"; +import { CHAIN_IDS, type ChainId } from "./config.js"; import { merger } from "./merger.js"; import { currentSeat, sanitizeMove } from "./moves.js"; +import { sharePurchaseLimit } from "./options.js"; import { maxStockSwap } from "./stock-swap.js"; import { tileLabel } from "./tiles.js"; import type { GameState, Move, Shares } from "./types.js"; -function buyCombinations(chains: ChainId[]): Partial[] { +function buyCombinations(chains: ChainId[], limit: number): Partial[] { const result: Partial[] = []; const visit = (from: number, remaining: number, current: Partial) => { result.push({ ...current }); @@ -23,7 +24,7 @@ function buyCombinations(chains: ChainId[]): Partial[] { } } }; - visit(0, MAX_BUY, {}); + visit(0, limit, {}); return result; } @@ -72,7 +73,10 @@ function phaseCandidates(state: GameState): Move[] { } case "buy": { const active = activeChains(state.board); - const moves: Move[] = buyCombinations(active).map((shares) => ({ type: "buy", shares })); + const moves: Move[] = buyCombinations(active, sharePurchaseLimit(state.options)).map((shares) => ({ + type: "buy", + shares, + })); for (const from of active) { for (const to of active) { const max = maxStockSwap(state, from, to); diff --git a/packages/engine/src/moves.ts b/packages/engine/src/moves.ts index ec9e3fd..1a10f8a 100644 --- a/packages/engine/src/moves.ts +++ b/packages/engine/src/moves.ts @@ -1,6 +1,7 @@ import { activeChains, chainSize, connectedLoose, placementEffect, playableTiles, tileLegality } from "./board.js"; import { defaultMove } from "./autoplay.js"; -import { AUTO_MOVE_LIMIT, CHAIN_IDS, MAX_BUY, isChainId, type ChainId } from "./config.js"; +import { AUTO_MOVE_LIMIT, CHAIN_IDS, isChainId, type ChainId } from "./config.js"; +import { sharePurchaseLimit } from "./options.js"; import { dispose, isValidDefunctOrder, @@ -160,8 +161,9 @@ export function sanitizeMove(state: GameState, raw: unknown, seat: number): Move total += n; cost += n * sharePrice(key, chainSize(state.board, key)); } - if (total > MAX_BUY) { - throw new Error(`You can buy at most ${MAX_BUY} shares per turn`); + const limit = sharePurchaseLimit(state.options); + if (total > limit) { + throw new Error(`You can buy at most ${limit} shares per turn`); } if (cost > state.seats[seat]!.cash) { throw new Error("You cannot afford those shares"); diff --git a/packages/engine/src/options.ts b/packages/engine/src/options.ts index 940d819..ded5bc5 100644 --- a/packages/engine/src/options.ts +++ b/packages/engine/src/options.ts @@ -1,4 +1,4 @@ -import { END_SIZE, HAND_SIZE, TWO_TILE_HAND_SIZE } from "./config.js"; +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 { @@ -9,6 +9,8 @@ export interface GameOptions { endSize: number; /** Omitted when off, preserving the init log of games created before this variant. */ stockSwap?: 3 | 5 | 7 | "unlimited"; + /** Omitted at the standard limit of 3, preserving historical init logs. */ + sharesPerTurn?: 4 | 5; /** Omitted when off, like stockSwap. */ twoTiles?: true; /** Omitted when off, like stockSwap. */ @@ -84,6 +86,14 @@ export function normalizeOptions( } } + if (raw.sharesPerTurn !== undefined) { + if ([4, 5, "4", "5"].includes(raw.sharesPerTurn as number | string)) { + options.sharesPerTurn = Number(raw.sharesPerTurn) as 4 | 5; + } else if (raw.sharesPerTurn !== 3 && raw.sharesPerTurn !== "3") { + ignored.push({ option: "sharesPerTurn", value: raw.sharesPerTurn, reason: "unknown value" }); + } + } + if (raw.twoTiles === true) { options.twoTiles = true; } @@ -94,6 +104,11 @@ export function normalizeOptions( return { options, ignored }; } +/** Total purchases across all chains, independent of stock swaps and tile placements. */ +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 { return options.twoTiles ? TWO_TILE_HAND_SIZE : HAND_SIZE; diff --git a/packages/engine/src/purchase-limit.spec.ts b/packages/engine/src/purchase-limit.spec.ts new file mode 100644 index 0000000..d29eb51 --- /dev/null +++ b/packages/engine/src/purchase-limit.spec.ts @@ -0,0 +1,157 @@ +import assert from "node:assert/strict"; +import { test } from "node:test"; +import * as wrapper from "../wrapper.js"; +import { legalMoves } from "./legal.js"; +import { applyMove, currentSeat } from "./moves.js"; +import { DEFAULT_OPTIONS, normalizeOptions, sharePurchaseLimit } from "./options.js"; +import { positionAt } from "./position.js"; +import { initGame } from "./setup.js"; +import { stockSwapsRemaining } from "./stock-swap.js"; +import { chainAt, checkInvariants, scenario } from "./test/helpers.js"; +import type { Move } from "./types.js"; + +function position(options: Record = {}) { + return scenario({ + board: { ...chainAt("tower", ["1A", "2A"]), ...chainAt("continental", ["1E", "2E"]) }, + hands: [["12I", "10I"], ["8I"], ["6I"], ["4I"]], + shares: [{ tower: 6, continental: 6 }], + options, + }); +} + +test("purchase limit accepts only 3/4/5 and leaves standard and historical options unchanged", () => { + for (let players = 2; players <= 6; players++) { + for (const sharesPerTurn of [undefined, 3, "3"]) { + const normalized = normalizeOptions(players, { sharesPerTurn }); + assert.deepEqual(normalized, { options: DEFAULT_OPTIONS, ignored: [] }); + assert.equal(sharePurchaseLimit(normalized.options), 3); + } + for (const sharesPerTurn of [4, "4", 5, "5"]) { + const { options, ignored } = normalizeOptions(players, { sharesPerTurn }); + assert.equal(sharePurchaseLimit(options), Number(sharesPerTurn)); + assert.deepEqual(ignored, []); + } + } + for (const sharesPerTurn of [null, true, 0, 2, 6, 7, -1, [], [4], {}, "4.0", "unlimited", Infinity]) { + const { options, ignored } = normalizeOptions(3, { sharesPerTurn }); + assert.deepEqual(options, DEFAULT_OPTIONS); + assert.deepEqual(ignored, [{ option: "sharesPerTurn", value: sharesPerTurn, reason: "unknown value" }]); + } + assert.deepEqual(initGame(3, {}, "old-purchases").options, DEFAULT_OPTIONS); +}); + +test("purchase limit applies to the total across chains in validation and legal moves", () => { + for (const limit of [3, 4, 5]) { + const state = position({ sharesPerTurn: String(limit) }); + applyMove(state, { type: "place", tile: "12I" }, 0); + const choices = legalMoves(state).filter((move) => move.type === "buy"); + assert.equal(choices.length, ((limit + 1) * (limit + 2)) / 2, "all splits across two affordable chains"); + assert.deepEqual(legalMoves(wrapper.stripSecret(state, 0)), legalMoves(state)); + const original = structuredClone(state); + for (const shares of [{ tower: limit + 1 }, { tower: 2, continental: limit - 1 }]) { + assert.throws(() => applyMove(state, { type: "buy", shares }, 0), new RegExp(`at most ${limit}`)); + assert.deepEqual(state, original, "invalid purchases are atomic"); + } + applyMove(state, { type: "buy", shares: { tower: 2, continental: limit - 2 } }, 0); + assert.equal(state.seats[0]!.cash, 6000 - 400 - (limit - 2) * 400); + assert.equal(state.seats[0]!.shares.tower, 8); + assert.equal(state.seats[0]!.shares.continental, 6 + limit - 2); + assert.equal(state.activeSeat, 1); + checkInvariants(state); + } +}); + +test("larger purchase limits still enforce cash, bank stock, active chains and turn ownership", () => { + const state = position({ sharesPerTurn: 5 }); + applyMove(state, { type: "place", tile: "12I" }, 0); + state.seats[0]!.cash = 900; + assert.throws(() => applyMove(state, { type: "buy", shares: { tower: 5 } }, 0), /afford/); + assert.ok(!legalMoves(state).some((m) => m.type === "buy" && m.shares.tower === 5)); + state.seats[0]!.cash = 6000; + state.bank.tower = 4; + assert.throws(() => applyMove(state, { type: "buy", shares: { tower: 5 } }, 0), /bank/); + assert.ok(!legalMoves(state).some((m) => m.type === "buy" && m.shares.tower === 5)); + assert.throws(() => applyMove(state, { type: "buy", shares: { luxor: 1 } }, 0), /on the board/); + assert.throws(() => applyMove(state, { type: "buy", shares: { tower: 1 } }, 1), /not your turn/); +}); + +test("five purchases remain independent of swaps and cover the whole two-tile turn", () => { + const state = position({ sharesPerTurn: 5, stockSwap: 3, twoTiles: true }); + applyMove(state, { type: "place", tile: "12I" }, 0); + assert.equal(state.phase, "place"); + assert.throws(() => applyMove(state, { type: "buy", shares: { tower: 5 } }, 0)); + applyMove(state, { type: "place", tile: "10I" }, 0); + applyMove(state, { type: "swap", from: "continental", to: "tower", count: 3 }, 0); + assert.equal(stockSwapsRemaining(state), 0); + applyMove(state, { type: "buy", shares: { tower: 5 } }, 0); + assert.equal(state.seats[0]!.shares.tower, 14); + assert.equal(state.seats[0]!.cash, 5600); + assert.equal(state.activeSeat, 1); + assert.equal(state.log.filter((e) => e.type === "bought").length, 1); + checkInvariants(state); +}); + +test("four- and five-share turn drafts commit once after revisions without extra history or time", () => { + for (const limit of [4, 5]) { + const base = position({ sharesPerTurn: limit, stockSwap: 3 }); + const original = structuredClone(base); + const moves: Move[] = [ + { type: "place", tile: "12I" }, + { type: "swap", from: "continental", to: "tower", count: 1 }, + ]; + for (let i = 0; i < 4; i++) { + const preview = wrapper.move( + base, + { type: "turn", from: base.log.length, moves: moves.slice(0, (i % 2) + 1) }, + 0 + ); + assert.equal(wrapper.toSave(preview), undefined); + assert.deepEqual(wrapper.timeIncrements(preview), [0, 0, 0]); + } + const saved = wrapper.move( + base, + { + type: "turn", + from: base.log.length, + moves: [...moves, { type: "buy", shares: { tower: limit } }], + }, + 0 + ); + assert.deepEqual(base, original); + assert.equal(wrapper.toSave(saved), saved); + assert.equal(saved.log.filter((entry) => entry.type === "move").length, 3); + assert.deepEqual(wrapper.timeIncrements(saved), [1, 0, 0]); + checkInvariants(saved); + } +}); + +test("purchase variants replay across bank, four-hands, team and two-tile games, including the old default", () => { + for (const [players, options] of [ + [3, {}], + [3, { sharesPerTurn: "3" }], + [2, { sharesPerTurn: "4" }], + [2, { sharesPerTurn: "5", twoPlayerMode: "fourHands" }], + [4, { sharesPerTurn: "4", teamPlay: true }], + [3, { sharesPerTurn: "5", twoTiles: true, limitedLog: true }], + ] as [number, Record][]) { + const state = initGame(players, options, "purchase-replay"); + let largestBuy = 0; + for (let i = 0; i < 150 && !state.ended; i++) { + const moves = legalMoves(state).filter((m) => m.type !== "announce"); + const move = moves.at(-1)!; + if (move.type === "buy") { + largestBuy = Math.max( + largestBuy, + Object.values(move.shares).reduce((a, b) => a + b, 0) + ); + } + applyMove(state, move, currentSeat(state)!); + } + assert.equal(largestBuy, sharePurchaseLimit(state.options)); + assert.deepEqual(wrapper.replay(state), state); + const reconstructed = positionAt(state, state.log.length); + assert.deepEqual(reconstructed.board, state.board); + assert.deepEqual(reconstructed.bank, state.bank); + checkInvariants(state); + } +}); diff --git a/packages/viewer/package.json b/packages/viewer/package.json index 339a27e..9272b4c 100644 --- a/packages/viewer/package.json +++ b/packages/viewer/package.json @@ -1,6 +1,6 @@ { "name": "acquire-viewer", - "version": "0.0.18", + "version": "0.0.19", "private": true, "description": "Browser viewer for Acquire on boardgamers.space", "license": "AGPL-3.0-only", diff --git a/packages/viewer/src/dev.ts b/packages/viewer/src/dev.ts index 7ac0ece..480a4f2 100644 --- a/packages/viewer/src/dev.ts +++ b/packages/viewer/src/dev.ts @@ -34,7 +34,7 @@ for (const key of ["publicHoldings", "teamPlay", "autoEnd", "twoTiles", "limited options[key] = true; } } -for (const key of ["twoPlayerMode", "endSize", "stockSwap"]) { +for (const key of ["twoPlayerMode", "endSize", "stockSwap", "sharesPerTurn"]) { const value = params.get(key); if (value) { options[key] = value; diff --git a/packages/viewer/src/lib/ActionPanel.svelte b/packages/viewer/src/lib/ActionPanel.svelte index 95f5b01..b21dd03 100644 --- a/packages/viewer/src/lib/ActionPanel.svelte +++ b/packages/viewer/src/lib/ActionPanel.svelte @@ -6,6 +6,7 @@ currentSeat, merger, sharePrice, + sharePurchaseLimit, tileLabel, type ChainId, type Shares, @@ -67,6 +68,7 @@ const valueChange = $derived(`${tradeValue < 0 ? "−" : "+"}${money(Math.abs(tradeValue))}`); const buyable = $derived(activeChains(game.board)); + const buyLimit = $derived(sharePurchaseLimit(game.options)); 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)); @@ -296,7 +298,7 @@ > {:else if game.phase === "buy"} {#if game.options.stockSwap}{/if} -

{t("buy.prompt")}

+

{t("buy.prompt", { limit: buyLimit })}

{#if buyable.length > 0} @@ -337,7 +339,12 @@
{/if}

- {t("buy.total", { count: total, cost: money(cost), cash: money(game.seats[seat!]!.cash - cost) })} + {t("buy.total", { + count: total, + limit: buyLimit, + cost: money(cost), + cash: money(game.seats[seat!]!.cash - cost), + })}