@champions-digital-game/mod-sdk 0.50.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +3 -3
  2. package/dist/build.js +1 -1
  3. package/dist/chunks/chunk-3ZP7JFBM.js +7 -0
  4. package/dist/chunks/chunk-DH3FUEOQ.js +22 -0
  5. package/dist/chunks/{chunk-JYDEFRIZ.js → chunk-GIPUMXZ5.js} +11 -11
  6. package/dist/chunks/{chunk-A3WBGQ2N.js → chunk-KWTX5B5J.js} +1 -1
  7. package/dist/chunks/{chunk-URLIN52M.js → chunk-RRZU6F4D.js} +1 -1
  8. package/dist/chunks/chunk-STQU5RJP.js +1 -0
  9. package/dist/chunks/{chunk-DKCXOHRM.js → chunk-XDNO5DKC.js} +1 -1
  10. package/dist/import.js +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/mc-pack.js +2 -2
  13. package/dist/testing.js +1 -1
  14. package/package.json +1 -1
  15. package/types/cards/src/dsl/abilities.d.ts +91 -1
  16. package/types/cards/src/dsl/effects.d.ts +33 -0
  17. package/types/cards/src/dsl/engine-only-features.d.ts +0 -10
  18. package/types/cards/src/dsl/values.d.ts +15 -2
  19. package/types/cards/src/playable/custom.d.ts +3 -2
  20. package/types/cards/src/wave2/ant/obligation-nemesis.d.ts +0 -1
  21. package/types/cards/src/wave5/sm/campaign/shield-tech.d.ts +2 -0
  22. package/types/content/src/index.d.ts +1 -1
  23. package/types/content/src/schema/cards/player-cards.d.ts +7 -0
  24. package/types/content/src/schema/packs.d.ts +5 -0
  25. package/types/engine/src/abilities.d.ts +40 -1
  26. package/types/engine/src/actions.d.ts +3 -1
  27. package/types/engine/src/campaign.d.ts +46 -0
  28. package/types/engine/src/choices.d.ts +2 -0
  29. package/types/engine/src/cost-damage.d.ts +2 -2
  30. package/types/engine/src/effects.d.ts +39 -2
  31. package/types/engine/src/events.d.ts +1 -1
  32. package/types/engine/src/index.d.ts +3 -3
  33. package/types/engine/src/keywords.d.ts +3 -3
  34. package/types/engine/src/legal.d.ts +22 -1
  35. package/types/engine/src/query.d.ts +7 -0
  36. package/types/engine/src/resolve/hand-discard.d.ts +20 -0
  37. package/types/engine/src/select.d.ts +4 -0
  38. package/types/engine/src/spec.d.ts +62 -1
  39. package/types/engine/src/stack.d.ts +5 -0
  40. package/types/engine/src/state.d.ts +30 -0
  41. package/types/engine/src/trigger-events.d.ts +53 -2
  42. package/dist/chunks/chunk-2XS47E3T.js +0 -7
  43. package/dist/chunks/chunk-HVUCR22H.js +0 -1
  44. package/dist/chunks/chunk-PB6KXNXP.js +0 -22
