Tests: added booster stats collection script (see #8081);

This commit is contained in:
Oleg Agafonov 2021-07-31 19:12:43 +04:00
parent 1baf523522
commit 810e1babd5
2 changed files with 53 additions and 0 deletions

View file

@ -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<String, Integer> resRatio = new HashMap<>();
int totalCards = 0;
for (int i = 1; i <= openBoosters; i++) {
List<Card> 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<String> info = resRatio.entrySet().stream()
.sorted(new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> 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")));
}
}

View file

@ -905,6 +905,12 @@ public class VerifyCardDataTest {
}
for (ExpansionSet set : sets) {
// additional info
Set<String> 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());
}
*/
}
}