Keep undo within the active turn and explicitly edit early choices

This commit is contained in:
coyotte508 2026-10-28 22:43:04 +01:00
commit 52289dc2ab
25 changed files with 316 additions and 71 deletions

View file

@ -56,9 +56,9 @@ export function move(s, m, p) {
// Reopening a completed choice must not earn a second clock increment.
// Keep this entitlement across other seats' independent placement updates.
const editing = new Set(s.undoResubmitSeats ?? s.placementUndoSeats ?? []);
if (m?.type === "undo") {
if (["undo", "editPlacement", "editProduction"].includes(m?.type)) {
next.liveUndo = true;
if (!game.currentPlayers(s).includes(p)) editing.add(p);
if (["editPlacement", "editProduction"].includes(m.type)) editing.add(p);
} else if (editing.delete(p)) next.liveUndo = true;
delete next.placementUndoSeats;
if (editing.size) next.undoResubmitSeats = [...editing];

View file

@ -1386,13 +1386,76 @@ function placementUndoState(s, p) {
return null;
return candidate;
}
function productionEditState(s, p) {
if (s.tutorial || s.finished || s.puertoma || s.tasks[0]?.kind !== "produce")
return null;
const index = s.history.findLastIndex((h) => h.p === p);
if (
index < (s.roleHistoryStart ?? 0) ||
!["produce", "produceBonus", "pass"].includes(
s.history[index]?.move.type,
) ||
s.history
.slice(index + 1)
.some((h) => !["produce", "produceBonus", "pass"].includes(h.move.type))
)
return null;
const before = replay(s, index + 1);
const task = playerTask(before, p);
if (
!["produce", "produceBonus"].includes(task?.kind) ||
task.p !== p ||
parallelProductionTasks(before).length < 2
)
return null;
const rank = (seat) => (seat - s.owner + s.players.length) % s.players.length;
if (
task.kind === "produce" &&
!s.tasks.some((t) => t.kind === "produce" && rank(t.p) < rank(p))
)
return null;
let candidate;
try {
candidate = replay({
...s,
history: s.history.filter((_, i) => i !== index),
});
} catch {
return null;
} // A later choice depends on this one: keep it committed.
if (
s.players.some(
(a, i) =>
i !== p && JSON.stringify(a) !== JSON.stringify(candidate.players[i]),
)
)
return null;
const reveals = (state) =>
JSON.stringify([
state.players.map((a) =>
(a.achievements ?? []).filter((c) => c.completed),
),
state.festivals,
state.bag,
state.random,
]);
return reveals(candidate) === reveals(s) ? candidate : null;
}
export function canEditProduction(s, p) {
return !!productionEditState(s, p);
}
export function canEditPlacement(s, p) {
return !!placementUndoState(s, p);
}
export function canUndo(s, p) {
if (s.tutorial) return false;
if (placementUndoState(s, p)) return true;
const last = s.history.at(-1);
if (!last || last.p !== p || s.finished) return false;
if (!last || last.p !== p || s.finished || !currentPlayers(s).includes(p))
return false;
const before = replay(s, logLength(s) - 1);
return (
JSON.stringify(currentPlayers(before).slice().sort()) ===
JSON.stringify(currentPlayers(s).slice().sort()) &&
!s.players.some((a, i) =>
(a.achievements ?? []).some(
(c) =>
@ -1417,9 +1480,19 @@ export function canUndo(s, p) {
);
}
export function move(state, m, p) {
if (m?.type === "editProduction") {
const edited = productionEditState(state, p);
assert(edited, "This production can no longer be edited");
return edited;
}
if (m?.type === "editPlacement") {
const edited = placementUndoState(state, p);
assert(edited, "This placement can no longer be edited");
return edited;
}
if (m?.type === "undo") {
assert(canUndo(state, p), "This move can no longer be undone");
return placementUndoState(state, p) ?? replay(state, logLength(state) - 1);
return replay(state, logLength(state) - 1);
}
return resolveForcedActions(applyMove(state, m, p));
}
@ -1986,6 +2059,8 @@ export function currentPlayer(s) {
export function canMoveOutOfTurn(s, m, p) {
return (
(m?.type === "undo" && canUndo(s, p)) ||
(m?.type === "editPlacement" && canEditPlacement(s, p)) ||
(m?.type === "editProduction" && canEditProduction(s, p)) ||
(m?.type === "bohio" && legal(s, p).some((x) => sameMove(x, m)))
);
}
@ -2083,6 +2158,8 @@ export function stripSecret(state, p) {
}
// Logs contain only public moves; historical earned points are public even though totals are concealed.
s.canUndo = Number.isInteger(p) && canUndo(state, p);
s.canEditPlacement = Number.isInteger(p) && canEditPlacement(state, p);
s.canEditProduction = Number.isInteger(p) && canEditProduction(state, p);
s.currentPlayers = currentPlayers(state);
const ownTask = Number.isInteger(p) ? playerTask(state, p) : null;
if (ownTask && ownTask.p === p && ownTask !== state.tasks[0]) {

View file

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

View file

@ -1154,13 +1154,13 @@ try {
},
E.stripSecret(undoPlacement, 1),
);
await page.locator(".action-dock .dock-undo").click();
await page.locator(".action-dock .dock-edit-placement").click();
assert.deepEqual(await page.evaluate(() => played.at(-1)), {
type: "undo",
type: "editPlacement",
});
await page.evaluate(
(s) => host.emit("state", s),
E.stripSecret(E.move(undoPlacement, { type: "undo" }, 1), 1),
E.stripSecret(E.move(undoPlacement, { type: "editPlacement" }, 1), 1),
);
await page.locator(".action-dock [data-actions]").click();
assert.ok(
@ -1203,6 +1203,55 @@ try {
type: "produceBonus",
good: "corn",
});
let editProduction = E.init(3, [], {}, "production-edit");
editProduction = E.move(
editProduction,
{ type: "role", id: "recruiter" },
0,
);
editProduction = E.move(editProduction, { type: "recruitBonus" }, 0);
while (editProduction.tasks[0].kind === "assign") {
const p = E.currentPlayer(editProduction);
editProduction = E.move(
editProduction,
{ type: "assign", ...E.autoAssignment(editProduction, p) },
p,
);
}
editProduction = E.move(editProduction, { type: "role", id: "trader" }, 1);
while (editProduction.tasks[0].kind !== "role")
editProduction = E.move(
editProduction,
{ type: "pass" },
E.currentPlayer(editProduction),
);
editProduction = E.move(
editProduction,
{ type: "role", id: "craftsman" },
2,
);
editProduction = E.move(
editProduction,
E.legal(editProduction, 2).find((m) => m.type === "produce"),
2,
);
editProduction = E.move(
editProduction,
{ type: "produceBonus", good: "corn" },
2,
);
await page.evaluate(
(s) => {
host.emit("player", { index: 2 });
host.emit("state", s);
},
E.stripSecret(editProduction, 2),
);
assert.equal(await page.locator(".action-dock .dock-undo").count(), 0);
await page.locator(".action-dock .dock-edit-production").click();
assert.deepEqual(await page.evaluate(() => played.at(-1)), {
type: "editProduction",
});
assert.deepEqual(errors, [], `No browser errors at ${width}`);
console.log(
`Browser ${width}px: actions, allocation, layout, journal, chat and scrolling OK`,

View file

@ -0,0 +1,55 @@
import test from "node:test";
import assert from "node:assert/strict";
import * as E from "../engine/index.js";
import * as host from "../bgs/engine.js";
function fixture() {
let s = E.init(3, [], {}, "production-edit");
s = E.move(s, { type: "role", id: "recruiter" }, 0);
s = E.move(s, { type: "recruitBonus" }, 0);
while (s.tasks[0].kind === "assign") {
const p = E.currentPlayer(s);
s = E.move(s, { type: "assign", ...E.autoAssignment(s, p) }, p);
}
s = E.move(s, { type: "role", id: "trader" }, 1);
while (s.tasks[0].kind !== "role")
s = E.move(s, { type: "pass" }, E.currentPlayer(s));
return E.move(s, { type: "role", id: "craftsman" }, 2);
}
const produce = (s, p) =>
E.move(
s,
E.legal(s, p).find((m) => m.type === "produce"),
p,
);
test("early production can be edited without retracting another producer's choice", () => {
const start = fixture();
let s = produce(start, 1);
s = produce(s, 0);
assert.equal(E.canUndo(s, 1), false);
assert.equal(E.canEditProduction(s, 1), true);
const edited = E.move(s, { type: "editProduction" }, 1);
assert.deepEqual(edited.players[0], s.players[0]);
assert.deepEqual(edited.players[1], start.players[1]);
assert.equal(edited.history.length, s.history.length - 1);
assert.deepEqual(E.replay(edited), edited);
});
test("early Craftsman bonus is editable and re-confirmation adds no time", () => {
let s = produce(fixture(), 2);
s = host.move(s, { type: "produceBonus", good: "corn" }, 2);
s = produce(s, 0);
assert.equal(E.canUndo(s, 2), false);
assert.equal(E.canEditProduction(s, 2), true);
const edited = host.move(s, { type: "editProduction" }, 2);
assert.equal(host.isLiveUpdate(edited), true);
assert.deepEqual(edited.players[0], s.players[0]);
assert.equal(E.stripSecret(edited, 2).tasks[0].kind, "produceBonus");
const confirmed = host.move(
edited,
{ type: "produceBonus", good: "corn" },
2,
);
assert.equal(host.isLiveUpdate(confirmed), true);
const finished = produce(confirmed, 1);
assert.equal(E.canEditProduction(finished, 2), false);
assert.throws(() => E.move(finished, { type: "editProduction" }, 2));
});

View file

@ -88,11 +88,18 @@ test("Builder selection can be undone before purchase", () => {
assert.deepEqual(E.move(chosen, { type: "undo" }, 0), s);
});
test("BGS supports undo after choosing every available role, without a clock increment", async () => {
test("BGS role undo preserves the active seats and grants no clock increment", async () => {
const host = await import("../bgs/engine.js");
const start = host.init(3, [], {}, "undo-all-roles");
for (const role of host.legal(start, 0).filter((m) => m.type === "role")) {
const chosen = host.move(start, role, 0);
if (
JSON.stringify(host.currentPlayers(start)) !==
JSON.stringify(host.currentPlayers(chosen))
) {
assert.equal(host.canUndo(chosen, 0), false, role.id);
continue;
}
assert.equal(host.canUndo(chosen, 0), true, role.id);
const undone = host.move(chosen, { type: "undo" }, 0);
assert.equal(host.isLiveUpdate(undone), true);
@ -113,35 +120,39 @@ test("a later seat can withdraw its placement without undoing another seat", ()
const start = recruit();
let s = E.move(start, { type: "assign", ...E.autoAssignment(start, 1) }, 1);
s = E.move(s, { type: "assign", ...E.autoAssignment(s, 2) }, 2);
assert.equal(E.canUndo(s, 1), true);
assert.equal(E.canMoveOutOfTurn(s, { type: "undo" }, 1), true);
const restored = E.move(s, { type: "undo" }, 1);
assert.equal(E.canEditPlacement(s, 1), true);
assert.equal(E.canMoveOutOfTurn(s, { type: "editPlacement" }, 1), true);
const restored = E.move(s, { type: "editPlacement" }, 1);
assert.deepEqual(restored.players[1], start.players[1]);
assert.deepEqual(restored.players[2], s.players[2]);
assert.deepEqual(E.currentPlayers(restored), [0, 1]);
assert.equal(restored.history.length, s.history.length - 1);
assert.deepEqual(E.replay(restored), restored);
assert.equal(E.canUndo(restored, 1), false);
assert.equal(E.canEditPlacement(restored, 1), false);
const firstDone = E.move(
restored,
{ type: "assign", ...E.autoAssignment(restored, 0) },
0,
);
assert.equal(E.canUndo(firstDone, 2), true, "seat 1 still precedes seat 2");
assert.equal(
E.canEditPlacement(firstDone, 2),
true,
"seat 1 still precedes seat 2",
);
const finished = E.move(
firstDone,
{ type: "assign", ...E.autoAssignment(firstDone, 1) },
1,
);
assert.equal(E.canUndo(finished, 2), false);
assert.equal(E.canEditPlacement(finished, 2), false);
});
test("an earlier seat cannot withdraw after only later seats remain", () => {
const start = recruit();
const s = E.move(start, { type: "assign", ...E.autoAssignment(start, 0) }, 0);
assert.equal(E.canUndo(s, 0), false);
assert.equal(E.canMoveOutOfTurn(s, { type: "undo" }, 0), false);
assert.throws(() => E.move(s, { type: "undo" }, 0));
assert.equal(E.canEditPlacement(s, 0), false);
assert.equal(E.canMoveOutOfTurn(s, { type: "editPlacement" }, 0), false);
assert.throws(() => E.move(s, { type: "editPlacement" }, 0));
});
test("withdrawing and re-confirming placement do not award another clock increment", async () => {
@ -150,7 +161,7 @@ test("withdrawing and re-confirming placement do not award another clock increme
for (let i = 0; i < 3; i++) {
s = host.move(s, { type: "assign", ...E.autoAssignment(s, 2) }, 2);
assert.equal(host.isLiveUpdate(s), i > 0);
s = host.move(s, { type: "undo" }, 2);
s = host.move(s, { type: "editPlacement" }, 2);
assert.equal(host.isLiveUpdate(s), true);
assert.deepEqual(s.undoResubmitSeats, [2]);
assert.equal(host.stripSecret(s, 2).undoResubmitSeats, undefined);
@ -162,8 +173,8 @@ test("placement undo never retracts a revealed achievement or Festival reward",
const start = recruit();
const s = E.move(start, { type: "assign", ...E.autoAssignment(start, 2) }, 2);
s.players[2].achievements = [{ id: "revealed", completed: true }];
assert.equal(E.canUndo(s, 2), false);
assert.equal(E.canEditPlacement(s, 2), false);
s.players[2].achievements = [];
s.festivals = [{ id: "claimed", claimed: 2 }];
assert.equal(E.canUndo(s, 2), false);
assert.equal(E.canEditPlacement(s, 2), false);
});

View file

@ -1,9 +1,8 @@
import test from "node:test";
import assert from "node:assert/strict";
import * as E from "../engine/index.js";
import * as host from "../bgs/engine.js";
test("completed choices remain undoable until another player acts or new information is revealed", () => {
test("undo never restores an earlier turn after a completed action", () => {
let s = E.init(3, ["smuggler"], {}, "undo-handoffs");
const covered = new Set();
let blockedDraw = false;
@ -26,32 +25,21 @@ test("completed choices remain undoable until another player acts or new informa
after.history.length === s.history.length + 1 &&
E.currentPlayer(after) !== p
) {
if (E.canUndo(after, p)) {
const m = after.history.at(-1).move;
covered.add(m.type);
assert.equal(E.canMoveOutOfTurn(after, { type: "undo" }, p), true);
assert.deepEqual(E.move(after, { type: "undo" }, p), s);
if (!E.currentPlayers(after).includes(p)) {
const undone = host.move(after, { type: "undo" }, p);
assert.equal(host.isLiveUpdate(undone), true);
const redone = host.move(undone, m, p);
assert.equal(
host.isLiveUpdate(redone),
true,
`${m.type} must not credit time twice`,
);
if (!after.finished) {
const next = E.moveAI(after);
if (next.history.at(-1).p !== p)
assert.equal(E.canUndo(next, p), false);
}
}
} else if (
s.random !== after.random ||
JSON.stringify(s.bag) !== JSON.stringify(after.bag)
)
blockedDraw = true;
const type = after.history.at(-1).move.type;
if (
JSON.stringify(E.currentPlayers(s).slice().sort()) !==
JSON.stringify(E.currentPlayers(after).slice().sort())
) {
covered.add(type);
assert.equal(
E.canUndo(after, p),
false,
`${type} cannot change active players`,
);
assert.throws(() => E.move(after, { type: "undo" }, p));
}
}
s = after;
}
for (const type of [

View file

@ -595,5 +595,7 @@
"metadata.rules": "Vælg en rolle: alle udfører handlingen, og du får et privilegium. Plant, rekrutter, byg, producer, handl og afskib. Flest point fra afskibning, bygninger og bonusser vinder.",
"smugglerRaidHelp": "Tag op til 3 varer fra ét skib; læg resten tilbage i forsyningen.",
"smugglerPlunderHelp": "Læg alle handelshusets varer tilbage i forsyningen; få 1 sejrspoint pr. vare.",
"smugglerPoachHelp": "Tag op til 3 overskydende arbejdere, og placér dem straks."
"smugglerPoachHelp": "Tag op til 3 overskydende arbejdere, og placér dem straks.",
"editPlacement": "Redigér placering",
"editProduction": "Redigér produktion"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Wähle eine Rolle: Alle führen ihre Aktion aus, du erhältst ein Privileg. Pflanze, wirb an, baue, produziere, handle und verschiffe. Die meisten Punkte aus Verschiffung, Gebäuden und Boni gewinnen.",
"smugglerRaidHelp": "Nimm bis zu 3 Waren von einem Schiff; lege den Rest in den Vorrat zurück.",
"smugglerPlunderHelp": "Lege alle Waren des Handelshauses in den Vorrat zurück; erhalte 1 SP pro Ware.",
"smugglerPoachHelp": "Nimm bis zu 3 überzählige Arbeiter und setze sie sofort ein."
"smugglerPoachHelp": "Nimm bis zu 3 überzählige Arbeiter und setze sie sofort ein.",
"editPlacement": "Platzierung ändern",
"editProduction": "Produktion ändern"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Επιλέξτε ρόλο: όλοι εκτελούν την ενέργειά του και εσείς παίρνετε προνόμιο. Φυτέψτε, προσλάβετε, χτίστε, παράγετε, πουλήστε και στείλτε. Κερδίζουν οι περισσότεροι πόντοι από αποστολές, κτίρια και μπόνους.",
"smugglerRaidHelp": "Πάρε έως 3 αγαθά από ένα πλοίο· επέστρεψε τα υπόλοιπα στο απόθεμα.",
"smugglerPlunderHelp": "Επέστρεψε όλα τα αγαθά του εμπορικού οίκου στο απόθεμα· κέρδισε 1 ΠΝ ανά αγαθό.",
"smugglerPoachHelp": "Πάρε έως 3 πλεονάζοντες εργάτες και τοποθέτησέ τους αμέσως."
"smugglerPoachHelp": "Πάρε έως 3 πλεονάζοντες εργάτες και τοποθέτησέ τους αμέσως.",
"editPlacement": "Αλλαγή τοποθέτησης",
"editProduction": "Αλλαγή παραγωγής"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Choose a role: all players perform its action, and you receive a privilege. Plant, recruit, build, produce, trade and ship. Most points from shipping, buildings and bonuses wins.",
"smugglerRaidHelp": "Take up to 3 goods from one ship; return the rest to the supply.",
"smugglerPlunderHelp": "Return all trading-house goods to the supply; gain 1 VP per good.",
"smugglerPoachHelp": "Take up to 3 surplus workers and place them immediately."
"smugglerPoachHelp": "Take up to 3 surplus workers and place them immediately.",
"editPlacement": "Edit placement",
"editProduction": "Edit production"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "نقشی انتخاب کنید: همه اقدامش را انجام می‌دهند و شما امتیاز ویژه می‌گیرید. کشت، استخدام، ساخت، تولید، تجارت و ارسال کنید. بیشترین امتیاز از ارسال، ساختمان‌ها و پاداش‌ها برنده است.",
"smugglerRaidHelp": "از یک کشتی حداکثر ۳ کالا بردارید؛ باقی را به ذخیره برگردانید.",
"smugglerPlunderHelp": "همهٔ کالاهای تجارت‌خانه را به ذخیره برگردانید؛ برای هر کالا ۱ امتیاز پیروزی بگیرید.",
"smugglerPoachHelp": "حداکثر ۳ کارگر اضافی بردارید و فوراً آن‌ها را مستقر کنید."
"smugglerPoachHelp": "حداکثر ۳ کارگر اضافی بردارید و فوراً آن‌ها را مستقر کنید.",
"editPlacement": "ویرایش جای‌گذاری",
"editProduction": "ویرایش تولید"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Choisissez un rôle : tous les joueurs effectuent son action et vous recevez un privilège. Plantez, recrutez, construisez, produisez, vendez et expédiez. Le plus de points grâce aux expéditions, bâtiments et bonus remporte la partie.",
"smugglerRaidHelp": "Prenez jusqu’à 3 marchandises sur un bateau ; remettez le reste dans la réserve.",
"smugglerPlunderHelp": "Remettez toutes les marchandises du comptoir dans la réserve ; gagnez 1 PV par marchandise.",
"smugglerPoachHelp": "Prenez jusqu’à 3 ouvriers excédentaires et placez-les immédiatement."
"smugglerPoachHelp": "Prenez jusqu’à 3 ouvriers excédentaires et placez-les immédiatement.",
"editPlacement": "Modifier le placement",
"editProduction": "Modifier la production"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "भूमिका चुनें: सभी उसकी कार्रवाई करते हैं और आपको विशेषाधिकार मिलता है। बागान लें, भर्ती करें, बनाएँ, उत्पादन करें, व्यापार करें और माल भेजें। माल भेजने, इमारतों और बोनस से सबसे अधिक अंक पाने वाला जीतता है।",
"smugglerRaidHelp": "एक जहाज़ से अधिकतम 3 माल लें; बाकी भंडार में लौटाएँ।",
"smugglerPlunderHelp": "व्यापार गृह का सारा माल भंडार में लौटाएँ; हर माल के लिए 1 विजय अंक पाएँ।",
"smugglerPoachHelp": "अधिकतम 3 अतिरिक्त श्रमिक लें और उन्हें तुरंत तैनात करें।"
"smugglerPoachHelp": "अधिकतम 3 अतिरिक्त श्रमिक लें और उन्हें तुरंत तैनात करें।",
"editPlacement": "तैनाती बदलें",
"editProduction": "उत्पादन बदलें"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Scegli un ruolo: tutti eseguono la sua azione e tu ricevi un privilegio. Pianta, recluta, costruisci, produci, commercia e spedisci. Vince chi ottiene più punti da spedizioni, edifici e bonus.",
"smugglerRaidHelp": "Prendi fino a 3 merci da una nave; rimetti le altre nella riserva.",
"smugglerPlunderHelp": "Rimetti tutte le merci dell’emporio nella riserva; ottieni 1 PV per merce.",
"smugglerPoachHelp": "Prendi fino a 3 lavoratori in eccedenza e collocali subito."
"smugglerPoachHelp": "Prendi fino a 3 lavoratori in eccedenza e collocali subito.",
"editPlacement": "Modifica collocazione",
"editProduction": "Modifica produzione"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "역할을 고르면 모두 그 행동을 하고 선택자는 특권을 받습니다. 경작, 모집, 건설, 생산, 교역, 배송을 하세요. 배송, 건물, 보너스로 가장 많은 점수를 얻으면 승리합니다.",
"smugglerRaidHelp": "배 한 척에서 상품을 최대 3개 가져오고, 나머지는 공급처에 돌려놓습니다.",
"smugglerPlunderHelp": "교역소의 상품을 모두 공급처에 돌려놓고, 상품마다 승점 1점을 얻습니다.",
"smugglerPoachHelp": "남는 일꾼을 최대 3명 가져와 즉시 배치합니다."
"smugglerPoachHelp": "남는 일꾼을 최대 3명 가져와 즉시 배치합니다.",
"editPlacement": "배치 수정",
"editProduction": "생산 수정"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Kies een rol: iedereen voert de actie uit en jij krijgt een privilege. Plant, rekruteer, bouw, produceer, handel en verscheep. De meeste punten uit verscheping, gebouwen en bonussen winnen.",
"smugglerRaidHelp": "Neem maximaal 3 goederen van één schip; leg de rest terug in de voorraad.",
"smugglerPlunderHelp": "Leg alle goederen uit het handelshuis terug in de voorraad; ontvang 1 overwinningspunt per goed.",
"smugglerPoachHelp": "Neem maximaal 3 overtollige arbeiders en plaats ze onmiddellijk."
"smugglerPoachHelp": "Neem maximaal 3 overtollige arbeiders en plaats ze onmiddellijk.",
"editPlacement": "Plaatsing wijzigen",
"editProduction": "Productie wijzigen"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Wybierz rolę: wszyscy wykonują jej akcję, a ty otrzymujesz przywilej. Sadź, werbuj, buduj, produkuj, handluj i wysyłaj. Wygrywa najwięcej punktów za wysyłkę, budynki i premie.",
"smugglerRaidHelp": "Weź do 3 towarów z jednego statku; resztę zwróć do zasobów.",
"smugglerPlunderHelp": "Zwróć wszystkie towary z domu handlowego do zasobów; zdobądź 1 PZ za każdy towar.",
"smugglerPoachHelp": "Weź do 3 nadmiarowych robotników i natychmiast ich rozmieść."
"smugglerPoachHelp": "Weź do 3 nadmiarowych robotników i natychmiast ich rozmieść.",
"editPlacement": "Zmień rozmieszczenie",
"editProduction": "Zmień produkcję"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Escolha um papel: todos realizam a ação e você recebe um privilégio. Plante, recrute, construa, produza, negocie e embarque. Vence quem tiver mais pontos de embarques, edifícios e bônus.",
"smugglerRaidHelp": "Pegue até 3 mercadorias de um navio; devolva o restante à reserva.",
"smugglerPlunderHelp": "Devolva todas as mercadorias da casa de comércio à reserva; ganhe 1 PV por mercadoria.",
"smugglerPoachHelp": "Pegue até 3 trabalhadores excedentes e coloque-os imediatamente."
"smugglerPoachHelp": "Pegue até 3 trabalhadores excedentes e coloque-os imediatamente.",
"editPlacement": "Editar alocação",
"editProduction": "Editar produção"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Alege un rol: toți îi efectuează acțiunea, iar tu primești un privilegiu. Plantează, recrutează, construiește, produce, vinde și expediază. Câștigă cele mai multe puncte din expedieri, clădiri și bonusuri.",
"smugglerRaidHelp": "Ia până la 3 mărfuri de pe o navă; returnează restul în rezervă.",
"smugglerPlunderHelp": "Returnează toate mărfurile din casa de comerț în rezervă; câștigă 1 PV pentru fiecare.",
"smugglerPoachHelp": "Ia până la 3 muncitori excedentari și plasează-i imediat."
"smugglerPoachHelp": "Ia până la 3 muncitori excedentari și plasează-i imediat.",
"editPlacement": "Modifică plasarea",
"editProduction": "Modifică producția"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Выберите роль: все выполняют её действие, а вы получаете привилегию. Создавайте плантации, нанимайте, стройте, производите, торгуйте и отправляйте товары. Побеждает набравший больше очков за отправки, здания и бонусы.",
"smugglerRaidHelp": "Возьмите до 3 товаров с одного корабля; остальные верните в запас.",
"smugglerPlunderHelp": "Верните все товары из торгового дома в запас; получите по 1 ПО за каждый товар.",
"smugglerPoachHelp": "Возьмите до 3 лишних рабочих и сразу разместите их."
"smugglerPoachHelp": "Возьмите до 3 лишних рабочих и сразу разместите их.",
"editPlacement": "Изменить размещение",
"editProduction": "Изменить производство"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Chọn vai trò: mọi người thực hiện hành động, bạn nhận đặc quyền. Trồng trọt, tuyển người, xây dựng, sản xuất, buôn bán và giao hàng. Ai có nhiều điểm nhất từ giao hàng, tòa nhà và thưởng sẽ thắng.",
"smugglerRaidHelp": "Lấy tối đa 3 hàng hóa từ một tàu; trả số còn lại về kho chung.",
"smugglerPlunderHelp": "Trả toàn bộ hàng hóa trong nhà giao dịch về kho chung; nhận 1 điểm chiến thắng cho mỗi hàng hóa.",
"smugglerPoachHelp": "Lấy tối đa 3 công nhân dư và bố trí ngay."
"smugglerPoachHelp": "Lấy tối đa 3 công nhân dư và bố trí ngay.",
"editPlacement": "Sửa cách bố trí",
"editProduction": "Sửa sản xuất"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "Choose a role: all players perform its action, and you receive a privilege. Plant, recruit, build, produce, trade and ship. Most points from shipping, buildings and bonuses wins.",
"smugglerRaidHelp": "从一艘船上拿取至多3份货物;其余归还供应区。",
"smugglerPlunderHelp": "将交易所所有货物归还供应区;每份获得1胜利点。",
"smugglerPoachHelp": "拿取至多3名多余工人并立即放置。"
"smugglerPoachHelp": "拿取至多3名多余工人并立即放置。",
"editPlacement": "修改放置",
"editProduction": "修改生产"
}

View file

@ -595,5 +595,7 @@
"metadata.rules": "選擇角色:所有玩家執行其行動,而你獲得特權。開墾、招募、建造、生產、交易及運輸。運輸、建築與獎勵總分最高者獲勝。",
"smugglerRaidHelp": "從一艘船上拿取最多 3 個貨物,其餘貨物放回供應區。",
"smugglerPlunderHelp": "將交易所內所有貨物放回供應區,每個貨物獲得 1 勝利點。",
"smugglerPoachHelp": "拿取最多 3 名多餘的工人並立即配置。"
"smugglerPoachHelp": "拿取最多 3 名多餘的工人並立即配置。",
"editPlacement": "修改放置",
"editProduction": "修改生產"
}

View file

@ -254,7 +254,7 @@ export function mountGame(
.filter(Boolean)
.join(" · ");
const bonus = rewardPreview(m);
return `<button type="button" class="move ${classes}" data-move="${encode(m)}" ${hint ? `title="${esc(hint)}" ${description ? `aria-label="${esc(hint)}"` : ""}` : ""} ${allowed() || (enabled && !pending && (m.type === "bohio" || (m.type === "undo" && state.canUndo))) ? "" : "disabled"}>${pictogram ? icon(pictogram, 26) : ""}<span>${label}${bonus}</span></button>`;
return `<button type="button" class="move ${classes}" data-move="${encode(m)}" ${hint ? `title="${esc(hint)}" ${description ? `aria-label="${esc(hint)}"` : ""}` : ""} ${allowed() || (enabled && !pending && (m.type === "bohio" || (m.type === "undo" && state.canUndo) || (m.type === "editPlacement" && state.canEditPlacement) || (m.type === "editProduction" && state.canEditProduction))) ? "" : "disabled"}>${pictogram ? icon(pictogram, 26) : ""}<span>${label}${bonus}</span></button>`;
};
function rewardPreview(move) {
const festival = festivalRewards(state, seat, move);
@ -929,7 +929,33 @@ export function mountGame(
state.canUndo && enabled
? moveButton({ type: "undo" }, t("undo"), "undo", "quiet dock-undo")
: "";
const controls = special + undo + choices + confirm + passControl + order;
const edit =
enabled && state.canEditPlacement
? moveButton(
{ type: "editPlacement" },
t("editPlacement"),
"worker",
"quiet dock-edit-placement",
)
: "";
const editProduction =
enabled && state.canEditProduction
? moveButton(
{ type: "editProduction" },
t("editProduction"),
"edit",
"quiet dock-edit-production",
)
: "";
const controls =
special +
undo +
edit +
editProduction +
choices +
confirm +
passControl +
order;
const compact = (controls.match(/<button\b/g)?.length ?? 0) <= 1;
return `<div class="action-dock${compact ? " action-dock-compact" : ""}"><div class="dock-prompt" aria-live="polite">${icon(task?.kind === "role" ? "governor" : (state.role ?? "building"), 26)}<strong>${title()}</strong></div><div class="dock-controls">${controls}</div></div>`;
}
@ -1282,6 +1308,8 @@ export function mountGame(
enabled &&
!pending &&
((m.type === "undo" && state.canUndo) ||
(m.type === "editPlacement" && state.canEditPlacement) ||
(m.type === "editProduction" && state.canEditProduction) ||
(m.type === "bohio" &&
state.legal.some((x) => JSON.stringify(x) === JSON.stringify(m))))
)
@ -1426,9 +1454,12 @@ export function mountGame(
!el.hasAttribute("data-bohio") &&
!(
el.dataset.move &&
["bohio", ...(state.canUndo ? ["undo"] : [])].includes(
JSON.parse(decodeURIComponent(el.dataset.move)).type,
)
[
"bohio",
...(state.canUndo ? ["undo"] : []),
...(state.canEditPlacement ? ["editPlacement"] : []),
...(state.canEditProduction ? ["editProduction"] : []),
].includes(JSON.parse(decodeURIComponent(el.dataset.move)).type)
)
)
return;