@@ -47,7 +47,7 @@ export declare function costDamageEffects(amount: number, paidFor: Frame<"abilit
47
47
  * status card (the Focused Rage FAQ entry, RRG 1.8 p. 57). Damage past its remaining hit points is still taken (it is
48
48
  * then defeated), so hit points do not limit it.
49
49
  */
50
- export declare function canTakeCostDamage(state: GameState, deps: EngineDeps, id: InstanceId, sourceId: InstanceId | null, amount: number): boolean;
50
+ export declare function canTakeCostDamage(state: GameState, deps: EngineDeps, id: InstanceId, sourceId: InstanceId | null, amount: number, unpreventable?: boolean): boolean;
51
51
  /**
52
52
  * Whether `id` can be picked for a "deal N damage to a [chosen] character →" cost (`AbilityCost.damageCards`) of
53
53
  * `sourceId`'s ability: a character, and not one that cannot take damage from the source.
@@ -77,7 +77,7 @@ export declare function pickedCostDamageEffects(slot: string, amount: number): E
77
77
  * Not to be confused with `AbilityCost.dealDamage` (`attach-cost.ts`, Energy Transfer): "If dealing damage is a cost,
78
78
  * that cost is considered paid even if some or all of that damage is prevented" (same page), so it is never settled.
79
79
  */
80
- export declare function selfCostDamageEffects(amount: number, paidFor: Frame<"ability"> | Frame<"playCard"> | null): EffectSpec[];
80
+ export declare function selfCostDamageEffects(amount: number, paidFor: Frame<"ability"> | Frame<"playCard"> | null, unpreventable?: boolean): EffectSpec[];
81
81
  /** The plan vars holding the range a chosen "take any amount of damage →" cost is picked from (`damageSelfChoiceRange`). */
82
82
  export declare const DAMAGE_SELF_MIN_VAR = "cost.damageSelf.min";
83
83
  export declare const DAMAGE_SELF_MAX_VAR = "cost.damageSelf.max";
@@ -340,6 +340,10 @@ export declare function takeTopOfDeck(ctx: Ctx, playerId: PlayerId): InstanceId
340
340
  export interface DeckDiscarder {
341
341
  readonly sourceInstanceId: InstanceId | null;
342
342
  readonly boundOn?: DeckDiscard["boundOn"];
343
+ /** Whether that card's ability discarded it as its effect or as its cost (`cardDiscardedFromDeck.how`). */
344
+ readonly how?: "effect" | "cost";
345
+ /** The effects frame making the discard, for a card of a hand it moves (`HandDiscard.madeBy`). */
346
+ readonly madeBy?: FrameId | undefined;
343
347
  }
344
348
  /**
345
349
  * Whether any ability in the registry triggers on `tuckedCardDiscarded` (docs/phase7-wave9.md §3.40 (b)); cached per
@@ -398,6 +402,32 @@ export declare function listensForDeckDiscard(deps: EngineDeps): boolean;
398
402
  * is recorded only in a game with an ability that hears one (`listensForDeckDiscard`).
399
403
  */
400
404
  export declare function recordDeckDiscard(ctx: Ctx, playerId: PlayerId, id: InstanceId, by: DeckDiscarder): void;
405
+ /**
406
+ * Whether any ability in the registry triggers on `cardDiscardedFromHand` (issue #922); cached per registry. Cards are
407
+ * discarded from hands in most games, so nothing is recorded or announced for a registry with no such ability: its
408
+ * games keep their state and their log.
409
+ */
410
+ export declare function listensForHandDiscard(deps: EngineDeps): boolean;
411
+ /**
412
+ * What discarded a card from a hand (`TriggerEvent cardDiscardedFromHand`, issue #922): the card whose ability did, and
413
+ * whether as its effect or its cost. `sourceCardId` when the caller already has it; otherwise it is read from
414
+ * `sourceInstanceId`.
415
+ */
416
+ export interface HandDiscarder {
417
+ readonly sourceInstanceId: InstanceId | null;
418
+ readonly sourceCardId?: CardId | undefined;
419
+ readonly how: "effect" | "cost";
420
+ /** The effects frame making the discard (`HandDiscard.madeBy`); absent for a cost. */
421
+ readonly madeBy?: FrameId | undefined;
422
+ }
423
+ /**
424
+ * The one place a card's discard from a hand by an ability is recorded for its `cardDiscardedFromHand` announcement
425
+ * (issue #922; `GameState.pendingHandDiscards`, announced between frames by `announceHandDiscards`). Called right after
426
+ * the move by `discardFromHand` when its caller names the discarding ability, and by `moveCardsTo` for a card it moved
427
+ * from a hand to a discard pile. A card that did not reach a discard pile was not discarded, and nothing is recorded;
428
+ * nor is anything in a game with no ability that hears one (`listensForHandDiscard`).
429
+ */
430
+ export declare function recordHandDiscard(ctx: Ctx, playerId: PlayerId, id: InstanceId, cause: HandDiscarder): void;
401
431
  /**
402
432
  * Whether any ability in the registry triggers on a card discarded from the top of an encounter deck
403
433
  * (docs/phase7-wave9.md §3.43 (b)); cached per registry. Encounter cards are discarded from the deck in most games, so
@@ -480,13 +510,20 @@ export declare function releaseRefillEncounterCards(ctx: Ctx, refill: string): v
480
510
  * Control" (p. 31), "That card is discarded from a player's hand, it is placed in its owner's discard pile". The log's
481
511
  * `cardDiscardedFromHand` names the player whose hand it left either way.
482
512
  */
483
- export declare function discardFromHand(ctx: Ctx, playerId: PlayerId, id: InstanceId): void;
513
+ export declare function discardFromHand(ctx: Ctx, playerId: PlayerId, id: InstanceId,
514
+ /**
515
+ * The ability whose effect or cost discards the card, which makes the discard one `cardDiscardedFromHand` hears
516
+ * (issue #922). Absent for the game's own discards and for spent resources, which are not heard.
517
+ */
518
+ by?: HandDiscarder): void;
484
519
  /**
485
520
  * "Discard N cards at random from your hand", one card at a time with the game's seeded RNG, so a replay discards the
486
521
  * same cards. Stops early when no eligible card is left; a hand of one still discards it (ruling, Feb 28, 2026 (4)).
487
522
  * `exclude` keeps cards out of the pick (the card whose cost this is). Returns the discarded cards in order.
488
523
  */
489
- export declare function discardRandomFromHand(ctx: Ctx, playerId: PlayerId, amount: number, exclude?: readonly InstanceId[]): readonly InstanceId[];
524
+ export declare function discardRandomFromHand(ctx: Ctx, playerId: PlayerId, amount: number, exclude?: readonly InstanceId[],
525
+ /** The discarding ability (`discardFromHand`'s `by`). */
526
+ by?: HandDiscarder): readonly InstanceId[];
490
527
  /**
491
528
  * Sends a card in play to the discard pile its `home` names (its owner's, or its encounter deck's). `sourceCardId`: the
492
529
  * card whose ability discards it, if any (`permanentStopsLeaving`); `asCost`: as that ability's cost (`leaveCauseSide`).
@@ -280,7 +280,7 @@ export type GameEvent = {
280
280
  * an effect names (Med Lab 38028, Avengers Compound 58034), each "as if it were in your hand", with
281
281
  * `countsAsFrom: "hand"` (`PlayOrigin`). A play from the hand logs neither.
282
282
  */
283
- readonly from?: "deckTop" | "separateDeck" | "tucked" | "deck" | "setAside";
283
+ readonly from?: "deckTop" | "separateDeck" | "tucked" | "deck" | "setAside" | "discard";
284
284
  readonly countsAsFrom?: "hand";
285
285
  /**
286
286
  * Present only for a play under an "as if it were in your hand" permission printed on a card in the player's
@@ -1,4 +1,4 @@
1
- export declare const ENGINE_VERSION = "0.50.0";
1
+ export declare const ENGINE_VERSION = "0.52.0";
2
2
  export type { PlayerId, InstanceId, ChoiceId, EncounterDeckId, FrameId, GroupId, TeamId } from "./ids.js";
3
3
  export { playerId, instanceId, choiceId, encounterDeckId, frameId, groupId, teamId } from "./ids.js";
4
4
  export type { GroupRef, PodNeutralArea, PodNeutralSetup, PodSetup, PodState, SharedEvent, SharedPodState, SharedResult, SharedThreatCause, } from "./pod.js";
@@ -49,7 +49,7 @@ export { characterTitledAs, identityCardTitledAs } from "./titles.js";
49
49
  export type { CostChoices, CostPartPayers, CostSelection, DelegableCostPart } from "./commands.js";
50
50
  export { DELEGABLE_COST_PARTS } from "./commands.js";
51
51
  export type { DeferredEffects, ReportTarget, Vars } from "./stack.js";
52
- export { attackPreventedVars, currentActivationFrameId, PAID_CARDS_SLOT, PAID_IN_PLAY_CARDS_SLOT } from "./stack.js";
52
+ export { attackPreventedVars, currentActivationFrameId, PAID_CARDS_SLOT, PAID_IN_PLAY_CARDS_SLOT, READIED_CARDS_SLOT, } from "./stack.js";
53
53
  export { abilityUseKey, BORROWED_BOOST_ICONS_SLOT, DEFAULT_DEPS, fixedResourcesOf, GRANTED_BY_SLOT, inPlayPicksOf, tuckedPickOf, labeledResolvedVar, isResourcesChoice, NO_ABILITIES, playableAsIfInHandOf, resourcesChoiceOf, } from "./abilities.js";
54
54
  export type { InPlayCostMode, ResourcesChoice } from "./abilities.js";
55
55
  export type { AbilityTimingWord, BoostCardDestination, CardDestination, DefeatDestination, DefeatPlacement, CardSelector, CharacterNames, EffectSpec, LastingUntil, LastingGrantUntil, NextBasicPowerUntil, PairLimit, PlayerRef, PlayerZone, Predicate, ScenarioDeckSource, SchemeValueName, StatName, BasicPowerName, BasicPowerTerms, StatComparison, StatusName, CollectionSearchFilter, TargetCategory, TargetQuery, TargetRef, ValueSpec, AttachCategory, } from "./spec.js";
@@ -58,7 +58,7 @@ export type { AbilityTimingWord, BoostCardDestination, CardDestination, DefeatDe
58
58
  * into, the log it writes, and the two values that cross the game/campaign boundary. Types only; the runner that
59
59
  * interprets them is below (docs/campaign-mode-design.md §11).
60
60
  */
61
- export type { CampaignAttempt, CampaignAttemptOutcome, CampaignCardFace, CampaignChoiceRecord, CampaignChoiceSource, CampaignDefinition, CampaignGameInput, CampaignGameQuery, CampaignGameResult, CampaignGrant, CampaignGraph, CampaignHistoryEntry, CampaignInGameWrites, CampaignInstruction, CampaignLog, CampaignLogValueSpec, CampaignLogSnapshot, CampaignLogView, CampaignNode, CampaignOp, CampaignPosition, CampaignPredicate, CampaignScenarioRef, CampaignSeat, CampaignSeatInput, CampaignStatus, CampaignStep, CampaignStepTrace, CampaignValue, CampaignWindow, CollectionFilter, EliminationPolicy, GrantDeckSize, GrantDeckSizeRule, GrantPermanence, LogFieldDef, LogFieldType, LogValue, LogValueContent, LogValueSeal, LogWrite, LogWriteMode, LogWriteSpec, LossPolicy, ResolvedInstruction, } from "./campaign.js";
61
+ export type { CampaignAttempt, CampaignAttemptOutcome, CampaignCardFace, CampaignChoiceRecord, CampaignChoiceSource, CampaignDefinition, CampaignGameInput, CampaignGameQuery, CampaignGameResult, CampaignGrant, CampaignGrantFace, CampaignGraph, CampaignHistoryEntry, CampaignInGameWrites, CampaignInstruction, CampaignLog, CampaignLogValueSpec, CampaignLogSnapshot, CampaignLogView, CampaignNode, CampaignOp, CampaignPosition, CampaignPredicate, CampaignScenarioRef, CampaignSeat, CampaignSeatInput, CampaignStatus, CampaignStep, CampaignStepTrace, CampaignValue, CampaignWindow, CollectionFilter, EliminationPolicy, GrantDeckSize, GrantDeckSizeRule, GrantPermanence, LogFieldDef, LogFieldType, LogValue, LogValueContent, LogValueSeal, LogWrite, LogWriteMode, LogWriteSpec, LossPolicy, ResolvedInstruction, } from "./campaign.js";
62
62
  export { CAMPAIGN_LOG_SCHEMA, CAMPAIGN_WINDOW_ORDER, DEFAULT_CAMPAIGN_WINDOW, grantDeckSizesOf, includedGrantsOf, NO_CAMPAIGN_WRITES, } from "./campaign.js";
63
63
  /**
64
64
  * The campaign runner (docs/campaign-mode-design.md §7): the four pure functions that compose the next scenario,
@@ -60,8 +60,8 @@ export declare function hasGrantedPermanent(state: GameState, id: InstanceId, de
60
60
  * `permanentProtectsFrom`).
61
61
  */
62
62
  export declare function hasLostPermanent(state: GameState, id: InstanceId, deps?: EngineDeps): boolean;
63
- export declare function keywordsOf(state: GameState, id: InstanceId, deps?: EngineDeps): readonly KeywordInstance[];
64
- export declare const hasKeyword: (state: GameState, id: InstanceId, name: KeywordName, deps?: EngineDeps) => boolean;
63
+ export declare function keywordsOf(state: GameState, id: InstanceId, deps?: EngineDeps, notFrom?: InstanceId | null): readonly KeywordInstance[];
64
+ export declare const hasKeyword: (state: GameState, id: InstanceId, name: KeywordName, deps?: EngineDeps, notFrom?: InstanceId | null) => boolean;
65
65
  /**
66
66
  * Permanent (RRG 1.8 "Permanent", p. 32): "Effects on cards not from this card's set cannot defeat this card, remove
67
67
  * this card from play, or blank any part of its text box." Read off the printed card as well as its keywords right
@@ -76,7 +76,7 @@ export declare function isPermanent(state: GameState, id: InstanceId, deps?: Eng
76
76
  * counts, docs/phase7-wave5.md §4.1 Q45). Inside a keyword-grant scan only printed keywords are read (see
77
77
  * `readingKeywordGrants`).
78
78
  */
79
- export declare function queryHasKeyword(state: GameState, id: InstanceId, name: KeywordName, deps: EngineDeps): boolean;
79
+ export declare function queryHasKeyword(state: GameState, id: InstanceId, name: KeywordName, deps: EngineDeps, notFrom?: InstanceId | null): boolean;
80
80
  /** RRG "Keywords": repeated instances of a numbered keyword add their values together. */
81
81
  export declare function keywordTotal(state: GameState, id: InstanceId, name: "retaliate" | "incite" | "hinder" | "victory", deps?: EngineDeps): number;
82
82
  export declare const usesKeyword: (state: GameState, id: InstanceId, deps?: EngineDeps) => Extract<KeywordInstance, {
@@ -12,7 +12,7 @@
12
12
  * what to pay with.
13
13
  */
14
14
  import type { AbilityId, ResourceIconType } from "../../content/src/index.js";
15
- import { type EngineDeps } from "./abilities.js";
15
+ import { type AbilityCost, type EngineDeps } from "./abilities.js";
16
16
  import type { PendingChoice } from "./choices.js";
17
17
  import { type Command, type CostChoices, type CostSelection, type DelegableCostPart } from "./commands.js";
18
18
  import { type EngineErrorCode } from "./errors.js";
@@ -218,6 +218,17 @@ export type LegalActions = {
218
218
  readonly legal: readonly LegalAction[];
219
219
  readonly illegal: readonly IllegalAction[];
220
220
  };
221
+ type CostChoiceSet = {
222
+ readonly costChoices: CostChoices | undefined;
223
+ readonly target: InstanceId | null;
224
+ };
225
+ /**
226
+ * The cost-choice sets a regular `useAbility` of `source`'s ability is tried with (`costChoiceSets`, its hand discard
227
+ * defaulted as `legalActions` defaults it): one per legal pick of a chosen card, a card whose printed cost is paid, an
228
+ * attach host, a character a cost damages or heals, a target or a Special to resolve. For an effect that initiates
229
+ * an Action itself (`EffectSpec useActionAbility`, PR #903 review), so it judges and asks the same choices.
230
+ */
231
+ export declare function abilityCostChoiceSets(state: GameState, deps: EngineDeps, playerId: PlayerId, source: InstanceId, cost: AbilityCost | undefined): readonly CostChoiceSet[];
221
232
  /** A "Forced Action" its player could trigger right now, with a command that does (`outstandingForcedActions`). */
222
233
  export interface OutstandingForcedAction {
223
234
  readonly playerId: PlayerId;
@@ -241,6 +252,15 @@ export declare const forcedActionOptionId: (instanceId: InstanceId, abilityId: A
241
252
  * to act, so what is on the stack or which step the game is in does not matter. An eliminated player has none.
242
253
  */
243
254
  export declare function outstandingForcedActions(state: GameState, playerId: PlayerId, deps?: EngineDeps): readonly OutstandingForcedAction[];
255
+ /**
256
+ * Whether `playerId` could use the Action `abilityId` of `instanceId` were it their moment to act, as
257
+ * `outstandingForcedActions` asks it: `evaluateAbility` on the state as their turn, with nothing resolving and nothing
258
+ * asked, so the cost, its choices, its branches and the payment are judged exactly as for a regular use (the same
259
+ * wallets, the same "when spent" and chosen-amount handling). For an effect that initiates an Action itself out of turn
260
+ * (`EffectSpec useActionAbility`, #890 item 6; PR #903 reviews). The `LegalAction` (its `costBranches`, `costCounters`
261
+ * and `example`) or null.
262
+ */
263
+ export declare function abilityUsableAsTheirMoment(state: GameState, deps: EngineDeps, playerId: PlayerId, instanceId: InstanceId, abilityId: AbilityId): LegalAction | null;
244
264
  /**
245
265
  * Every action `playerId` could take right now, split into legal (with an
246
266
  * example command and legal targets) and illegal (with the engine's reason).
@@ -432,3 +452,4 @@ export type CostHelpAnswer = {
432
452
  * those over (RRG 1.8 "Cost", p. 14; owner answer 21B).
433
453
  */
434
454
  export declare function costHelpFor(state: GameState, playerId: PlayerId, action: ActionRef, helperId: PlayerId, options?: Pick<PaymentContext, "costSelection" | "abilityId">, deps?: EngineDeps): readonly CostHelpAnswer[];
455
+ export {};
@@ -504,6 +504,13 @@ export declare function deckDiscardStillThere(state: GameState, discard: {
504
504
  readonly at: "discard" | "deck";
505
505
  readonly encounterDeckId?: EncounterDeckId;
506
506
  }): boolean;
507
+ /**
508
+ * Whether a card discarded from a hand is still in a discard pile (`TriggerEvent cardDiscardedFromHand`, issue #922): a
509
+ * response that took it away leaves nothing for another response to act on.
510
+ */
511
+ export declare function handDiscardStillThere(state: GameState, discard: {
512
+ readonly instanceId: InstanceId;
513
+ }): boolean;
507
514
  /** Where a card currently is. Linear scan; the number of cards in a game is small. */
508
515
  export declare function locateCard(state: GameState, id: InstanceId): ZoneId | null;
509
516
  /** The in-play scenario area a card is in: its own, or the one the card it is attached to is in. Null outside one. */
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Announcing cards discarded from a hand by a card's ability (`TriggerEvent cardDiscardedFromHand`, issue #922): the
3
+ * hand's counterpart of `announceDeckDiscards` and `announceTuckedDiscards`.
4
+ */
5
+ import type { Ctx } from "../ctx.js";
6
+ /**
7
+ * Announces each card discarded from a hand by an ability since the last look (recorded by `recordHandDiscard`), when
8
+ * an ability hears it, and empties the list; the first discarded resolves first. Those recorded since the last look
9
+ * were discarded by one effect or one cost payment, so they share one response window (RRG 1.8 "Discard", p. 16:
10
+ * "Responses to the discarding of any of those cards are resolved after all discards are made"; "Triggering
11
+ * Condition", p. 45). The flow looks here between frames, so the window resolves before the discarding ability's next
12
+ * effect, or, for a cost, before the ability's effects. A card no longer in a discard pile is not announced. Returns
13
+ * true when it pushed a frame.
14
+ *
15
+ * A card whose discarding effect is still making its discards stays recorded for a later look (`discardStillMaking`):
16
+ * "each player discards" asks one player at a time, and a card some ability may replace waits in its own "would be
17
+ * discarded" window, but the discards are one simultaneous set whose responses come after all of them (RRG 1.8
18
+ * "Discard", p. 16).
19
+ */
20
+ export declare function announceHandDiscards(ctx: Ctx): boolean;
@@ -453,6 +453,8 @@ export type QueryExclusion = "unknownCard"
453
453
  | "hasExcludedKeyword"
454
454
  /** Matches none of the query's `anyOf` alternatives, or matches the query it must not (`not`). */
455
455
  | "matchesNoAlternative" | "wrongName" | "wrongPrintedId" | "wrongFacedown"
456
+ /** Not on the face the query's `flipped` asks for. */
457
+ | "wrongFlipped"
456
458
  /** The card prints no form keyword of the query's `printedForm` type (docs/phase7-wave4.md §3.1). */
457
459
  | "wrongForm"
458
460
  /** No ability with one of the query's `abilityTiming` words (docs/phase7-wave4.md §3.33), or none printed with a `printsAbility` label. */
@@ -957,6 +959,8 @@ export declare function activeAbilityRefs(state: GameState, id: InstanceId, deps
957
959
  * bubbles"), read as `activeAbilityRefs` reads them: `TargetQuery hasTaggedAbility`, `ValueSpec taggedAbilities`.
958
960
  */
959
961
  export declare function taggedAbilityCount(state: GameState, id: InstanceId, tag: string, deps: EngineDeps): number;
962
+ /** `activeAbilityRefs` less the abilities the card gains from rules: its live printed abilities. */
963
+ export declare function activePrintedAbilityRefs(state: GameState, id: InstanceId, deps: EngineDeps): readonly AbilityReference[];
960
964
  /** One ability a card gains from a rule in effect, and the card whose constant gives it (null: a scenario rule). */
961
965
  export interface GrantedAbility {
962
966
  readonly abilityId: AbilityId;
@@ -119,6 +119,16 @@ export interface TargetQuery {
119
119
  readonly withKeyword?: KeywordName;
120
120
  /** Excludes cards that have this keyword now (printed or granted), read exactly as `withKeyword` reads it. */
121
121
  readonly withoutKeyword?: KeywordName;
122
+ /**
123
+ * `withKeyword` / `withoutKeyword` leave out what the query's own card (`self`) grants by a constant ability:
124
+ * "Attached villain gains steady. If it already has steady or stalwart, it gets +4[per_hero] hit points instead"
125
+ * (Rose's Greenhouse, the `the-rose-bf` community pack; #890 item 9) asks whether the villain has steady apart from
126
+ * the attachment's own grant, which would otherwise always answer yes. Every other source still counts: printed
127
+ * keywords, other cards' constants and lasting grants. Asked from inside a keyword grant's own `while` (as that card
128
+ * asks it), the other cards' grants are read one level deep, not printed keywords only as other queries there are:
129
+ * with its own grant left out the scan cannot reach itself (`keywords.ts` `queryHasKeyword`).
130
+ */
131
+ readonly keywordNotFromSelf?: true;
122
132
  /**
123
133
  * Matches at least one of these queries, each read in this query's own context: "choose an attachment, non-Elite
124
134
  * minion, or non-permanent side scheme" (Vivian, `ironheart` 29024) is `{ anyOf: [query("attachment"),
@@ -266,6 +276,14 @@ export interface TargetQuery {
266
276
  readonly canFlip?: true;
267
277
  /** In play facedown as something else ("each facedown Drone minion"). */
268
278
  readonly facedown?: boolean;
279
+ /**
280
+ * Showing the other face of a double-sided card (`flipSide`; `CardInstance.flipped`), or its front (false). For a
281
+ * card whose two faces print the same title, where `name` cannot tell them apart: MC27 p. 22's "**Setup:** Each
282
+ * player flips their 'Campaign - S.H.I.E.L.D. Tech' upgrade to its Enhanced side" flips only a copy still on its
283
+ * front, since `flipCard` turns a card over whichever face is up. Always false for a villain, a main scheme stage or
284
+ * an `otherFaceId` card, whose face is kept elsewhere: do not use it to tell their sides apart.
285
+ */
286
+ readonly flipped?: boolean;
269
287
  /**
270
288
  * The card's boost area prints a star icon (★), or does not: "If that card has a star icon (★) in the boost area,
271
289
  * defeat the attacked minion" (Longshot 35033, `wolv`) is `{ starIcon: true }` over the discarded card.
@@ -1201,6 +1219,17 @@ export type ValueSpec = {
1201
1219
  readonly kind: "defeatExcessDamage";
1202
1220
  readonly consequential?: boolean;
1203
1221
  }
1222
+ /**
1223
+ * The excess threat the triggering `schemeDefeated` event recorded (`schemeDefeated.excessThreat`): how much more
1224
+ * threat the defeating removal attempted than the scheme had, after every modifier (#890 item 8). 0 when the removal
1225
+ * took exactly the last threat, for a defeat no removal made, or any other event. "After a side scheme is
1226
+ * overdefeated (more threat was removed from it than it had)" (The Rose, the `the-rose-bf` community pack: Hero
1227
+ * Resistance, Rose's Greenhouse) is this at least 1, from any removal, a thwart's or not; the threat counterpart of
1228
+ * `defeatExcessDamage`.
1229
+ */
1230
+ | {
1231
+ readonly kind: "defeatExcessThreat";
1232
+ }
1204
1233
  /**
1205
1234
  * Arithmetic on another value: "2 damage for each counter (max 10)" → `{ value, times: 2, max: 10 }`; "X is 1 more
1206
1235
  * than" → `plus: 1`; "half of the cards in your hand, rounded down" (Man Out of Time, `cap` pack) → `{ value:
@@ -3203,7 +3232,27 @@ export type EffectSpec =
3203
3232
  readonly bind: string;
3204
3233
  }
3205
3234
  /** "Cancel that card's boost ability" (Target Acquired): only before that ability resolves. `bind`: `<bind>.made`. */
3235
+ /**
3236
+ * "… or resolve an 'Action' ability on a card you control" (War Machine Armor, the `punisher-msp` community pack;
3237
+ * #890 item 6): the player uses one Action ability of a card in play they control as they could on their own turn,
3238
+ * its cost paid (the author's answer, 2026-11-17: "Yes you pay the cost"), at this effect's moment, which need not be
3239
+ * their turn (the Action timing is not asked, as `playFromHand.ignoreActionTiming` does not ask it of an event).
3240
+ * Everything else about using the ability applies: its condition, limit and targets (`useAbility`), and its form: an
3241
+ * "Action", a "Hero Action" or an "Alter-Ego Action" may be picked, each only in its own form (the designer, PR #903).
3242
+ * Only printed abilities (`activePrintedAbilityRefs`): an Action another card grants is not "on a card you control".
3243
+ *
3244
+ * The player picks among the abilities that could be used now (each checked by triggering it on a copy of the game),
3245
+ * then answers what using it on their turn would ask: the branch of an either/or cost, each choice of cards in play
3246
+ * its cost makes, and its resources in a `spendResources` choice priced as an ability's payment (so a resource "for
3247
+ * an upgrade ability" pays). `filter`: only cards matching it. `optional`: the player may pick none. With nothing
3248
+ * usable, nothing happens.
3249
+ */
3206
3250
  | {
3251
+ readonly kind: "useActionAbility";
3252
+ readonly player: PlayerRef;
3253
+ readonly filter?: TargetQuery;
3254
+ readonly optional?: boolean;
3255
+ } | {
3207
3256
  readonly kind: "cancelBoostAbility";
3208
3257
  readonly bind?: string;
3209
3258
  }
@@ -4639,6 +4688,11 @@ export type EffectSpec =
4639
4688
  * such card prints "as if it were in your hand"); one from `"deck"` or a separate deck does not unless marked
4640
4689
  * `asIfInHand` (`PlayOrigin`, `actions.ts`). RRG 1.8 FAQ "Magik (#30A)", p. 64.
4641
4690
  *
4691
+ * `"discard"`: a card from the player's own discard pile ("play an Attack event from your discard pile, paying its
4692
+ * costs", Warzone, `punisher-msp`; #890 item 5). It is a play (RRG 1.8 "Play, Put Into Play", p. 32) from that
4693
+ * pile, not one "as if it were in your hand": the log's `cardPlayed` carries `from: "discard"` and no
4694
+ * `countsAsFrom`, so a "from your hand" response does not answer it.
4695
+ *
4642
4696
  * `{ deck: "search", asIfInHand: true }`: `"deck"` for text that says "as if it were in your hand" ("search your
4643
4697
  * deck for an ally and play it as if it were in your hand, reducing its resource cost by 2", Calling in Favors
4644
4698
  * 61008; hero-pack spec H3.16). The same search, play and shuffle; the log's `cardPlayed` carries `from: "deck",
@@ -4646,7 +4700,7 @@ export type EffectSpec =
4646
4700
  * So an "after you play [this card] from your hand" response (`EventPattern.playedFromHand`) answers it, as it
4647
4701
  * does not answer the plain `"deck"` play.
4648
4702
  */
4649
- readonly from?: "hand" | "setAside" | "deck" | {
4703
+ readonly from?: "hand" | "setAside" | "deck" | "discard" | {
4650
4704
  readonly deck: "search";
4651
4705
  readonly asIfInHand: true;
4652
4706
  } | {
@@ -6526,6 +6580,13 @@ export type EffectSpec =
6526
6580
  readonly count?: number | ValueSpec;
6527
6581
  readonly upTo?: true;
6528
6582
  readonly optional?: boolean;
6583
+ /**
6584
+ * What the client asks in place of "Choose a target" when the printed text picks two cards for different roles
6585
+ * ("Move a counter FROM which support?" then "... TO which support?", Maria Hill's Reassignment 50001a; issue
6586
+ * #911). Display only: the engine passes it to the pending choice as `title` and never reads it. A message key of the client's
6587
+ * catalog (`choicePrompt.*`) is shown translated; any other text is shown as it is.
6588
+ */
6589
+ readonly prompt?: string;
6529
6590
  } | {
6530
6591
  readonly kind: "if";
6531
6592
  readonly condition: Predicate;
@@ -1238,6 +1238,11 @@ export declare const PAID_CARDS_SLOT = "paid.cards";
1238
1238
  * spent as cards ("paid with a resource card", Concussive Blast). Bound and carried as `PAID_CARDS_SLOT` is.
1239
1239
  */
1240
1240
  export declare const PAID_IN_PLAY_CARDS_SLOT = "paid.inPlayCards";
1241
+ /**
1242
+ * The slot an `endPhaseCardsReadied` event hands its answering abilities: the player's cards the end-of-player-phase
1243
+ * ready step readied ("for each 2 upgrades you readied this way", #890 item 1).
1244
+ */
1245
+ export declare const READIED_CARDS_SLOT = "readied.cards";
1241
1246
  /**
1242
1247
  * The cards that paid for the play of `instanceId` while that play is still resolving, as the bindings its own
1243
1248
  * abilities start with (`PAID_CARDS_SLOT`); empty when none did or the card is not being played. The slot twin of
@@ -532,6 +532,15 @@ export interface ScenarioDeckState {
532
532
  export type TuckedDiscard = Omit<Extract<TriggerEvent, {
533
533
  kind: "tuckedCardDiscarded";
534
534
  }>, "kind">;
535
+ /**
536
+ * A card discarded from a hand by an ability, waiting to be announced: the fields of `cardDiscardedFromHand`, and the
537
+ * effects frame that made it (`madeBy`), whose other discards it waits for (issue #922). Absent for a cost.
538
+ */
539
+ export type HandDiscard = Omit<Extract<TriggerEvent, {
540
+ kind: "cardDiscardedFromHand";
541
+ }>, "kind"> & {
542
+ readonly madeBy?: FrameId;
543
+ };
535
544
  /** A facedown encounter card dealt to a player, waiting to be announced (`TriggerEvent encounterCardDealt`). */
536
545
  export interface DealtEncounterCard {
537
546
  readonly playerId: PlayerId;
@@ -978,6 +987,13 @@ export type GameStep =
978
987
  readonly phase: "player";
979
988
  readonly kind: "endPhaseReady";
980
989
  readonly readied?: true;
990
+ /**
991
+ * The cards in play that were exhausted as the step began, read again once it has resolved to announce what it
992
+ * readied (`endPhaseCardsReadied`, #890 item 1). Only when an ability could hear that announcement.
993
+ */
994
+ readonly exhausted?: readonly InstanceId[];
995
+ /** The announcement was pushed: step 5 follows once it has resolved. */
996
+ readonly announced?: true;
981
997
  }
982
998
  /** `placed`: step one's threat has been pushed; the step stays current until it (and its responses) resolve. */
983
999
  | {
@@ -1294,6 +1310,13 @@ export interface GameState {
1294
1310
  * shared response window, and empties the list. Absent until one is first recorded. docs/phase7-wave9.md §3.40.
1295
1311
  */
1296
1312
  readonly pendingTuckedDiscards?: readonly TuckedDiscard[];
1313
+ /**
1314
+ * Cards discarded from a hand by a card's ability since the flow last looked, oldest first, recorded by
1315
+ * `recordHandDiscard` only when some ability in the registry triggers on it: the flow announces them as
1316
+ * `cardDiscardedFromHand` between frames, in one shared response window, and empties the list. Absent until one is
1317
+ * first recorded. Issue #922.
1318
+ */
1319
+ readonly pendingHandDiscards?: readonly HandDiscard[];
1297
1320
  /**
1298
1321
  * Facedown boost cards given since the flow last looked, oldest first, recorded by `recordBoostGiven` only when some
1299
1322
  * ability in the registry triggers on it: the flow announces each as `boostCardGiven` between frames, with a
@@ -1449,6 +1472,13 @@ export interface GameState {
1449
1472
  * game's first reveal, so a freshly set-up game serializes as before. docs/phase7-wave3.md §3.8.
1450
1473
  */
1451
1474
  readonly revealedThisRound?: readonly RevealRecord[];
1475
+ /**
1476
+ * Cards played this round keyed `<game area id>:<card type>`, the area the player was in when they played it, `""`
1477
+ * while the players shared one (The Once and Future Kang, docs/phase7-wave2.md §3.1): "the first ally played each
1478
+ * round" in a split area still counts a play made before the split. Absent until a card is played; reset when the
1479
+ * round ends.
1480
+ */
1481
+ readonly playedInAreaThisRound?: Readonly<Record<string, number>>;
1452
1482
  /**
1453
1483
  * The cards each player has played **this turn**, in order: "7 damage instead if you have played a [Thwart] event this
1454
1484
  * turn" (Decisive Blow, `gam`), "5 threat instead if you have played an [Attack] event this turn" (Forward Momentum).
@@ -68,7 +68,7 @@ export interface DefeatedSnapshot {
68
68
  * Where a played card was played from (`TriggerEvent cardPlayed.from`, `PlayOrigin` in `actions.ts`): its owner's hand,
69
69
  * the top of the deck or a tuck under an as-if-in-hand permission, or a zone an effect played it from.
70
70
  */
71
- export type PlayedFrom = "hand" | "deckTop" | "tucked" | "separateDeck" | "deck" | "setAside";
71
+ export type PlayedFrom = "hand" | "deckTop" | "tucked" | "separateDeck" | "deck" | "setAside" | "discard";
72
72
  export type TriggerEventBody = {
73
73
  readonly kind: "dealDamage";
74
74
  readonly targetInstanceId: InstanceId;
@@ -1624,6 +1624,39 @@ export type TriggerEventBody = {
1624
1624
  readonly by?: LeaveCauseSide;
1625
1625
  readonly how?: "effect" | "cost";
1626
1626
  }
1627
+ /**
1628
+ * A card was discarded from a player's hand by a card's ability (issue #922): "Response: After an identity-specific
1629
+ * card is discarded by an ability, tuck that card under here from your discard pile" (the Hulk house rule pack
1630
+ * `hulk-angry-bf`). The hand's counterpart of `cardDiscardedFromDeck`, and the "after" of `cardBeingDiscarded`'s
1631
+ * "when … would". `instanceId` is the card ("that card", `eventTarget`), now in a discard pile; `playerId` the player
1632
+ * whose hand held it (`eventPlayer`), `sourceInstanceId` the card whose ability discarded it (`eventSource`).
1633
+ *
1634
+ * The cause is two fields, as on `tuckedCardDiscarded`: `by` is the side of the discarding card (`LeaveCauseSide`,
1635
+ * `leaveCauseSide`, read from the source card), **whether as its ability's effect or as its cost**, and `how` says
1636
+ * which. `to` is always `"discard"`, so one `eventIs: { to: "discard", by }` reads this event, `cardBeingDiscarded`
1637
+ * and `cardLeavesPlay` alike.
1638
+ *
1639
+ * Which discards: an `EffectSpec discardFromHand` (chosen or random, the "would" window's discard included), a
1640
+ * `moveCards` to the discard pile of a card in a hand, a cost that discards cards from a hand (chosen or random) and
1641
+ * the "discard this card from your hand to play …" additional cost, each card its own event. **Not** heard: the cards
1642
+ * spent to pay a cost (RRG 1.8 "Resource", p. 37: spent, not discarded by an ability), the discard down to hand size
1643
+ * and a mulligan (the game's own steps), and a manual adjustment.
1644
+ *
1645
+ * Response only: announced after the card has reached its discard pile, between frames (`announceHandDiscards`), so
1646
+ * the cards one effect or one cost discarded share one response window (RRG 1.8 "Discard", p. 16: "Responses to the
1647
+ * discarding of any of those cards are resolved after all discards are made"; "Triggering Condition", p. 45). A
1648
+ * response that takes the card out of the discard pile leaves nothing for another to act on (`handDiscardStillThere`).
1649
+ * Recorded (`recordHandDiscard`) only when an ability in the registry listens.
1650
+ */
1651
+ | {
1652
+ readonly kind: "cardDiscardedFromHand";
1653
+ readonly instanceId: InstanceId;
1654
+ readonly playerId: PlayerId;
1655
+ readonly to: "discard";
1656
+ readonly sourceInstanceId: InstanceId | null;
1657
+ readonly by?: LeaveCauseSide;
1658
+ readonly how: "effect" | "cost";
1659
+ }
1627
1660
  /**
1628
1661
  * A card leaves play (docs/phase7-wave5.md §3.13): "Interrupt: When Spider-Man leaves play, …" (`sm` 27017,
1629
1662
  * Ghost-Spider 27048) and "Response: After a [Web-Warrior] ally leaves play, …" (Web of Life and Destiny 27023, Warrior
@@ -2011,6 +2044,18 @@ export type TriggerEventBody = {
2011
2044
  readonly carriedVars?: Readonly<Record<string, number>>;
2012
2045
  } | {
2013
2046
  readonly kind: "playerPhaseEnded";
2047
+ }
2048
+ /**
2049
+ * RRG 1.8 "End of Player Phase" (p. 18) step 3 has resolved: `readied` are the cards `playerId` controls that were
2050
+ * exhausted before the step and are ready after it (#890 item 1). "Response: After you ready your cards at the end of
2051
+ * the player phase, for each 2 upgrades you readied this way, …" (Web-Sling, the `spider-punisher-tw` community
2052
+ * pack). Announced once per player, in player order, before step 5 ("when/after the player phase ends"); only when an
2053
+ * ability hears it. The answering ability reads the cards as slot `readied.cards` (`READIED_CARDS_SLOT`).
2054
+ */
2055
+ | {
2056
+ readonly kind: "endPhaseCardsReadied";
2057
+ readonly playerId: PlayerId;
2058
+ readonly readied: readonly InstanceId[];
2014
2059
  } | {
2015
2060
  readonly kind: "villainPhaseEnded";
2016
2061
  }
@@ -2313,12 +2358,18 @@ export type LeaveCauseSide = "encounterCard" | "playerCard";
2313
2358
  * through `moveCardsTo`. `boundOn`: the set the discarding ability keeps of the cards "discarded this way"
2314
2359
  * (`DeckDiscard.boundOn`); a card whose discard is replaced leaves it.
2315
2360
  */
2316
- export type OutOfPlayDiscard = {
2361
+ export type OutOfPlayDiscard = ({
2317
2362
  readonly kind: "hand";
2318
2363
  readonly random?: true;
2319
2364
  } | {
2320
2365
  readonly kind: "moveCards";
2321
2366
  readonly boundOn?: DeckDiscard["boundOn"];
2367
+ }) & {
2368
+ /**
2369
+ * The effects frame making this discard, so a response to a card it discards from a hand waits for the effect's
2370
+ * other discards (`cardDiscardedFromHand`, issue #922). Set only when an ability hears that event.
2371
+ */
2372
+ readonly madeBy?: FrameId;
2322
2373
  };
2323
2374
  /**
2324
2375
  * What a tucked card's host is (`TriggerEvent cardBeingTucked.under`, `tuckedCardDiscarded.under`): an identity card