From 8bcac56550cdc6043353d9bf9db7febe910cc303 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Sun, 29 Sep 2024 18:28:10 -0400 Subject: [PATCH] tests: improve booster generation summary output --- .../mage/test/sets/BoosterGenerationTest.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 a1272a2f066..97c8b2acf2b 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 @@ -514,8 +514,9 @@ public class BoosterGenerationTest extends MageTestPlayerBase { @Ignore // debug only: collect info about cards in boosters, see https://github.com/magefree/mage/issues/8081 @Test public void test_CollectBoosterStats() { - ExpansionSet setToAnalyse = ModernHorizons3.getInstance(); - int openBoosters = 10000; + ExpansionSet setToAnalyse = NewPhyrexia.getInstance(); + // Takes about a minute for 100,000 boosters + int openBoosters = 100000; Map resRatio = new HashMap<>(); int totalCards = 0; @@ -523,11 +524,23 @@ public class BoosterGenerationTest extends MageTestPlayerBase { List booster = setToAnalyse.createBooster(); totalCards += booster.size(); booster.forEach(card -> { - String code = String.format("%s %s %s", card.getExpansionSetCode(), card.getRarity().getCode(), card.getName()); + String code = String.format("%s %s %s", card.getExpansionSetCode(), card.getRarity().toString().charAt(0), card.getName()); resRatio.putIfAbsent(code, 0); resRatio.computeIfPresent(code, (u, count) -> count + 1); }); } + System.out.println(setToAnalyse.getName() + " - boosters opened: " + openBoosters + ". Found cards: " + totalCards + "\n"); + for (char rarity : Arrays.asList('C', 'U', 'R', 'M', 'S', 'L', 'B')) { + List rarityCounts = resRatio.entrySet().stream() + .filter(e -> e.getKey().charAt(4) == rarity) + .map(Map.Entry::getValue) + .collect(Collectors.toList()); + if (!rarityCounts.isEmpty()) { + System.out.println(rarity + String.format(": %s unique, min %s, max %s, total %s", + rarityCounts.size(), Collections.min(rarityCounts), Collections.max(rarityCounts), + rarityCounts.stream().mapToInt(x -> x).sum())); + } + } List info = resRatio.entrySet().stream() .sorted((o1, o2) -> Integer.compare(o2.getValue(), o1.getValue())) .map(e -> String.format("%s: %d", @@ -535,8 +548,7 @@ public class BoosterGenerationTest extends MageTestPlayerBase { e.getValue() )) .collect(Collectors.toList()); - System.out.println(setToAnalyse.getName() + " - boosters opened: " + openBoosters + ". Found cards: " + totalCards + "\n" - + String.join("\n", info)); + System.out.println("\n" + String.join("\n", info)); } @Ignore // debug only