Added single cards support in constructed format (like historic, see #6626);

This commit is contained in:
Oleg Agafonov 2020-06-12 00:18:40 +04:00
parent c592542ff6
commit 642cdea2f8

View file

@ -27,6 +27,7 @@ public class Constructed extends DeckValidator {
protected List<String> restricted = new ArrayList<>();
protected List<String> setCodes = new ArrayList<>();
protected List<Rarity> rarities = new ArrayList<>();
protected Set<String> singleCards = new HashSet<>();
public Constructed() {
super("Constructed");
@ -153,7 +154,7 @@ public class Constructed extends DeckValidator {
}
/**
* Checks if the given card is legal in any of the given sets
* Checks if the given card is legal in any of the given sets or as single card
*
* @param card - the card to check
* @return Whether the card was printed in any of this format's sets.
@ -168,6 +169,12 @@ public class Constructed extends DeckValidator {
break;
}
}
// check if single card allows
if (singleCards.contains(card.getName())) {
legal = true;
}
if (!legal && !invalid.containsKey(card.getName())) {
invalid.put(card.getName(), "Invalid set: " + card.getExpansionSetCode());
}