Add CustomPool property to deck file for filtering from HomeScreen's deck list.

This commit is contained in:
Rob Cashwalker
2011-09-24 16:43:14 +00:00
parent c064acf9e4
commit fd55737978
2 changed files with 29 additions and 4 deletions

View File

@@ -32,6 +32,8 @@ public final class Deck implements Comparable<Deck>, Serializable {
private String comment = null; private String comment = null;
private PlayerType playerType = null; private PlayerType playerType = null;
private boolean customPool = false;
private ItemPool<CardPrinted> main; private ItemPool<CardPrinted> main;
private ItemPool<CardPrinted> sideboard; private ItemPool<CardPrinted> sideboard;
@@ -254,4 +256,12 @@ public final class Deck implements Comparable<Deck>, Serializable {
public final void setPlayerType(PlayerType recommendedPlayer0) { public final void setPlayerType(PlayerType recommendedPlayer0) {
this.playerType = recommendedPlayer0; this.playerType = recommendedPlayer0;
} }
public boolean isCustomPool() {
return customPool;
}
public void setCustomPool(boolean cp) {
customPool = cp;
}
} }

View File

@@ -64,6 +64,7 @@ public class DeckManager {
private static final String DECK_TYPE = "Deck Type"; private static final String DECK_TYPE = "Deck Type";
private static final String COMMENT = "Comment"; private static final String COMMENT = "Comment";
private static final String PLAYER = "Player"; private static final String PLAYER = "Player";
private static final String CSTM_POOL = "Custom Pool";
private File deckDir; private File deckDir;
Map<String, Deck> deckMap; Map<String, Deck> deckMap;
@@ -330,15 +331,27 @@ public class DeckManager {
String[] linedata = line.split("=", 2); String[] linedata = line.split("=", 2);
String field = linedata[0].toLowerCase(); String field = linedata[0].toLowerCase();
String value = "";
if (linedata.length > 1)
value = linedata[1];
if (NAME.equalsIgnoreCase(field)) { if (NAME.equalsIgnoreCase(field)) {
d.setName(linedata[1]); d.setName(value);
} else if (COMMENT.equalsIgnoreCase(field)) { } else if (COMMENT.equalsIgnoreCase(field)) {
d.setComment(linedata[1]); d.setComment(value);
} else if (DECK_TYPE.equalsIgnoreCase(field)) { } else if (DECK_TYPE.equalsIgnoreCase(field)) {
d.setDeckType(GameType.smartValueOf(linedata[1])); d.setDeckType(GameType.smartValueOf(value));
} else if (CSTM_POOL.equalsIgnoreCase(field)) {
d.setCustomPool(value.equalsIgnoreCase("true"));
} else if (PLAYER.equalsIgnoreCase(field)) { } else if (PLAYER.equalsIgnoreCase(field)) {
if ("human".equalsIgnoreCase(linedata[1])) { if ("human".equalsIgnoreCase(value)) {
d.setPlayerType(PlayerType.HUMAN); d.setPlayerType(PlayerType.HUMAN);
} else { } else {
d.setPlayerType(PlayerType.COMPUTER); d.setPlayerType(PlayerType.COMPUTER);
} }
@@ -466,6 +479,8 @@ public class DeckManager {
// these are optional // these are optional
if (d.getComment() != null) { out.write(format("%s=%s%n", COMMENT, d.getComment().replaceAll("\n", ""))); } if (d.getComment() != null) { out.write(format("%s=%s%n", COMMENT, d.getComment().replaceAll("\n", ""))); }
if (d.getPlayerType() != null) { out.write(format("%s=%s%n", PLAYER, d.getPlayerType())); } if (d.getPlayerType() != null) { out.write(format("%s=%s%n", PLAYER, d.getPlayerType())); }
if (d.isCustomPool()) { out.write(format("%s=%s%n", CSTM_POOL, "true")); }
out.write(format("%s%n", "[main]")); out.write(format("%s%n", "[main]"));
writeCardPool(d.getMain(), out); writeCardPool(d.getMain(), out);