Account for commander as part of main deck size

This commit is contained in:
drdev
2014-08-06 15:03:22 +00:00
parent f330f8d513
commit a23e6ae000

View File

@@ -51,8 +51,8 @@ public class DeckProxy implements InventoryItem {
protected ColorSet color; protected ColorSet color;
protected ColorSet colorIdentity; protected ColorSet colorIdentity;
protected Iterable<GameFormat> formats; protected Iterable<GameFormat> formats;
private int mainSize = Integer.MIN_VALUE; private Integer mainSize = null;
private int sbSize = Integer.MIN_VALUE; private Integer sbSize = null;
private final String path; private final String path;
private final Function<IHasName, Deck> fnGetDeck; private final Function<IHasName, Deck> fnGetDeck;
private CardEdition edition; private CardEdition edition;
@@ -134,8 +134,8 @@ public class DeckProxy implements InventoryItem {
highestRarity = null; highestRarity = null;
formats = null; formats = null;
edition = null; edition = null;
mainSize = Integer.MIN_VALUE; mainSize = null;
sbSize = Integer.MIN_VALUE; sbSize = null;
} }
public ColorSet getColor() { public ColorSet getColor() {
@@ -231,19 +231,26 @@ public class DeckProxy implements InventoryItem {
} }
public int getMainSize() { public int getMainSize() {
if (mainSize == Integer.MIN_VALUE) { if (mainSize == null) {
if (deck == null) { if (deck == null) {
mainSize = -1; mainSize = -1;
} }
else { else {
mainSize = getDeck().getMain().countAll(); Deck d = getDeck();
mainSize = d.getMain().countAll();
//account for commander as part of main deck size
CardPool commander = d.get(DeckSection.Commander);
if (commander != null) {
mainSize += commander.countAll();
}
} }
} }
return mainSize; return mainSize;
} }
public int getSideSize() { public int getSideSize() {
if (sbSize == Integer.MIN_VALUE) { if (sbSize == null) {
CardPool sb = getDeck().get(DeckSection.Sideboard); CardPool sb = getDeck().get(DeckSection.Sideboard);
sbSize = sb == null ? -1 : sb.countAll(); sbSize = sb == null ? -1 : sb.countAll();
if (sbSize == 0) { if (sbSize == 0) {