Rev 14: elimination sweeps the board by either door
Two ways out of the game, one cleanup. A wizard killed by damage took their monsters, sustained spells, and armed ambushes with them; a wizard eliminated by treasure loss left everything standing — a fire imp scorching for a dead master, a Medusa still gazing at a corpse. Both paths now share one sweep, gated at rev 14 so stored games keep their orphans acting as recorded. Also: Lifesaver lasts until used, carried as a near-billion-turn sentinel — which the scoresheet printed. Durations that mean forever no longer show a number. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
a60467c6fc
commit
d4565006bc
@@ -3335,6 +3335,17 @@ function clone(state: GameState): GameState {
|
||||
return structuredClone(state);
|
||||
}
|
||||
|
||||
/** Everything an eliminated wizard leaves behind goes with them.
|
||||
* "If you die, any monster controlled by you immediately disappears." */
|
||||
function sweepEliminated(state: GameState, playerId: PlayerId): void {
|
||||
state.sustained = state.sustained.filter((s) => s.targetId !== playerId && s.casterId !== playerId);
|
||||
state.creatures = state.creatures.filter((c) => c.controllerId !== playerId);
|
||||
for (const a of state.ambushes.filter((a) => a.ownerId === playerId)) {
|
||||
state.discard.push(a.via, a.spell, ...a.numbers);
|
||||
}
|
||||
state.ambushes = state.ambushes.filter((a) => a.ownerId !== playerId);
|
||||
}
|
||||
|
||||
function requireActionsAvailable(state: GameState): string | null {
|
||||
if (state.turn.actionsEnded) return "your turn's actions ended when you picked up an object";
|
||||
return null;
|
||||
@@ -5094,13 +5105,7 @@ function applyDamage(
|
||||
target.finalHand = [...target.hand];
|
||||
events.push({ type: "died", player: target.id, killedBy: attackerId });
|
||||
events.push({ type: "playerEliminated", player: target.id, reason: "killed" });
|
||||
state.sustained = state.sustained.filter((s) => s.targetId !== target.id && s.casterId !== target.id);
|
||||
// "If you die, any monster controlled by you immediately disappears."
|
||||
state.creatures = state.creatures.filter((c) => c.controllerId !== target.id);
|
||||
for (const a of state.ambushes.filter((a) => a.ownerId === target.id)) {
|
||||
state.discard.push(a.via, a.spell, ...a.numbers);
|
||||
}
|
||||
state.ambushes = state.ambushes.filter((a) => a.ownerId !== target.id);
|
||||
sweepEliminated(state, target.id);
|
||||
|
||||
if (target.carriedTreasureId) {
|
||||
const t = state.treasures.find((t) => t.id === target.carriedTreasureId)!;
|
||||
@@ -5281,6 +5286,7 @@ function checkVictory(state: GameState, events: GameEvent[]): void {
|
||||
state.discard.push(...p.hand.splice(0));
|
||||
p.displayed = [];
|
||||
events.push({ type: "playerEliminated", player: p.id, reason: "treasuresLost" });
|
||||
if ((state.config.deckRev ?? 1) >= 14) sweepEliminated(state, p.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user