@champions-digital-game/mod-sdk 0.47.0 → 0.49.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-QM4LCKP5.js → chunk-2XS47E3T.js} +1 -1
  4. package/dist/chunks/{chunk-SSVC7TJ6.js → chunk-A3WBGQ2N.js} +1 -1
  5. package/dist/chunks/{chunk-V5MJXIOQ.js → chunk-DKCXOHRM.js} +1 -1
  6. package/dist/chunks/chunk-HVUCR22H.js +1 -0
  7. package/dist/chunks/{chunk-EQL5OYKH.js → chunk-JYDEFRIZ.js} +543 -543
  8. package/dist/chunks/chunk-PB6KXNXP.js +22 -0
  9. package/dist/chunks/{chunk-Q57JMRMI.js → chunk-URLIN52M.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/core/index.d.ts +1 -1
  16. package/types/cards/src/core/setup.d.ts +26 -0
  17. package/types/cards/src/dsl/abilities.d.ts +39 -15
  18. package/types/cards/src/index.d.ts +2 -2
  19. package/types/cards/src/playable/custom.d.ts +1 -1
  20. package/types/cards/src/playable/index.d.ts +11 -2
  21. package/types/cards/src/playable/scenario-options.d.ts +11 -0
  22. package/types/cards/src/wave2/trors/crossbones.d.ts +1 -0
  23. package/types/cards/src/wave9/silk/silk/identity.d.ts +3 -3
  24. package/types/content/src/index.d.ts +1 -1
  25. package/types/content/src/schema/cards/encounter-cards.d.ts +7 -1
  26. package/types/content/src/schema/cards/identity.d.ts +5 -1
  27. package/types/content/src/schema/cards/player-cards.d.ts +3 -1
  28. package/types/content/src/schema/cards/villain.d.ts +3 -1
  29. package/types/content/src/schema/common.d.ts +7 -0
  30. package/types/content/src/schema/validation.d.ts +5 -0
  31. package/types/engine/src/actions.d.ts +34 -16
  32. package/types/engine/src/adjust.d.ts +38 -0
  33. package/types/engine/src/campaign.d.ts +6 -0
  34. package/types/engine/src/commands.d.ts +78 -0
  35. package/types/engine/src/effects.d.ts +14 -0
  36. package/types/engine/src/events.d.ts +18 -1
  37. package/types/engine/src/index.d.ts +6 -5
  38. package/types/engine/src/resolve/attack-ability.d.ts +5 -1
  39. package/types/engine/src/resolve/eliminated-attack.d.ts +32 -0
  40. package/types/engine/src/stack.d.ts +14 -0
  41. package/types/engine/src/trigger-events.d.ts +8 -0
  42. package/types/engine/src/villain/step-one-threat.d.ts +37 -0
  43. package/dist/chunks/chunk-6WFYI6O7.js +0 -22
  44. package/dist/chunks/chunk-C2OAZ3V7.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { Aspect, CoreAspect } from "../aspects.js";
2
- import type { CardText, PrintedStat, ResourceIconCounts, ScalingValue, Trait } from "../common.js";
2
+ import type { CardText, PrintedStat, ResourceIconCounts, ScalingValue, StatStar, Trait } from "../common.js";
3
3
  import type { KeywordInstance } from "../keywords.js";
4
4
  import type { AbilityReference } from "../abilities.js";
5
5
  import type { EncounterSetId } from "../ids.js";
@@ -193,6 +193,8 @@ export interface AllyCard extends PlayerCardCommon, CostedCard {
193
193
  * each pym counter" placed by an "Interrupt: When [this ally] enters play" (docs/phase7-wave2.md §3.9).
194
194
  */
195
195
  readonly hp: number;
196
+ /** Stats of the ally's front face (ATK, THW, HP) that print a star beside them (see `StatStar`). Absent: none. */
197
+ readonly statStars?: readonly StatStar[];
196
198
  /** The small number printed beside ATK/THW: damage the ally takes after using that icon (RRG "Consequential Damage"). */
197
199
  readonly consequentialDamage: {
198
200
  readonly attack: number;
@@ -1,4 +1,4 @@
1
- import type { CardText, ScalingValue, Trait } from "../common.js";
1
+ import type { CardText, ScalingValue, StatStar, Trait } from "../common.js";
2
2
  import type { KeywordInstance } from "../keywords.js";
3
3
  import type { AbilityReference } from "../abilities.js";
4
4
  import type { EncounterSetId, ImageRef } from "../ids.js";
@@ -47,6 +47,8 @@ export interface VillainStage {
47
47
  readonly atk: number;
48
48
  /** Printed SCH. 0 when `dashedStats` lists `"sch"`. */
49
49
  readonly sch: number;
50
+ /** Stats of this stage (ATK, SCH, HP) that print a star beside them (see `StatStar`). Absent: none. */
51
+ readonly statStars?: readonly StatStar[];
50
52
  /**
51
53
  * Stats printed as "—" (RRG 1.8 "Dash (Value)": the character "cannot exhaust to use that power", and a
52
54
  * referenced dash "is treated as an unmodifiable 0"). Norman Osborn prints no ATK and Risky Business's Green
@@ -106,3 +106,10 @@ export interface CardImages {
106
106
  readonly front?: ImageRef;
107
107
  readonly back?: ImageRef;
108
108
  }
109
+ /**
110
+ * A printed stat that carries a star beside it: a card ability tied to that stat (a villain's "Forced Interrupt" when
111
+ * it attacks, a minion's when it schedules). MarvelCDB's `attack_star`, `scheme_star`, `thwart_star`, `defense_star`,
112
+ * `health_star` and `recover_star`. A card's or face's `statStars` lists the stats that print one, in this order;
113
+ * absent means none. Data only: the star changes no stat, the ability it points at is the card's own text.
114
+ */
115
+ export type StatStar = "atk" | "sch" | "thw" | "def" | "hp" | "rec";
@@ -42,6 +42,11 @@ export declare function validateTreacheryCard(card: TreacheryCard): ValidationRe
42
42
  export declare function validateEvidenceCard(card: EvidenceCard): ValidationResult;
43
43
  /** Dispatches to the type-specific validator. */
44
44
  export declare function validateCard(card: AnyCard): ValidationResult;
45
+ /**
46
+ * `statStars` (`StatStar`, `common.ts`) wherever a card or one of its faces carries it: a non-empty list of distinct
47
+ * stats in the canonical order (atk, sch, thw, def, hp, rec). Absent means no star.
48
+ */
49
+ export declare function statStarsErrors(card: AnyCard): string[];
45
50
  export declare function validateScenario(scenario: Scenario): ValidationResult;
46
51
  /** An encounter set's own fields (docs/phase7-wave4.md §1.9, §1.10). */
47
52
  export declare function validateEncounterSet(set: EncounterSet): ValidationResult;
@@ -448,6 +448,18 @@ export interface ResourceDamageCost {
448
448
  readonly spender: PlayerId;
449
449
  readonly amount: number;
450
450
  }
451
+ /**
452
+ * A step of a resource ability's cost that `payCost` would push as an effects frame (Clarity of Purpose's "deal 1
453
+ * damage to attached character →", a picked `damageCards`; a `readyCards`; an `indirectDamage`), held for
454
+ * `announceResourcesSpent` instead. Pushed while paying, it would sit under the card or ability paid for, which is
455
+ * pushed after the payment, so the cost would resolve after that card (issue #813). Plain data: the `pushEffects` spec.
456
+ */
457
+ export interface ResourceCostStep {
458
+ readonly effects: readonly EffectSpec[];
459
+ readonly selfInstanceId: InstanceId;
460
+ readonly controllerId: PlayerId;
461
+ readonly bindings?: Bindings;
462
+ }
451
463
  /** Resources one player generated in a payment (docs/phase7-wave5.md §3.25). */
452
464
  export interface GeneratedByPlayer {
453
465
  readonly playerId: PlayerId;
@@ -474,19 +486,19 @@ export interface SpentPayment {
474
486
  */
475
487
  readonly countersRemoved?: readonly TriggerEvent[];
476
488
  /**
477
- * The threat costs of the resource abilities used ("remove up to 2 threat from … → generate a resource for each
478
- * threat you removed this way"; docs/phase7-wave9.md §3.7 (b)), held for `announceResourcesSpent` like
479
- * `countersRemoved`: the removal is an ordinary `removeThreat` event, which has to sit above the card or ability
480
- * paid for so that it resolves first (RRG 1.8 "Initiating Abilities", p. 24, step 5 before step 6).
489
+ * The frame-pushing cost steps of the resource abilities used, in the order they resolve: one resource ability's
490
+ * after the one paid before it in the payment (`payPayment`). Only these keep payment order: a counter cost
491
+ * (`countersRemoved` above) or an exhaust is applied when paid, before any of them. Each is held for `announceResourcesSpent`, so it
492
+ * resolves in full (damage, a defeat, the interrupts and responses to it) before the card or ability paid for
493
+ * commences (RRG 1.8 "Initiating Abilities", p. 24, step 5 before step 6; "Cost", p. 13–14). They are:
494
+ * - the threat costs ("remove up to 2 threat from … → generate a resource for each threat you removed this way";
495
+ * docs/phase7-wave9.md §3.7 (b), `ResourceThreatCost`), an ordinary `removeThreat` event;
496
+ * - the damage costs ("When you spend this card, take up to 3 damage → …"; docs/phase7-wave10-hero-packs.md H3.14,
497
+ * `ResourceDamageCost`), an ordinary deal to the spender's identity;
498
+ * - the other steps `payCost` would push (Clarity of Purpose's "deal 1 damage to attached character →", a
499
+ * `readyCards`, an `indirectDamage`; issue #813).
481
500
  */
482
- readonly threatCosts?: readonly ResourceThreatCost[];
483
- /**
484
- * The damage costs of the resource abilities used ("When you spend this card, take up to 3 damage → this card
485
- * generates 1 additional [energy] resource for each damage taken this way"; docs/phase7-wave10-hero-packs.md H3.14),
486
- * held for `announceResourcesSpent` like `threatCosts`: the damage is an ordinary deal, which has to sit above the
487
- * card or ability paid for so that it is taken first (RRG 1.8 "Initiating Abilities", p. 24, step 5 before step 6).
488
- */
489
- readonly damageCosts?: readonly ResourceDamageCost[];
501
+ readonly costSteps?: readonly ResourceCostStep[];
490
502
  }
491
503
  export declare const NOTHING_SPENT: SpentPayment;
492
504
  /** Two payments' spending together (a basic power's extra cost). */
@@ -638,15 +650,21 @@ export declare function payCost(ctx: Ctx, sourceId: InstanceId, playerId: Player
638
650
  collectCounterEvents?: TriggerEvent[],
639
651
  /**
640
652
  * Where a `removeThreat` cost's steps go instead of the stack, for the same reason: a resource ability's threat
641
- * cost (`SpentPayment.threatCosts`), pushed by `announceResourcesSpent` above the card or ability paid for.
653
+ * cost (`threatCostStep`, held in `SpentPayment.costSteps`), pushed by `announceResourcesSpent` above the card or
654
+ * ability paid for.
642
655
  */
643
656
  collectThreatCosts?: ResourceThreatCost[],
644
657
  /**
645
658
  * Where a `damageSelf` cost goes instead of the stack, for the same reason: a resource ability's damage cost
646
- * (`SpentPayment.damageCosts`), pushed by `announceResourcesSpent` above the card or ability paid for. A chosen
647
- * amount is the plan's one number (`resourceCostPlan`).
659
+ * (`damageCostStep`, held in `SpentPayment.costSteps`), pushed by `announceResourcesSpent` above the card or
660
+ * ability paid for. A chosen amount is the plan's one number (`resourceCostPlan`).
661
+ */
662
+ collectDamageCosts?: ResourceDamageCost[],
663
+ /**
664
+ * Where a picked `damageCards`, a `readyCards` and an `indirectDamage` cost go instead of the stack, for the same
665
+ * reason (`SpentPayment.costSteps`; issue #813).
648
666
  */
649
- collectDamageCosts?: ResourceDamageCost[]): void;
667
+ collectCostSteps?: ResourceCostStep[]): void;
650
668
  /** The action ability an event resolves when played from hand, if it has one. */
651
669
  /**
652
670
  * Whether an action's pre-cost condition is false right now, so the action cannot be initiated at all (docs/phase7-
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Manual adjustments (`Command adjust`, issue #791): a player corrects the game state by hand from the pause menu,
3
+ * after a bug or a misclick.
4
+ *
5
+ * **Not an RRG rule.** Like `concede`, this is a digital-implementation affordance, so its behavior is our decision,
6
+ * written down here rather than implied. One policy runs through every kind:
7
+ *
8
+ * - **The adjustment itself is not a game event.** It opens no interrupt or response window of its own: placing damage
9
+ * here is not damage dealt (no toughness, retaliate, "after X takes damage"), threat placed or removed here is no
10
+ * scheme or thwart (no crisis, patrol, acceleration, "after threat is placed"), a status card removed here is not
11
+ * announced as discarded, and a form change here has no "when/after you change form" window. A correction should put
12
+ * the table where it should have been, not set off card text a second time.
13
+ * - **Player-action limits and costs are skipped.** The once-per-round form change and its costs, "cannot be healed",
14
+ * "cannot ready", crisis and patrol: they govern what a player may *do*, and this is a repair, not a play.
15
+ * - **The game's standing rules still follow from the new state**, because the engine keeps them as invariants and
16
+ * would apply them anyway: a character at zero hit points is defeated (its When Defeated and its leave-play windows
17
+ * resolve as for any defeat), a side scheme left with no threat is defeated, a main scheme at its target threat is
18
+ * completed, a uses card emptied of its counters is discarded, a vulnerable character given a stun or confuse is
19
+ * discarded, and a card discarded from play goes through `discardFromPlay` (its "when this leaves play" interrupts,
20
+ * its attachments with it; a "cannot leave play" card stays and the refusal is logged, and discarding a permanent
21
+ * card is refused outright). Status card
22
+ * capacity (one of each, steady two, stalwart none), counter limits and sustained damage caps hold too: giving a
23
+ * status card a character cannot hold is refused, and placed damage or counters stop at the cap, as the
24
+ * state checks between frames would otherwise shed them again.
25
+ * - **Drawing is drawing** (`drawCards`): an emptied deck resets with its encounter card, a drawn obligation enters
26
+ * play, and "after this card enters your hand" answers, exactly as a card effect's draw does.
27
+ *
28
+ * Every adjustment logs `manualAdjustment` first, then the ordinary events of what it changed. A refused adjustment is
29
+ * an `EngineError` and changes nothing.
30
+ */
31
+ import type { Command } from "./commands.js";
32
+ import { type Ctx } from "./ctx.js";
33
+ import { type EngineError } from "./errors.js";
34
+ type AdjustCommand = Command & {
35
+ type: "adjust";
36
+ };
37
+ export declare function adjust(ctx: Ctx, command: AdjustCommand): EngineError | null;
38
+ export {};
@@ -394,6 +394,12 @@ export type CampaignGameQuery =
394
394
  {
395
395
  readonly kind: "cardsThatEnteredPlay";
396
396
  readonly query: TargetQuery;
397
+ /**
398
+ * Each card once, however often it entered play: a card that left play and came back is still one physical card.
399
+ * MC10 p. 5's Experimental Weapons are one copy each, and a weapon discarded and revealed again from the reshuffled
400
+ * encounter deck must not be recorded (and carried into the next scenario) twice. Absent: every entry is kept.
401
+ */
402
+ readonly distinct?: true;
397
403
  }
398
404
  /** MC60 p. 13: "Record the title of each unique ally and support that was removed from the game in the campaign log." */
399
405
  | {
@@ -279,6 +279,17 @@ export type Command =
279
279
  | {
280
280
  readonly type: "concede";
281
281
  readonly playerId: PlayerId;
282
+ }
283
+ /**
284
+ * A manual correction of the game state, from the pause menu, after a bug or a misclick (issue #791). **Not an RRG
285
+ * rule**: like `concede`, a digital-implementation affordance, and a command for the same reason, so a `GameLog`
286
+ * replays it (saves, rewind, replays). `playerId` is the seat that made it; `adjustment` says what it does
287
+ * (`Adjustment`, applied by `adjust.ts`, which documents what each kind does and does not set off).
288
+ */
289
+ | {
290
+ readonly type: "adjust";
291
+ readonly playerId: PlayerId;
292
+ readonly adjustment: Adjustment;
282
293
  } | {
283
294
  readonly type: "resolveChoice";
284
295
  readonly playerId: PlayerId;
@@ -286,3 +297,70 @@ export type Command =
286
297
  readonly selectedOptionIds: readonly string[];
287
298
  };
288
299
  export type CommandType = Command["type"];
300
+ /** A status card a manual adjustment gives or removes. */
301
+ export type AdjustableStatus = "stunned" | "confused" | "tough";
302
+ /**
303
+ * What one manual adjustment (`Command adjust`) does. Amounts are whole numbers and never 0: a positive amount places,
304
+ * a negative one removes (never below 0). See `adjust.ts` for which game rules still follow each kind.
305
+ */
306
+ export type Adjustment =
307
+ /** `playerId` draws `count` cards, as drawing normally does (an emptied deck resets, a drawn obligation enters play). */
308
+ {
309
+ readonly kind: "draw";
310
+ readonly playerId: PlayerId;
311
+ readonly count: number;
312
+ }
313
+ /** A card in a player's hand goes to its discard pile. */
314
+ | {
315
+ readonly kind: "discardFromHand";
316
+ readonly instanceId: InstanceId;
317
+ }
318
+ /** A card in play (not an identity, villain or main scheme) is discarded, its attachments with it. */
319
+ | {
320
+ readonly kind: "discardFromPlay";
321
+ readonly instanceId: InstanceId;
322
+ }
323
+ /** Damage placed on (positive) or removed from (negative) a character. */
324
+ | {
325
+ readonly kind: "damage";
326
+ readonly instanceId: InstanceId;
327
+ readonly amount: number;
328
+ }
329
+ /** Threat placed on (positive) or removed from (negative) a main or side scheme. */
330
+ | {
331
+ readonly kind: "threat";
332
+ readonly instanceId: InstanceId;
333
+ readonly amount: number;
334
+ }
335
+ /** Counters of `counterType` placed on (positive) or removed from (negative) a card in play. */
336
+ | {
337
+ readonly kind: "counters";
338
+ readonly instanceId: InstanceId;
339
+ readonly counterType: string;
340
+ readonly amount: number;
341
+ }
342
+ /** One status card given to (`present: true`) or removed from (`present: false`) a character. */
343
+ | {
344
+ readonly kind: "status";
345
+ readonly instanceId: InstanceId;
346
+ readonly status: AdjustableStatus;
347
+ readonly present: boolean;
348
+ } | {
349
+ readonly kind: "exhaust";
350
+ readonly instanceId: InstanceId;
351
+ } | {
352
+ readonly kind: "ready";
353
+ readonly instanceId: InstanceId;
354
+ }
355
+ /**
356
+ * The player's identity turns to its other form, with no once-per-round limit and no form-change cost. `to` as for
357
+ * `Command changeForm`: required for a three-sided identity changing from alter-ego.
358
+ */
359
+ | {
360
+ readonly kind: "changeForm";
361
+ readonly playerId: PlayerId;
362
+ readonly to?: "alterEgo" | {
363
+ readonly heroForm: number;
364
+ };
365
+ };
366
+ export type AdjustmentKind = Adjustment["kind"];
@@ -35,6 +35,14 @@ export declare function changeIdentityForm(ctx: Ctx, playerId: PlayerId, to: "he
35
35
  */
36
36
  export declare function swapIdentity(ctx: Ctx, playerId: PlayerId): boolean;
37
37
  export declare function endGame(ctx: Ctx, outcome: GameOutcome): void;
38
+ /**
39
+ * The rest of RRG 1.8 "Player Elimination" (p. 34) step 5 for a hand `eliminatePlayer` left cards in (an ability still
40
+ * resolving had chosen them; #816): each card still in an eliminated player's hand goes to their discard pile, as the
41
+ * elimination's own sweep would have sent it. Returns true when it moved any. Called by `runFlow` with an empty stack,
42
+ * so the ability that held them, and anything it pushed, has resolved; and by `endGame` before `gameEnded`, since
43
+ * nothing more resolves once the game is over.
44
+ */
45
+ export declare function discardEliminatedHands(ctx: Ctx): boolean;
38
46
  export declare function shuffleZone(ctx: Ctx, zone: ZoneId, ids: readonly InstanceId[]): readonly InstanceId[];
39
47
  /**
40
48
  * Exhausts a card. `sourceInstanceId` is the card whose effect exhausts it (Sonic Boom's "exhaust each character you
@@ -709,6 +717,12 @@ export declare function settlePaidForEffects(ctx: Ctx, frameId: FrameId, effects
709
717
  * May 16, 2024): the attack on event frame `attackFrameId`, whose source is `sourceId`, is being initiated. Every
710
718
  * effect still waiting on the first attack of that card is retimed to `endOfEvent` on it, so it applies to this attack
711
719
  * only and ends as the attack finishes.
720
+ *
721
+ * An effect an earlier attack of the same card already claimed ends here instead: a second attack of that card is not
722
+ * "that attack". The earlier attack's frame can still be on the stack, waiting beneath its "(attack)" ability until the
723
+ * whole ability has resolved (`waitBeneathAbility`, owner ruling Q47), as when Berserker Barrage repeats its ability
724
+ * (FFG ruling, Wolverine, rrg-1-0-to-1-4/54-wolverine.md: "if you repeat its ability, the new attack will not have
725
+ * piercing"; #811). Ended, not retimed back: the earlier attack was made, so a later cancel cannot hand it on.
712
726
  */
713
727
  export declare function startFirstAttackEffects(ctx: Ctx, sourceId: InstanceId, attackFrameId: FrameId): void;
714
728
  /** "That attack" on a resource ability: the paid-for card's `playCard` frame, or the ability's effects frame, finished. */
@@ -3,7 +3,7 @@ import type { CampaignCardFace, CampaignWindow, LogWrite } from "./campaign.js";
3
3
  import type { RulesCardType } from "./card-types.js";
4
4
  import type { ChoiceId, EncounterDeckId, FrameId, GameAreaId, InstanceId, PlayerId } from "./ids.js";
5
5
  import type { CardPosition, ChoiceBehalf, PendingChoice, UnavailableOptions } from "./choices.js";
6
- import type { DelegableCostPart } from "./commands.js";
6
+ import type { Adjustment, DelegableCostPart } from "./commands.js";
7
7
  import type { GroupId } from "./ids.js";
8
8
  import type { SharedEvent, SharedPodState, SharedResult } from "./pod.js";
9
9
  import type { AccusationGuess, FacedownRole, Form, GameOutcome, GameStep, MainSchemeAdvancedBy, ZoneId } from "./state.js";
@@ -358,6 +358,8 @@ export type GameEvent = {
358
358
  * to its owner when it moves to a card no other player controls (RRG 1.8 "Ownership and Control", p. 31).
359
359
  */
360
360
  readonly reason: "firstPlayer" | "effect" | "attachedTo";
361
+ /** The host the upgrade was attached to when this was logged (reason `attachedTo`; absent in older logs). */
362
+ readonly hostInstanceId?: InstanceId;
361
363
  }
362
364
  /** A player became a card's owner by taking it (RRG 1.8 "Ownership and Control", p. 31; docs/phase7-wave2.md §3.10). */
363
365
  | {
@@ -1028,6 +1030,11 @@ export type GameEvent = {
1028
1030
  readonly instanceId: InstanceId;
1029
1031
  readonly status: "stunned" | "confused" | "tough";
1030
1032
  readonly reason: StatusDiscardCause;
1033
+ /**
1034
+ * Which activity a `cancelledSchemeOrThwart` removal cancelled, read from the character's role when it happened
1035
+ * (an ally treated as a minion schemes, so it cancels a scheme). Absent in older logs.
1036
+ */
1037
+ readonly cancelled?: "thwart" | "scheme";
1031
1038
  } | {
1032
1039
  readonly type: "threatPlaced";
1033
1040
  readonly schemeInstanceId: InstanceId;
@@ -2668,6 +2675,16 @@ export type GameEvent = {
2668
2675
  readonly type: "campaignCardRemoved";
2669
2676
  readonly instanceId: InstanceId;
2670
2677
  readonly card: CampaignCardFace;
2678
+ }
2679
+ /**
2680
+ * A manual adjustment began (`Command adjust`, issue #791): `playerId` corrected the game state by hand. Logged first,
2681
+ * so the events that follow (a `damagePlaced`, a `cardDiscarded`, a defeat) read as its result. Not a game event:
2682
+ * nothing in the rules answers it.
2683
+ */
2684
+ | {
2685
+ readonly type: "manualAdjustment";
2686
+ readonly playerId: PlayerId;
2687
+ readonly adjustment: Adjustment;
2671
2688
  } | {
2672
2689
  readonly type: "gameEnded";
2673
2690
  readonly outcome: GameOutcome;
@@ -1,4 +1,4 @@
1
- export declare const ENGINE_VERSION = "0.47.0";
1
+ export declare const ENGINE_VERSION = "0.49.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";
@@ -18,6 +18,7 @@ export { cardTotalFault, cardTotalOf, ENEMY_TEAM_CHOICE_INSTRUCTION, ENEMY_TEAM_
18
18
  export { effectChoiceAuthority, encounterTargetSelector, isEncounterSide, simultaneousOrderer, } from "./villain/authority.js";
19
19
  export type { AuditViolation, VillainActivationRecord, VillainAudit, VillainDecisionRecord, VillainPhaseRecord, } from "./villain/audit.js";
20
20
  export { auditVillainPhases } from "./villain/audit.js";
21
+ export { stepOneThreatOf, stepOneThreats, stepThreeDealCount, type StepOneThreat } from "./villain/step-one-threat.js";
21
22
  export type { ActionRef, BlockedTarget, IllegalAction, LegalAction, LegalActions, PaymentAttempt, PaymentContext, PaymentNotFor, PaymentQuery, PaymentSource, CostHelp, CostHelpAnswer, } from "./legal.js";
22
23
  export { costHelpFor, forcedActionOptionId, legalActions, outstandingForcedActions, doubledPaymentSource, paymentFor, tryPayment, type OutstandingForcedAction, } from "./legal.js";
23
24
  /** What a card costs right now vs. what is printed on it, and the cards moving the price (Steve Rogers' Living Legend). */
@@ -25,7 +26,7 @@ export type { PlayCost, PlayCostContribution } from "./actions.js";
25
26
  export { PAID_FOR_SLOT, additionalPlayCostOf, basicPowerCost, basicPowerDivisionTotal, costAsDetermined, handDiscardCandidates, inPlayCostCandidates, minimumChosenX, playCostOf, playCostWith, playableOutsideHand, } from "./actions.js";
26
27
  export { encounterSearchCostCandidates } from "./encounter-search-cost.js";
27
28
  export { asIfInHandPermissions, asIfInHandPlayOf, deckTopPermission, deckTopPlayOf, type AsIfInHandPermission, type DeckTopPermission, } from "./actions.js";
28
- export type { Command, CommandType, Payment, ResourceAbilityUse, SpentCardAbilityUse } from "./commands.js";
29
+ export type { AdjustableStatus, Adjustment, AdjustmentKind, Command, CommandType, Payment, ResourceAbilityUse, SpentCardAbilityUse, } from "./commands.js";
29
30
  export type { GameEvent, GameEventType } from "./events.js";
30
31
  export type { EngineError, EngineErrorCode, IllegalDeck } from "./errors.js";
31
32
  /** Deck legality (RRG 1.8 Appendix I) and playability in this build: two separate questions. */
@@ -38,7 +39,7 @@ export { addPools, combineRequirements, countUsableAs, declaredPool, EMPTY_POOL,
38
39
  export type { AttachmentBound, LastingDuration, LastingEffect, LastingEffectBody, LastingReach, LastingScope, } from "./lasting.js";
39
40
  export { allyLimitFor, cannotEnterPlay, enterPlayBarMessage, cannotFlip, cannotLeavePlay, cardAbilitiesCannotRemove, resourceIconsInPlay, canDivideBasicPower, cannotBeDealtDamage, cannotTakeDamage, evenlyDividesBasicPower, playDestinationsOf, countSchemeIcons, damageTakenAfterConstants, damageTakenAllowance, damageTakenBeforeSustainedCap, damageTakenBreakdown, damageSourceCard, phaseDamageAllowance, maxSustainedDamageOf, sustainedDamageAllowance, excessDamageBonus, formChangeCostsFor, grantedIcons, grantedLabeledAbilities, iconsBlankedOn, iconsInPlay, iconsOn, losesIcon, mayThwartWithAtk, mustDefendWithAlly, nonSchemeIcons, notDefeatedWithoutThreat, playerSideSchemeLimit, restrictedLimitFor, restrictedStanding, schemeThreatDestination, threatCannotBeRemoved, } from "./rules.js";
40
41
  export type { ConsequentialDamage, DamageSourceInfo, FormChangeCost, GrantedAbility } from "./rules.js";
41
- export { hasKeyword, isPermanent, keywordsOf, keywordTotal, printedFormTypes, printedKeywordsOf, statusActive, } from "./keywords.js";
42
+ export { hasKeyword, heldStatusCapacity, isPermanent, keywordsOf, keywordTotal, printedFormTypes, printedKeywordsOf, statusActive, } from "./keywords.js";
42
43
  export { linkedKeywordNames, linkedKeywordsOf } from "./linked.js";
43
44
  export { counterRoom } from "./counter-limit.js";
44
45
  export { tuckLimitOf, tuckRoom } from "./tuck-limit.js";
@@ -112,8 +113,8 @@ export { autoIncludedSetsInGame, chosenVillainOf, createGame, illegalDecksOf, ma
112
113
  export type { ApplyOptions, CommandResult, EventState, GameLog, GameSession, ReplayResult, SessionResult, } from "./engine.js";
113
114
  export { appendCommand, applyCommand, applyCommands, createLog, replay, sessionApply, startSession } from "./engine.js";
114
115
  export type { CharacterKind, CharacterProfile, HeroFaceWithTraits } from "./query.js";
115
- export { activeEncounterDeck, activeEncounterDeckId, activeVillain, cardZoneCandidates, currentName, encounterFace, showingResources, separateDeckDefinition, separateDeckOf, isFixedOrderDeck, mayLookThroughSeparateDeck, discardZoneFor, encounterDeckOf, heroFacesOf, identityFace, isVillain, undefeatedVillains, villainOf, villainStageOf, cardOf, characterProfile, getCard, getInstance, getPlayer, handSize, hasStarIcon, printsBoostAbility, isMinion, isLooseVillainCard, looseVillainSide, looseVillainStage, villainSideShowing, isTerminal, maxHitPoints, printedHpNumeral, printedMinionHp, printedHandSize, inClosedScenarioPlayArea, isOwnedEncounterCard, locateCard, playerCardOwnerOf, scenarioPlayAreaOf, mainSchemeStage, mainSchemeStageCount, mainSchemeStageOf, mainSchemeStagePosition, mainSchemeStateOf, mainSchemeStageMatches, mainSchemeValue, startingThreatOf, minionsEngagedWith, nextClockwisePlayer, playerOrder, printedCostOf, printedProfile, remainingHitPoints, scale, scaleIn, sharedScheme, sharedVillain, schemesInPlay, villainStage, zoneContents, } from "./query.js";
116
- export { legalDefenders } from "./resolve/enemy-activation.js";
116
+ export { activeEncounterDeck, activeEncounterDeckId, activeVillain, cardZoneCandidates, currentName, encounterFace, showingResources, separateDeckDefinition, separateDeckOf, isFixedOrderDeck, mayLookThroughSeparateDeck, discardZoneFor, encounterDeckOf, heroFacesOf, identityFace, areaOfCard, sameGameArea, isVillain, undefeatedVillains, villainOf, villainStageOf, cardOf, characterProfile, getCard, getInstance, getPlayer, handSize, hasStarIcon, printsBoostAbility, isMinion, isLooseVillainCard, looseVillainSide, looseVillainStage, villainSideShowing, isTerminal, maxHitPoints, printedHpNumeral, printedMinionHp, printedHandSize, inClosedScenarioPlayArea, isOwnedEncounterCard, locateCard, playerCardOwnerOf, scenarioPlayAreaOf, mainSchemeStage, mainSchemeStageCount, mainSchemeStageOf, mainSchemeStagePosition, mainSchemeStateOf, mainSchemeStageMatches, mainSchemeValue, startingThreatOf, minionsEngagedWith, nextClockwisePlayer, playerOrder, printedCostOf, printedProfile, remainingHitPoints, scale, scaleIn, sharedScheme, sharedVillain, schemesInPlay, villainStage, zoneContents, } from "./query.js";
117
+ export { getsBoostCard, legalDefenders } from "./resolve/enemy-activation.js";
117
118
  export { UNRESOLVED_VAR } from "./resolve/target-validity.js";
118
119
  export { mainSchemeCompletionLoses } from "./resolve/defeat.js";
119
120
  export { collectionCandidates } from "./resolve/collection.js";
@@ -587,7 +587,11 @@ export declare function waitBeneathAbility(ctx: Ctx, frame: AttackFrame): void;
587
587
  * resolves on from the frame as it is on the stack after this.
588
588
  */
589
589
  export declare function pushAttackedByAbility(ctx: Ctx, frame: Frame<"event">): boolean;
590
- /** The attack of `frame`'s "(attack)" ability that is waiting for it: the one made last, when there are several. */
590
+ /**
591
+ * The attack of `frame`'s "(attack)" ability that is waiting for it: the one made last, when there are several. Not one
592
+ * its player's elimination ended (`attackerEliminated`, `eliminated-attack.ts`): damage the rest of the ability deals is
593
+ * no longer that attack's.
594
+ */
591
595
  export declare function waitingAbilityAttack(state: GameState, deps: EngineDeps, frame: Frame<"effects">): AttackFrame | undefined;
592
596
  /**
593
597
  * What makes a `dealDamage` event of the waiting attack's ability that attack's damage to the enemy `targetId`
@@ -0,0 +1,32 @@
1
+ /**
2
+ * RRG 1.8 "Player Elimination" (p. 34): "If a player is eliminated in the middle of an attack, that attack ends." An
3
+ * attack of the eliminated identity on the stack at the elimination is marked (`Frame<"event">.attackerEliminated`,
4
+ * `eliminatePlayer` in `defeat.ts`), and the mark ends it wherever it stands:
5
+ *
6
+ * - **Before its damage step**: `applyPlayerAttack` deals nothing (`resolve/event.ts`).
7
+ * - **At its response step**, reached from its own apply step or, for an "(attack)" ability's attack waiting beneath the
8
+ * ability (`attack-ability.ts`), once the ability has finished: `endEliminatedAttack`. The attack is logged as ended
9
+ * (`playerAttackEnded`) and none of its remaining results resolve: no `characterAttacked` for the enemies a waiting
10
+ * attack attacked (so no retaliate), no "resolved" line and no response window for the attack itself ("after … attacks
11
+ * [and defeats]"). Damage it had already dealt stays dealt, so the conditions of that damage handed to the attack's
12
+ * window (`joinedResponses`, "after … takes damage") still open; its "at the end of this attack" effects still
13
+ * resolve, as for an attack that ended early (RRG 1.8 "Delayed Effect", p. 16).
14
+ * - **A `characterAttacked` of the attack not yet applied** (`partOfEliminatedAttack`): a basic attack pushes it with
15
+ * its damage, and an elimination while that damage resolves leaves it on the stack. It is taken off unapplied.
16
+ *
17
+ * A new attack begun after the elimination is not marked and resolves (owner call, #816; `attackOfEliminatedResolves`).
18
+ * A mark set during the attack's own response window (the attack has already resolved; its step 8 responses are being
19
+ * used) changes nothing.
20
+ */
21
+ import { type Ctx } from "../ctx.js";
22
+ import type { Frame } from "./frames.js";
23
+ import type { GameState } from "../state.js";
24
+ /** An attack frame its player's elimination ended (`attackerEliminated`). */
25
+ export declare function endedByElimination(frame: Frame<"event">): boolean;
26
+ /**
27
+ * Ends an attack frame at its response step (see the file header). Leaves it at `done`, holding only the damage
28
+ * conditions it was handed, so the `done` stage opens their window, runs its end-of-attack effects and pops it.
29
+ */
30
+ export declare function endEliminatedAttack(ctx: Ctx, frame: Frame<"event">): void;
31
+ /** A `characterAttacked` waiting to join the window of an attack its player's elimination ended. */
32
+ export declare function partOfEliminatedAttack(state: GameState, frame: Frame<"event">): boolean;
@@ -430,6 +430,13 @@ export type StackFrame =
430
430
  * finishes: no instruction made it, so it attacked only the enemies the ability's damage instructions named.
431
431
  */
432
432
  readonly attackBegun?: true;
433
+ /**
434
+ * On a player's `attack` event: its attacker's player was eliminated while this attack was underway (on the stack),
435
+ * so it ends (RRG 1.8 "Player Elimination", p. 34: "If a player is eliminated in the middle of an attack, that
436
+ * attack ends"; `eliminatePlayer`). An attack its identity begins after that, as the rest of an ability that is
437
+ * resolved in full, is not marked and resolves (owner call, #816; `applyPlayerAttack`).
438
+ */
439
+ readonly attackerEliminated?: true;
433
440
  /**
434
441
  * On an attack whose damage is all prevented (`modifyAttack.preventAllDamage` with a `bind`,
435
442
  * docs/phase7-wave9.md §3.4): where each instance the prevention stops is recorded, as this frame's vars
@@ -543,6 +550,13 @@ export type StackFrame =
543
550
  * `pending` are offered again, and the tier ends with a round in which nobody picks.
544
551
  */
545
552
  readonly pickedThisRound?: true;
553
+ /**
554
+ * The cards this window has played as events from a hand (or as if from a hand), by instance, in play order.
555
+ * Each play moved the card out of the hand, so one found in a hand again when the picked abilities have resolved
556
+ * came back (Morphogenetics returning the event it answered) and is a fresh copy: it is offered again for the
557
+ * same occurrence (`returnedToHandCandidates`). Absent until the window plays one.
558
+ */
559
+ readonly eventsPlayed?: readonly InstanceId[];
546
560
  /**
547
561
  * Interrupt windows only: the optional abilities that were live as the window opened and listen for this kind
548
562
  * of event (`hearersOf`), by key, whether or not their whole condition was met then. One of them whose
@@ -175,6 +175,14 @@ export type TriggerEventBody = {
175
175
  * this attack" budget (all about the attacked character) do not apply to it.
176
176
  */
177
177
  readonly notAttacked?: true;
178
+ /**
179
+ * The card whose effect redirected that damage (`notAttacked`; Psychic Misdirection), when it is a card of a player
180
+ * (`modifyAttack.damageTo` records it, enemy-activation.ts). The damage keeps the attacker as its source, but a
181
+ * defeat it causes is the redirecting card's: its `characterDefeated.sourceInstanceId` and defeating player are
182
+ * that card and its controller, so "after you defeat an enemy" hears it (FFG ruling January 24, 2025: Psychic
183
+ * Misdirection is an extension of your identity, so your identity defeated the enemy).
184
+ */
185
+ readonly redirectedBy?: InstanceId;
178
186
  /**
179
187
  * A share of an attack's damage dealt to a character that is not the attacked character: indirect damage assigned
180
188
  * to another character (RRG 1.8 "Indirect Damage", p. 24: "Only the defending character, or the attacked player's
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The threat each main scheme gains in step one of the villain phase (RRG 1.8 "Villain Phase", step 1; "Acceleration
3
+ * Icon" and "Acceleration Token", p. 5), split into where it comes from. `executePlaceThreat` places exactly these
4
+ * amounts, and the table reads the same numbers to show "+N per round" on a main scheme (issue #765), so the two can
5
+ * never disagree.
6
+ */
7
+ import type { EngineDeps } from "../abilities.js";
8
+ import type { InstanceId } from "../ids.js";
9
+ import type { GameState } from "../state.js";
10
+ /** One main scheme's step-one threat and its parts. */
11
+ export interface StepOneThreat {
12
+ readonly schemeInstanceId: InstanceId;
13
+ /** The stage's printed (or modified) acceleration value. */
14
+ readonly printed: number;
15
+ /** Acceleration tokens on this scheme. */
16
+ readonly tokens: number;
17
+ /**
18
+ * Acceleration tokens that add to this scheme from elsewhere: tokens on other cards (docs/phase7-wave5.md §3.4), or
19
+ * the central stage's tokens in a game with separate game areas (docs/phase7-wave2.md §4.3).
20
+ */
21
+ readonly otherTokens: number;
22
+ /** Acceleration icons in play that count for this scheme, printed and gained. */
23
+ readonly icons: number;
24
+ /** The sum: what step one places. */
25
+ readonly total: number;
26
+ }
27
+ /** Every main scheme that gains threat in step one, in the order `executePlaceThreat` places it. */
28
+ export declare function stepOneThreats(state: GameState, deps: EngineDeps): readonly StepOneThreat[];
29
+ /** One main scheme's step-one threat, or null for a card that gains none (a side scheme, a stage out of play). */
30
+ export declare const stepOneThreatOf: (state: GameState, deps: EngineDeps, schemeInstanceId: InstanceId) => StepOneThreat | null;
31
+ /**
32
+ * How many encounter cards step 3 of the villain phase deals (RRG 1.8 "Villain Phase", p. 47): one to each player, X
33
+ * more each at heroic level X (RRG 1.8 "Modes of Play", p. 29), then one per hazard icon in play in total, "not one
34
+ * card per player" (RRG 1.8 "Hazard Icon", p. 21). `executeDealEncounterCards` deals exactly this many, and the table's
35
+ * encounter deck forecast (issue #769) reads it.
36
+ */
37
+ export declare function stepThreeDealCount(state: GameState, deps: EngineDeps): number;