-
-
Notifications
You must be signed in to change notification settings - Fork 139
fix(parser): parse "Activate only during an opponent's upkeep" (Trade… #6284
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6781,6 +6781,13 @@ fn parse_activation_during_role_gate(i: &str) -> OracleResult<'_, ActivationRest | |
| tag::<_, _, OracleError<'_>>("as a sorcery"), | ||
| ), | ||
| value(ActivationRestriction::AsInstant, tag("as an instant")), | ||
| value( | ||
| opponents_upkeep_activation_restriction(), | ||
| alt(( | ||
| tag("during an opponent's upkeep"), | ||
| tag("during an opponents upkeep"), | ||
| )), | ||
| ), | ||
|
Comment on lines
+6784
to
+6790
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Compose the role and step grammar instead of tagging whole clauses. These full-clause As per coding guidelines, “Never dispatch parsing by matching verbatim Oracle strings” and “Compose nom combinators across independent dimensions instead of enumerating full-string permutations.” 🤖 Prompt for AI AgentsSources: Coding guidelines, Path instructions |
||
| value( | ||
| opponents_turn_activation_restriction(), | ||
| alt(( | ||
|
|
@@ -7010,6 +7017,24 @@ fn opponents_turn_activation_condition() -> ParsedCondition { | |
| } | ||
| } | ||
|
|
||
| /// CR 602.5b + CR 102.1 + CR 503.1: "Activate only during an opponent's upkeep" | ||
| /// gates activation to the upkeep step of a turn where the activator is not the | ||
| /// active player (Trade Caravan). Composed from the same `Not(IsYourTurn)` | ||
| /// opponent-turn leaf as `opponents_turn_activation_condition` plus the | ||
| /// `IsDuringUpkeep` step predicate, so the opponent scope reuses the existing | ||
| /// composition idiom instead of a dedicated `DuringOpponents*` restriction | ||
| /// sibling. | ||
| fn opponents_upkeep_activation_restriction() -> ActivationRestriction { | ||
| ActivationRestriction::RequiresCondition { | ||
| condition: Some(ParsedCondition::And { | ||
| conditions: vec![ | ||
| opponents_turn_activation_condition(), | ||
| ParsedCondition::IsDuringUpkeep, | ||
| ], | ||
| }), | ||
| } | ||
| } | ||
|
|
||
| pub(super) fn strip_activated_constraints(text: &str) -> (String, ActivatedConstraintAst) { | ||
| let mut remaining = text.trim().trim_end_matches('.').trim().to_string(); | ||
| let mut constraints = ActivatedConstraintAst::default(); | ||
|
|
||
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.
Avoid verbatim string equality for parsing Oracle phrases as it bypasses the robust nom-based parser and creates fragile matches. Instead of adding verbatim string variants to the
altcombinator, decompose compound phrases into modular, reusable parsers for constituent parts (e.g., the preposition, determiner, subject, and phase) and compose them using idiomatic combinator aggregates to prevent combinatorial explosion and improve maintainability.References