Verify tests: added checks for wrong ability/effect hint description in card text;

This commit is contained in:
Oleg Agafonov 2020-06-26 10:14:08 +04:00
parent 445686a1ad
commit f19c929229
2 changed files with 27 additions and 2 deletions

View file

@ -42,7 +42,7 @@ class TrackDownEffect extends OneShotEffect {
public TrackDownEffect() {
super(Outcome.DrawCard);
this.staticText = "reveal the top card of your library. If its a creature or land card, draw a card";
this.staticText = "reveal the top card of your library. If it's a creature or land card, draw a card";
}
public TrackDownEffect(final TrackDownEffect effect) {

View file

@ -3,6 +3,9 @@ package mage.verify;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.effects.CostModificationEffect;
import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect;
import mage.abilities.effects.keyword.ScryEffect;
import mage.abilities.keyword.MenaceAbility;
import mage.abilities.keyword.MultikickerAbility;
import mage.cards.*;
import mage.cards.basiclands.BasicLand;
@ -158,7 +161,7 @@ public class VerifyCardDataTest {
printMessages(outputMessages);
if (failed > 0) {
Assert.fail(failed + " errors in verify");
Assert.fail("found " + failed + " errors in cards verify (see errors list above)");
}
}
@ -925,6 +928,28 @@ public class VerifyCardDataTest {
fail(card, "abilities", "card have Multikicker ability, but missing it in rules text");
}
// special check: missing or wrong ability/effect hints
Map<Class, String> hints = new HashMap<>();
hints.put(MenaceAbility.class, "can't be blocked except by two or more");
hints.put(ScryEffect.class, "Look at the top card of your library");
for (Class objectClass : hints.keySet()) {
String objectHint = hints.get(objectClass);
// ability/effect must have description or not
boolean mustCheck = card.getAbilities().containsClass(objectClass)
|| card.getAbilities().stream()
.map(Ability::getAllEffects)
.flatMap(Collection::stream)
.anyMatch(effect -> effect.getClass().isAssignableFrom(objectClass));
mustCheck = false; // TODO: enable and fix all problems with effect and ability hints
if (mustCheck) {
boolean needHint = ref.text.contains(objectHint);
boolean haveHint = card.getRules().stream().anyMatch(rule -> rule.contains(objectHint));
if (needHint != haveHint) {
fail(card, "abilities", "card have " + objectClass.getSimpleName() + " but hint is wrong (it must be " + (needHint ? "enabled" : "disabled") + ")");
}
}
}
// spells have only 1 ability
if (card.isSorcery() || card.isInstant()) {
return;