mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
Tests: Add Rarity Verify Test out of mtgjson data. (#10782)
* Tests: Add Rarity Verify Test out of mtgjson data. * skip some of the Special rarity. * remove skip (fixed in master)
This commit is contained in:
parent
2d53668c96
commit
23cc483a09
2 changed files with 44 additions and 3 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package mage.verify.mtgjson;
|
package mage.verify.mtgjson;
|
||||||
|
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class MtgJsonCard {
|
public final class MtgJsonCard {
|
||||||
|
|
@ -9,7 +11,8 @@ public final class MtgJsonCard {
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public String asciiName; // mtgjson uses it for some cards like El-Hajjaj
|
public String asciiName; // mtgjson uses it for some cards like El-Hajjaj
|
||||||
public String number; // from sets source only, see https://mtgjson.com/data-models/card/
|
public String number; // from sets source only, see https://mtgjson.com/data-models/card-set/
|
||||||
|
public String rarity; // from sets source only, see https://mtgjson.com/data-models/card-set/
|
||||||
|
|
||||||
public String faceName;
|
public String faceName;
|
||||||
public String side;
|
public String side;
|
||||||
|
|
@ -79,4 +82,32 @@ public final class MtgJsonCard {
|
||||||
public boolean isUseUnicodeName() {
|
public boolean isUseUnicodeName() {
|
||||||
return this.asciiName != null && this.name != null && !this.asciiName.equals(this.name);
|
return this.asciiName != null && this.name != null && !this.asciiName.equals(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Rarity of the card if present in the mtgjson file
|
||||||
|
* null if not present.
|
||||||
|
*/
|
||||||
|
public Rarity getRarity() {
|
||||||
|
if (rarity.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (rarity) {
|
||||||
|
case "common":
|
||||||
|
return Rarity.COMMON;
|
||||||
|
case "uncommon":
|
||||||
|
return Rarity.UNCOMMON;
|
||||||
|
case "rare":
|
||||||
|
return Rarity.RARE;
|
||||||
|
case "mythic":
|
||||||
|
return Rarity.MYTHIC;
|
||||||
|
case "special":
|
||||||
|
return Rarity.SPECIAL;
|
||||||
|
case "bonus":
|
||||||
|
return Rarity.BONUS;
|
||||||
|
|
||||||
|
default: // Maybe a new rarity has been introduced?
|
||||||
|
throw new EnumConstantNotPresentException(Rarity.class, rarity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ public class VerifyCardDataTest {
|
||||||
private static final String SKIP_LIST_TYPE = "TYPE";
|
private static final String SKIP_LIST_TYPE = "TYPE";
|
||||||
private static final String SKIP_LIST_SUBTYPE = "SUBTYPE";
|
private static final String SKIP_LIST_SUBTYPE = "SUBTYPE";
|
||||||
private static final String SKIP_LIST_NUMBER = "NUMBER";
|
private static final String SKIP_LIST_NUMBER = "NUMBER";
|
||||||
|
private static final String SKIP_LIST_RARITY = "RARITY";
|
||||||
private static final String SKIP_LIST_MISSING_ABILITIES = "MISSING_ABILITIES";
|
private static final String SKIP_LIST_MISSING_ABILITIES = "MISSING_ABILITIES";
|
||||||
private static final String SKIP_LIST_DOUBLE_RARE = "DOUBLE_RARE";
|
private static final String SKIP_LIST_DOUBLE_RARE = "DOUBLE_RARE";
|
||||||
private static final String SKIP_LIST_UNSUPPORTED_SETS = "UNSUPPORTED_SETS";
|
private static final String SKIP_LIST_UNSUPPORTED_SETS = "UNSUPPORTED_SETS";
|
||||||
|
|
@ -137,6 +138,10 @@ public class VerifyCardDataTest {
|
||||||
// number
|
// number
|
||||||
skipListCreate(SKIP_LIST_NUMBER);
|
skipListCreate(SKIP_LIST_NUMBER);
|
||||||
|
|
||||||
|
// rarity
|
||||||
|
skipListCreate(SKIP_LIST_RARITY);
|
||||||
|
skipListAddName(SKIP_LIST_RARITY, "CMR", "The Prismatic Piper"); // Collation is not yet set up for CMR https://www.lethe.xyz/mtg/collation/cmr.html
|
||||||
|
|
||||||
// missing abilities
|
// missing abilities
|
||||||
skipListCreate(SKIP_LIST_MISSING_ABILITIES);
|
skipListCreate(SKIP_LIST_MISSING_ABILITIES);
|
||||||
|
|
||||||
|
|
@ -1605,7 +1610,7 @@ public class VerifyCardDataTest {
|
||||||
checkSupertypes(card, ref);
|
checkSupertypes(card, ref);
|
||||||
checkTypes(card, ref);
|
checkTypes(card, ref);
|
||||||
checkColors(card, ref);
|
checkColors(card, ref);
|
||||||
checkBasicLands(card, ref);
|
checkRarityAndBasicLands(card, ref);
|
||||||
checkMissingAbilities(card, ref);
|
checkMissingAbilities(card, ref);
|
||||||
checkWrongSymbolsInRules(card);
|
checkWrongSymbolsInRules(card);
|
||||||
checkCardCanBeCopied(card);
|
checkCardCanBeCopied(card);
|
||||||
|
|
@ -2291,7 +2296,10 @@ public class VerifyCardDataTest {
|
||||||
|| name.equals("Mountain");
|
|| name.equals("Mountain");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBasicLands(Card card, MtgJsonCard ref) {
|
private void checkRarityAndBasicLands(Card card, MtgJsonCard ref) {
|
||||||
|
if (skipListHaveName(SKIP_LIST_RARITY, card.getExpansionSetCode(), card.getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// basic lands must have Rarity.LAND and SuperType.BASIC
|
// basic lands must have Rarity.LAND and SuperType.BASIC
|
||||||
// other cards can't have that stats
|
// other cards can't have that stats
|
||||||
|
|
@ -2314,6 +2322,8 @@ public class VerifyCardDataTest {
|
||||||
// non lands
|
// non lands
|
||||||
if (card.getRarity() == Rarity.LAND) {
|
if (card.getRarity() == Rarity.LAND) {
|
||||||
fail(card, "rarity", "only basic land can be Rarity.LAND");
|
fail(card, "rarity", "only basic land can be Rarity.LAND");
|
||||||
|
} else if (!card.getRarity().equals(ref.getRarity())) {
|
||||||
|
fail(card, "rarity", "mismatched. MtgJson has " + ref.getRarity() + " while set file has " + card.getRarity());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.isBasic()) {
|
if (card.isBasic()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue