Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions crates/engine/tests/integration/issue_1515_emperor_of_bones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ use engine::types::zones::Zone;
const EMPEROR_COUNTER_TRIGGER_EFFECT: &str = "put a creature card exiled with this creature onto \
the battlefield under your control with a finality counter on it. it gains haste. sacrifice it at \
the beginning of the next end step.";
const EMPEROR_ORACLE: &str =
"At the beginning of combat on your turn, exile up to one target card from a graveyard.\n\
{1}{B}: Adapt 2.\n\
Whenever one or more +1/+1 counters are put on this creature, put a creature card exiled with this \
creature onto the battlefield under your control with a finality counter on it. It gains haste. \
Sacrifice it at the beginning of the next end step.";
Comment on lines +29 to +31

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the authoritative Oracle wording for both self-references.

The fixture replaces both self-references with this creature. The authoritative Modern Horizons 3 text uses Emperor of Bones in both places. (magic.wizards.com) This test can otherwise exercise a different parser path from the production card text.

Proposed Oracle-text fix
-Whenever one or more +1/+1 counters are put on this creature, put a creature card exiled with this \
-creature onto the battlefield under your control with a finality counter on it. It gains haste. \
+Whenever one or more +1/+1 counters are put on Emperor of Bones, put a creature card exiled with \
+Emperor of Bones onto the battlefield under your control with a finality counter on it. It gains haste. \

As per path instructions: “Preserve authoritative Oracle text.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Whenever one or more +1/+1 counters are put on this creature, put a creature card exiled with this \
creature onto the battlefield under your control with a finality counter on it. It gains haste. \
Sacrifice it at the beginning of the next end step.";
Whenever one or more +1/+1 counters are put on Emperor of Bones, put a creature card exiled with \
Emperor of Bones onto the battlefield under your control with a finality counter on it. It gains haste. \
Sacrifice it at the beginning of the next end step.";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/engine/tests/integration/issue_1515_emperor_of_bones.rs` around lines
29 - 31, Update the Emperor of Bones fixture text in the affected test to
replace both “this creature” self-references with “Emperor of Bones,” preserving
the authoritative Oracle wording and all other text unchanged.

Source: Path instructions

const PUT_COUNTER_ORACLE: &str = "Put a +1/+1 counter on target creature.";

const ANOINTED_PEACEKEEPER: &str = "Vigilance\n\
As this creature enters, look at an opponent's hand, then choose any card name.\n\
Expand Down Expand Up @@ -167,6 +174,68 @@ fn issue_1515_emperor_of_bones_binds_haste_and_delayed_sacrifice_to_returned_cre
);
}

/// CR 122.1 + CR 603.2 + CR 608.2c: Drive the printed counter trigger through
/// the reducer so the returned creature, rather than the trigger source, owns
/// both anaphoric riders.
#[test]
fn emperor_of_bones_counter_trigger_uses_returned_creature_in_cast_pipeline() {
let mut scenario = GameScenario::new();
scenario.at_phase(Phase::PreCombatMain);
let emperor = scenario
.add_creature_from_oracle(P0, "Emperor of Bones", 2, 2, EMPEROR_ORACLE)
.id();
let returned = scenario
.add_creature_to_exile(P0, "Linked Gravebeast", 3, 3)
.id();
let counter_spell = scenario
.add_spell_to_hand_from_oracle(P0, "Counter Placement", false, PUT_COUNTER_ORACLE)
.id();

let mut runner = scenario.build();
runner.state_mut().exile_links.push(ExileLink {
exiled_id: returned,
source_id: emperor,
kind: ExileLinkKind::TrackedBySource,
});

runner.cast(counter_spell).target_object(emperor).resolve();

let state = runner.state();
assert_eq!(
state.objects[&returned].zone,
Zone::Battlefield,
"the counter trigger must return the linked creature through apply()"
);
Comment on lines +203 to +208

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Assert the finality counter on the returned creature.

The test proves that returned reaches the battlefield, but it does not prove that the return effect adds the required finality counter. The upstream build_dies_return_with_counter_trigger contract explicitly models this with enter_with_counters.

A regression that omits the counter would still pass these assertions. Under CR 122.1h, the counter changes a later graveyard move into exile. (media.wizards.com) Add an assertion using the existing counter accessor, and reference CR 122.1h in the test comment.

As per path instructions: “A test must exercise the failure path the fix prevents.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/engine/tests/integration/issue_1515_emperor_of_bones.rs` around lines
203 - 208, Extend the assertions in the test around returned and state to verify
that the returned creature has the required finality counter using the existing
counter accessor. Update the test comment to reference CR 122.1h, ensuring the
test fails when enter_with_counters is omitted.

Source: Path instructions

assert_eq!(
state.objects[&returned]
.counters
.get(&CounterType::Finality)
.copied()
.unwrap_or(0),
1,
"the returned creature must receive Emperor's finality entry modifier"
);
assert_eq!(
state.objects[&emperor].zone,
Zone::Battlefield,
"the counter trigger must not sacrifice Emperor while resolving"
);
assert!(
creature_has_haste_from_transient_effects(state, returned),
"the printed haste rider must bind to the returned creature"
);
assert!(
!creature_has_haste_from_transient_effects(state, emperor),
"the printed haste rider must not bind to Emperor"
);
assert_eq!(state.delayed_triggers.len(), 1);
assert_eq!(
state.delayed_triggers[0].ability.targets,
vec![engine::types::ability::TargetRef::Object(returned)],
"the delayed sacrifice must snapshot the returned creature"
);
}

/// CR 614.12a + CR 400.7j: An as-enters choice on the returned permanent must
/// complete without losing later instructions that refer to that permanent.
#[test]
Expand Down
Loading