Two treasures, one square: the taker names their prize
pickUpTreasure grabbed whichever treasure the list offered first — with two on a square, no choice and sometimes the wrong one. The command now takes an optional treasureId (absent in every stored ledger, so old replays keep their old grab), and when the square holds more than one, the button asks "whose?" before dispatching. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
794b809a1b
commit
aef88d892a
@@ -313,6 +313,7 @@
|
||||
selectedCard = null;
|
||||
megaBoost = "life";
|
||||
holdDoor = false;
|
||||
pickChoice = false;
|
||||
pendingTeleport = null;
|
||||
attachedNumber = null;
|
||||
attachedMods = [];
|
||||
@@ -821,11 +822,26 @@
|
||||
dispatch({ type: "endTurn", draw: drawCount });
|
||||
}
|
||||
|
||||
function pickUp() { dispatch({ type: "pickUpTreasure" }); }
|
||||
let pickChoice = $state(false);
|
||||
function pickUp() {
|
||||
if (treasuresHere.length > 1) { pickChoice = true; return; }
|
||||
dispatch({ type: "pickUpTreasure" });
|
||||
}
|
||||
function pickUpNamed(treasureId: string) {
|
||||
pickChoice = false;
|
||||
dispatch({ type: "pickUpTreasure", treasureId });
|
||||
}
|
||||
function drop() { dispatch({ type: "dropTreasure" }); }
|
||||
function pass() { dispatch({ type: "pass" }); }
|
||||
|
||||
const me = $derived(view?.players.find((p) => p.id === view?.you) ?? null);
|
||||
/** Two treasures can share a square: one dispatches, more ask whose. */
|
||||
const treasuresHere = $derived(
|
||||
view && me
|
||||
? view.treasures.filter((t) => t.position && t.position.x === me.position.x &&
|
||||
t.position.y === me.position.y && !t.carriedBy)
|
||||
: [],
|
||||
);
|
||||
const carryingTreasure = $derived(me?.carriedTreasureId != null);
|
||||
const treasureHere = $derived(
|
||||
view != null && me != null &&
|
||||
@@ -1659,6 +1675,15 @@
|
||||
{#if isYourTurn}
|
||||
<button class="stamp" disabled={!treasureHere || carryingTreasure || view.turn.actionsEnded}
|
||||
onclick={pickUp}>Pick up treasure</button>
|
||||
{#if pickChoice}
|
||||
<span class="pick-which">
|
||||
— whose?
|
||||
{#each treasuresHere as t (t.id)}
|
||||
<button class="stamp tiny" onclick={() => pickUpNamed(t.id)}>{t.owner}'s</button>
|
||||
{/each}
|
||||
<button class="hint-cancel" onclick={() => (pickChoice = false)}>never mind</button>
|
||||
</span>
|
||||
{/if}
|
||||
<button class="stamp" disabled={!carryingTreasure} onclick={drop}>Drop treasure</button>
|
||||
{#each objectsHere as obj (obj.instanceId)}
|
||||
<button class="stamp" disabled={view.turn.actionsEnded}
|
||||
|
||||
Reference in New Issue
Block a user