Limit role confirmation to Adventurer and existing role warnings

This commit is contained in:
coyotte508 2026-10-31 20:46:08 +01:00
commit 3e9a34eba9
2 changed files with 47 additions and 5 deletions

View file

@ -383,17 +383,56 @@ try {
assert.equal(await overflow(), false);
await page.screenshot({ path: `.local/qa/${width}-role-picker.png` });
await page.keyboard.press("Escape");
// Even safe roles require confirmation; cancelling must not submit a move.
// Recruiter opens its normal action flow without an extra confirmation.
await page.locator('.shared-board [data-role-id="recruiter"]').click();
assert.equal(await page.locator(".action-dock [data-confirm-role]").count(), 1);
assert.equal(await page.locator("dialog[open]").count(), 0);
assert.deepEqual(await page.evaluate(() => played), [
{ type: "role", id: "recruiter" },
]);
assert.equal(await page.locator("[data-confirm-role]").count(), 0);
await page.evaluate(
(s) => {
played = [];
host.emit("state", s);
},
E.stripSecret(original, 0),
);
// Adventurer resolves immediately, so only commit it from the action bar.
let adventurerState = E.init(
4,
RELEASE.expansions,
RELEASE.options,
"adventurer-confirm",
);
while (adventurerState.tasks[0].kind === "draft")
adventurerState = E.moveAI(adventurerState);
await page.evaluate(
(s) => host.emit("state", s),
E.stripSecret(adventurerState, 0),
);
await page.locator('[data-role-id="adventurer"]').click();
assert.deepEqual(await page.evaluate(() => played), []);
assert.equal(await page.locator("dialog[open]").count(), 0);
await page.locator("[data-cancel-role]").click();
assert.deepEqual(await page.evaluate(() => played), []);
await page.locator('[data-role-id="adventurer"]').click();
await page.locator(".action-dock [data-confirm-role]").click();
assert.deepEqual(await page.evaluate(() => played), [
{ type: "role", id: "adventurer" },
]);
await page.evaluate(
(s) => {
played = [];
host.emit("state", s);
},
E.stripSecret(original, 0),
);
const craftsman = page.locator('[data-role-id="craftsman"]');
assert.equal(await craftsman.locator(".role-warning").count(), 1);
await craftsman.click();
assert.equal(await page.locator(".action-dock [data-confirm-role]").count(), 1);
assert.equal(
await page.locator(".action-dock [data-confirm-role]").count(),
1,
);
assert.equal(await page.locator("dialog[open]").count(), 0);
assert.deepEqual(await page.evaluate(() => played), []);
await page.locator("[data-cancel-role]").click();
@ -430,7 +469,6 @@ try {
`.pr-modal [data-move="${encodeURIComponent(JSON.stringify(m))}"]`,
)
.click();
await page.locator(".action-dock [data-confirm-role]").click();
assert.deepEqual(await page.evaluate(() => played.at(-1)), m);
let s = E.move(original, m, 0);
while (s.tasks[0].kind !== "recruit") s = E.moveAI(s);

View file

@ -1107,6 +1107,10 @@ export function mountGame(
}${id === "recruiter" ? `<p>${t("ruleWorkerPool")}</p>` : ""}${id === "trader" ? `<div class="trade-prices"><small>${t("baseSalePrices")}</small><div>${GOODS.map((good, price) => `<span title="${esc(t(good))}">${icon(good, 22)}${icon("arrow", 14)}${metric("coin", price)}</span>`).join("")}</div></div>` : ""}</div>${privilege ? `<div class="role-privilege"><small>${t(solo ? "roleNote" : "privilege")}</small><p>${t.rolePrivilegeHtml(id)}</p></div>` : ""}</article>`;
}
function confirmRole(m) {
// Normal roles already have an action to confirm (and can be undone).
// Adventurer pays immediately; keep its confirmation and existing warnings.
if (!m.id.startsWith("adventurer") && !state.roleWarnings?.[m.id])
return false;
hide(modal);
roleConfirmation = { move: m, seat, historyLength: state.historyLength };
render();