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:
Susucre 2023-08-12 22:16:22 +02:00 committed by GitHub
parent 2d53668c96
commit 23cc483a09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 3 deletions

View file

@ -1,5 +1,7 @@
package mage.verify.mtgjson;
import mage.constants.Rarity;
import java.util.List;
public final class MtgJsonCard {
@ -9,7 +11,8 @@ public final class MtgJsonCard {
public String name;
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 side;
@ -79,4 +82,32 @@ public final class MtgJsonCard {
public boolean isUseUnicodeName() {
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);
}
}
}