Skip to content

feat(parser): global double-all-damage replacement statics#3387

Open
glorysr1209-png wants to merge 1 commit into
phase-rs:mainfrom
glorysr1209-png:feat/02-global-damage-double
Open

feat(parser): global double-all-damage replacement statics#3387
glorysr1209-png wants to merge 1 commit into
phase-rs:mainfrom
glorysr1209-png:feat/02-global-damage-double

Conversation

@glorysr1209-png

Copy link
Copy Markdown
Contributor

Summary

Closes 3386. High-score replacement parser gap: global double-all-damage statics (Collective Inferno / Fiery Emancipation class). Token score ~5.

Changes

  • Extend crates/engine/src/parser/oracle_replacement.rs with focused parser arm + unit test
  • Minimal diff scoped to one high-leverage replacement pattern family

Test plan

  • New #[test] in oracle_replacement.rs covers representative Oracle text
  • CI cargo test -p engine (authoritative gate — not run locally)

@gemini-code-assist gemini-code-assist Bot left a comment

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.

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.

Comment on lines +11884 to +11892

#[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));
}

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.

medium

Test Placement & Assertion Improvement

  1. Placement: This test is currently defined outside the mod tests block. To maintain the file's structure and keep all unit tests grouped together, please move this test inside the mod tests block (before line 11882).
  2. Assertion: Update the test to assert that the damage_source_filter is correctly parsed with the FilterProp::IsChosenCardType property 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])
            ))
        );
    }

@glorysr1209-png glorysr1209-png force-pushed the feat/02-global-damage-double branch 3 times, most recently from 434bb7c to 2fd0618 Compare June 15, 2026 20:45
@glorysr1209-png glorysr1209-png force-pushed the feat/02-global-damage-double branch from 2fd0618 to 53daf67 Compare June 15, 2026 20:45

@matthewevans matthewevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants