Deck: commander decks may have 0-10 cards sideboard

This commit is contained in:
Maxmtg
2013-01-13 19:19:06 +00:00
parent cc8c27ecb6
commit e7021c11e0
3 changed files with 22 additions and 16 deletions

View File

@@ -62,6 +62,7 @@ public class Deck extends DeckBase {
private final DeckSection main;
private final DeckSection sideboard; // commander, planes or schemes are also stored here
private CardPrinted avatar;
private CardPrinted commander;
// gameType is from Constant.GameType, like GameType.Regular
/**
@@ -132,6 +133,7 @@ public class Deck extends DeckBase {
result.main.addAll(this.main);
result.sideboard.addAll(this.sideboard);
result.avatar = this.avatar;
result.commander = this.commander;
}
/*
@@ -189,11 +191,15 @@ public class Deck extends DeckBase {
// try also earlier deck formats
if ( d.getSideboard().isEmpty() ) { d.getSideboard().set(Deck.readCardList(sections.get("schemes"))); }
if ( d.getSideboard().isEmpty() ) { d.getSideboard().set(Deck.readCardList(sections.get("planes"))); }
if ( d.getSideboard().isEmpty() ) { d.getSideboard().set(Deck.readCardList(sections.get("commander"))); }
List<String> av = Deck.readCardList(sections.get("avatar"));
String avName = av.isEmpty() ? null : av.get(0);
d.avatar = CardDb.instance().isCardSupported(avName) ? CardDb.instance().getCard(avName) : null;
List<String> cmd = Deck.readCardList(sections.get("commander"));
String cmdName = cmd.isEmpty() ? null : cmd.get(0);
d.commander = CardDb.instance().isCardSupported(cmdName) ? CardDb.instance().getCard(cmdName) : null;
return d;
}
@@ -267,13 +273,18 @@ public class Deck extends DeckBase {
out.add(String.format("%s", "[main]"));
out.addAll(Deck.writeCardPool(this.getMain()));
out.add(String.format("%s", "[sideboard]"));
out.add("[sideboard]");
out.addAll(Deck.writeCardPool(this.getSideboard()));
if (getAvatar() != null) {
out.add(String.format("%s", "[avatar]"));
out.add("[avatar]");
out.add(Deck.serializeSingleCard(getAvatar(), 1));
}
if (getCommander() != null) {
out.add("[commander]");
out.add(Deck.serializeSingleCard(getCommander(), 1));
}
return out;
}
@@ -281,7 +292,7 @@ public class Deck extends DeckBase {
* @return the commander
*/
public CardPrinted getCommander() {
return sideboard != null && !sideboard.isEmpty() ? sideboard.get(0) : null;
return commander;
}

View File

@@ -34,12 +34,12 @@ import forge.util.Aggregates;
public enum DeckFormat {
// Main board: allowed size SB: restriction Max distinct non basic cards
Constructed ( new IntRange(60, Integer.MAX_VALUE), new IntRange(15), 4),
Limited ( new IntRange(40, Integer.MAX_VALUE), null, Integer.MAX_VALUE),
Commander ( new IntRange(99 /* commndr in SB*/), new IntRange(1), 1),
Vanguard ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4),
Planechase ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4),
Archenemy ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4);
Constructed ( new IntRange(60, Integer.MAX_VALUE), new IntRange(15), 4),
Limited ( new IntRange(40, Integer.MAX_VALUE), null, Integer.MAX_VALUE),
Commander ( new IntRange(99), new IntRange(0, 10), 1),
Vanguard ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4),
Planechase ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4),
Archenemy ( new IntRange(60, Integer.MAX_VALUE), new IntRange(0), 4);
private final IntRange mainRange;
private final IntRange sideRange; // null => no check
@@ -132,10 +132,6 @@ public enum DeckFormat {
return "has a commander that is not a legendary creature";
}
//No sideboarding in Commander
if (!deck.getSideboard().isEmpty()) {
return "has sideboard";
}
break;
case Planechase: //Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.

View File

@@ -18,7 +18,6 @@
package forge.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;