The door can be held open, as both key cards always promised

MASTER KEY and PICK LOCK each read: "You may 'hold the door open' for
others, if you wish" — and the engine always slammed it at end of
turn. Now the cast takes a hold param: the door stays unlocked past
the turn, for anyone, as long as its holder stands adjacent and
alive. A step away, a shove, a teleport, or a killing blow lets it
swing shut — swept after every command, since anything can move a
wizard. New state, new param: no old ledger contains either, so no
rev gate is needed.

The client offers a "hold the door open" checkbox when either card is
selected; a held door shows pale with a green jamb ("held open by a
standing wizard"), and the chronicle records the holding and the
shutting. Pinned: a held door outlives the turn and admits the other
wizard; walking away releases it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Eric Wagoner
2026-08-17 13:15:57 -04:00
co-authored by Claude Fable 5
parent d2b40ec6f8
commit a0c65413ef
6 changed files with 122 additions and 3 deletions
+39 -1
View File
@@ -205,6 +205,8 @@ export interface CastParams {
clockwise?: boolean;
/** MEGA-MONSTER: which stat doubles. */
boost?: "life" | "movement";
/** PICK LOCK / MASTER KEY: hold the door open for others. */
hold?: boolean;
}
export interface GameConfig {
@@ -250,6 +252,10 @@ export interface GameState {
doorStates: Record<string, "jammed" | "removed">;
/** Door edges unlocked until the end of the current turn. */
openDoorEdges: string[];
/** Doors physically HELD open ("You may 'hold the door open' for others"
* — MASTER KEY, PICK LOCK): unlocked past end of turn, until the holder
* steps out of adjacency or falls. */
heldDoors: { key: string; by: PlayerId; cell: Cell; side: Side }[];
/** Walls/firewalls conjured during play (dispellable), by edge key. */
createdEdges: Record<string, true>;
/** Square-filling creations, by cell key. */
@@ -573,6 +579,8 @@ export type GameEvent =
| { type: "wallDestroyed"; caster: PlayerId; edge: { cell: Cell; side: Side }; wasDoor: boolean }
| { type: "wallDamaged"; player: PlayerId; edge: { cell: Cell; side: Side }; amount: number; total: number; needed: number; source: string }
| { type: "doorUnlocked"; player: PlayerId; edge: { cell: Cell; side: Side }; withCardId: string }
| { type: "doorHeld"; player: PlayerId; edge: { cell: Cell; side: Side } }
| { type: "doorReleased"; edge: { cell: Cell; side: Side } }
| { type: "doorsRelocked"; count: number }
| { type: "doorJammed"; player: PlayerId; edge: { cell: Cell; side: Side } }
| { type: "lockRemoved"; player: PlayerId; edge: { cell: Cell; side: Side } }
@@ -2798,6 +2806,10 @@ function remapState(
state.doorStates = remapRecord(state.doorStates, mapEdgeKey);
state.illusionWalls = remapRecord(state.illusionWalls, mapEdgeKey);
state.openDoorEdges = state.openDoorEdges.map(mapEdgeKey);
for (const h of state.heldDoors) {
h.key = mapEdgeKey(h.key);
if (inSector(h.cell)) h.cell = mapCell(h.cell);
}
state.squareContents = remapRecord(state.squareContents, mapCellKey);
state.slimeTraps = remapRecord(state.slimeTraps, mapCellKey);
state.groundObjects = remapRecord(state.groundObjects, mapCellKey);
@@ -2967,9 +2979,27 @@ function unlockDoor(
}
if (!state.openDoorEdges.includes(key)) state.openDoorEdges.push(key);
events.push({ type: "doorUnlocked", player: caster.id, edge: found, withCardId: cardId });
if (cmd.params?.hold) {
if (!state.heldDoors.some((h) => h.key === key)) {
state.heldDoors.push({ key, by: caster.id, cell: found.cell, side: found.side });
}
events.push({ type: "doorHeld", player: caster.id, edge: found });
}
return null;
}
/** A held door needs its holder: standing adjacent and alive. Anything that
* moves or fells them — a step, a shove, a teleport, a killing blow — lets
* the door swing shut. */
function sweepHeldDoors(state: GameState, events: GameEvent[]): void {
for (const h of [...state.heldDoors]) {
const holder = state.players.find((p) => p.id === h.by);
if (holder?.alive && isAdjacentToEdge(holder.position, h.cell, h.side)) continue;
state.heldDoors = state.heldDoors.filter((x) => x !== h);
events.push({ type: "doorReleased", edge: { cell: h.cell, side: h.side } });
}
}
function attachSustained(
state: GameState,
events: GameEvent[],
@@ -3131,6 +3161,7 @@ export function createGame(config: GameConfig): { state: GameState; events: Game
chaosPending: null,
doorStates: {},
openDoorEdges: [],
heldDoors: [],
createdEdges: {},
squareContents: {},
groundObjects: {},
@@ -3191,6 +3222,12 @@ export function createGame(config: GameConfig): { state: GameState; events: Game
// Command application
export function applyCommand(state: GameState, playerId: PlayerId, command: Command): CommandResult {
const result = applyCommandInner(state, playerId, command);
if (result.ok) sweepHeldDoors(result.state, result.events);
return result;
}
function applyCommandInner(state: GameState, playerId: PlayerId, command: Command): CommandResult {
if (state.phase !== "playing") return err("game is over");
if (state.pendingDiscard) {
@@ -3439,7 +3476,8 @@ function doMove(prev: GameState, direction: Side, over = false): CommandResult {
if (isBlinded(state, p)) return blindBump(state, events, p, direction);
return err("blocked");
}
if (edge === "door" && (state.doorStates[key] === "removed" || state.openDoorEdges.includes(key))) {
if (edge === "door" && (state.doorStates[key] === "removed" || state.openDoorEdges.includes(key) ||
state.heldDoors.some((h) => h.key === key))) {
p.position = dest;
via = "step";
} else if (edge === "firewall") {