Keep hidden VP totals out of ongoing platform scores

This commit is contained in:
coyotte508 2026-10-27 09:29:27 +01:00
commit 2e48abd368
3 changed files with 23 additions and 2 deletions

View file

@ -75,7 +75,11 @@ export function setPlayerMetaData(s, p, data) {
return game.setPlayerMetaData(s, p, data);
}
export function scores(s) {
const result = game.scores(s);
// Platform scores are public, unlike the seat-filtered viewer state.
const result =
!s.finished && s.options.showVP !== true
? s.players.map(() => 0)
: game.scores(s);
return solo(s) ? result.slice(0, 1) : result;
}
export function rankings(s) {

View file

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

View file

@ -101,3 +101,20 @@ test("building selection is opt-in and keeps the interactive draft", () => {
host.init(3, [], { chooseBuildings: false }, "auto-market"),
);
});
test("platform scores never reveal hidden totals in ongoing games", () => {
for (const n of [1, 3, 5]) {
const s = host.init(n, [], {}, "score-privacy");
s.players.forEach((p, i) => {
p.vp = 17 + i;
});
const before = structuredClone(s);
assert.deepEqual(host.scores(s), Array(n).fill(0));
assert.deepEqual(s, before);
s.options.showVP = true;
assert.deepEqual(host.scores(s), game.scores(s).slice(0, n));
s.options.showVP = false;
s.finished = true;
assert.deepEqual(host.scores(s), game.scores(s).slice(0, n));
}
});