tests: added verify check for missing card hints (city's blessing, monarch)

This commit is contained in:
Oleg Agafonov 2023-11-19 22:34:48 +04:00
parent 225da087f9
commit 77eb3b35b8

View file

@ -15,6 +15,8 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.effects.common.FightTargetsEffect;
import mage.abilities.effects.common.counter.ProliferateEffect; import mage.abilities.effects.common.counter.ProliferateEffect;
import mage.abilities.effects.keyword.ScryEffect; import mage.abilities.effects.keyword.ScryEffect;
import mage.abilities.hint.common.CitysBlessingHint;
import mage.abilities.hint.common.MonarchHint;
import mage.abilities.keyword.*; import mage.abilities.keyword.*;
import mage.cards.*; import mage.cards.*;
import mage.cards.decks.CardNameUtil; import mage.cards.decks.CardNameUtil;
@ -36,7 +38,9 @@ import mage.server.util.SystemUtil;
import mage.sets.TherosBeyondDeath; import mage.sets.TherosBeyondDeath;
import mage.target.targetpointer.TargetPointer; import mage.target.targetpointer.TargetPointer;
import mage.util.CardUtil; import mage.util.CardUtil;
import mage.verify.mtgjson.*; import mage.verify.mtgjson.MtgJsonCard;
import mage.verify.mtgjson.MtgJsonService;
import mage.verify.mtgjson.MtgJsonSet;
import mage.watchers.Watcher; import mage.watchers.Watcher;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.Assert; import org.junit.Assert;
@ -2022,25 +2026,42 @@ public class VerifyCardDataTest {
fail(card, "abilities", "wrong target settings (must set withNotTarget(true), but it not)"); fail(card, "abilities", "wrong target settings (must set withNotTarget(true), but it not)");
} }
// special check: missing or wrong ability/effect hints // special check: missing or wrong ability/effect rules hint
Map<Class, String> hints = new HashMap<>(); Map<Class, String> ruleHints = new HashMap<>();
hints.put(FightTargetsEffect.class, "Each deals damage equal to its power to the other"); ruleHints.put(FightTargetsEffect.class, "Each deals damage equal to its power to the other");
hints.put(MenaceAbility.class, "can't be blocked except by two or more"); ruleHints.put(MenaceAbility.class, "can't be blocked except by two or more");
hints.put(ScryEffect.class, "Look at the top card of your library. You may put that card on the bottom"); ruleHints.put(ScryEffect.class, "Look at the top card of your library. You may put that card on the bottom");
hints.put(EquipAbility.class, "Equip only as a sorcery."); ruleHints.put(EquipAbility.class, "Equip only as a sorcery.");
hints.put(WardAbility.class, "becomes the target of a spell or ability an opponent controls"); ruleHints.put(WardAbility.class, "becomes the target of a spell or ability an opponent controls");
hints.put(ProliferateEffect.class, "Choose any number of permanents and/or players, then give each another counter of each kind already there."); ruleHints.put(ProliferateEffect.class, "Choose any number of permanents and/or players, then give each another counter of each kind already there.");
for (Class objectClass : ruleHints.keySet()) {
for (Class objectClass : hints.keySet()) { String needText = ruleHints.get(objectClass);
String objectHint = hints.get(objectClass);
// ability/effect must have description or not // ability/effect must have description or not
boolean needHint = ref.text.contains(objectHint); boolean needHint = ref.text.contains(needText);
boolean haveHint = card.getRules().stream().anyMatch(rule -> rule.contains(objectHint)); boolean haveHint = card.getRules().stream().anyMatch(rule -> rule.contains(needText));
if (needHint != haveHint) { if (needHint != haveHint) {
warn(card, "card have " + objectClass.getSimpleName() + " but hint is wrong (it must be " + (needHint ? "enabled" : "disabled") + ")"); warn(card, "card have " + objectClass.getSimpleName() + " but hint is wrong (it must be " + (needHint ? "enabled" : "disabled") + ")");
} }
} }
// special check: missing card hints like designation
Map<Class, String> cardHints = new HashMap<>();
cardHints.put(CitysBlessingHint.class, "city's blessing");
cardHints.put(MonarchHint.class, "the monarch");
for (Class hintClass : cardHints.keySet()) {
String lookupText = cardHints.get(hintClass);
boolean needHint = ref.text.contains(lookupText);
if (needHint) {
boolean haveHint = card.getAbilities()
.stream()
.flatMap(ability -> ability.getHints().stream())
.anyMatch(h -> h.getClass().equals(hintClass));
if (!haveHint) {
fail(card, "abilities", "miss card hint: " + hintClass.getSimpleName());
}
}
}
// spells have only 1 ability // spells have only 1 ability
if (card.isInstantOrSorcery()) { if (card.isInstantOrSorcery()) {
return; return;