From 810e1babd57e2c5bbaace3b495a941a7ce0445e2 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 31 Jul 2021 19:12:43 +0400 Subject: [PATCH] Tests: added booster stats collection script (see #8081); --- .../mage/test/sets/BoosterGenerationTest.java | 37 +++++++++++++++++++ .../java/mage/verify/VerifyCardDataTest.java | 16 ++++++++ 2 files changed, 53 insertions(+) diff --git a/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java b/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java index c8f4088933..2cb8eb45a3 100644 --- a/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java @@ -4,6 +4,7 @@ import mage.MageObject; import mage.abilities.Ability; import mage.abilities.keyword.PartnerWithAbility; import mage.cards.Card; +import mage.cards.ExpansionSet; import mage.cards.ModalDoubleFacesCard; import mage.cards.repository.CardInfo; import mage.cards.repository.CardScanner; @@ -13,6 +14,7 @@ import mage.constants.SubType; import mage.sets.*; import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.MageTestBase; @@ -561,4 +563,39 @@ public class BoosterGenerationTest extends MageTestBase { ); } } + + @Ignore // debug only: collect info about cards in boosters, see https://github.com/magefree/mage/issues/8081 + @Test + public void test_CollectBoosterStats() { + ExpansionSet setToAnalyse = Innistrad.getInstance(); + int openBoosters = 1000; + + Map resRatio = new HashMap<>(); + int totalCards = 0; + for (int i = 1; i <= openBoosters; i++) { + List booster = setToAnalyse.createBooster(); + totalCards += booster.size(); + booster.forEach(card -> { + String code = String.format("%s %s", card.getRarity().getCode(), card.getName()); + resRatio.putIfAbsent(code, 0); + resRatio.computeIfPresent(code, (u, count) -> count + 1); + }); + } + final Integer totalCardsFinal = totalCards; + List info = resRatio.entrySet().stream() + .sorted(new Comparator>() { + @Override + public int compare(Map.Entry o1, Map.Entry o2) { + return Integer.compare(o2.getValue(), o1.getValue()); + } + }) + .map(e -> String.format("%s: %d", + e.getKey(), + e.getValue() + //(double) e.getValue() / totalCardsFinal * 100.0 + )) + .collect(Collectors.toList()); + System.out.println(setToAnalyse.getName() + " - boosters opened: " + openBoosters + ". Found cards: " + totalCardsFinal + "\n" + + info.stream().collect(Collectors.joining("\n"))); + } } diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index b4ca616f0b..15f6f3bf3f 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -905,6 +905,12 @@ public class VerifyCardDataTest { } for (ExpansionSet set : sets) { + // additional info + Set cardNames = new HashSet<>(); + for (ExpansionSet.SetCardInfo cardInfo : set.getSetCardInfo()) { + cardNames.add(cardInfo.getName()); + } + for (ExpansionSet.SetCardInfo cardInfo : set.getSetCardInfo()) { Card card = CardImpl.createCard(cardInfo.getCardClass(), new CardSetInfo(cardInfo.getName(), set.getCode(), cardInfo.getCardNumber(), cardInfo.getRarity(), cardInfo.getGraphicInfo())); @@ -923,6 +929,16 @@ public class VerifyCardDataTest { if (!CharMatcher.ascii().matchesAllOf(card.getName()) || !CharMatcher.ascii().matchesAllOf(card.getCardNumber())) { errorsList.add("Error: card name or number contains non-ascii symbols: " + set.getCode() + " - " + set.getName() + " - " + card.getName() + " - " + card.getCardNumber()); } + + // CHECK: second side cards in one set + // https://github.com/magefree/mage/issues/8081 + /* + if (card.getSecondCardFace() != null && cardNames.contains(card.getSecondCardFace().getName())) { + errorsList.add("Error: set contains second side cards: " + set.getCode() + " - " + set.getName() + + " - " + card.getName() + " - " + card.getCardNumber() + + " - " + card.getSecondCardFace().getName() + " - " + card.getSecondCardFace().getCardNumber()); + } + */ } }