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
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyCommand, activePlayer, boardView, gameLos, sustainedOn } from "../src/game";
|
||||
import { applyCommand, activePlayer, boardView, createGame, gameLos, sustainedOn } from "../src/game";
|
||||
import { cellKey, edgeKey, neighbor, SIDES } from "../src/board";
|
||||
import type { CardInstance } from "../src/cards";
|
||||
import { newGame, must, giveCard, toRound2, faceOff, castAt, emptyNeighborCell } from "./helpers";
|
||||
@@ -277,3 +277,17 @@ describe("control effects", () => {
|
||||
expect(state.players.find((p) => p.id === me.id)!.hand.some((c) => c.cardId === "create-wall")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("picking one of two treasures", () => {
|
||||
it("a named treasure is the one taken", () => {
|
||||
let { state } = createGame({ playerIds: ["a", "b"], seed: 42, sets: ["basic"], deckRev: 16 });
|
||||
state = toRound2(state);
|
||||
const p = activePlayer(state);
|
||||
const [t1, t2] = state.treasures.filter((t) => t.owner !== p.id);
|
||||
t1!.position = { ...p.position }; t1!.carriedBy = null;
|
||||
t2!.position = { ...p.position }; t2!.carriedBy = null;
|
||||
const r = applyCommand(state, p.id, { type: "pickUpTreasure", treasureId: t2!.id });
|
||||
if (!r.ok) throw new Error(r.error);
|
||||
expect(r.state.players.find((q) => q.id === p.id)!.carriedTreasureId).toBe(t2!.id);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user