card Rule lookup #3
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
pyaniz/mtg-bot#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add the ability to look up for specific card text examples in the rules. For example /rules "blood moon" should return all the rules that have the text blood moon in it. This is for rules, not gatherer.
Implemented. This turned out to need two separate things, because the literal request doesn't work on its own.
Finding first: the Comprehensive Rules contain zero occurrences of "blood moon". The CR is a rules document and almost never names individual cards, so
/rules "blood moon"searching rule text correctly returns nothing. Implementing only the literal request would have looked broken on the exact example in this issue.1. Phrase search (the literal request)
/rules "double strike"now matches those words adjacently. Previously the query was tokenised and OR'd, soblood moonreturned every rule containing blood or moon — 5 results, all noise. Now:2. Card lookup (what the example actually needed)
When a text search finds nothing and the query names a card, the bot answers the question being asked instead:
The bridge is the glossary: 657 of its 739 entries cite a rule number, so a card's type line and oracle text map onto the rules that govern them. Cards with keyword abilities lead with those — Questing Beast returns vigilance (702.20), haste (702.10) and deathtouch (702.2).
Known quirk
/rules lightning boltreturns rule 107.10, which genuinely contains the phrase "a lightning bolt for instant" while describing Future Sight frame icons. It's a correct literal match, so the card path doesn't trigger.Left literal on purpose: preferring cards would hijack searches for terms that are both a card and a rules concept, such as
counterspell. Easy to flip if the card reading is preferred.Changed
bot/rules_engine/search.py— phrase/all/any search modes, glossary concept extractionbot/handlers/rules.py— search order and the card fallbackbot/scryfall.py— expose card keywordsVerified no regressions in the inline
!qrules mode or the/askretrieval path.