Expansion wave 2: the magic wand system, plus Deja-Vu
Wands charge on first use from the number card(s) played (Amplify and Add both work when setting charges), spend one charge per use with a hard once-per-turn limit, stay displayed while charged, and crumble to the discard when the last charge goes. They are isolated from their wielder — usable under NO SPELL — and Absorb Spell cannot eat them. BLASTER WAND fires 3-point bolts through the normal counteraction stack; STICKY WAND webs its victim (movement -3 for a turn, +2 to any fire damage, including hotter firewall crossings); SHIFT WAND shoves a wizard one space in any direction straight through stone walls; WARP WAND opens a wall section that snaps back at the end of the turn. DEJA-VU retrieves any discard except a wand. The wands' 5e-era "stick" subtype is renamed "wand" per Eric (the 6e faces say Wand; Exp2 shelf cards keep their period names). Client: charge badges, shove targeting, retrieve-by-name. 101 tests passing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
df0675c735
commit
28949bdb7d
+185
-6
@@ -121,6 +121,8 @@ export interface TurnState {
|
||||
attackUsed: boolean;
|
||||
/** ADRENALINE's second attack, once spent. */
|
||||
secondAttackUsed: boolean;
|
||||
/** Wand instances already used this turn ("maximum of once per turn"). */
|
||||
wandsUsed: string[];
|
||||
/** SLOW: "his attacks [reduce] to every other turn". */
|
||||
attackForbidden: boolean;
|
||||
actionsEnded: boolean;
|
||||
@@ -179,6 +181,10 @@ export interface GameState {
|
||||
illusionWalls: Record<string, { createdBy: PlayerId; belief: Record<PlayerId, "believes" | "seesThrough"> }>;
|
||||
creatures: CreatureState[];
|
||||
nextCreatureId: number;
|
||||
/** Remaining charges per wand card instance (set on first use). */
|
||||
wandCharges: Record<string, number>;
|
||||
/** WARP WAND: walls opened for this turn only, with their prior state. */
|
||||
tempWarpEdges: { key: string; prior: EdgeState | null }[];
|
||||
players: PlayerState[];
|
||||
treasures: TreasureState[];
|
||||
sustained: SustainedEffect[];
|
||||
@@ -402,6 +408,14 @@ export type GameEvent =
|
||||
| { type: "shadowUpkeep"; player: PlayerId; lifeAfter: number }
|
||||
| { type: "impScorches"; creatureId: string; player: PlayerId }
|
||||
| { type: "monsterBoosted"; creatureId: string; boost: "life" | "movement" }
|
||||
| { type: "wandCharged"; player: PlayerId; card: CardInstance; charges: number }
|
||||
| { type: "wandUsed"; player: PlayerId; cardId: string; chargesLeft: number }
|
||||
| { type: "wandExhausted"; player: PlayerId; card: CardInstance }
|
||||
| { type: "wallWarpedOpen"; player: PlayerId; edge: { cell: Cell; side: Side } }
|
||||
| { type: "wallsWarpedBack"; count: number }
|
||||
| { type: "shoved"; player: PlayerId; from: Cell; to: Cell; by: PlayerId }
|
||||
| { type: "webbed"; player: PlayerId }
|
||||
| { type: "cardRetrieved"; player: PlayerId; cardId: string }
|
||||
| { type: "wallDestroyed"; caster: PlayerId; edge: { cell: Cell; side: Side }; wasDoor: boolean }
|
||||
| { type: "doorUnlocked"; player: PlayerId; edge: { cell: Cell; side: Side }; withCardId: string }
|
||||
| { type: "doorsRelocked"; count: number }
|
||||
@@ -1340,6 +1354,90 @@ const CARD_EFFECTS: Record<string, AttackEffect | NeutralEffect | CounterEffect>
|
||||
return null;
|
||||
},
|
||||
},
|
||||
// --- Expansion #1: magic wands -------------------------------------------
|
||||
"blaster-wand": {
|
||||
kind: "attack",
|
||||
requiresLos: true,
|
||||
keepInHand: true,
|
||||
// "does 3 points of magical damage per charge"
|
||||
baseDamage: () => 3,
|
||||
},
|
||||
"sticky-wand": {
|
||||
kind: "attack",
|
||||
requiresLos: true,
|
||||
keepInHand: true,
|
||||
baseDamage: () => 0,
|
||||
onResolved: (ctx) => {
|
||||
if (ctx.fullyStopped || !ctx.defender.alive) return;
|
||||
// "reducing movement by 3 ... Lasts one turn. Any fire damage done to
|
||||
// player in webs causes two extra points."
|
||||
attachSustained(ctx.state, ctx.events, "sticky-web", ctx.attacker.id, ctx.defender.id, 1);
|
||||
ctx.events.push({ type: "webbed", player: ctx.defender.id });
|
||||
},
|
||||
},
|
||||
"shift-wand": {
|
||||
kind: "attack",
|
||||
requiresLos: true,
|
||||
keepInHand: true,
|
||||
baseDamage: () => 0,
|
||||
validate: (state, cmd) => {
|
||||
const cell = cmd.params?.cell;
|
||||
if (!cell) return "choose the adjacent space to shove them into";
|
||||
if (!boardView(state).cells[cellKey(cell)]) return "off the board";
|
||||
if (state.squareContents[cellKey(cell)]?.kind === "stone") return "that square is solid stone";
|
||||
return null;
|
||||
},
|
||||
onResolved: (ctx) => {
|
||||
if (ctx.fullyStopped || !ctx.defender.alive) return;
|
||||
if (isLockedInPlace(ctx.state, ctx.defender.id)) return;
|
||||
const to = ctx.stack.params!.cell!;
|
||||
const from = ctx.defender.position;
|
||||
const dist = Math.abs(to.x - from.x) + Math.abs(to.y - from.y);
|
||||
if (dist !== 1) return; // must be adjacent to where they stand
|
||||
// "he could be shoved through a stone wall" — walls do not stop it.
|
||||
ctx.defender.position = to;
|
||||
ctx.events.push({ type: "shoved", player: ctx.defender.id, from, to, by: ctx.attacker.id });
|
||||
},
|
||||
},
|
||||
"warp-wand": {
|
||||
kind: "neutral",
|
||||
keepInHand: true,
|
||||
// "makes 1 section (one space long) of wall disappear during your turn,
|
||||
// reappearing at the end of your turn."
|
||||
resolve: (state, events, caster, cmd) => {
|
||||
if (!cmd.target || cmd.target.kind !== "edge") return "aim the wand at a wall section";
|
||||
const { cell, side } = cmd.target;
|
||||
const key = edgeKey(cell, side);
|
||||
const view = boardView(state);
|
||||
if ((view.edges[key] ?? "open") !== "wall") return "that is not a wall";
|
||||
if (!losToEdge(view, caster.position, cell, side)) return "no line of sight";
|
||||
state.tempWarpEdges.push({ key, prior: state.edgeOverrides[key] ?? null });
|
||||
state.edgeOverrides[key] = "open";
|
||||
events.push({ type: "wallWarpedOpen", player: caster.id, edge: { cell, side } });
|
||||
return null;
|
||||
},
|
||||
},
|
||||
"deja-vu": {
|
||||
kind: "neutral",
|
||||
// "Retrieve any one card from the discard pile (except a MAGIC WAND)."
|
||||
resolve: (state, events, caster, cmd) => {
|
||||
const wanted = cmd.params?.cardId;
|
||||
if (!wanted) return "name the card to retrieve";
|
||||
if (["blaster-wand", "sticky-wand", "shift-wand", "warp-wand"].includes(wanted)) {
|
||||
return "deja-vu cannot retrieve a magic wand";
|
||||
}
|
||||
for (let i = state.discard.length - 1; i >= 0; i--) {
|
||||
if (state.discard[i]!.cardId === wanted) {
|
||||
const [card] = state.discard.splice(i, 1);
|
||||
caster.hand.push(card!);
|
||||
events.push({ type: "cardRetrieved", player: caster.id, cardId: wanted });
|
||||
if (caster.hand.length > handLimit(caster)) state.pendingDiscard = caster.id;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return "that card is not in the discard pile";
|
||||
},
|
||||
},
|
||||
"reuse-spell": {
|
||||
kind: "neutral",
|
||||
// "You may retrieve any spell you use immediately after you use it (but
|
||||
@@ -1995,6 +2093,8 @@ export function createGame(config: GameConfig): { state: GameState; events: Game
|
||||
illusionWalls: {},
|
||||
creatures: [],
|
||||
nextCreatureId: 1,
|
||||
wandCharges: {},
|
||||
tempWarpEdges: [],
|
||||
players,
|
||||
treasures,
|
||||
sustained: [],
|
||||
@@ -2009,6 +2109,7 @@ export function createGame(config: GameConfig): { state: GameState; events: Game
|
||||
numberPlayedForMovement: false,
|
||||
attackUsed: false,
|
||||
secondAttackUsed: false,
|
||||
wandsUsed: [],
|
||||
attackForbidden: false,
|
||||
actionsEnded: false,
|
||||
},
|
||||
@@ -2190,7 +2291,8 @@ function doMove(prev: GameState, direction: Side): CommandResult {
|
||||
|
||||
if (crossedFirewall) {
|
||||
events.push({ type: "firewallBurned", player: p.id });
|
||||
applyDamage(state, events, p, 4, "wall of fire", null);
|
||||
const webbed = sustainedOn(state, p.id, "sticky-web").length > 0;
|
||||
applyDamage(state, events, p, webbed ? 6 : 4, "wall of fire", null);
|
||||
checkVictory(state, events);
|
||||
}
|
||||
|
||||
@@ -2426,8 +2528,13 @@ function consumeCast(
|
||||
mods: CastConsumables,
|
||||
keepInHand: boolean,
|
||||
): void {
|
||||
// (Wand cards manage their own lifetime via charges — callers pass
|
||||
// keepInHand=true for them and never discard here.)
|
||||
if (keepInHand) {
|
||||
if (!caster.displayed.includes(card.instanceId)) caster.displayed.push(card.instanceId);
|
||||
if (caster.hand.some((c) => c.instanceId === card.instanceId) &&
|
||||
!caster.displayed.includes(card.instanceId)) {
|
||||
caster.displayed.push(card.instanceId);
|
||||
}
|
||||
} else {
|
||||
takeFromHand(caster, card.instanceId);
|
||||
state.discard.push(card);
|
||||
@@ -2458,13 +2565,23 @@ function doCast(prev: GameState, cmd: Extract<Command, { type: "cast" }>): Comma
|
||||
return err(`${def.name} is already displayed`);
|
||||
}
|
||||
|
||||
// Magic wands: charged on first use by the number card(s) played; one
|
||||
// charge per use, one use per turn; discarded when the last charge goes.
|
||||
const WANDS = new Set(["blaster-wand", "sticky-wand", "shift-wand", "warp-wand"]);
|
||||
const isWand = WANDS.has(inHand.cardId);
|
||||
if (isWand && state.turn.wandsUsed.includes(inHand.instanceId)) {
|
||||
return err("any wand operates a maximum of once per turn");
|
||||
}
|
||||
|
||||
// "Some cards involve physical actions, like picking locks, removing
|
||||
// locks, jamming locks, and throwing daggers. These are not spells."
|
||||
// (PICK LOCK's 6e face: "This is not a spell.")
|
||||
const NOT_SPELLS = new Set([
|
||||
"pick-lock", "master-key", "jam-lock", "remove-lock", "dagger", "large-rock",
|
||||
]);
|
||||
const isSpell = def.cardType !== "object" && !NOT_SPELLS.has(inHand.cardId);
|
||||
// "This isolation of the wand from you allows you to use it even with
|
||||
// NO SPELL cast on you."
|
||||
const isSpell = def.cardType !== "object" && !NOT_SPELLS.has(inHand.cardId) && !isWand;
|
||||
if (isSpell) {
|
||||
const castBlock = castingBlocked(state, caster.id);
|
||||
if (castBlock) return err(castBlock);
|
||||
@@ -2475,6 +2592,32 @@ function doCast(prev: GameState, cmd: Extract<Command, { type: "cast" }>): Comma
|
||||
const mods = gatherModifiers(caster, cmd);
|
||||
if (typeof mods === "string") return err(mods);
|
||||
|
||||
/** Set charges on first use, spend one, discard the wand when empty. */
|
||||
const spendWandCharge = (st: GameState, wielder: PlayerState, events: GameEvent[]): string | null => {
|
||||
if (!isWand) return null;
|
||||
let charges = st.wandCharges[inHand.instanceId];
|
||||
if (charges === undefined) {
|
||||
if (mods.numbers.length === 0) return "a wand's first use needs a number card to set its charges";
|
||||
charges = mods.magnitude.power; // AMPLIFY and ADD both work here
|
||||
st.wandCharges[inHand.instanceId] = charges;
|
||||
if (!wielder.displayed.includes(inHand.instanceId)) wielder.displayed.push(inHand.instanceId);
|
||||
events.push({ type: "wandCharged", player: wielder.id, card: inHand, charges });
|
||||
}
|
||||
charges -= 1;
|
||||
st.turn.wandsUsed.push(inHand.instanceId);
|
||||
if (charges <= 0) {
|
||||
delete st.wandCharges[inHand.instanceId];
|
||||
takeFromHand(wielder, inHand.instanceId);
|
||||
st.discard.push(inHand);
|
||||
events.push({ type: "wandUsed", player: wielder.id, cardId: inHand.cardId, chargesLeft: 0 });
|
||||
events.push({ type: "wandExhausted", player: wielder.id, card: inHand });
|
||||
} else {
|
||||
st.wandCharges[inHand.instanceId] = charges;
|
||||
events.push({ type: "wandUsed", player: wielder.id, cardId: inHand.cardId, chargesLeft: charges });
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
if (effect.kind === "attack") {
|
||||
const pre = attackPreconditions(state);
|
||||
if (pre) return err(pre);
|
||||
@@ -2489,11 +2632,16 @@ function doCast(prev: GameState, cmd: Extract<Command, { type: "cast" }>): Comma
|
||||
if (effect.requiresLos && !casterLos(state, caster, caster.position, creature.position)) {
|
||||
return err("no line of sight to the creature");
|
||||
}
|
||||
const wandEvents: GameEvent[] = [];
|
||||
{
|
||||
const werr = spendWandCharge(state, caster, wandEvents);
|
||||
if (werr) return err(werr);
|
||||
}
|
||||
consumeCast(state, caster, inHand, mods, effect.keepInHand ?? false);
|
||||
if (state.turn.attackUsed) state.turn.secondAttackUsed = true;
|
||||
state.turn.attackUsed = true;
|
||||
state.lastSpellUsed[caster.id] = inHand.cardId;
|
||||
const events: GameEvent[] = [{
|
||||
const events: GameEvent[] = [...wandEvents, {
|
||||
type: "spellCast", caster: caster.id, card: inHand, cardId: inHand.cardId,
|
||||
numberCards: mods.numbers, numberValue: mods.magnitude.numberValue,
|
||||
from: caster.position, target: null, targetCell: creature.position,
|
||||
@@ -2544,6 +2692,12 @@ function doCast(prev: GameState, cmd: Extract<Command, { type: "cast" }>): Comma
|
||||
}
|
||||
}
|
||||
|
||||
const wandEvents: GameEvent[] = [];
|
||||
{
|
||||
const werr = spendWandCharge(state, caster, wandEvents);
|
||||
if (werr) return err(werr);
|
||||
}
|
||||
|
||||
// BLIND: casts at others fly in a rolled direction. "Misdirected spells
|
||||
// go intended distance" — if the die disagrees with the true direction,
|
||||
// the spell hits whoever lies that way, or dissipates.
|
||||
@@ -2569,7 +2723,7 @@ function doCast(prev: GameState, cmd: Extract<Command, { type: "cast" }>): Comma
|
||||
consumeCast(state, caster, inHand, mods, effect.keepInHand ?? false);
|
||||
state.turn.attackUsed = true;
|
||||
state.lastSpellUsed[caster.id] = inHand.cardId;
|
||||
const missEvents: GameEvent[] = [...preEvents, {
|
||||
const missEvents: GameEvent[] = [...wandEvents, ...preEvents, {
|
||||
type: "attackMisdirected", attacker: caster.id, intended: target.id,
|
||||
rolledDirection: rolled, newTarget: along?.id ?? null,
|
||||
}];
|
||||
@@ -2613,7 +2767,7 @@ function doCast(prev: GameState, cmd: Extract<Command, { type: "cast" }>): Comma
|
||||
waitingOn: target.id,
|
||||
};
|
||||
state.lastSpellUsed[caster.id] = inHand.cardId;
|
||||
const events: GameEvent[] = [...preEvents];
|
||||
const events: GameEvent[] = [...wandEvents, ...preEvents];
|
||||
if (mods.aroundCorner) events.push({ type: "castAroundCorner", caster: caster.id });
|
||||
events.push({
|
||||
type: "spellCast",
|
||||
@@ -2650,6 +2804,10 @@ function doCast(prev: GameState, cmd: Extract<Command, { type: "cast" }>): Comma
|
||||
);
|
||||
if (problem) return err(problem);
|
||||
|
||||
if (isWand) {
|
||||
const werr = spendWandCharge(state, caster, events);
|
||||
if (werr) return err(werr);
|
||||
}
|
||||
consumeCast(state, caster, inHand, mods, effect.keepInHand ?? false);
|
||||
if (effect.keepInHand) {
|
||||
events.push({ type: "cardDisplayed", player: caster.id, card: inHand });
|
||||
@@ -2678,6 +2836,9 @@ function doCounteract(prev: GameState, playerId: PlayerId, instanceId: string):
|
||||
if (playerId === stack.defenderId) {
|
||||
if (card.cardId === "absorb-spell") {
|
||||
if (stack.kind !== "spell") return err("absorb spell only works against spells");
|
||||
if (stack.attackCard && ["blaster-wand", "sticky-wand", "shift-wand", "warp-wand"].includes(stack.attackCard.cardId)) {
|
||||
return err("Absorb Spell has no effect on magic wands");
|
||||
}
|
||||
takeFromHand(player, instanceId);
|
||||
state.discard.push(card);
|
||||
const attackCard = stack.attackCard!;
|
||||
@@ -2809,6 +2970,10 @@ function resolveStack(state: GameState, events: GameEvent[]): void {
|
||||
}
|
||||
|
||||
let base = effect ? effect.baseDamage(stack.numberValue, stack.params) : 1; // punch = 1
|
||||
// Webs burn: "Any fire damage done to player in webs causes two extra points."
|
||||
if (attackId === "fireball" && sustainedOn(state, defender.id, "sticky-web").length > 0) {
|
||||
base += 2;
|
||||
}
|
||||
// STONE DEAD: number x the stones the defender carries.
|
||||
if (attackId === "stone-dead") {
|
||||
base = (stack.numberValue ?? 1) * defender.hand.filter((c) => isMagicStone(c.cardId)).length;
|
||||
@@ -3233,6 +3398,9 @@ function beginTurnFor(state: GameState, events: GameEvent[], index: number): voi
|
||||
let allowance = BASE_MOVEMENT;
|
||||
if (sustainedOn(state, player.id, "shrink").length > 0) allowance = Math.min(allowance, 2);
|
||||
if (displays(player, "speedstone")) allowance += 1;
|
||||
// STICKY WAND webs: "reducing movement by 3 (enemy can still use NUMBER
|
||||
// cards for additional movement)."
|
||||
allowance = Math.max(0, allowance - 3 * sustainedOn(state, player.id, "sticky-web").length);
|
||||
const slows = sustainedOn(state, player.id, "slow");
|
||||
if (slows.length > 0) allowance = 1;
|
||||
|
||||
@@ -3253,6 +3421,7 @@ function beginTurnFor(state: GameState, events: GameEvent[], index: number): voi
|
||||
numberPlayedForMovement: false,
|
||||
attackUsed: false,
|
||||
secondAttackUsed: false,
|
||||
wandsUsed: [],
|
||||
attackForbidden,
|
||||
actionsEnded: false,
|
||||
};
|
||||
@@ -3296,6 +3465,16 @@ function doEndTurn(prev: GameState, draw: number): CommandResult {
|
||||
}
|
||||
}
|
||||
|
||||
// WARP WAND: opened walls reappear at the end of the turn.
|
||||
if (state.tempWarpEdges.length > 0) {
|
||||
for (const t of state.tempWarpEdges) {
|
||||
if (t.prior === null) delete state.edgeOverrides[t.key];
|
||||
else state.edgeOverrides[t.key] = t.prior;
|
||||
}
|
||||
events.push({ type: "wallsWarpedBack", count: state.tempWarpEdges.length });
|
||||
state.tempWarpEdges = [];
|
||||
}
|
||||
|
||||
// Doors unlocked this turn relock ("the door will relock behind you").
|
||||
if (state.openDoorEdges.length > 0) {
|
||||
events.push({ type: "doorsRelocked", count: state.openDoorEdges.length });
|
||||
|
||||
@@ -54,6 +54,8 @@ export interface GameView {
|
||||
/** Illusion edges YOU know are fake (creator or saw through); others see walls. */
|
||||
knownIllusionEdges: string[];
|
||||
creatures: CreatureState[];
|
||||
/** Charges left on displayed wands (public), by card instance id. */
|
||||
wandCharges: Record<string, number>;
|
||||
}
|
||||
|
||||
export function viewFor(state: GameState, playerId: PlayerId): GameView {
|
||||
@@ -106,5 +108,6 @@ export function viewFor(state: GameState, playerId: PlayerId): GameView {
|
||||
openDoorEdges: [...state.openDoorEdges],
|
||||
knownIllusionEdges,
|
||||
creatures: state.creatures.map((c) => ({ ...c, scorchedThisTurn: [...c.scorchedThisTurn] })),
|
||||
wandCharges: { ...state.wandCharges },
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user