Prioritize Festival dispatch ships for Puertoma

This commit is contained in:
coyotte508 2026-10-06 20:10:45 +02:00
commit 0f9c08aad3
4 changed files with 37 additions and 3 deletions

View file

@ -2,7 +2,7 @@
[Play now at boardgamers.space](https://boardgamers.space/boardgame/puerto-rico)
Implementation for Boardgamers Space, targeting **Puerto Rico 1897: Special Edition** and the official June 2026 errata. Version 1 is published as a **private beta** on [BGS](https://boardgamers.space/boardgame/puerto-rico), with Unlisted disabled. The engine package is `@boardgamers/puerto-rico@0.2.0`; English and French are configured in the platform metadata.
Implementation for Boardgamers Space, targeting **Puerto Rico 1897: Special Edition** and the official June 2026 errata. Version 1 is published as a **private beta** on [BGS](https://boardgamers.space/boardgame/puerto-rico), with Unlisted disabled. The engine package is `@boardgamers/puerto-rico@0.2.1`; English and French are configured in the platform metadata.
```sh
pnpm install

View file

@ -480,7 +480,19 @@ export function choice(state, t, api) {
break;
}
case "ship": {
const moves = api.shipping(s, p).filter((m) => Number.isInteger(m.ship));
// Festival dispatch priorities can override the normal requirement to
// maximize cargo on an empty ship. Enumerate compatible shared ships
// first, preserving the one-Goods-type-per-ship rule.
const moves = GOODS.flatMap((g) => {
if (!a.goods[g]) return [];
const matching = s.ships.findIndex((sh) => sh.good === g);
return s.ships.flatMap((sh, ship) =>
sh.amount < sh.capacity &&
(matching >= 0 ? ship === matching : sh.good === null)
? [{ type: "ship", good: g, ship }]
: [],
);
});
const ceremony = moves.filter((m) =>
s.festivals.some(
(f) =>

View file

@ -1,6 +1,6 @@
{
"name": "@boardgamers/puerto-rico",
"version": "0.2.0",
"version": "0.2.1",
"private": true,
"type": "module",
"description": "Puerto Rico 1897 Special Edition for Boardgamers Space",

View file

@ -230,3 +230,25 @@ test("Capture the Role is disabled for humans in a Puertoma game", () => {
s = E.move(s, { type: "role", id: "smuggler" }, 0);
assert(!E.legal(s, 0).some((m) => m.type === "capture"));
});
test("Festival dispatch overrides normal empty-ship cargo maximization", () => {
let s = fresh();
s.players[1].goods.corn = 7;
s = E.move(s, { type: "role", id: "captain" }, 0);
s.tasks[0].p = 1;
s.festivals = [
{
id: "traditionalSendoff",
goal: "dispatchSmall",
targets: { goods: ["corn"], estates: [], building: null },
reward: { coins: 2 },
},
];
const m = E.legal(s, 1)[0];
assert.equal(m.ship, 0);
assert.equal(s.ships[0].capacity, 4);
s = E.move(s, m, 1);
assert.equal(s.festivals[0].claimed, 1);
assert(
s.events.some((e) => e.type === "ship" && e.p === 1 && e.goods.corn === 4),
);
});