diff --git a/src/main/java/forge/deck/Deck.java b/src/main/java/forge/deck/Deck.java index 0916a0cbb9d..f4f7bff0c41 100644 --- a/src/main/java/forge/deck/Deck.java +++ b/src/main/java/forge/deck/Deck.java @@ -1,5 +1,7 @@ package forge.deck; +import java.io.Serializable; + import forge.PlayerType; import forge.game.GameType; import forge.item.CardDb; @@ -7,15 +9,16 @@ import forge.item.CardPrinted; import forge.item.ItemPool; import forge.item.ItemPoolView; -import java.io.Serializable; - /** - *
Deck class.
+ *+ * Deck class. + *
+ * + * The set of MTG legal cards that become player's library when the game starts. + * Any other data is not part of a deck and should be stored elsewhere. Current + * fields allowed for deck metadata are Name, Title, Description, Difficulty, + * Icon, Deck Type. * - * The set of MTG legal cards that become player's library when the game starts. - * Any other data is not part of a deck and should be stored elsewhere. - * Current fields allowed for deck metadata are Name, Title, Description, Difficulty, Icon, Deck Type. - * * @author Forge * @version $Id$ */ @@ -25,22 +28,23 @@ public final class Deck implements ComparableConstructor for Deck.
+ *+ * Constructor for Deck. + *
*/ public Deck() { main = new ItemPoolConstructor for Deck.
- * - * @param type a {@link java.lang.String} object. + *+ * Constructor for Deck. + *
+ * + * @param type + * a {@link java.lang.String} object. */ public Deck(final GameType type) { this(); @@ -58,8 +65,10 @@ public final class Deck implements ComparableGetter for the field main.
+ * Getter for the field main.
+ *
Getter for the field sideboard.
+ * Getter for the field sideboard.
+ *
getDeckType.
- * + *+ * getDeckType. + *
+ * * @return a {@link java.lang.String} object. */ public GameType getDeckType() { return deckType; } - //can only call this method ONCE + // can only call this method ONCE /** - *setDeckType.
- * - * @param deckType a {@link java.lang.String} object. + *+ * setDeckType. + *
+ * + * @param deckType + * a {@link java.lang.String} object. */ - void setDeckType(GameType deckType) { + void setDeckType(final GameType deckType) { if (this.getDeckType() != null) { - throw new IllegalStateException( - "Deck : setDeckType() error, deck type has already been set"); + throw new IllegalStateException("Deck : setDeckType() error, deck type has already been set"); } this.deckType = deckType; } /** - *setName.
- * - * @param s a {@link java.lang.String} object. + *+ * setName. + *
+ * + * @param s + * a {@link java.lang.String} object. */ - public void setName(String s) { + public void setName(final String s) { name = s; } /** - *getName.
- * + *+ * getName. + *
+ * * @return a {@link java.lang.String} object. */ public String getName() { @@ -118,17 +138,22 @@ public final class Deck implements ComparablesetComment.
- * - * @param comment a {@link java.lang.String} object. + *+ * setComment. + *
+ * + * @param comment + * a {@link java.lang.String} object. */ - public void setComment(String comment) { + public void setComment(final String comment) { this.comment = comment; } /** - *getComment.
- * + *+ * getComment. + *
+ * * @return a {@link java.lang.String} object. */ public String getComment() { @@ -136,33 +161,149 @@ public final class Deck implements ComparableaddMain.
- * - * @param cardName a {@link java.lang.String} object. + *+ * addMain. + *
+ * + * @param cardName + * a {@link java.lang.String} object. */ - public void addMain(final String cardName) { addMain(CardDb.instance().getCard(cardName)); } - public void addMain(final CardPrinted card) { main.add(card); } - public void addMain(final CardPrinted card, final int amount) { main.add(card, amount); } - public void addMain(final ItemPoolViewaddSideboard.
- * - * @param cardName a {@link java.lang.String} object. + * Adds the main. + * + * @param card + * the card */ - public final void addSideboard(final String cardName) { addSideboard(CardDb.instance().getCard(cardName)); } - public final void addSideboard(final CardPrinted card) { sideboard.add(card); } - public final void addSideboard(final CardPrinted card, final int amount) { sideboard.add(card, amount); } - public final void addSideboard(final ItemPoolViewcountSideboard.
- * + * Adds the main. + * + * @param card + * the card + * @param amount + * the amount + */ + public void addMain(final CardPrinted card, final int amount) { + main.add(card, amount); + } + + /** + * Adds the main. + * + * @param list + * the list + */ + public void addMain(final ItemPoolView+ * addSideboard. + *
+ * + * @param cardName + * a {@link java.lang.String} object. + */ + public void addSideboard(final String cardName) { + addSideboard(CardDb.instance().getCard(cardName)); + } + + /** + * Adds the sideboard. + * + * @param card + * the card + */ + public void addSideboard(final CardPrinted card) { + sideboard.add(card); + } + + /** + * Adds the sideboard. + * + * @param card + * the card + * @param amount + * the amount + */ + public void addSideboard(final CardPrinted card, final int amount) { + sideboard.add(card, amount); + } + + /** + * Adds the sideboard. + * + * @param cards + * the cards + */ + public void addSideboard(final ItemPoolView+ * countSideboard. + *
+ * * @return a int. */ public int countSideboard() { @@ -170,18 +311,23 @@ public final class Deck implements ComparableremoveSideboard.
+ *+ * removeSideboard. + *
+ * + * @param card + * the card * - * @param index a int. - * @return a {@link java.lang.String} object. */ - public void removeFromSideboard(CardPrinted card) { + public void removeFromSideboard(final CardPrinted card) { sideboard.remove(card); } /** - *isDraft.
- * + *+ * isDraft. + *
+ * * @return a boolean. */ public boolean isDraft() { @@ -189,8 +335,10 @@ public final class Deck implements ComparableisSealed.
- * + *+ * isSealed. + *
+ * * @return a boolean. */ public boolean isSealed() { @@ -198,8 +346,10 @@ public final class Deck implements ComparableisRegular.
- * + *+ * isRegular. + *
+ * * @return a boolean. */ public boolean isRegular() { @@ -207,8 +357,10 @@ public final class Deck implements ComparablehashCode.
- * + *+ * hashCode. + *
+ * * @return a int. */ public int hashCode() { @@ -222,17 +374,20 @@ public final class Deck implements ComparablecompareTo.
- * - * @param d a {@link forge.deck.Deck} object. + *+ * compareTo. + *
+ * + * @param d + * a {@link forge.deck.Deck} object. * @return a int. */ - public int compareTo(Deck d) { + public int compareTo(final Deck d) { return getName().compareTo(d.getName()); } /** {@inheritDoc} */ - public boolean equals(Object o) { + public boolean equals(final Object o) { if (o instanceof Deck) { Deck d = (Deck) o; return getName().equals(d.getName()); @@ -240,28 +395,56 @@ public final class Deck implements Comparable* genDecks. *
- * + * * @param playerType - * {@link java.lang.String} object. + * the player type {@link java.lang.String} object. */ public static void genDecks(final PlayerType playerType) { // TODO jendave to refactor deck generation @@ -45,7 +47,6 @@ public abstract class DeckGeneration { String playerName = playerType.equals(PlayerType.HUMAN) ? "Human" : "Computer"; String prompt = String.format("Generate %s Deck", playerName); - Object o = GuiUtils.getChoice(prompt, decks.toArray()); if (o.toString().equals(decks.get(0))) { @@ -75,7 +76,7 @@ public abstract class DeckGeneration { ** generateConstructedDeck. *
- * + * * @return a {@link forge.deck.Deck} object. */ private static Deck generateConstructedDeck() { @@ -93,7 +94,7 @@ public abstract class DeckGeneration { ** generateConstructed3ColorDeck. *
- * + * * @return a {@link forge.deck.Deck} object. */ private static Deck generateConstructed3ColorDeck() { @@ -111,7 +112,7 @@ public abstract class DeckGeneration { ** generateConstructed5ColorDeck. *
- * + * * @return a {@link forge.deck.Deck} object. */ private static Deck generateConstructed5ColorDeck() { @@ -129,7 +130,7 @@ public abstract class DeckGeneration { ** generateConstructedThemeDeck. *
- * + * * @return a {@link forge.deck.Deck} object. */ private static Deck generateConstructedThemeDeck() { @@ -160,7 +161,7 @@ public abstract class DeckGeneration { ** generate2ColorDeck. *
- * + * * @param p * a {@link java.lang.String} object. * @return a {@link forge.deck.Deck} object. @@ -215,7 +216,7 @@ public abstract class DeckGeneration { ** generate3ColorDeck. *
- * + * * @param p * a {@link java.lang.String} object. * @return a {@link forge.deck.Deck} object. @@ -281,22 +282,21 @@ public abstract class DeckGeneration { ** generate5ColorDeck. *
- * + * * @param p * a {@link java.lang.String} object. * @return a {@link forge.deck.Deck} object. */ private static Deck generate5ColorDeck(final PlayerType p) { - //Random r = MyRandom.random; - - //ArrayListDeckRecognizer class.
- * +/** + *+ * DeckRecognizer class. + *
+ * * @author Forge * @version $Id: DeckRecognizer.java 10499 2011-09-17 15:08:47Z Max mtg $ - * + * */ public class DeckRecognizer { + + /** + * The Enum TokenType. + */ public enum TokenType { + + /** The Known card. */ KnownCard, + + /** The Unknown card. */ UnknownCard, + + /** The Section name. */ SectionName, + + /** The Comment. */ Comment, + + /** The Unknown text. */ UnknownText } - + + /** + * The Class Token. + */ public static class Token { private final TokenType type; private final CardPrinted card; private final int number; private final String text; - - public static Token knownCard(CardPrinted theCard, int count) { + + /** + * Known card. + * + * @param theCard + * the the card + * @param count + * the count + * @return the token + */ + public static Token knownCard(final CardPrinted theCard, final int count) { return new Token(theCard, TokenType.KnownCard, count, null); } - public static Token unknownCard(String cardNme, int count) { + + /** + * Unknown card. + * + * @param cardNme + * the card nme + * @param count + * the count + * @return the token + */ + public static Token unknownCard(final String cardNme, final int count) { return new Token(null, TokenType.UnknownCard, count, cardNme); } - private Token(CardPrinted knownCard, TokenType type1, int count, String message) - { + private Token(final CardPrinted knownCard, final TokenType type1, final int count, final String message) { card = knownCard; number = count; type = type1; text = message; } - public Token(TokenType type1, int count, String message) - { + /** + * Instantiates a new token. + * + * @param type1 + * the type1 + * @param count + * the count + * @param message + * the message + */ + public Token(final TokenType type1, final int count, final String message) { this(null, type1, count, message); if (type1 == TokenType.KnownCard || type1 == TokenType.UnknownCard) { throw new IllegalArgumentException("Use factory methods for recognized card lines"); } } - public String getText() { return text; } - public CardPrinted getCard() { return card; } - public TokenType getType() { return type; } - public int getNumber() { return number; } + /** + * Gets the text. + * + * @return the text + */ + public final String getText() { + return text; + } + + /** + * Gets the card. + * + * @return the card + */ + public final CardPrinted getCard() { + return card; + } + + /** + * Gets the type. + * + * @return the type + */ + public final TokenType getType() { + return type; + } + + /** + * Gets the number. + * + * @return the number + */ + public final int getNumber() { + return number; + } } -// Let's think about it numbers in the back later -// private static final Pattern searchNumbersInBack = Pattern.compile("(.*)[^A-Za-wyz]*\\s+([\\d]{1,2})"); + // Let's think about it numbers in the back later + // private static final Pattern searchNumbersInBack = + // Pattern.compile("(.*)[^A-Za-wyz]*\\s+([\\d]{1,2})"); private static final Pattern searchNumbersInFront = Pattern.compile("([\\d]{1,2})[^A-Za-wyz]*\\s+(.*)"); - public static Token recognizeLine(String raw_line) - { - if (StringUtils.isBlank(raw_line)) { return new Token(TokenType.Comment, 0, raw_line); } + + /** + * Recognize line. + * + * @param raw_line + * the raw_line + * @return the token + */ + public static Token recognizeLine(final String raw_line) { + if (StringUtils.isBlank(raw_line)) { + return new Token(TokenType.Comment, 0, raw_line); + } String line = raw_line.trim(); - + Token result = null; Matcher foundNumbersInFront = searchNumbersInFront.matcher(line); // Matcher foundNumbersInBack = searchNumbersInBack.matcher(line); @@ -73,53 +161,67 @@ public class DeckRecognizer { String cardName = foundNumbersInFront.group(2); int amount = Integer.parseInt(foundNumbersInFront.group(1)); result = recognizePossibleNameAndNumber(cardName, amount); - } /* else if (foundNumbersInBack.matches()) { - String cardName = foundNumbersInBack.group(1); - int amount = Integer.parseInt(foundNumbersInBack.group(2)); - return new Token(cardName, amount); - } */else { - if ( CardDb.instance().isCardSupported(line)) { + } /* + * else if (foundNumbersInBack.matches()) { String cardName = + * foundNumbersInBack.group(1); int amount = + * Integer.parseInt(foundNumbersInBack.group(2)); return new + * Token(cardName, amount); } + */ + else { + if (CardDb.instance().isCardSupported(line)) { return Token.knownCard(CardDb.instance().getCard(line), 1); } result = recognizeNonCard(line, 1); } - return result != null ? result : new Token(TokenType.UnknownText, 0, line); + return result != null ? result : new Token(TokenType.UnknownText, 0, line); } - - private static Token recognizePossibleNameAndNumber(String name, int n) { - if ( CardDb.instance().isCardSupported(name)) + + private static Token recognizePossibleNameAndNumber(final String name, final int n) { + if (CardDb.instance().isCardSupported(name)) { return Token.knownCard(CardDb.instance().getCard(name), n); - + } + Token known = recognizeNonCard(name, n); return null == known ? Token.unknownCard(name, n) : known; } - - private static Token recognizeNonCard(String text, int n) { - if (isDecoration(text)) { return new Token(TokenType.Comment, n, text); } - if (isSectionName(text)) { return new Token(TokenType.SectionName, n, text); } + + private static Token recognizeNonCard(final String text, final int n) { + if (isDecoration(text)) { + return new Token(TokenType.Comment, n, text); + } + if (isSectionName(text)) { + return new Token(TokenType.SectionName, n, text); + } return null; } - - private final static String[] knownComments = new String[] { - "land", "lands", "creatures", "creature", "spells", "enchancements", "other spells", "artifacts" }; - private final static String[] knownCommentParts = new String[] { "card" }; - private static boolean isDecoration(String lineAsIs) { + private static final String[] knownComments = new String[] { "land", "lands", "creatures", "creature", "spells", + "enchancements", "other spells", "artifacts" }; + private static final String[] knownCommentParts = new String[] { "card" }; + + private static boolean isDecoration(final String lineAsIs) { String line = lineAsIs.toLowerCase(); for (String s : knownCommentParts) { - if (line.contains(s)) { return true; } + if (line.contains(s)) { + return true; + } } for (String s : knownComments) { - if (line.equalsIgnoreCase(s)) { return true; } + if (line.equalsIgnoreCase(s)) { + return true; + } } return false; } - private static boolean isSectionName(String line) { - if (line.toLowerCase().contains("side")) { return true; } - if (line.toLowerCase().contains("main")) { return true; } + private static boolean isSectionName(final String line) { + if (line.toLowerCase().contains("side")) { + return true; + } + if (line.toLowerCase().contains("main")) { + return true; + } return false; } - - + } diff --git a/src/main/java/forge/deck/generate/Generate2ColorDeck.java b/src/main/java/forge/deck/generate/Generate2ColorDeck.java index dd170dafa2c..6d72394da56 100644 --- a/src/main/java/forge/deck/generate/Generate2ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate2ColorDeck.java @@ -1,17 +1,26 @@ package forge.deck.generate; -import forge.*; -import forge.error.ErrorViewer; -import forge.properties.ForgeProps; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Random; +import forge.AllZone; +import forge.Card; +import forge.CardFilter; +import forge.CardList; +import forge.CardListFilter; +import forge.Constant; +import forge.MyRandom; +import forge.PlayerType; +import forge.error.ErrorViewer; +import forge.properties.ForgeProps; + /** - *Generate2ColorDeck class.
- * + *+ * Generate2ColorDeck class. + *
+ * * @author Forge * @version $Id$ */ @@ -25,12 +34,16 @@ public class Generate2ColorDeck { private MapConstructor for Generate2ColorDeck.
- * - * @param Clr1 a {@link java.lang.String} object. - * @param Clr2 a {@link java.lang.String} object. + *+ * Constructor for Generate2ColorDeck. + *
+ * + * @param Clr1 + * a {@link java.lang.String} object. + * @param Clr2 + * a {@link java.lang.String} object. */ - public Generate2ColorDeck(String Clr1, String Clr2) { + public Generate2ColorDeck(final String Clr1, final String Clr2) { r = MyRandom.random; cardCounts = new HashMapget2ColorDeck.
- * - * @param Size a int. + *+ * get2ColorDeck. + *
+ * + * @param Size + * a int. + * @param pt + * the pt * @return a {@link forge.CardList} object. */ - public CardList get2ColorDeck(int Size, final PlayerType pt) { + public final CardList get2ColorDeck(final int Size, final PlayerType pt) { int lc = 0; // loop counter to prevent infinite card selection loops String tmpDeck = ""; CardList tDeck = new CardList(); @@ -92,9 +111,9 @@ public class Generate2ColorDeck { // start with all cards // remove cards that generated decks don't like CardList AllCards = CardFilter.filter(AllZone.getCardFactory(), new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { if (c.getSVar("RemRandomDeck").equals("True")) { - return false; + return false; } return (!c.getSVar("RemAIDeck").equals("True") || (pt != null && pt.equals(PlayerType.HUMAN))); } @@ -107,7 +126,7 @@ public class Generate2ColorDeck { // remove multicolor cards that don't match the colors CardListFilter clrF = new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { for (int i = 0; i < notColors.size(); i++) { if (c.getManaCost().contains(clrMap.get(notColors.get(i)))) { return false; @@ -123,7 +142,7 @@ public class Generate2ColorDeck { CardList Cr1 = CL1.getType("Creature"); CardList Cr2 = CL2.getType("Creature"); - String ISE[] = {"Instant", "Sorcery", "Enchantment", "Planeswalker", "Artifact.nonCreature"}; + String[] ISE = { "Instant", "Sorcery", "Enchantment", "Planeswalker", "Artifact.nonCreature" }; CardList Sp1 = CL1.getValidCards(ISE, null, null); CardList Sp2 = CL2.getValidCards(ISE, null, null); @@ -132,9 +151,9 @@ public class Generate2ColorDeck { CardList Sp12 = new CardList(); // used for mana curve in the card pool - final int MinCMC[] = {1}, MaxCMC[] = {2}; + final int MinCMC[] = { 1 }, MaxCMC[] = { 2 }; CardListFilter cmcF = new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { int cCMC = c.getCMC(); return (cCMC >= MinCMC[0]) && (cCMC <= MaxCMC[0]); } @@ -168,11 +187,12 @@ public class Generate2ColorDeck { MinCMC[0] += 2; MaxCMC[0] += 2; // resulting mana curve of the card pool - //16x 1 - 2 - //12x 3 - 4 - //8x 5 - 6 - //4x 7 - 8 - //=40x - card pool could support up to a 275 card deck (all 4-ofs plus basic lands) + // 16x 1 - 2 + // 12x 3 - 4 + // 8x 5 - 6 + // 4x 7 - 8 + // =40x - card pool could support up to a 275 card deck (all 4-ofs + // plus basic lands) } // shuffle card pools @@ -230,7 +250,8 @@ public class Generate2ColorDeck { if (LandsPercentage > 0) { p = (float) ((float) LandsPercentage * .01); numLands = (int) (p * (float) Size); - } else { // otherwise, just fill in the rest of the deck with basic lands + } else { // otherwise, just fill in the rest of the deck with basic + // lands numLands = Size - tDeck.size(); } @@ -257,16 +278,14 @@ public class Generate2ColorDeck { numLands -= nDLands; - if (numLands > 0) // attempt to optimize basic land counts according to color representation + if (numLands > 0) // attempt to optimize basic land counts according to + // color representation { - CCnt ClrCnts[] = {new CCnt("Plains", 0), - new CCnt("Island", 0), - new CCnt("Swamp", 0), - new CCnt("Mountain", 0), - new CCnt("Forest", 0)}; + CCnt[] ClrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), + new CCnt("Mountain", 0), new CCnt("Forest", 0) }; // count each card color using mana costs - // TODO: count hybrid mana differently? + // TODO count hybrid mana differently? for (int i = 0; i < tDeck.size(); i++) { String mc = tDeck.get(i).getManaCost(); @@ -276,17 +295,13 @@ public class Generate2ColorDeck { if (c == 'W') { ClrCnts[0].Count++; - } - else if (c == 'U') { + } else if (c == 'U') { ClrCnts[1].Count++; - } - else if (c == 'B') { + } else if (c == 'B') { ClrCnts[2].Count++; - } - else if (c == 'R') { + } else if (c == 'R') { ClrCnts[3].Count++; - } - else if (c == 'G') { + } else if (c == 'G') { ClrCnts[4].Count++; } } @@ -302,12 +317,14 @@ public class Generate2ColorDeck { tmpDeck += "totalColor:" + totalColor + "\n"; for (int i = 0; i < 5; i++) { - if (ClrCnts[i].Count > 0) { // calculate number of lands for each color + if (ClrCnts[i].Count > 0) { // calculate number of lands for + // each color p = (float) ClrCnts[i].Count / (float) totalColor; int nLand = (int) ((float) numLands * p); tmpDeck += "nLand-" + ClrCnts[i].Color + ":" + nLand + "\n"; - // just to prevent a null exception by the deck size fixing code + // just to prevent a null exception by the deck size fixing + // code cardCounts.put(ClrCnts[i].Color, nLand); for (int j = 0; j <= nLand; j++) { @@ -345,7 +362,7 @@ public class Generate2ColorDeck { for (int i = 0; i < diff; i++) { Card c = tDeck.get(r.nextInt(tDeck.size())); - while (c.isBasicLand()) { // don't remove basic lands + while (c.isBasicLand()) { // don't remove basic lands c = tDeck.get(r.nextInt(tDeck.size())); } @@ -366,7 +383,7 @@ public class Generate2ColorDeck { public String Color; public int Count; - public CCnt(String clr, int cnt) { + public CCnt(final String clr, final int cnt) { Color = clr; Count = cnt; } diff --git a/src/main/java/forge/deck/generate/Generate3ColorDeck.java b/src/main/java/forge/deck/generate/Generate3ColorDeck.java index 72956acb2b4..96c2ec42067 100644 --- a/src/main/java/forge/deck/generate/Generate3ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate3ColorDeck.java @@ -1,17 +1,26 @@ package forge.deck.generate; -import forge.*; -import forge.error.ErrorViewer; -import forge.properties.ForgeProps; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Random; +import forge.AllZone; +import forge.Card; +import forge.CardFilter; +import forge.CardList; +import forge.CardListFilter; +import forge.Constant; +import forge.MyRandom; +import forge.PlayerType; +import forge.error.ErrorViewer; +import forge.properties.ForgeProps; + /** - *Generate3ColorDeck class.
- * + *+ * Generate3ColorDeck class. + *
+ * * @author Forge * @version $Id$ */ @@ -26,13 +35,18 @@ public class Generate3ColorDeck { private MapConstructor for Generate3ColorDeck.
- * - * @param Clr1 a {@link java.lang.String} object. - * @param Clr2 a {@link java.lang.String} object. - * @param Clr3 a {@link java.lang.String} object. + *+ * Constructor for Generate3ColorDeck. + *
+ * + * @param Clr1 + * a {@link java.lang.String} object. + * @param Clr2 + * a {@link java.lang.String} object. + * @param Clr3 + * a {@link java.lang.String} object. */ - public Generate3ColorDeck(String Clr1, String Clr2, String Clr3) { + public Generate3ColorDeck(final String Clr1, final String Clr2, final String Clr3) { r = MyRandom.random; cardCounts = new HashMapget3ColorDeck.
- * - * @param Size a int. + *+ * get3ColorDeck. + *
+ * + * @param Size + * a int. + * @param pt + * the pt * @return a {@link forge.CardList} object. */ - public CardList get3ColorDeck(int Size, final PlayerType pt) { + public final CardList get3ColorDeck(final int Size, final PlayerType pt) { int lc = 0; // loop counter to prevent infinite card selection loops String tmpDeck = ""; CardList tDeck = new CardList(); @@ -101,11 +122,11 @@ public class Generate3ColorDeck { // start with all cards // remove cards that generated decks don't like CardList AllCards = CardFilter.filter(AllZone.getCardFactory(), new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { if (c.getSVar("RemRandomDeck").equals("True")) { return false; - } - return (!c.getSVar("RemAIDeck").equals("True") || (pt != null && pt.equals(PlayerType.HUMAN))); + } + return (!c.getSVar("RemAIDeck").equals("True") || (pt != null && pt.equals(PlayerType.HUMAN))); } }); @@ -117,10 +138,11 @@ public class Generate3ColorDeck { // remove multicolor cards that don't match the colors CardListFilter clrF = new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { for (int i = 0; i < notColors.size(); i++) { - if (c.getManaCost().contains(crMap.get(notColors.get(i)))) + if (c.getManaCost().contains(crMap.get(notColors.get(i)))) { return false; + } } return true; } @@ -134,7 +156,7 @@ public class Generate3ColorDeck { CardList Cr2 = CL2.getType("Creature"); CardList Cr3 = CL3.getType("Creature"); - String ISE[] = {"Instant", "Sorcery", "Enchantment", "Planeswalker", "Artifact.nonCreature"}; + String[] ISE = { "Instant", "Sorcery", "Enchantment", "Planeswalker", "Artifact.nonCreature" }; CardList Sp1 = CL1.getValidCards(ISE, null, null); CardList Sp2 = CL2.getValidCards(ISE, null, null); CardList Sp3 = CL3.getValidCards(ISE, null, null); @@ -144,9 +166,9 @@ public class Generate3ColorDeck { CardList Sp123 = new CardList(); // used for mana curve in the card pool - final int MinCMC[] = {1}, MaxCMC[] = {3}; + final int MinCMC[] = { 1 }, MaxCMC[] = { 3 }; CardListFilter cmcF = new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { int cCMC = c.getCMC(); return (cCMC >= MinCMC[0]) && (cCMC <= MaxCMC[0]); } @@ -191,10 +213,11 @@ public class Generate3ColorDeck { MinCMC[0] += 2; MaxCMC[0] += 2; // resulting mana curve of the card pool - //18x 1 - 3 - //12x 3 - 5 - //6x 5 - 7 - //=36x - card pool could support up to a 257 card deck (all 4-ofs plus basic lands) + // 18x 1 - 3 + // 12x 3 - 5 + // 6x 5 - 7 + // =36x - card pool could support up to a 257 card deck (all 4-ofs + // plus basic lands) } // shuffle card pools @@ -219,8 +242,9 @@ public class Generate3ColorDeck { c = Cr123.get(r.nextInt(Cr123.size())); lc++; } - if (lc > 100) + if (lc > 100) { throw new RuntimeException("Generate3ColorDeck : get3ColorDeck -- looped too much -- Cr123"); + } tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer())); int n = cardCounts.get(c.getName()); @@ -236,8 +260,9 @@ public class Generate3ColorDeck { c = Sp123.get(r.nextInt(Sp123.size())); lc++; } - if (lc > 100) + if (lc > 100) { throw new RuntimeException("Generate3ColorDeck : get3ColorDeck -- looped too much -- Sp123"); + } tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer())); int n = cardCounts.get(c.getName()); @@ -250,8 +275,10 @@ public class Generate3ColorDeck { if (LandsPercentage > 0) { p = (float) ((float) LandsPercentage * .01); numLands = (int) (p * (float) Size); - } else // otherwise, just fill in the rest of the deck with basic lands + } else { + // otherwise, just fill in the rest of the deck with basic lands numLands = Size - tDeck.size(); + } tmpDeck += "numLands:" + numLands + "\n"; @@ -264,8 +291,9 @@ public class Generate3ColorDeck { s = dL.get(r.nextInt(dL.size())); lc++; } - if (lc > 20) + if (lc > 20) { throw new RuntimeException("Generate3ColorDeck : get3ColorDeck -- looped too much -- dL"); + } tDeck.add(AllZone.getCardFactory().getCard(s, AllZone.getHumanPlayer())); int n = cardCounts.get(s); @@ -275,16 +303,14 @@ public class Generate3ColorDeck { numLands -= ndLands; - if (numLands > 0) // attempt to optimize basic land counts according to color representation + if (numLands > 0) // attempt to optimize basic land counts according to + // color representation { - CCnt ClrCnts[] = {new CCnt("Plains", 0), - new CCnt("Island", 0), - new CCnt("Swamp", 0), - new CCnt("Mountain", 0), - new CCnt("Forest", 0)}; + CCnt[] ClrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), + new CCnt("Mountain", 0), new CCnt("Forest", 0) }; // count each card color using mana costs - // TODO: count hybrid mana differently? + // TODO count hybrid mana differently? for (int i = 0; i < tDeck.size(); i++) { String mc = tDeck.get(i).getManaCost(); @@ -292,16 +318,17 @@ public class Generate3ColorDeck { for (int j = 0; j < mc.length(); j++) { char c = mc.charAt(j); - if (c == 'W') + if (c == 'W') { ClrCnts[0].Count++; - else if (c == 'U') + } else if (c == 'U') { ClrCnts[1].Count++; - else if (c == 'B') + } else if (c == 'B') { ClrCnts[2].Count++; - else if (c == 'R') + } else if (c == 'R') { ClrCnts[3].Count++; - else if (c == 'G') + } else if (c == 'G') { ClrCnts[4].Count++; + } } } @@ -315,16 +342,19 @@ public class Generate3ColorDeck { tmpDeck += "totalColor:" + totalColor + "\n"; for (int i = 0; i < 5; i++) { - if (ClrCnts[i].Count > 0) { // calculate number of lands for each color + if (ClrCnts[i].Count > 0) { // calculate number of lands for + // each color p = (float) ClrCnts[i].Count / (float) totalColor; int nLand = (int) ((float) numLands * p); tmpDeck += "nLand-" + ClrCnts[i].Color + ":" + nLand + "\n"; - // just to prevent a null exception by the deck size fixing code + // just to prevent a null exception by the deck size fixing + // code cardCounts.put(ClrCnts[i].Color, nLand); - for (int j = 0; j <= nLand; j++) + for (int j = 0; j <= nLand; j++) { tDeck.add(AllZone.getCardFactory().getCard(ClrCnts[i].Color, AllZone.getComputerPlayer())); + } } } } @@ -342,8 +372,9 @@ public class Generate3ColorDeck { c = tDeck.get(r.nextInt(tDeck.size())); lc++; } - if (lc > Size) + if (lc > Size) { throw new RuntimeException("Generate3ColorDeck : get3ColorDeck -- looped too much -- undersize"); + } int n = cardCounts.get(c.getName()); tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer())); @@ -356,8 +387,10 @@ public class Generate3ColorDeck { for (int i = 0; i < diff; i++) { Card c = tDeck.get(r.nextInt(tDeck.size())); - while (c.isBasicLand()) // don't remove basic lands + while (c.isBasicLand()) { + // don't remove basic lands c = tDeck.get(r.nextInt(tDeck.size())); + } tDeck.remove(c); tmpDeck += "Removed:" + c.getName() + "\n"; @@ -365,8 +398,9 @@ public class Generate3ColorDeck { } tmpDeck += "DeckSize:" + tDeck.size() + "\n"; - if (ForgeProps.getProperty("showdeck/3color", "false").equals("true")) + if (ForgeProps.getProperty("showdeck/3color", "false").equals("true")) { ErrorViewer.showError(tmpDeck); + } return tDeck; } @@ -375,7 +409,7 @@ public class Generate3ColorDeck { public String Color; public int Count; - public CCnt(String clr, int cnt) { + public CCnt(final String clr, final int cnt) { Color = clr; Count = cnt; } diff --git a/src/main/java/forge/deck/generate/Generate5ColorDeck.java b/src/main/java/forge/deck/generate/Generate5ColorDeck.java index 3b90729f21d..62a0c383d24 100644 --- a/src/main/java/forge/deck/generate/Generate5ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate5ColorDeck.java @@ -17,8 +17,10 @@ import forge.error.ErrorViewer; import forge.properties.ForgeProps; /** - *Generate5ColorDeck class.
- * + *+ * Generate5ColorDeck class. + *
+ * * @author Forge * @version $Id$ */ @@ -35,24 +37,30 @@ public class Generate5ColorDeck { private MapConstructor for Generate5ColorDeck.
- * - * @param clr1 a {@link java.lang.String} object. - * @param clr2 a {@link java.lang.String} object. - * @param clr3 a {@link java.lang.String} object. - * @param clr4 a {@link java.lang.String} object. - * @param clr5 a {@link java.lang.String} object. + *+ * Constructor for Generate5ColorDeck. + *
+ * + * @param clr1 + * a {@link java.lang.String} object. + * @param clr2 + * a {@link java.lang.String} object. + * @param clr3 + * a {@link java.lang.String} object. + * @param clr4 + * a {@link java.lang.String} object. + * @param clr5 + * a {@link java.lang.String} object. */ - public Generate5ColorDeck(final String clr1, final String clr2, - final String clr3, final String clr4, final String clr5) - { + public Generate5ColorDeck(final String clr1, final String clr2, final String clr3, final String clr4, + final String clr5) { r = MyRandom.random; cardCounts = new HashMapget3ColorDeck.
- * - * @param size a int. - * @param pt a PlayerType + *+ * get3ColorDeck. + *
+ * + * @param size + * a int. + * @param pt + * a PlayerType * @return a {@link forge.CardList} object. */ public final CardList get5ColorDeck(final int size, final PlayerType pt) { @@ -112,8 +124,8 @@ public class Generate5ColorDeck { public boolean addCard(final Card c) { if (c.getSVar("RemRandomDeck").equals("True")) { return false; - } - return (!c.getSVar("RemAIDeck").equals("True") || (pt != null && pt.equals(PlayerType.HUMAN))); + } + return (!c.getSVar("RemAIDeck").equals("True") || (pt != null && pt.equals(PlayerType.HUMAN))); } }); @@ -149,7 +161,7 @@ public class Generate5ColorDeck { CardList cr4 = cL4.getType("Creature"); CardList cr5 = cL5.getType("Creature"); - String[] ise = {"Instant", "Sorcery", "Enchantment", "Planeswalker", "Artifact.nonCreature"}; + String[] ise = { "Instant", "Sorcery", "Enchantment", "Planeswalker", "Artifact.nonCreature" }; CardList sp1 = cL1.getValidCards(ise, null, null); CardList sp2 = cL2.getValidCards(ise, null, null); CardList sp3 = cL3.getValidCards(ise, null, null); @@ -161,8 +173,8 @@ public class Generate5ColorDeck { CardList sp12345 = new CardList(); // used for mana curve in the card pool - final int[] minCMC = {1}; - final int[] maxCMC = {3}; + final int[] minCMC = { 1 }; + final int[] maxCMC = { 3 }; CardListFilter cmcF = new CardListFilter() { public boolean addCard(final Card c) { int cCMC = c.getCMC(); @@ -229,10 +241,11 @@ public class Generate5ColorDeck { minCMC[0] += 2; maxCMC[0] += 2; // resulting mana curve of the card pool - //18x 1 - 3 - //12x 3 - 5 - //6x 5 - 7 - //=36x - card pool could support up to a 257 card deck (all 4-ofs plus basic lands) + // 18x 1 - 3 + // 12x 3 - 5 + // 6x 5 - 7 + // =36x - card pool could support up to a 257 card deck (all 4-ofs + // plus basic lands) } // shuffle card pools @@ -290,7 +303,8 @@ public class Generate5ColorDeck { if (landsPercentage > 0) { p = (float) ((float) landsPercentage * .01); numLands = (int) (p * (float) size); - } else { // otherwise, just fill in the rest of the deck with basic lands + } else { // otherwise, just fill in the rest of the deck with basic + // lands numLands = size - tDeck.size(); } @@ -317,13 +331,11 @@ public class Generate5ColorDeck { numLands -= nDLands; - if (numLands > 0) // attempt to optimize basic land counts according to color representation + if (numLands > 0) // attempt to optimize basic land counts according to + // color representation { - CCnt[] clrCnts = {new CCnt("Plains", 0), - new CCnt("Island", 0), - new CCnt("Swamp", 0), - new CCnt("Mountain", 0), - new CCnt("Forest", 0)}; + CCnt[] clrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), + new CCnt("Mountain", 0), new CCnt("Forest", 0) }; // count each card color using mana costs // TODO: count hybrid mana differently? @@ -336,17 +348,13 @@ public class Generate5ColorDeck { if (c == 'W') { clrCnts[0].setCount(clrCnts[0].getCount() + 1); - } - else if (c == 'U') { + } else if (c == 'U') { clrCnts[1].setCount(clrCnts[1].getCount() + 1); - } - else if (c == 'B') { + } else if (c == 'B') { clrCnts[2].setCount(clrCnts[2].getCount() + 1); - } - else if (c == 'R') { + } else if (c == 'R') { clrCnts[3].setCount(clrCnts[3].getCount() + 1); - } - else if (c == 'G') { + } else if (c == 'G') { clrCnts[4].setCount(clrCnts[4].getCount() + 1); } } @@ -362,12 +370,14 @@ public class Generate5ColorDeck { tmpDeck += "totalColor:" + totalColor + "\n"; for (int i = 0; i < 5; i++) { - if (clrCnts[i].getCount() > 0) { // calculate number of lands for each color + if (clrCnts[i].getCount() > 0) { // calculate number of lands + // for each color p = (float) clrCnts[i].getCount() / (float) totalColor; int nLand = (int) ((float) numLands * p); tmpDeck += "nLand-" + clrCnts[i].getColor() + ":" + nLand + "\n"; - // just to prevent a null exception by the deck size fixing code + // just to prevent a null exception by the deck size fixing + // code cardCounts.put(clrCnts[i].getColor(), nLand); for (int j = 0; j <= nLand; j++) { @@ -405,7 +415,7 @@ public class Generate5ColorDeck { for (int i = 0; i < diff; i++) { Card c = tDeck.get(r.nextInt(tDeck.size())); - while (c.isBasicLand()) { // don't remove basic lands + while (c.isBasicLand()) { // don't remove basic lands c = tDeck.get(r.nextInt(tDeck.size())); } diff --git a/src/main/java/forge/deck/generate/GenerateConstructedDeck.java b/src/main/java/forge/deck/generate/GenerateConstructedDeck.java index da3ac066a82..61a871c17f5 100644 --- a/src/main/java/forge/deck/generate/GenerateConstructedDeck.java +++ b/src/main/java/forge/deck/generate/GenerateConstructedDeck.java @@ -1,5 +1,9 @@ package forge.deck.generate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + import forge.AllZone; import forge.Card; import forge.CardFilter; @@ -9,13 +13,12 @@ import forge.CardListUtil; import forge.CardUtil; import forge.Constant; import forge.Singletons; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; /** - *GenerateConstructedDeck class.
- * + *+ * GenerateConstructedDeck class. + *
+ * * @author Forge * @version $Id$ */ @@ -26,14 +29,18 @@ public class GenerateConstructedDeck { private MapConstructor for GenerateConstructedDeck.
+ *+ * Constructor for GenerateConstructedDeck. + *
*/ public GenerateConstructedDeck() { setupMap(); } /** - *setupMap.
+ *+ * setupMap. + *
*/ private void setupMap() { map.put(Constant.Color.Black, "Swamp"); @@ -44,8 +51,10 @@ public class GenerateConstructedDeck { } /** - *generateDeck.
- * + *+ * generateDeck. + *
+ * * @return a {@link forge.CardList} object. */ public final CardList generateDeck() { @@ -62,16 +71,21 @@ public class GenerateConstructedDeck { addLand(deck); if (deck.size() != 60) { - throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size()); + throw new RuntimeException( + "GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + + deck.size()); } return deck; } - //25 lands + // 25 lands /** - *addLand.
- * - * @param list a {@link forge.CardList} object. + *+ * addLand. + *
+ * + * @param list + * a {@link forge.CardList} object. */ private void addLand(final CardList list) { Card land; @@ -82,25 +96,27 @@ public class GenerateConstructedDeck { land = AllZone.getCardFactory().getCard(map.get(color2).toString(), AllZone.getComputerPlayer()); list.add(land); } - } //addLand() + } // addLand() /** - * Creates a CardList from the set of all cards that meets the criteria - * for color(s), type, whether the card is suitable for - * placement in random decks and in AI decks, etc. - * + * Creates a CardList from the set of all cards that meets the criteria for + * color(s), type, whether the card is suitable for placement in random + * decks and in AI decks, etc. + * * @see #filterBadCards(Iterable) - * + * * @return a subset of cards <= the set of all cards; might be empty, but - * never null + * never null */ private CardList getCards() { return filterBadCards(AllZone.getCardFactory()); - } //getCards() + } // getCards() /** - *get2ColorDeck.
- * + *+ * get2ColorDeck. + *
+ * * @return a {@link forge.CardList} object. */ private CardList get2ColorDeck() { @@ -109,7 +125,8 @@ public class GenerateConstructedDeck { CardList out = new CardList(); deck.shuffle(); - //trim deck size down to 34 cards, presumes 26 land, for a total of 60 cards + // trim deck size down to 34 cards, presumes 26 land, for a total of 60 + // cards for (int i = 0; i < 34 && i < deck.size(); i++) { out.add(deck.get(i)); } @@ -117,9 +134,12 @@ public class GenerateConstructedDeck { } /** - *get2Colors.
- * - * @param in a {@link forge.CardList} object. + *+ * get2Colors. + *
+ * + * @param in + * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ private CardList get2Colors(final CardList in) { @@ -129,7 +149,7 @@ public class GenerateConstructedDeck { do { a = CardUtil.getRandomIndex(Constant.Color.onlyColors); b = CardUtil.getRandomIndex(Constant.Color.onlyColors); - } while (a == b); //do not want to get the same color twice + } while (a == b); // do not want to get the same color twice color1 = Constant.Color.onlyColors[a]; color2 = Constant.Color.onlyColors[b]; @@ -141,8 +161,8 @@ public class GenerateConstructedDeck { CardList artifact = in.filter(new CardListFilter() { public boolean addCard(final Card c) { - //is this really a colorless artifact and not something - //weird like Sarcomite Myr which is a colored artifact + // is this really a colorless artifact and not something + // weird like Sarcomite Myr which is a colored artifact return c.isArtifact() && CardUtil.getColors(c).contains(Constant.Color.Colorless) && !Singletons.getModel().getPreferences().deckGenRmvArtifacts; } @@ -164,14 +184,14 @@ public class GenerateConstructedDeck { } /** - * Creates a CardList from the given sequence that meets the criteria - * for color(s), type, whether the card is suitable for - * placement in random decks and in AI decks, etc. - * - * @param sequence an iterable over Card instances + * Creates a CardList from the given sequence that meets the criteria for + * color(s), type, whether the card is suitable for placement in random + * decks and in AI decks, etc. * - * @return a subset of sequence <= sequence; might be empty, but never - * null + * @param sequence + * an iterable over Card instances + * + * @return a subset of sequence <= sequence; might be empty, but never null */ private CardList filterBadCards(final IterableGenerateConstructedMultiColorDeck class.
- * + *+ * GenerateConstructedMultiColorDeck class. + *
+ * * @author Forge * @version $Id$ */ @@ -22,7 +33,9 @@ public class GenerateConstructedMultiColorDeck { private MapConstructor for GenerateConstructedMultiColorDeck.
+ *+ * Constructor for GenerateConstructedMultiColorDeck. + *
*/ public GenerateConstructedMultiColorDeck() { setupBasicLandMap(); @@ -30,7 +43,9 @@ public class GenerateConstructedMultiColorDeck { } /** - *setupBasicLandMap.
+ *+ * setupBasicLandMap. + *
*/ private void setupBasicLandMap() { map.put(Constant.Color.Black, "Swamp"); @@ -41,38 +56,41 @@ public class GenerateConstructedMultiColorDeck { } /** - *setupMultiMap.
+ *+ * setupMultiMap. + *
*/ private void setupMultiMap() { - multiMap.put(Constant.Color.Black + Constant.Color.Blue, new String[]{"Underground Sea", "Watery Grave"}); - multiMap.put(Constant.Color.Black + Constant.Color.Green, new String[]{"Bayou", "Overgrown Tomb"}); - multiMap.put(Constant.Color.Black + Constant.Color.Red, new String[]{"Badlands", "Blood Crypt"}); - multiMap.put(Constant.Color.Black + Constant.Color.White, new String[]{"Scrubland", "Godless Shrine"}); - multiMap.put(Constant.Color.Blue + Constant.Color.Black, new String[]{"Underground Sea", "Watery Grave"}); - multiMap.put(Constant.Color.Blue + Constant.Color.Green, new String[]{"Tropical Island", "Breeding Pool"}); - multiMap.put(Constant.Color.Blue + Constant.Color.Red, new String[]{"Volcanic Island", "Steam Vents"}); - multiMap.put(Constant.Color.Blue + Constant.Color.White, new String[]{"Tundra", "Hallowed Fountain"}); - multiMap.put(Constant.Color.Green + Constant.Color.Black, new String[]{"Bayou", "Overgrown Tomb"}); - multiMap.put(Constant.Color.Green + Constant.Color.Blue, new String[]{"Tropical Island", "Breeding Pool"}); - multiMap.put(Constant.Color.Green + Constant.Color.Red, new String[]{"Taiga", "Stomping Ground"}); - multiMap.put(Constant.Color.Green + Constant.Color.White, new String[]{"Savannah", "Temple Garden"}); - multiMap.put(Constant.Color.Red + Constant.Color.Black, new String[]{"Badlands", "Blood Crypt"}); - multiMap.put(Constant.Color.Red + Constant.Color.Blue, new String[]{"Volcanic Island", "Steam Vents"}); - multiMap.put(Constant.Color.Red + Constant.Color.Green, new String[]{"Taiga", "Stomping Ground"}); - multiMap.put(Constant.Color.Red + Constant.Color.White, new String[]{"Plateau", "Sacred Foundry"}); - multiMap.put(Constant.Color.White + Constant.Color.Black, new String[]{"Scrubland", "Godless Shrine"}); - multiMap.put(Constant.Color.White + Constant.Color.Blue, new String[]{"Tundra", "Hallowed Fountain"}); - multiMap.put(Constant.Color.White + Constant.Color.Green, new String[]{"Savannah", "Temple Garden"}); - multiMap.put(Constant.Color.White + Constant.Color.Red, new String[]{"Plateau", "Sacred Foundry"}); + multiMap.put(Constant.Color.Black + Constant.Color.Blue, new String[] { "Underground Sea", "Watery Grave" }); + multiMap.put(Constant.Color.Black + Constant.Color.Green, new String[] { "Bayou", "Overgrown Tomb" }); + multiMap.put(Constant.Color.Black + Constant.Color.Red, new String[] { "Badlands", "Blood Crypt" }); + multiMap.put(Constant.Color.Black + Constant.Color.White, new String[] { "Scrubland", "Godless Shrine" }); + multiMap.put(Constant.Color.Blue + Constant.Color.Black, new String[] { "Underground Sea", "Watery Grave" }); + multiMap.put(Constant.Color.Blue + Constant.Color.Green, new String[] { "Tropical Island", "Breeding Pool" }); + multiMap.put(Constant.Color.Blue + Constant.Color.Red, new String[] { "Volcanic Island", "Steam Vents" }); + multiMap.put(Constant.Color.Blue + Constant.Color.White, new String[] { "Tundra", "Hallowed Fountain" }); + multiMap.put(Constant.Color.Green + Constant.Color.Black, new String[] { "Bayou", "Overgrown Tomb" }); + multiMap.put(Constant.Color.Green + Constant.Color.Blue, new String[] { "Tropical Island", "Breeding Pool" }); + multiMap.put(Constant.Color.Green + Constant.Color.Red, new String[] { "Taiga", "Stomping Ground" }); + multiMap.put(Constant.Color.Green + Constant.Color.White, new String[] { "Savannah", "Temple Garden" }); + multiMap.put(Constant.Color.Red + Constant.Color.Black, new String[] { "Badlands", "Blood Crypt" }); + multiMap.put(Constant.Color.Red + Constant.Color.Blue, new String[] { "Volcanic Island", "Steam Vents" }); + multiMap.put(Constant.Color.Red + Constant.Color.Green, new String[] { "Taiga", "Stomping Ground" }); + multiMap.put(Constant.Color.Red + Constant.Color.White, new String[] { "Plateau", "Sacred Foundry" }); + multiMap.put(Constant.Color.White + Constant.Color.Black, new String[] { "Scrubland", "Godless Shrine" }); + multiMap.put(Constant.Color.White + Constant.Color.Blue, new String[] { "Tundra", "Hallowed Fountain" }); + multiMap.put(Constant.Color.White + Constant.Color.Green, new String[] { "Savannah", "Temple Garden" }); + multiMap.put(Constant.Color.White + Constant.Color.Red, new String[] { "Plateau", "Sacred Foundry" }); } - /** - *generate3ColorDeck.
- * + *+ * generate3ColorDeck. + *
+ * * @return a {@link forge.CardList} object. */ - public CardList generate3ColorDeck() { + public final CardList generate3ColorDeck() { CardList deck; int check; @@ -85,37 +103,49 @@ public class GenerateConstructedMultiColorDeck { addLand(deck, 3); - if (deck.size() != 60) - throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size()); + if (deck.size() != 60) { + throw new RuntimeException( + "GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + + deck.size()); + } return deck; } /** - *generate5ColorDeck.
- * + *+ * generate5ColorDeck. + *
+ * * @return a {@link forge.CardList} object. */ - public CardList generate5ColorDeck() { + public final CardList generate5ColorDeck() { CardList deck; deck = get5ColorDeck(); addLand(deck, 5); - if (deck.size() != 60) - throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size()); + if (deck.size() != 60) { + throw new RuntimeException( + "GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + + deck.size()); + } return deck; } /** - *addLand.
- * - * @param list a {@link forge.CardList} object. - * @param colors a int. + *+ * addLand. + *
+ * + * @param list + * a {@link forge.CardList} object. + * @param colors + * a int. */ - private void addLand(CardList list, int colors) { + private void addLand(final CardList list, final int colors) { if (colors == 3) { int numberBasic = 2; Card land; @@ -173,7 +203,6 @@ public class GenerateConstructedMultiColorDeck { list.add(land); } - int numberDual = 2; for (int i = 0; i < numberDual; i++) { land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color2)[0], AllZone.getComputerPlayer()); @@ -208,25 +237,28 @@ public class GenerateConstructedMultiColorDeck { } } - }//addLand() + } // addLand() /** - * Filters out cards by color and their suitability for being placed in - * a randomly created deck. - * - * @param colors the number of different colors the deck should have; - * if this is a number other than 3 or 5, we return an empty list. + * Filters out cards by color and their suitability for being placed in a + * randomly created deck. * - * @return a subset of all cards in the CardFactory database - * which might be empty, but never null + * @param colors + * the number of different colors the deck should have; if this + * is a number other than 3 or 5, we return an empty list. + * + * @return a subset of all cards in the CardFactory database which might be + * empty, but never null */ - private CardList getCards(int colors) { + private CardList getCards(final int colors) { return filterBadCards(AllZone.getCardFactory(), colors); - }//getCards() + } // getCards() /** - *get3ColorDeck.
- * + *+ * get3ColorDeck. + *
+ * * @return a {@link forge.CardList} object. */ private CardList get3ColorDeck() { @@ -235,16 +267,20 @@ public class GenerateConstructedMultiColorDeck { CardList out = new CardList(); deck.shuffle(); - //trim deck size down to 36 cards, presumes 24 land, for a total of 60 cards - for (int i = 0; i < 36 && i < deck.size(); i++) + // trim deck size down to 36 cards, presumes 24 land, for a total of 60 + // cards + for (int i = 0; i < 36 && i < deck.size(); i++) { out.add(deck.get(i)); + } return out; } /** - *get5ColorDeck.
- * + *+ * get5ColorDeck. + *
+ * * @return a {@link forge.CardList} object. */ private CardList get5ColorDeck() { @@ -253,20 +289,25 @@ public class GenerateConstructedMultiColorDeck { CardList out = new CardList(); deck.shuffle(); - //trim deck size down to 36 cards, presumes 24 land, for a total of 60 cards - for (int i = 0; i < 36 && i < deck.size(); i++) + // trim deck size down to 36 cards, presumes 24 land, for a total of 60 + // cards + for (int i = 0; i < 36 && i < deck.size(); i++) { out.add(deck.get(i)); + } return out; } /** - *get3Colors.
- * - * @param in a {@link forge.CardList} object. + *+ * get3Colors. + *
+ * + * @param in + * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - private CardList get3Colors(CardList in) { + private CardList get3Colors(final CardList in) { int a; int b; int c; @@ -275,7 +316,8 @@ public class GenerateConstructedMultiColorDeck { do { b = CardUtil.getRandomIndex(Constant.Color.onlyColors); c = CardUtil.getRandomIndex(Constant.Color.onlyColors); - } while (a == b || a == c || b == c);//do not want to get the same color thrice + } while (a == b || a == c || b == c); // do not want to get the same + // color thrice color1 = Constant.Color.onlyColors[a]; color2 = Constant.Color.onlyColors[b]; @@ -288,21 +330,18 @@ public class GenerateConstructedMultiColorDeck { out.shuffle(); CardList artifact = in.filter(new CardListFilter() { - public boolean addCard(Card c) { - //is this really a colorless artifact and not something - //wierd like Sarcomite Myr which is a colored artifact - return c.isArtifact() && - CardUtil.getColors(c).contains(Constant.Color.Colorless) && - !Singletons.getModel().getPreferences().deckGenRmvArtifacts; + public boolean addCard(final Card c) { + // is this really a colorless artifact and not something + // wierd like Sarcomite Myr which is a colored artifact + return c.isArtifact() && CardUtil.getColors(c).contains(Constant.Color.Colorless) + && !Singletons.getModel().getPreferences().deckGenRmvArtifacts; } }); out.addAll(artifact); out = out.filter(new CardListFilter() { - public boolean addCard(Card c) { - if (c.isCreature() && - c.getNetAttack() <= 1 && - Singletons.getModel().getPreferences().deckGenRmvSmall) { + public boolean addCard(final Card c) { + if (c.isCreature() && c.getNetAttack() <= 1 && Singletons.getModel().getPreferences().deckGenRmvSmall) { return false; } @@ -315,12 +354,15 @@ public class GenerateConstructedMultiColorDeck { } /** - *get5Colors.
- * - * @param in a {@link forge.CardList} object. + *+ * get5Colors. + *
+ * + * @param in + * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - private CardList get5Colors(CardList in) { + private CardList get5Colors(final CardList in) { color1 = Constant.Color.Black; color2 = Constant.Color.Blue; @@ -330,31 +372,28 @@ public class GenerateConstructedMultiColorDeck { CardList out = new CardList(); /* - out.addAll(CardListUtil.getColor(in, color1)); - out.addAll(CardListUtil.getColor(in, color2)); - out.addAll(CardListUtil.getColor(in, color3)); - out.addAll(CardListUtil.getColor(in, color4)); - out.addAll(CardListUtil.getColor(in, color5)); - */ + * out.addAll(CardListUtil.getColor(in, color1)); + * out.addAll(CardListUtil.getColor(in, color2)); + * out.addAll(CardListUtil.getColor(in, color3)); + * out.addAll(CardListUtil.getColor(in, color4)); + * out.addAll(CardListUtil.getColor(in, color5)); + */ out.addAll(CardListUtil.getGoldCards(in)); out.shuffle(); CardList artifact = in.filter(new CardListFilter() { - public boolean addCard(Card c) { - //is this really a colorless artifact and not something - //wierd like Sarcomite Myr which is a colored artifact - return c.isArtifact() && - CardUtil.getColors(c).contains(Constant.Color.Colorless) && - !Singletons.getModel().getPreferences().deckGenRmvArtifacts; + public boolean addCard(final Card c) { + // is this really a colorless artifact and not something + // wierd like Sarcomite Myr which is a colored artifact + return c.isArtifact() && CardUtil.getColors(c).contains(Constant.Color.Colorless) + && !Singletons.getModel().getPreferences().deckGenRmvArtifacts; } }); out.addAll(artifact); out = out.filter(new CardListFilter() { - public boolean addCard(Card c) { - if (c.isCreature() && - c.getNetAttack() <= 1 && - Singletons.getModel().getPreferences().deckGenRmvSmall) { + public boolean addCard(final Card c) { + if (c.isCreature() && c.getNetAttack() <= 1 && Singletons.getModel().getPreferences().deckGenRmvSmall) { return false; } @@ -366,56 +405,61 @@ public class GenerateConstructedMultiColorDeck { return out; } - /** - * Filters out cards by color and their suitability for being placed in - * a randomly created deck. - * - * @param sequence an Iterable of Card instances + * Filters out cards by color and their suitability for being placed in a + * randomly created deck. * - * @param colors the number of different colors the deck should have; - * if this is a number other than 3 or 5, we return an empty list. + * @param sequence + * an Iterable of Card instances * - * @return a subset of sequence <= sequence which might be empty, but - * never null + * @param colors + * the number of different colors the deck should have; if this + * is a number other than 3 or 5, we return an empty list. + * + * @return a subset of sequence <= sequence which might be empty, but never + * null */ - private CardList filterBadCards(IterableGenerateDeckUtil class.
- * + *+ * GenerateDeckUtil class. + *
+ * * @author Forge * @version $Id: GenerateDeckUtil.java 10011 2011-08-28 12:20:52Z Sloth $ */ @@ -13,7 +15,9 @@ public class GenerateDeckUtil { /** * * Arrays of dual and tri-land cards. - * @param colors a String + * + * @param colors + * a String * @return ArrayListGenerateThemeDeck class.
- * + *+ * GenerateThemeDeck class. + *
+ * * @author Forge * @version $Id$ */ @@ -25,15 +27,19 @@ public class GenerateThemeDeck { private BufferedReader in = null; /** - *Constructor for GenerateThemeDeck.
+ *+ * Constructor for GenerateThemeDeck. + *
*/ public GenerateThemeDeck() { } /** - *getThemeNames.
- * + *+ * getThemeNames. + *
+ * * @return a {@link java.util.ArrayList} object. */ public final ArrayListgetThemeDeck.
- * - * @param themeName a {@link java.lang.String} object. - * @param size a int. + *+ * getThemeDeck. + *
+ * + * @param themeName + * a {@link java.lang.String} object. + * @param size + * a int. * @return a {@link forge.CardList} object. */ - public CardList getThemeDeck(final String themeName, final int size) { + public final CardList getThemeDeck(final String themeName, final int size) { CardList tDeck = new CardList(); ArrayListreadLine.
- * + *+ * readLine. + *
+ * * @return a {@link java.lang.String} object. */ private String readLine() { - //makes the checked exception, into an unchecked runtime exception + // makes the checked exception, into an unchecked runtime exception try { String s = in.readLine(); if (s != null) { @@ -294,18 +308,30 @@ public class GenerateThemeDeck { ErrorViewer.showError(ex); throw new RuntimeException("GenerateThemeDeck : readLine error"); } - } //readLine(Card) + } // readLine(Card) /** * * TODO Write javadoc for this type. - * + * */ class CCnt { + + /** The Color. */ public String Color; + + /** The Count. */ public int Count; - public CCnt(String clr, int cnt) { + /** + * Instantiates a new c cnt. + * + * @param clr + * the clr + * @param cnt + * the cnt + */ + public CCnt(final String clr, final int cnt) { Color = clr; Count = cnt; } @@ -314,12 +340,17 @@ public class GenerateThemeDeck { /** * * TODO Write javadoc for this type. - * + * */ class Grp { + + /** The Cardnames. */ public ArrayList