Require dice selection before enabling Torch
This commit is contained in:
parent
b822d13c9e
commit
bb3b8564da
2 changed files with 26 additions and 2 deletions
|
|
@ -731,7 +731,11 @@
|
|||
{#if ["shovel", "torch", "tape", "machete", "compass", "map"].includes(actionTool ?? "")}<p
|
||||
class="muted small"
|
||||
>
|
||||
Select {actionTool === "machete" ? "one or two dice" : "the dice"} below the map. {dice.length} selected.
|
||||
Select {actionTool === "machete"
|
||||
? "one or two dice"
|
||||
: actionTool === "torch"
|
||||
? "one or more dice to reroll"
|
||||
: "the dice"} below the map. {dice.length} selected.
|
||||
</p>{/if}
|
||||
{#if actionTool === "shovel"}<label class="field"
|
||||
>New value<select bind:value={turnFace}
|
||||
|
|
@ -751,7 +755,8 @@
|
|||
s.phase === "planning" ? 2 : s.phase === "equipment" ? 4 : -1
|
||||
) ||
|
||||
!!s.pending ||
|
||||
(actionTool === "machete" && (dice.length < 1 || dice.length > 2))}
|
||||
(actionTool === "machete" && (dice.length < 1 || dice.length > 2)) ||
|
||||
(actionTool === "torch" && dice.length === 0)}
|
||||
onclick={confirmTool}>Use {info.name}</button
|
||||
>
|
||||
{#if hasSkill(me, "manager")}<label class="field"
|
||||
|
|
|
|||
|
|
@ -122,6 +122,25 @@ import path from "node:path";
|
|||
if (await page.locator(".tool-form").count()) throw Error("Discarded equipment left a stale action panel");
|
||||
if (await machete.count()) throw Error("Discarded machete remains usable");
|
||||
if (s.players[0].cards.some((c) => c.id === "machete")) throw Error("Machete was not consumed");
|
||||
const torchState = structuredClone(s);
|
||||
torchState.phase = "planning";
|
||||
torchState.players[0].cards = [{ id: "torch", used: 0, availableRound: 0 }];
|
||||
await page.evaluate((v) => window.bridge.emit("state", v), stripSecret(torchState, 0));
|
||||
await page.locator(".equipment-list button").filter({ hasText: "Torch" }).click();
|
||||
const torch = page.getByRole("button", { name: "Use Torch", exact: true });
|
||||
if (!(await torch.isDisabled())) throw Error("Torch needs at least one selected die");
|
||||
await page.getByText(/Select one or more dice to reroll below the map/).waitFor();
|
||||
const selectableDie = page.locator(".personal .die:not([disabled])").first();
|
||||
await selectableDie.click();
|
||||
if (!(await torch.isEnabled())) throw Error("Torch should accept one selected die");
|
||||
await selectableDie.click();
|
||||
if (!(await torch.isDisabled())) throw Error("Deselecting all dice must disable Torch again");
|
||||
await selectableDie.click();
|
||||
await torch.click();
|
||||
const torchMove = await page.evaluate(() => window.captured.findLast((e) => e.name === "move")?.payload);
|
||||
const torchResult = applyMove(torchState, torchMove, 0);
|
||||
if (torchResult.players[0].cards.length) throw Error("Torch should be consumed after a valid reroll");
|
||||
|
||||
s.phase = "movement";
|
||||
s.activeResolution = null;
|
||||
s.players[1].powerBars = 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue