Add 'the Ring tempts you' trigger parser (CR 701.52a) - #981
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for parsing 'The Ring tempts you' triggers in the Oracle parser and includes unit tests for both 'When' and 'Whenever' variants. The review feedback correctly identifies a violation of architectural rule R1, which prohibits verbatim string matching for Oracle phrases. The reviewer recommends refactoring the parser to use modular nom combinators to maintain consistency and improve maintainability.
| // CR 701.52a: "Whenever the Ring tempts you" / "When the Ring tempts you" — | ||
| // the Ring temptation event fires once per temptation resolution. | ||
| if matches!( | ||
| lower, | ||
| "whenever the ring tempts you" | "when the ring tempts you" | ||
| ) { |
There was a problem hiding this comment.
[MEDIUM] Verbatim string equality for Oracle phrase parsing. Rule R1 prohibits verbatim string matches (including matches! on full phrases) as they bypass the robust nom-based parser. Instead of matching the full phrase, decompose it into modular, reusable parsers for constituent parts (e.g., conjunctions and subjects) and compose them using combinators like alt and tuple to prevent combinatorial explosion and improve maintainability.
// CR 701.52a: Decomposed parser for "Whenever/When the Ring tempts you"
if all_consuming(tuple((
alt((tag("whenever "), tag("when "))),
tag("the ring tempts you"),
)))
.parse(lower).is_ok()References
- Rule R1 prohibits verbatim string equality on full Oracle phrases for parsing dispatch, requiring decomposition into modular nom combinators. (link)
Wire 'whenever/when the Ring tempts you' in try_parse_named_trigger_mode using matches! (same pattern as ChaosEnsues, SetInMotion, CrankContraption). Sets TriggerMode::RingTemptsYou — the matcher (match_ring_tempts_you) already exists and checks that the event player_id matches the source controller. Unlocks Sméagol Helpful Guide, Gandalf Friend of the Shire, Ringwraiths, Galadriel of Lothlórien, Faramir Field Commander, and Sauron the Dark Lord (all gap_count=1). Unit tests: trigger_ring_tempts_you_whenever, trigger_ring_tempts_you_when.
77504d5 to
3394245
Compare
Summary
Wire 'whenever/when the Ring tempts you' in
try_parse_named_trigger_modeusingmatches!(CR 701.52a). Same pattern asChaosEnsues,SetInMotion, andCrankContraption.Sets
TriggerMode::RingTemptsYou— the matcher (match_ring_tempts_you) already exists and checks that the eventplayer_idmatches the source controller.Unlocks Sméagol, Helpful Guide, Gandalf, Friend of the Shire, Ringwraiths, Galadriel of Lothlórien, Faramir, Field Commander, and Sauron, the Dark Lord (all gap_count=1).
Files changed
crates/engine/src/parser/oracle_trigger.rsmatches!arm for `"whenever the ring tempts you"Comprehensive Rules references
Track
Non-developer (parser-only)
LLM
Claude (Anthropic) — medium thinking
Verification
cargo fmt --all— cleanbash scripts/check-parser-combinators.sh— passcargo check -p engine --tests— pass (0 errors)Scope Expansion
None
Validation Failures
None
CI Failures
None (pre-push)