-
-
Notifications
You must be signed in to change notification settings - Fork 158
fix(parser): Runadi, Behemoth Caller ETB counters and haste threshold #6735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
matthewevans
merged 4 commits into
phase-rs:main
from
nghetien:fix/issue-6492-a1-runadi-behemoth-caller
Jul 29, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a475003
fix(parser): Runadi, Behemoth Caller ETB counters and haste threshold
nghetien 6f7275e
fix(PR-6735): address review feedback
nghetien 3ddbe75
fix(PR-6735): bind Runadi's floating replacement to its triggering spell
nghetien 48ebcdb
Merge remote-tracking branch 'origin/main' into pr/6735-sweep-0740
matthewevans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
crates/engine/tests/integration/runadi_behemoth_caller_etb_counters.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| //! Runadi, Behemoth Caller — RUNTIME witness for the ETB-counter replacement | ||
| //! and its downstream haste consequence (issue #6492). | ||
| //! | ||
| //! Oracle (verified via Scryfall, card j22/44): | ||
| //! "Whenever you cast a creature spell with mana value 5 or greater, that | ||
| //! creature enters with X additional +1/+1 counters on it, where X is its | ||
| //! mana value minus 4." | ||
| //! "Creatures you control with three or more +1/+1 counters on them have | ||
| //! haste." | ||
| //! "{T}: Add {G}." | ||
| //! | ||
| //! Pre-fix, the composite "its mana value minus 4" clause failed to parse | ||
| //! (the combinator only supported atomic quantity refs), misrouting the | ||
| //! ability to the self-ETB fallback with `valid_card: SelfRef` — Runadi would | ||
| //! try to put counters on HERSELF, not the cast creature, and the cast | ||
| //! creature would enter with 0 counters regardless of its mana value. | ||
| //! | ||
| //! CR references (verified against docs/MagicCompRules.txt): | ||
| //! - CR 614.1c: "[this permanent] enters with ..." is a replacement effect. | ||
| //! - CR 202.3: mana value. | ||
| //! - CR 122.1a: a +1/+1 counter adds 1 to power and 1 to toughness. | ||
| //! | ||
| //! Discrimination: a mana-value-8 creature must enter with 4 counters (8-4) | ||
| //! and gain Haste from the second ability's 3-or-more threshold; a | ||
| //! mana-value-4 creature must enter with 0 counters (filter excludes it) and | ||
| //! no Haste. | ||
|
|
||
| use engine::game::layers::evaluate_layers; | ||
| use engine::game::scenario::{GameScenario, P0}; | ||
| use engine::types::counter::CounterType; | ||
| use engine::types::keywords::Keyword; | ||
| use engine::types::mana::{ManaCost, ManaCostShard, ManaType, ManaUnit}; | ||
| use engine::types::phase::Phase; | ||
| use engine::types::zones::Zone; | ||
| use engine::types::ObjectId; | ||
|
|
||
| const RUNADI: &str = "Whenever you cast a creature spell with mana value 5 or greater, that creature enters with X additional +1/+1 counters on it, where X is its mana value minus 4.\nCreatures you control with three or more +1/+1 counters on them have haste.\n{T}: Add {G}."; | ||
|
|
||
| /// Cast a green creature of the given mana value (shards: GG, generic = mv - | ||
| /// 2) while Runadi is on P0's battlefield. Returns `(counters on the | ||
| /// entrant, entrant has Haste)`. | ||
| fn cast_creature_with_runadi(name: &str, mana_value: u32) -> (u32, bool) { | ||
| let mut scenario = GameScenario::new(); | ||
| scenario.at_phase(Phase::PreCombatMain); | ||
|
|
||
| scenario.add_creature_from_oracle(P0, "Runadi, Behemoth Caller", 1, 3, RUNADI); | ||
|
|
||
| let generic = mana_value.saturating_sub(2); | ||
| let spell = scenario | ||
| .add_creature_to_hand_from_oracle(P0, name, 1, 1, "") | ||
| .with_mana_cost(ManaCost::Cost { | ||
| shards: vec![ManaCostShard::Green, ManaCostShard::Green], | ||
| generic, | ||
| }) | ||
| .id(); | ||
|
|
||
| scenario.with_mana_pool( | ||
| P0, | ||
| (0..generic) | ||
| .map(|_| ManaUnit::new(ManaType::Colorless, ObjectId(0), false, Vec::new())) | ||
| .chain((0..2).map(|_| ManaUnit::new(ManaType::Green, ObjectId(0), false, Vec::new()))) | ||
| .collect(), | ||
| ); | ||
|
|
||
| let mut runner = scenario.build(); | ||
| let outcome = runner.cast(spell).resolve(); | ||
|
|
||
| let entered = outcome | ||
| .find_object(|o| o.name == name && o.zone == Zone::Battlefield) | ||
| .expect("cast creature must have entered the battlefield"); | ||
|
|
||
| let counters = outcome.counters(entered, CounterType::Plus1Plus1); | ||
|
|
||
| // Force a full layers re-evaluation to read the haste static's current | ||
| // grant — mirrors the established convention (see | ||
| // `frostcliff_siege_anchor_word_modes.rs`) since not every action reliably | ||
| // bumps `layers_dirty` on its own; this test cares about the counters | ||
| // (the actual bug) driving the static's condition, not about dirty-bit | ||
| // plumbing. | ||
| let state = runner.state_mut(); | ||
| state.layers_dirty.mark_full(); | ||
| evaluate_layers(state); | ||
| let has_haste = runner | ||
| .state() | ||
| .objects | ||
| .get(&entered) | ||
| .is_some_and(|obj| obj.keywords.contains(&Keyword::Haste)); | ||
| (counters, has_haste) | ||
| } | ||
|
|
||
| #[test] | ||
| fn runadi_grants_mv_minus_4_counters_and_downstream_haste_at_mv8() { | ||
| // MV 8: X = 8 - 4 = 4 counters, crossing the "three or more" haste | ||
| // threshold on the SAME creature. | ||
| assert_eq!( | ||
| cast_creature_with_runadi("Test Behemoth", 8), | ||
| (4, true), | ||
| "an MV8 creature must enter with 4 counters and gain haste from the \ | ||
| 3-or-more threshold; (0, false) means the ETB-counter replacement \ | ||
| never fired (issue #6492 regression)" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn runadi_grants_exactly_one_counter_at_mv5_threshold() { | ||
| // MV 5: X = 5 - 4 = 1 counter — below the haste threshold. | ||
| assert_eq!( | ||
| cast_creature_with_runadi("Test Whelp", 5), | ||
| (1, false), | ||
| "an MV5 creature (the exact threshold) must enter with exactly 1 \ | ||
| counter and not yet have haste" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn runadi_grants_no_counters_below_mv5_threshold() { | ||
| // MV 4: below the "mana value 5 or greater" filter — the replacement | ||
| // must not apply at all (proves the Cmc filter still gates correctly and | ||
| // the fix didn't turn this into an unconditional counter grant). | ||
| assert_eq!( | ||
| cast_creature_with_runadi("Test Sprite", 4), | ||
| (0, false), | ||
| "an MV4 creature must NOT receive any counters (mana value filter \ | ||
| excludes it) and must not have haste" | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.