tests: improved verify checks for emblems and tokens

This commit is contained in:
Oleg Agafonov 2023-06-17 01:41:23 +04:00
parent ebef329bc3
commit ef8535314f

View file

@ -1364,7 +1364,14 @@ public class VerifyCardDataTest {
List<Card> cardsList = new ArrayList<>(CardScanner.getAllCards());
Map<String, List<Card>> setsWithTokens = new HashMap<>();
for (Card card : cardsList) {
String allRules = String.join(" ", card.getRules()).toLowerCase(Locale.ENGLISH);
// must check all card parts (example: Mila, Crafty Companion with Lukka Emblem)
String allRules = CardUtil.getObjectPartsAsObjects(card)
.stream()
.map(obj -> (Card) obj)
.map(Card::getRules)
.flatMap(Collection::stream)
.map(r -> r.toLowerCase(Locale.ENGLISH))
.collect(Collectors.joining("; "));
if ((allRules.contains("create") && allRules.contains("token"))
|| (allRules.contains("get") && allRules.contains("emblem"))) {
List<Card> sourceCards = setsWithTokens.getOrDefault(card.getExpansionSetCode(), null);
@ -1400,8 +1407,12 @@ public class VerifyCardDataTest {
String needTokenName = token.getName()
.replace(" Token", "")
.replace("Emblem ", "");
// need add card name, so it will skip no name emblems like Sarkhan, the Dragonspeaker
// cards with emblems don't use emblem's name, so check it in card name itself (example: Sarkhan, the Dragonspeaker)
// also must check all card parts (example: Mila, Crafty Companion with Lukka Emblem)
if (sourceCards.stream()
.map(CardUtil::getObjectPartsAsObjects)
.flatMap(Collection::stream)
.map(obj -> (Card) obj)
.map(card -> card.getName() + " - " + String.join(", ", card.getRules()))
.noneMatch(s -> s.contains(needTokenName))) {
warningsList.add("info, tok-data has un-used tokens: "