docs(lessons): Sequence vs outermost Phase differs bullet (02, 03); lesson 01 cross-reference
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
bb98be089a
commit
6e95bef5a2
@@ -10,7 +10,7 @@ Acolyte of Pain is a 3-mana 1/4 ([Acolyte of Pain, hearthstone.wiki.gg](https://
|
||||
|
||||
> Whenever this minion takes damage, draw a card.
|
||||
|
||||
You have two Acolytes of Pain on your board. Call them A and B. You played A first. For this exercise, suppose B stands to the left of A. That is a setup the course chooses, not a claim about how the game places minions; the next paragraph shows one sourced way the newest minion can end up left of an older one. You cast Whirlwind: "Deal 1 damage to ALL minions." ([Whirlwind](https://hearthstone.wiki.gg/wiki/Whirlwind)).
|
||||
You have two Acolytes of Pain on your board. Call them A and B. You played A first. For this exercise, suppose B stands to the left of A. That is a setup the course chooses, not a claim about how the game places minions; an example below shows one sourced way the newest minion can end up left of an older one. You cast Whirlwind: "Deal 1 damage to ALL minions." ([Whirlwind](https://hearthstone.wiki.gg/wiki/Whirlwind)).
|
||||
|
||||
Both Acolytes take damage and both draw a card. By the rule quoted next, A's trigger goes first, even though B is further left. When Hearthstone orders triggers, it does not ask where a minion stands. It asks when the minion entered play. The Advanced rulebook's Rule 2a: "A Queue is created and filled with all triggers that can respond, in order of play." And its definition: "Order of play means the order the Entities each Event/trigger is associated with entered play, from oldest to newest." ([Advanced rulebook](https://hearthstone.wiki.gg/wiki/Advanced_rulebook)). Area damage follows the same order: "all of the Damage/Healing Events are created in play order" (same source).
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ function react(world: World, events: Event[]): void {
|
||||
}
|
||||
```
|
||||
|
||||
Two things to notice. The call stack *is* the depth-first order: `perform` calls `react`, which calls `perform` for a nested action, and the outer loop only continues once that returns. And `run_sequence` / `runSequence` is a single entry point for every player action. That is where Module 3 will add death processing, "once the outermost Phase ends".
|
||||
Two things to notice. The call stack *is* the depth-first order: `perform` calls `react`, which calls `perform` for a nested action, and the outer loop only continues once that returns. And `run_sequence` / `runSequence` is a single entry point for every player action. That is where Module 3 will add death processing. The course treats a player action's whole Sequence as one outermost Phase, so the end of `run_sequence` is where "the outermost Phase ends" ([Advanced rulebook](https://hearthstone.wiki.gg/wiki/Advanced_rulebook)); Module 3 says how the real game differs.
|
||||
|
||||
This is not the queue you may know from other games. Robert Nystrom's *Event Queue* chapter, the classic description of the general pattern, says "You only need a queue when you want to decouple something in time" and offers "A common rule to avoid this is to avoid sending events from within code that's handling one" ([*Game Programming Patterns*, Event Queue](https://gameprogrammingpatterns.com/event-queue.html)). A card game breaks that rule on purpose: reactions cause reactions. It survives by fixing the order explicitly (order of play) and the depth (finish the child before the sibling).
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ Make the four tests pass without breaking Modules 1 and 2. The rules for where c
|
||||
|
||||
<details><summary>Hint 1 — nudge</summary>
|
||||
|
||||
Your Module 2 `runSequence` has a comment where deaths go. After `perform` returns, every Queue of the Sequence has been resolved, so that line is the end of the outermost Phase. What should happen there? And what must happen *again* after the Deathrattles you resolve there have finished?
|
||||
Your Module 2 `runSequence` has a comment where deaths go. After `perform` returns, every Queue of the Sequence has been resolved. The course treats that point as the end of the outermost Phase (see "How the real game differs" below). What should happen there? And what must happen *again* after the Deathrattles you resolve there have finished?
|
||||
|
||||
</details>
|
||||
|
||||
@@ -229,6 +229,7 @@ Two decisions in the reference are worth naming, because the rulebook raises the
|
||||
- **"A trigger cannot be nested inside itself"** ([Advanced rulebook](https://hearthstone.wiki.gg/wiki/Advanced_rulebook)). The reference has no guard for this yet. No card in this module can nest a trigger inside itself: a Ghoul whose Deathrattle kills another Ghoul doesn't nest anything, because the second Ghoul's Deathrattle waits for the next Death Phase. Two Module 2-style cards that deal damage whenever a minion takes damage *would* recurse forever, and the rule is the cure. Add it when a card needs it.
|
||||
|
||||
> **How the real game differs**
|
||||
> - The course treats each player action (a `dealDamage`, a `cast`, from Module 4 a `play`) as one outermost Phase, and processes deaths once, after the whole action. In the real game "A Sequence is what begins when a Player Action is taken" and a Sequence is made of Phases, and "death processing is not done in the middle of a Phase, but is done between Phases" ([Advanced rulebook](https://hearthstone.wiki.gg/wiki/Advanced_rulebook)). So one player action can have deaths processed more than once, between its Phases. The course does not model which Phases each action has; none of the course's cards can tell the difference.
|
||||
> - The Death Creation Step is one of several steps at the end of the outermost Phase: "After the outermost Phase ends, Hearthstone does an Aura Update (Health/Attack), then does the Death Creation Step", and an Aura Update (Other) follows it ([Advanced rulebook](https://hearthstone.wiki.gg/wiki/Advanced_rulebook)). The course has no auras until Module 4, which adds both updates around the step.
|
||||
> - The rulebook says "negative (damaging/destroying/hindering/misdirecting) triggers ignore mortally wounded and pending destroy characters", while "AoE effects count mortally wounded" (same source). The course's area effects count them, which matches; nothing in the course is a targeted negative trigger, so the first rule is not modelled.
|
||||
> - A Death Phase queues "Deathrattles, on-Death Secrets and on-Death triggered effects" (same source). The course has only Deathrattles.
|
||||
|
||||
Reference in New Issue
Block a user