mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
[LTR] Implement Nazgul
This commit is contained in:
parent
75d1bdf71c
commit
82073bba73
5 changed files with 122 additions and 16 deletions
|
|
@ -16,14 +16,6 @@ public class Constructed extends DeckValidator {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(Constructed.class);
|
||||
|
||||
private static final List<String> anyNumberCardsAllowed = new ArrayList<>(Arrays.asList(
|
||||
"Relentless Rats", "Shadowborn Apostle", "Rat Colony",
|
||||
"Persistent Petitioners", "Seven Dwarves", "Dragon's Approach"
|
||||
));
|
||||
protected static final List<String> basicLandNames = new ArrayList<>(Arrays.asList(
|
||||
"Forest", "Island", "Mountain", "Swamp", "Plains", "Wastes", "Snow-Covered Forest",
|
||||
"Snow-Covered Island", "Snow-Covered Mountain", "Snow-Covered Swamp", "Snow-Covered Plains"
|
||||
));
|
||||
protected List<String> banned = new ArrayList<>();
|
||||
protected List<String> restricted = new ArrayList<>();
|
||||
protected List<String> setCodes = new ArrayList<>();
|
||||
|
|
@ -351,13 +343,7 @@ public class Constructed extends DeckValidator {
|
|||
protected boolean checkCounts(int maxCopies, Map<String, Integer> counts) {
|
||||
boolean valid = true;
|
||||
for (Entry<String, Integer> entry : counts.entrySet()) {
|
||||
if (entry.getValue() > maxCopies
|
||||
&& !basicLandNames.contains(entry.getKey())
|
||||
&& !anyNumberCardsAllowed.contains(entry.getKey())) {
|
||||
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true);
|
||||
valid = false;
|
||||
}
|
||||
if (entry.getValue() > 7 && entry.getKey().equals("Seven Dwarves")) {
|
||||
if (entry.getValue() > getMaxCopies(entry.getKey(), maxCopies)) {
|
||||
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true);
|
||||
valid = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,32 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public abstract class DeckValidator implements Serializable {
|
||||
|
||||
protected static final List<String> basicLandNames = Arrays.asList(
|
||||
"Plains",
|
||||
"Island",
|
||||
"Swamp",
|
||||
"Mountain",
|
||||
"Forest",
|
||||
"Wastes",
|
||||
"Snow-Covered Plains",
|
||||
"Snow-Covered Island",
|
||||
"Snow-Covered Swamp",
|
||||
"Snow-Covered Mountain",
|
||||
"Snow-Covered Forest"
|
||||
);
|
||||
protected static final Map<String, Integer> maxCopiesMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
basicLandNames.stream().forEach(s -> maxCopiesMap.put(s, Integer.MAX_VALUE));
|
||||
maxCopiesMap.put("Relentless Rats", Integer.MAX_VALUE);
|
||||
maxCopiesMap.put("Shadowborn Apostle", Integer.MAX_VALUE);
|
||||
maxCopiesMap.put("Rat Colony", Integer.MAX_VALUE);
|
||||
maxCopiesMap.put("Persistent Petitioners", Integer.MAX_VALUE);
|
||||
maxCopiesMap.put("Dragon's Approach", Integer.MAX_VALUE);
|
||||
maxCopiesMap.put("Seven Dwarves", 7);
|
||||
maxCopiesMap.put("Nazgul", 9);
|
||||
}
|
||||
|
||||
protected String name;
|
||||
protected String shortName;
|
||||
protected List<DeckValidatorError> errorsList = new ArrayList<>();
|
||||
|
|
@ -141,4 +167,8 @@ public abstract class DeckValidator implements Serializable {
|
|||
public abstract int getDeckMinSize();
|
||||
|
||||
public abstract int getSideboardMinSize();
|
||||
|
||||
protected static final int getMaxCopies(String name, int defaultAmount) {
|
||||
return maxCopiesMap.getOrDefault(name, defaultAmount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue