-
-
Notifications
You must be signed in to change notification settings - Fork 157
Fix Worldspine Wurm duplicate triggers #7526
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 11 commits into
phase-rs:main
from
traemyn:card/fix-worldspine-wurm
Aug 18, 2026
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
20e39f1
Fix duplicate Worldspine Wurm triggers
traemyn f58a465
Cover paused cost trigger ownership
traemyn 8726f63
Guard settled sacrifice trigger events
traemyn a5e5bf3
Guard activation sacrifice trigger settlement
traemyn 89f0daf
Filter pending-order cost events per occurrence
traemyn a49cc40
Route cost-event parking through the already-collected authority
traemyn ed9fba7
Merge remote-tracking branch 'upstream/main' into card/fix-worldspine…
traemyn fb9f0bd
Normalize the integration fixture to the one card the regression adds
traemyn 35defe5
Filter carried and current cost fragments on their own occurrence bases
traemyn a73ef53
Merge remote-tracking branch 'origin/main' into pr/7526-handler-199
matthewevans 9d15857
docs(PR-7526): correct occurrence identity annotation
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
113 changes: 113 additions & 0 deletions
113
crates/engine/tests/integration/issue_worldspine_wurm_duplicate_triggers.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,113 @@ | ||
| //! Regression coverage for duplicate Worldspine Wurm triggers during a | ||
| //! Recurring Nightmare activation. | ||
|
|
||
| use engine::database::card_db::CardDatabase; | ||
| use engine::game::scenario::{GameScenario, P0}; | ||
| use engine::game::scenario_db::GameScenarioDbExt; | ||
| use engine::types::ability::TargetRef; | ||
| use engine::types::actions::GameAction; | ||
| use engine::types::game_state::{PayCostKind, StackEntryKind, WaitingFor}; | ||
| use engine::types::identifiers::ObjectId; | ||
| use engine::types::mana::{ManaType, ManaUnit}; | ||
| use engine::types::phase::Phase; | ||
| use engine::types::zones::Zone; | ||
|
|
||
| use crate::support::shared_card_db; | ||
|
|
||
| fn card_db() -> &'static CardDatabase { | ||
| shared_card_db().expect("integration card fixture must load") | ||
| } | ||
|
|
||
| #[test] | ||
| fn worldspine_wurm_sacrifice_creates_each_trigger_once() { | ||
| let db = card_db(); | ||
| let mut scenario = GameScenario::new(); | ||
| scenario.at_phase(Phase::PreCombatMain); | ||
| scenario.with_mana_pool( | ||
| P0, | ||
| vec![ | ||
| ManaUnit::new(ManaType::Colorless, ObjectId(9_998), false, vec![]), | ||
| ManaUnit::new(ManaType::Colorless, ObjectId(9_999), false, vec![]), | ||
| ManaUnit::new(ManaType::Black, ObjectId(10_000), false, vec![]), | ||
| ], | ||
| ); | ||
|
|
||
| let wurm = scenario.add_real_card(P0, "Worldspine Wurm", Zone::Battlefield, db); | ||
| let nightmare = scenario.add_real_card(P0, "Recurring Nightmare", Zone::Battlefield, db); | ||
| let graveyard_creature = scenario.add_real_card(P0, "Grizzly Bears", Zone::Graveyard, db); | ||
| let _other_graveyard_creature = | ||
| scenario.add_real_card(P0, "Elvish Mystic", Zone::Graveyard, db); | ||
| let mut runner = scenario.build(); | ||
| let ability_index = runner.state().objects[&nightmare] | ||
| .abilities | ||
| .iter() | ||
| .position(|ability| matches!(ability.kind, engine::types::ability::AbilityKind::Activated)) | ||
| .expect("Recurring Nightmare must have an activated ability"); | ||
|
|
||
| runner | ||
| .act(GameAction::ActivateAbility { | ||
| source_id: nightmare, | ||
| ability_index, | ||
| }) | ||
| .expect("begin Recurring Nightmare activation"); | ||
|
|
||
| let mut saw_sacrifice = false; | ||
| let mut saw_target = false; | ||
| for _ in 0..32 { | ||
| match runner.state().waiting_for.clone() { | ||
| WaitingFor::TargetSelection { .. } => { | ||
| runner | ||
| .act(GameAction::SelectTargets { | ||
| targets: vec![TargetRef::Object(graveyard_creature)], | ||
| }) | ||
| .expect("select Recurring Nightmare target"); | ||
| saw_target = true; | ||
| } | ||
| WaitingFor::PayCost { | ||
| kind: PayCostKind::Sacrifice, | ||
| .. | ||
| } => { | ||
| runner | ||
| .act(GameAction::SelectCards { cards: vec![wurm] }) | ||
| .expect("sacrifice Worldspine Wurm"); | ||
| saw_sacrifice = true; | ||
| } | ||
| WaitingFor::ManaPayment { .. } => { | ||
| runner | ||
| .act(GameAction::PassPriority) | ||
| .expect("pay Recurring Nightmare's mana cost"); | ||
| } | ||
| WaitingFor::OrderTriggers { .. } => { | ||
| engine::game::triggers::drain_order_triggers_with_identity(runner.state_mut()); | ||
| } | ||
| WaitingFor::Priority { .. } => break, | ||
| other => panic!("unexpected waiting state during activation: {other:?}"), | ||
| } | ||
| } | ||
|
|
||
| assert!(saw_sacrifice, "activation must sacrifice Worldspine Wurm"); | ||
| assert!(saw_target, "activation must choose a graveyard creature"); | ||
|
|
||
| // Without the cost-event ownership check, the sacrifice event is parked a | ||
| // second time while this ordering prompt is being returned, producing four | ||
| // Wurm trigger entries instead of the two below. | ||
| let wurm_triggers: Vec<_> = runner | ||
| .state() | ||
| .stack | ||
| .iter() | ||
| .filter(|entry| entry.source_id == wurm) | ||
| .filter_map(|entry| match &entry.kind { | ||
| StackEntryKind::TriggeredAbility { description, .. } => description.clone(), | ||
| _ => None, | ||
| }) | ||
| .collect(); | ||
| assert_eq!( | ||
| wurm_triggers, | ||
| vec![ | ||
| "When ~ dies, create three 5/5 green Wurm creature tokens with trample.".to_string(), | ||
| "When ~ is put into a graveyard from anywhere, shuffle it into its owner's library." | ||
| .to_string(), | ||
| ], | ||
| "a single Battlefield-to-Graveyard move must create one of each Wurm trigger", | ||
| ); | ||
| } |
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 50370
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 50371
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 50371
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 50370
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 50371
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 50371
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 50371
🏁 Script executed:
Repository: phase-rs/phase
Length of output: 390
Journal current occurrences before returning.
pending_trigger_order_owns_eventchecks pending contexts, but it does not prove that the event exists inconsumed_before_priority_trigger_events. This return skipsConsumeBeforePriorityfor the current slice. Record the exact full-buffer occurrence identities before returning, and add a pause/resume regression test that checks repeated settlement does not duplicate triggers.🤖 Prompt for AI Agents
Source: Learnings