Skip to content

Commit

Permalink
tests: added verify checks for missing boosters or draft related sets…
Browse files Browse the repository at this point in the history
… (related to #13160)
  • Loading branch information
JayDi85 committed Jan 31, 2025
1 parent 55a532c commit 18fd7be
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Mage.Verify/src/main/java/mage/verify/mtgjson/MtgJsonSet.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mage.verify.mtgjson;

import java.util.HashMap;
import java.util.List;

/**
Expand All @@ -20,6 +21,9 @@ public final class MtgJsonSet {
public String releaseDate;
public int totalSetSize;

// mtgjson contains detailed stats, but verify needs only booster types info
public HashMap<String, Object> booster;

public String block;

public String parentCode;
Expand Down
51 changes: 51 additions & 0 deletions Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,57 @@ public void test_checkMissingSetData() {
}
}

// CHECK: miss booster settings
Set<String> ignoreBoosterSets = new HashSet<>();
// temporary, TODO: remove after set release and mtgjson get info
ignoreBoosterSets.add("Innistrad Remastered");
// jumpstart, TODO: must implement from JumpstartPoolGenerator, see #13264
ignoreBoosterSets.add("Jumpstart");
ignoreBoosterSets.add("Jumpstart 2022");
ignoreBoosterSets.add("Foundations Jumpstart");
ignoreBoosterSets.add("Ravnica: Clue Edition");
// joke or un-sets, low implemented cards
ignoreBoosterSets.add("Unglued");
ignoreBoosterSets.add("Unhinged");
ignoreBoosterSets.add("Unstable");
ignoreBoosterSets.add("Unfinity");
// other
ignoreBoosterSets.add("Secret Lair Drop"); // cards shop
ignoreBoosterSets.add("Zendikar Rising Expeditions"); // box toppers
ignoreBoosterSets.add("March of the Machine: The Aftermath"); // epilogue boosters aren't for draft

for (ExpansionSet set : sets) {
MtgJsonSet jsonSet = MtgJsonService.sets().getOrDefault(set.getCode().toUpperCase(Locale.ENGLISH), null);
if (jsonSet == null) {
continue;
}
boolean needBooster = jsonSet.booster != null && !jsonSet.booster.isEmpty();
if (set.hasBoosters() != needBooster) {
if (ignoreBoosterSets.contains(set.getName())) {
continue;
}
// error example: wrong booster settings (set MUST HAVE booster, but haven't) - 2020 - J22 - Jumpstart 2022 - boosters: [jumpstart]
errorsList.add(String.format("Error: wrong booster settings (set %s booster, but %s) - %s%s",
(needBooster ? "MUST HAVE" : "MUST HAVEN'T"),
(set.hasBoosters() ? "have" : "haven't"),
set.getReleaseYear() + " - " + set.getCode() + " - " + set.getName(),
(jsonSet.booster == null ? "" : " - boosters: " + jsonSet.booster.keySet())
));
}
}

// CHECK: missing important sets for draft format
Set<String> implementedSets = sets.stream().map(ExpansionSet::getCode).collect(Collectors.toSet());
MtgJsonService.sets().values().forEach(jsonSet -> {
if (jsonSet.booster != null && !jsonSet.booster.isEmpty() && !implementedSets.contains(jsonSet.code)) {
errorsList.add(String.format("Error: missing set implementation (important for draft format) - %s - %s - boosters: %s",
jsonSet.code,
jsonSet.name,
jsonSet.booster.keySet()
));
}
});

// TODO: add test to check num cards for rarity (rarityStats > 0 and numRarity > 0)
printMessages(warningsList);
printMessages(errorsList);
Expand Down

0 comments on commit 18fd7be

Please sign in to comment.