-
-
Notifications
You must be signed in to change notification settings - Fork 153
fix(parser): parse Faerie Miscreant singleton named condition #7297
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fa55eaf
fix(parser): parse singleton named control conditions
keloide e048205
docs(parser): clear faerie miscreant backlog entry
keloide 8a79a7e
test(parser): correct Faerie Miscreant ETB assertion
keloide 3f0a333
test(PR-7297): harden Faerie Miscreant regressions
matthewevans cda8ae0
Merge branch 'main' into card/faerie-miscreant
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
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
133 changes: 133 additions & 0 deletions
133
crates/engine/tests/integration/issue_7154_faerie_miscreant.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,133 @@ | ||
| //! Regression for issue #7154 — Faerie Miscreant's named-card intervening-if. | ||
| //! | ||
| //! The exact Oracle condition is checked when Faerie Miscreant enters and again | ||
| //! while its trigger resolves (CR 603.4). These tests use the real cast, | ||
| //! battlefield-entry, trigger-collection, and resolution pipeline. | ||
|
|
||
| use engine::game::scenario::{GameRunner, GameScenario, P0}; | ||
| use engine::types::ability::{FilterProp, TargetFilter, TriggerCondition, TypeFilter}; | ||
| use engine::types::actions::GameAction; | ||
| use engine::types::game_state::StackEntryKind; | ||
| use engine::types::mana::ManaCost; | ||
| use engine::types::phase::Phase; | ||
| use engine::types::zones::Zone; | ||
| use engine::types::ObjectId; | ||
|
|
||
| const FAERIE_MISCREANT: &str = | ||
| "Flying\nWhen this creature enters, if you control another creature named Faerie Miscreant, draw a card."; | ||
| const DESTROY_TARGET_CREATURE: &str = "Destroy target creature."; | ||
|
|
||
| fn has_named_companion_condition(runner: &GameRunner, source: ObjectId) -> bool { | ||
| runner.state().objects[&source] | ||
| .trigger_definitions | ||
| .as_slice() | ||
| .iter() | ||
| .any(|entry| matches!( | ||
| &entry.definition.condition, | ||
| Some(TriggerCondition::ControlsType { | ||
| filter: TargetFilter::Typed(filter), | ||
| }) if filter.type_filters.contains(&TypeFilter::Creature) | ||
| && filter.properties.iter().any(|property| matches!( | ||
| property, | ||
| FilterProp::Named { name } if name == "faerie miscreant" | ||
| )) | ||
| && filter.properties.iter().any(|property| matches!(property, FilterProp::Another)) | ||
| )) | ||
| } | ||
|
|
||
| fn faerie_on_stack(runner: &GameRunner, source: ObjectId) -> bool { | ||
| runner.state().stack.iter().any(|entry| { | ||
| matches!( | ||
| &entry.kind, | ||
| StackEntryKind::TriggeredAbility { source_id, .. } if *source_id == source | ||
| ) | ||
| }) | ||
| } | ||
|
|
||
| #[test] | ||
| fn draws_when_another_faerie_miscreant_is_present() { | ||
| let mut scenario = GameScenario::new(); | ||
| scenario.at_phase(Phase::PreCombatMain); | ||
| scenario.with_library_top(P0, &["Drawn card"]); | ||
| scenario.add_creature(P0, "Faerie Miscreant", 1, 1); | ||
| let faerie = scenario | ||
| .add_creature_to_hand_from_oracle(P0, "Faerie Miscreant", 1, 1, FAERIE_MISCREANT) | ||
| .with_mana_cost(ManaCost::zero()) | ||
| .id(); | ||
|
|
||
| let mut runner = scenario.build(); | ||
| assert!( | ||
| has_named_companion_condition(&runner, faerie), | ||
| "reach-guard: exact Oracle must synthesize the named companion condition" | ||
| ); | ||
|
|
||
| let outcome = runner.cast(faerie).resolve(); | ||
| outcome.assert_hand_drawn(P0, 1); | ||
| } | ||
|
|
||
| #[test] | ||
| fn does_not_draw_without_another_faerie_miscreant() { | ||
| let mut scenario = GameScenario::new(); | ||
| scenario.at_phase(Phase::PreCombatMain); | ||
| scenario.with_library_top(P0, &["Drawn card"]); | ||
| scenario.add_creature(P0, "Wrong Name Companion", 1, 1); | ||
| let faerie = scenario | ||
| .add_creature_to_hand_from_oracle(P0, "Faerie Miscreant", 1, 1, FAERIE_MISCREANT) | ||
| .with_mana_cost(ManaCost::zero()) | ||
| .id(); | ||
|
|
||
| let mut runner = scenario.build(); | ||
| assert!( | ||
| has_named_companion_condition(&runner, faerie), | ||
| "reach-guard: the negative starts from the parsed named companion condition" | ||
| ); | ||
|
|
||
| let outcome = runner.cast(faerie).resolve(); | ||
| outcome.assert_hand_drawn(P0, 0); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| #[test] | ||
| fn companion_removed_after_trigger_fires_prevents_resolution_draw() { | ||
| let mut scenario = GameScenario::new(); | ||
| scenario.at_phase(Phase::PreCombatMain); | ||
| scenario.with_library_top(P0, &["Drawn card"]); | ||
| let companion = scenario.add_creature(P0, "Faerie Miscreant", 1, 1).id(); | ||
| let faerie = scenario | ||
| .add_creature_to_hand_from_oracle(P0, "Faerie Miscreant", 1, 1, FAERIE_MISCREANT) | ||
| .with_mana_cost(ManaCost::zero()) | ||
| .id(); | ||
| let destroy_spell = scenario | ||
| .add_spell_to_hand_from_oracle(P0, "Destroy Companion", true, DESTROY_TARGET_CREATURE) | ||
| .with_mana_cost(ManaCost::zero()) | ||
| .id(); | ||
|
|
||
| let mut runner = scenario.build(); | ||
| runner.cast(faerie).commit(); | ||
|
|
||
| let mut fired = false; | ||
| for _ in 0..12 { | ||
| let entered = runner.state().objects[&faerie].zone == Zone::Battlefield; | ||
| if entered && faerie_on_stack(&runner, faerie) { | ||
| fired = true; | ||
| break; | ||
| } | ||
| runner | ||
| .act(GameAction::PassPriority) | ||
| .expect("advance creature spell to its triggered ability"); | ||
| } | ||
| assert!( | ||
| fired, | ||
| "reach-guard: the condition held on entry and Faerie Miscreant's trigger reached the stack" | ||
| ); | ||
|
|
||
| let outcome = runner | ||
| .cast(destroy_spell) | ||
| .target_object(companion) | ||
| .resolve(); | ||
| assert_eq!( | ||
| outcome.zone_of(companion), | ||
| Zone::Graveyard, | ||
| "the production Destroy pipeline must move the companion before the trigger rechecks" | ||
| ); | ||
| outcome.assert_hand_drawn(P0, 0); | ||
| } | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Add a verified CR annotation for singleton named-card parsing.
Lines 965-976 make a connector-less named card valid as one condition. This rules-facing behavior has no verified
CR <number>: <description>annotation. Add an annotation that describes the named-card rule basis and the singleton condition semantics.As per coding guidelines: “Implement MTG behavior according to the Comprehensive Rules; verify the relevant CR section before completion, and annotate rules-related code with a verified CR number and description.”
🤖 Prompt for AI Agents
Sources: Coding guidelines, Path instructions