-
Notifications
You must be signed in to change notification settings - Fork 855
Verify card name not in rules #13768
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: master
Are you sure you want to change the base?
Conversation
| if (rule.contains("&mdash ")) { | ||
| fail(card, "rules", "card's rules contains restricted test [&mdash ] instead [—]"); | ||
| } | ||
| if (Pattern.compile("(?<!named )"+Pattern.quote(card.getName())+"(?! \\{)").matcher(rule).find()) { |
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.
Why regexp and compile each call instead !string.contains(named {this})?
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.
The first commit has that, rule.contains(card.getName()) && !rule.contains("named " + card.getName()) && !rule.contains(card.getName()+" {"). However, that both involves searching through the rule string three times (which I think mostly negates the efficiency gains, though I didn't check) and more importantly would fail if the rule contains both an allowed use of the card's name and an invalid one.
Though I should compile the pattern just once per card.
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.
Use string contains instead regexp as much as possible. Also add how-to fix comment before verify check or in error message.
I’m not sure why you add \n to the rules restrict, but it’s ok for xmage for multilines rules/texts (in most use cases it’s use <br>).
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.
It should be using <br> instead of \n, right? Or have I misunderstood?
Anyway, I just checked. Of the 6 cards using "\n", 2 of them are definitely wrong (Paroxysm and Scorching Lava). The other 4 should probably be using <br>, assuming I understand correctly.
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.
Should use br for formatted rules text anyway. It will be visible in card view. If there are low amount of \n usage then it’s better to fix it with br and keep \n restrict.
|
This is ready to merge/be reviewed. The exception list is composed of:
There's also Krovikan Vampire which I think has some incorrect references to the name in the effect, but it was easy to fix the card text for that one. |
Cards should not be referring to themselves by name directly, they should be using "{this}", except in the situation of checking for cards "named ~" in which case it should not be using "{this}", or for Adventure/Omen cards where that SpellAbility is in the rules text.
I also added "\n" to the list of wrongSymbols, as they should not be within an individual ability's rules.
There are 166 cards with the card's name in the text, 10 with "named {this}", and 6 with "\n". That's a lot, but they should all be pretty easy text fixes. I'll do those in master directly, then merge this once that's done.