feat(parser): global double-all-damage replacement statics#3387
feat(parser): global double-all-damage replacement statics#3387glorysr1209-png wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces parsing support for global damage doubling replacement effects (CR 614.1a) in crates/engine/src/parser/oracle_replacement.rs, including a new helper function and a unit test. Feedback on the changes suggests moving the newly added unit test inside the mod tests block and improving its assertions to verify that the damage_source_filter is correctly parsed with the IsChosenCardType property.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| #[test] | ||
| fn parses_global_damage_double_sources_you_control() { | ||
| let def = parse_replacement_line( | ||
| "Double all damage that sources you control of the chosen type would deal.", | ||
| "Collective Inferno", | ||
| ).expect("global doubler"); | ||
| assert_eq!(def.damage_modification, Some(DamageModification::Double)); | ||
| } |
There was a problem hiding this comment.
Test Placement & Assertion Improvement
- Placement: This test is currently defined outside the
mod testsblock. To maintain the file's structure and keep all unit tests grouped together, please move this test inside themod testsblock (before line 11882). - Assertion: Update the test to assert that the
damage_source_filteris correctly parsed with theFilterProp::IsChosenCardTypeproperty to prevent future regressions.
#[test]
fn parses_global_damage_double_sources_you_control() {
let def = parse_replacement_line(
"Double all damage that sources you control of the chosen type would deal.",
"Collective Inferno",
).expect("global doubler");
assert_eq!(def.damage_modification, Some(DamageModification::Double));
assert_eq!(
def.damage_source_filter,
Some(TargetFilter::Typed(
TypedFilter::default()
.controller(ControllerRef::You)
.properties(vec![FilterProp::IsChosenCardType])
))
);
}434bb7c to
2fd0618
Compare
2fd0618 to
53daf67
Compare
matthewevans
left a comment
There was a problem hiding this comment.
Maintainer review — changes requested
Thanks for this. The seam is right (parse_replacement_line_inner → a dedicated parse_global_damage_double_replacement, building a ReplacementDefinition with DamageModification::Double + a damage_source_filter), and routing the source-subject through chained tag() combinators off split_once_on_lower is the idiomatic dispatch. Two blocking issues before this can merge:
1. The "of the chosen type" branch silently drops the chosen-type constraint (rules-correctness)
} else if let Ok((rest, _)) = tag(... "that sources you control of the chosen type would deal" ...) {
(Some(TargetFilter::Typed(TypedFilter::default().controller(ControllerRef::You))), rest)
}This produces an identical filter to the plain "that sources you control" branch — it doubles all of the controller's damage, not only damage from sources of the chosen type. For Collective Inferno that is a misparse: the card only doubles damage from sources of the chosen card type. The engine already has the building block for this — attach FilterProp::IsChosenCardType (see crates/engine/src/types/ability.rs:2462, resolved at crates/engine/src/game/filter.rs:2410). The branch must build:
TypedFilter::default().controller(ControllerRef::You).properties(vec![FilterProp::IsChosenCardType])As written, the named test card resolves incorrectly in-game.
2. Test does not discriminate the filter behavior
parses_global_damage_double_sources_you_control asserts only damage_modification == Some(Double). That assertion passes for every branch, so it would not catch the chosen-type drop above (it stays green whether or not the filter is correct). Add an assertion on def.damage_source_filter that pins IsChosenCardType for the chosen-type case, per the constituent the card requires.
3. Merge state is DIRTY
This branch has a textual conflict with origin/main (overlapping oracle_replacement.rs edits, including with the sibling PR #3391 in the same test region). It cannot enter the merge queue until rebased clean.
Once the chosen-type filter is correct, the test discriminates it, and the branch is rebased, this is mergeable.
Summary
Closes 3386. High-score replacement parser gap: global double-all-damage statics (Collective Inferno / Fiery Emancipation class). Token score ~5.
Changes
crates/engine/src/parser/oracle_replacement.rswith focused parser arm + unit testTest plan
#[test]inoracle_replacement.rscovers representative Oracle textcargo test -p engine(authoritative gate — not run locally)