fix(parser): compose Class-level trigger conditions instead of overwriting them (#5638)#6021
Conversation
…iting them (phase-rs#5638) parse_class_oracle_text gated level-2+ triggers by unconditionally assigning trigger.condition = ClassLevelGE, which silently dropped any printed intervening-if already parsed onto the trigger. Intermediate Chirography's level-3 ability ("if a modified creature died under your control this turn") lost its death check entirely and always created a token at end step. Compose with TriggerCondition::And instead, mirroring the existing static/replacement class-level wrappers. Closes phase-rs#5638
There was a problem hiding this comment.
Code Review
This pull request fixes a bug where class-level triggers with printed intervening-if conditions had their conditions unconditionally overwritten by the class level gate. The fix introduces wrap_trigger_with_class_level to compose both conditions using TriggerCondition::And instead of overwriting, and updates the corresponding tests and fixtures. The review feedback suggests flattening nested TriggerCondition::And structures to improve composability and using structured fields instead of fragile substring matching in tests.
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.
| .find(|t| { | ||
| t.description | ||
| .as_deref() | ||
| .is_some_and(|d| d.contains("end step")) | ||
| }) |
There was a problem hiding this comment.
Locating the trigger by searching for the substring "end step" in its description is a bit fragile. This could break if the description text is changed in the future. A more robust approach would be to match on the structured TriggerDefinition fields, such as mode and phase, which are less likely to change.
.find(|t| {
t.mode == crate::types::triggers::TriggerMode::Phase
&& t.phase == Some(crate::types::phase::Phase::End)
})
Parse changes introduced by this PR · 4 card(s), 4 signature(s) (baseline: main
|
…evel trigger Addresses Gemini review feedback on PR phase-rs#6021 (issue phase-rs#5638): - wrap_trigger_with_class_level now flattens into the existing And's conditions vec instead of nesting a new And around it, matching the composability convention used elsewhere in this module. - the level-3 trigger regression test now locates the end-step trigger by its structured mode/phase fields instead of a fragile substring match on the rendered description.
matthewevans
left a comment
There was a problem hiding this comment.
Approved: the Class-level gate now composes with each printed intervening-if at the parser authority, and the current parse-diff is limited to the four expected Class triggers.
fix(parser): compose Class-level trigger conditions instead of overwriting them (#5638)
parse_class_oracle_text gated level-2+ triggers by unconditionally
assigning trigger.condition = ClassLevelGE, which silently dropped any
printed intervening-if already parsed onto the trigger. Intermediate
Chirography's level-3 ability ("if a modified creature died under your
control this turn") lost its death check entirely and always created
a token at end step. Compose with TriggerCondition::And instead,
mirroring the existing static/replacement class-level wrappers.
Closes #5638