diff --git a/.gitattributes b/.gitattributes index d7fc14f0878..f7a7dea34a0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11375,7 +11375,6 @@ src/main/java/forge/ComputerUtil.java svneol=native#text/plain src/main/java/forge/ComputerUtilAttack.java svneol=native#text/plain src/main/java/forge/ComputerUtilBlock.java svneol=native#text/plain src/main/java/forge/Constant.java svneol=native#text/plain -src/main/java/forge/ConstantStringArrayList.java svneol=native#text/plain src/main/java/forge/Counters.java svneol=native#text/plain src/main/java/forge/DefaultPlayerZone.java svneol=native#text/plain src/main/java/forge/ExternalPanel.java svneol=native#text/plain diff --git a/src/main/java/forge/CardUtil.java b/src/main/java/forge/CardUtil.java index 43c3d84fbe2..9a0f2af448e 100644 --- a/src/main/java/forge/CardUtil.java +++ b/src/main/java/forge/CardUtil.java @@ -453,7 +453,7 @@ public final class CardUtil { final ArrayList types = new ArrayList(); // types.addAll(getCardTypes()); - types.addAll(Constant.CardTypes.CARD_TYPES[0].getList()); + types.addAll(Constant.CardTypes.CARD_TYPES); // not currently used by Forge types.add("Plane"); @@ -482,7 +482,7 @@ public final class CardUtil { // types.add("Sorcery"); // types.add("Tribal"); - types.addAll(Constant.CardTypes.CARD_TYPES[0].getList()); + types.addAll(Constant.CardTypes.CARD_TYPES); return types; } @@ -498,7 +498,7 @@ public final class CardUtil { public static ArrayList getBasicTypes() { final ArrayList types = new ArrayList(); - types.addAll(Constant.CardTypes.BASIC_TYPES[0].getList()); + types.addAll(Constant.CardTypes.BASIC_TYPES); return types; } @@ -511,8 +511,8 @@ public final class CardUtil { public static ArrayList getLandTypes() { final ArrayList types = new ArrayList(); - types.addAll(Constant.CardTypes.BASIC_TYPES[0].getList()); - types.addAll(Constant.CardTypes.LAND_TYPES[0].getList()); + types.addAll(Constant.CardTypes.BASIC_TYPES); + types.addAll(Constant.CardTypes.LAND_TYPES); return types; } @@ -528,7 +528,7 @@ public final class CardUtil { public static ArrayList getCreatureTypes() { final ArrayList types = new ArrayList(); - types.addAll(Constant.CardTypes.CREATURE_TYPES[0].getList()); + types.addAll(Constant.CardTypes.CREATURE_TYPES); return types; } @@ -544,7 +544,7 @@ public final class CardUtil { */ public static boolean isASuperType(final String cardType) { - return (Constant.CardTypes.SUPER_TYPES[0].getList().contains(cardType)); + return (Constant.CardTypes.SUPER_TYPES.contains(cardType)); } /** @@ -570,7 +570,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isACreatureType(final String cardType) { - return (Constant.CardTypes.CREATURE_TYPES[0].getList().contains(cardType)); + return (Constant.CardTypes.CREATURE_TYPES.contains(cardType)); } /** @@ -583,7 +583,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isALandType(final String cardType) { - return (Constant.CardTypes.LAND_TYPES[0].getList().contains(cardType)); + return (Constant.CardTypes.LAND_TYPES.contains(cardType)); } /** @@ -594,7 +594,7 @@ public final class CardUtil { * @return true, if is a planeswalker type */ public static boolean isAPlaneswalkerType(final String cardType) { - return (Constant.CardTypes.WALKER_TYPES[0].getList().contains(cardType)); + return (Constant.CardTypes.WALKER_TYPES.contains(cardType)); } /** @@ -607,7 +607,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isABasicLandType(final String cardType) { - return (Constant.CardTypes.BASIC_TYPES[0].getList().contains(cardType)); + return (Constant.CardTypes.BASIC_TYPES.contains(cardType)); } // this function checks, if duplicates of a keyword are not necessary (like @@ -622,7 +622,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isNonStackingKeyword(final String keyword) { - return Constant.Keywords.NON_STACKING_LIST[0].getList().contains(keyword); + return Constant.Keywords.NON_STACKING_LIST.contains(keyword); } /** diff --git a/src/main/java/forge/Constant.java b/src/main/java/forge/Constant.java index b38115b4b4d..8562cd9c678 100644 --- a/src/main/java/forge/Constant.java +++ b/src/main/java/forge/Constant.java @@ -248,34 +248,34 @@ public final class Constant { public static final boolean[] LOADED = { false }; /** The card types. */ - public static final ConstantStringArrayList[] CARD_TYPES = new ConstantStringArrayList[1]; + public static final List CARD_TYPES = new ArrayList(); /** The super types. */ - public static final ConstantStringArrayList[] SUPER_TYPES = new ConstantStringArrayList[1]; + public static final List SUPER_TYPES = new ArrayList(); /** The basic types. */ - public static final ConstantStringArrayList[] BASIC_TYPES = new ConstantStringArrayList[1]; + public static final List BASIC_TYPES = new ArrayList(); /** The land types. */ - public static final ConstantStringArrayList[] LAND_TYPES = new ConstantStringArrayList[1]; + public static final List LAND_TYPES = new ArrayList(); /** The creature types. */ - public static final ConstantStringArrayList[] CREATURE_TYPES = new ConstantStringArrayList[1]; + public static final List CREATURE_TYPES = new ArrayList(); /** The instant types. */ - public static final ConstantStringArrayList[] INSTANT_TYPES = new ConstantStringArrayList[1]; + public static final List INSTANT_TYPES = new ArrayList(); /** The sorcery types. */ - public static final ConstantStringArrayList[] SORCERY_TYPES = new ConstantStringArrayList[1]; + public static final List SORCERY_TYPES = new ArrayList(); /** The enchantment types. */ - public static final ConstantStringArrayList[] ENCHANTMENT_TYPES = new ConstantStringArrayList[1]; + public static final List ENCHANTMENT_TYPES = new ArrayList(); /** The artifact types. */ - public static final ConstantStringArrayList[] ARTIFACT_TYPES = new ConstantStringArrayList[1]; + public static final List ARTIFACT_TYPES = new ArrayList(); /** The walker types. */ - public static final ConstantStringArrayList[] WALKER_TYPES = new ConstantStringArrayList[1]; + public static final List WALKER_TYPES = new ArrayList(); } /** @@ -287,7 +287,7 @@ public final class Constant { public static final boolean[] LOADED = { false }; /** The Non stacking list. */ - public static final ConstantStringArrayList[] NON_STACKING_LIST = new ConstantStringArrayList[1]; + public static final List NON_STACKING_LIST = new ArrayList(); } } // Constant diff --git a/src/main/java/forge/ConstantStringArrayList.java b/src/main/java/forge/ConstantStringArrayList.java deleted file mode 100644 index be493743472..00000000000 --- a/src/main/java/forge/ConstantStringArrayList.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Forge: Play Magic: the Gathering. - * Copyright (C) 2011 Forge Team - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package forge; - -import java.util.ArrayList; - -/** - * The Class Constant_StringArrayList. - */ -public class ConstantStringArrayList { - - /** The list. */ - private ArrayList list = new ArrayList(); - - /** - * Gets the list. - * - * @return the list - */ - public ArrayList getList() { - return this.list; - } - - /** - * Sets the list. - * - * @param list0 - * the list to set - */ - public void setList(final ArrayList list0) { - this.list = list0; - } - -} diff --git a/src/main/java/forge/card/trigger/TriggerHandler.java b/src/main/java/forge/card/trigger/TriggerHandler.java index 08d20eac5ac..e048ade3c7a 100644 --- a/src/main/java/forge/card/trigger/TriggerHandler.java +++ b/src/main/java/forge/card/trigger/TriggerHandler.java @@ -44,7 +44,7 @@ import forge.card.spellability.SpellAbilityRestriction; import forge.card.spellability.Target; import forge.control.input.Input; import forge.game.phase.PhaseType; -import forge.util.TextUtil; +//import forge.util.TextUtil; /** *

diff --git a/src/main/java/forge/deck/generate/Generate2ColorDeck.java b/src/main/java/forge/deck/generate/Generate2ColorDeck.java index 433163cb9d1..74cb7699af6 100644 --- a/src/main/java/forge/deck/generate/Generate2ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate2ColorDeck.java @@ -25,7 +25,6 @@ import forge.card.CardRules; import forge.deck.generate.GenerateDeckUtil.FilterCMC; import forge.error.ErrorViewer; import forge.item.CardPrinted; -import forge.item.ItemPool; import forge.item.ItemPoolView; import forge.properties.ForgeProps; @@ -85,18 +84,17 @@ public class Generate2ColorDeck extends GenerateColoredDeckBase { final List spells = CardRules.Predicates.Presets.isNonCreatureSpellForGenerator.select(cards, CardPrinted.FN_GET_RULES); - final ItemPool tDeck = new ItemPool(CardPrinted.class); final int creatCnt = (int) (creatPercentage * size); tmpDeck.append( "Creature Count:" + creatCnt + "\n" ); - addCmcAdjusted(tDeck, creatures, creatCnt, cmcLevels, cmcAmounts); + addCmcAdjusted(creatures, creatCnt, cmcLevels, cmcAmounts); final int spellCnt = (int) (spellPercentage * size); tmpDeck.append( "Spell Count:" + spellCnt + "\n" ); - addCmcAdjusted(tDeck, spells, spellCnt, cmcLevels, cmcAmounts); + addCmcAdjusted(spells, spellCnt, cmcLevels, cmcAmounts); // Add lands - int numLands = landsPercentage > 0 ? (int) (landsPercentage * size) : size - tDeck.countAll(); + int numLands = (int) (landsPercentage * size); tmpDeck.append( "numLands:" + numLands + "\n"); @@ -107,13 +105,13 @@ public class Generate2ColorDeck extends GenerateColoredDeckBase { this.cardCounts.put(s, 0); } - int dblsAdded = addSomeStr(tDeck, (numLands / 6), duals); + int dblsAdded = addSomeStr((numLands / 6), duals); numLands -= dblsAdded; - addBasicLand(tDeck, numLands); + addBasicLand(numLands); tmpDeck.append( "DeckSize:" + tDeck.countAll() + "\n" ); - adjustDeckSize(tDeck, size); + adjustDeckSize(size); tmpDeck.append( "DeckSize:" + tDeck.countAll() + "\n" ); if (ForgeProps.getProperty("showdeck/2color", "false").equals("true")) { ErrorViewer.showError(tmpDeck.toString()); diff --git a/src/main/java/forge/deck/generate/Generate3ColorDeck.java b/src/main/java/forge/deck/generate/Generate3ColorDeck.java index 5ae00c9cece..eccdaf576d5 100644 --- a/src/main/java/forge/deck/generate/Generate3ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate3ColorDeck.java @@ -25,7 +25,6 @@ import forge.card.CardRules; import forge.deck.generate.GenerateDeckUtil.FilterCMC; import forge.error.ErrorViewer; import forge.item.CardPrinted; -import forge.item.ItemPool; import forge.item.ItemPoolView; import forge.properties.ForgeProps; @@ -87,19 +86,16 @@ public class Generate3ColorDeck extends GenerateColoredDeckBase { final List creatures = CardRules.Predicates.Presets.IS_CREATURE.select(cards, CardPrinted.FN_GET_RULES); final List spells = CardRules.Predicates.Presets.isNonCreatureSpellForGenerator.select(cards, CardPrinted.FN_GET_RULES); - - final ItemPool tDeck = new ItemPool(CardPrinted.class); - final int creatCnt = (int) (creatPercentage * size); tmpDeck.append( "Creature Count:" + creatCnt + "\n" ); - addCmcAdjusted(tDeck, creatures, creatCnt, cmcLevels, cmcAmounts); + addCmcAdjusted(creatures, creatCnt, cmcLevels, cmcAmounts); final int spellCnt = (int) (spellPercentage * size); tmpDeck.append( "Spell Count:" + spellCnt + "\n" ); - addCmcAdjusted(tDeck, spells, spellCnt, cmcLevels, cmcAmounts); + addCmcAdjusted(spells, spellCnt, cmcLevels, cmcAmounts); // Add lands - int numLands = landsPercentage > 0 ? (int) (landsPercentage * size) : size - tDeck.countAll(); + int numLands = (int) (landsPercentage * size); tmpDeck.append( "numLands:" + numLands + "\n"); @@ -109,13 +105,13 @@ public class Generate3ColorDeck extends GenerateColoredDeckBase { for(String s : duals) { this.cardCounts.put(s, 0); } - int dblsAdded = addSomeStr(tDeck, (numLands / 4), duals); + int dblsAdded = addSomeStr((numLands / 4), duals); numLands -= dblsAdded; - addBasicLand(tDeck, numLands); + addBasicLand(numLands); tmpDeck.append( "DeckSize:" + tDeck.countAll() + "\n" ); - adjustDeckSize(tDeck, size); + adjustDeckSize(size); tmpDeck.append( "DeckSize:" + tDeck.countAll() + "\n" ); if (ForgeProps.getProperty("showdeck/3color", "false").equals("true")) { ErrorViewer.showError(tmpDeck.toString()); diff --git a/src/main/java/forge/deck/generate/Generate5ColorDeck.java b/src/main/java/forge/deck/generate/Generate5ColorDeck.java index 273b611dec6..cda664c5a9a 100644 --- a/src/main/java/forge/deck/generate/Generate5ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate5ColorDeck.java @@ -25,7 +25,6 @@ import forge.card.CardRules; import forge.deck.generate.GenerateDeckUtil.FilterCMC; import forge.error.ErrorViewer; import forge.item.CardPrinted; -import forge.item.ItemPool; import forge.item.ItemPoolView; import forge.properties.ForgeProps; @@ -77,20 +76,17 @@ public class Generate5ColorDeck extends GenerateColoredDeckBase { // build subsets based on type final List creatures = CardRules.Predicates.Presets.IS_CREATURE.select(cards, CardPrinted.FN_GET_RULES); final List spells = CardRules.Predicates.Presets.isNonCreatureSpellForGenerator.select(cards, CardPrinted.FN_GET_RULES); - - - final ItemPool tDeck = new ItemPool(CardPrinted.class); - + final int creatCnt = (int) (creatPercentage * size); tmpDeck.append( "Creature Count:" + creatCnt + "\n" ); - addCmcAdjusted(tDeck, creatures, creatCnt, cmcLevels, cmcAmounts); + addCmcAdjusted(creatures, creatCnt, cmcLevels, cmcAmounts); final int spellCnt = (int) (spellPercentage * size); tmpDeck.append( "Spell Count:" + spellCnt + "\n" ); - addCmcAdjusted(tDeck, spells, spellCnt, cmcLevels, cmcAmounts); + addCmcAdjusted(spells, spellCnt, cmcLevels, cmcAmounts); // Add lands - int numLands = landsPercentage > 0 ? (int) (landsPercentage * size) : size - tDeck.countAll(); + int numLands = (int) (landsPercentage * size); tmpDeck.append( "numLands:" + numLands + "\n"); @@ -100,13 +96,13 @@ public class Generate5ColorDeck extends GenerateColoredDeckBase { for(String s : duals) { this.cardCounts.put(s, 0); } - int dblsAdded = addSomeStr(tDeck, (numLands / 4), duals); + int dblsAdded = addSomeStr((numLands / 4), duals); numLands -= dblsAdded; - addBasicLand(tDeck, numLands); + addBasicLand(numLands); tmpDeck.append( "DeckSize:" + tDeck.countAll() + "\n" ); - adjustDeckSize(tDeck, size); + adjustDeckSize(size); tmpDeck.append( "DeckSize:" + tDeck.countAll() + "\n" ); if (ForgeProps.getProperty("showdeck/5color", "false").equals("true")) { ErrorViewer.showError(tmpDeck.toString()); diff --git a/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java b/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java index 78bb84a67d2..c4f62ce3bd3 100644 --- a/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java +++ b/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Random; +import forge.Constant; import forge.PlayerType; import forge.Singletons; import forge.card.CardColor; @@ -50,6 +51,7 @@ public abstract class GenerateColoredDeckBase { protected final int maxDuplicates; protected CardColor colors; + protected final ItemPool tDeck; StringBuilder tmpDeck = new StringBuilder(); @@ -68,11 +70,12 @@ public abstract class GenerateColoredDeckBase { */ public GenerateColoredDeckBase() { this.maxDuplicates = Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_SINGLETONS) ? 1 : 4; + tDeck = new ItemPool(CardPrinted.class); } - protected void addSome(ItemPool tDeck, int cnt, List source) { + protected void addSome(int cnt, List source) { for (int i = 0; i < cnt; i++) { CardPrinted c; int lc = 0; @@ -92,7 +95,7 @@ public abstract class GenerateColoredDeckBase { } } - protected int addSomeStr(ItemPool tDeck, int cnt, List source) { + protected int addSomeStr(int cnt, List source) { int res = 0; for (int i = 0; i < cnt; i++) { String s; @@ -111,7 +114,7 @@ public abstract class GenerateColoredDeckBase { return res; } - protected void addBasicLand(ItemPool tDeck, int cnt) { + protected void addBasicLand(int cnt) { // attempt to optimize basic land counts according to colors of picked cards final CCnt[] clrCnts = countLands(tDeck); // total of all ClrCnts @@ -141,12 +144,12 @@ public abstract class GenerateColoredDeckBase { } } - protected void adjustDeckSize(ItemPool tDeck, int targetSize) { + protected void adjustDeckSize(int targetSize) { // fix under-sized or over-sized decks, due to integer arithmetic int actualSize = tDeck.countAll(); if (actualSize < targetSize) { final int diff = targetSize - actualSize; - addSome(tDeck, diff, tDeck.toFlatList()); + addSome(diff, tDeck.toFlatList()); } else if (actualSize > targetSize) { Predicate exceptBasicLand = Predicate.not(CardRules.Predicates.Presets.IS_BASIC_LAND); @@ -164,7 +167,7 @@ public abstract class GenerateColoredDeckBase { } - protected void addCmcAdjusted(ItemPool tDeck, List source, int cnt, List cmcLevels, int[] cmcAmounts) { + protected void addCmcAdjusted(List source, int cnt, List cmcLevels, int[] cmcAmounts) { final List curved = new ArrayList(); @@ -175,7 +178,7 @@ public abstract class GenerateColoredDeckBase { for(CardPrinted c: curved) this.cardCounts.put(c.getName(), 0); - addSome(tDeck, cnt, curved); + addSome(cnt, curved); } protected List selectCardsOfMatchingColorForPlayer(PlayerType pt) @@ -196,8 +199,11 @@ public abstract class GenerateColoredDeckBase { protected static CCnt[] countLands(ItemPool outList) { // attempt to optimize basic land counts according // to color representation - final CCnt[] clrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), - new CCnt("Mountain", 0), new CCnt("Forest", 0) }; + + String[] bl = Constant.Color.BASIC_LANDS; + + final CCnt[] clrCnts = { new CCnt(bl[0], 0), new CCnt(bl[1], 0), new CCnt(bl[2], 0), + new CCnt(bl[3], 0), new CCnt(bl[4], 0) }; // count each card color using mana costs // TODO: count hybrid mana differently? diff --git a/src/main/java/forge/deck/generate/GenerateThemeDeck.java b/src/main/java/forge/deck/generate/GenerateThemeDeck.java index 46aab5286fb..4753def2c91 100644 --- a/src/main/java/forge/deck/generate/GenerateThemeDeck.java +++ b/src/main/java/forge/deck/generate/GenerateThemeDeck.java @@ -17,20 +17,16 @@ */ package forge.deck.generate; -import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; -import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import java.util.List; import java.util.Random; import forge.error.ErrorViewer; import forge.item.CardDb; import forge.item.CardPrinted; -import forge.item.ItemPool; import forge.item.ItemPoolView; +import forge.util.FileUtil; import forge.util.MyRandom; /** @@ -42,8 +38,9 @@ import forge.util.MyRandom; * @version $Id$ */ public class GenerateThemeDeck extends GenerateColoredDeckBase{ - private BufferedReader in = null; - + private int basicLandPercentage = 0; + private boolean testing = false; + /** *

* Constructor for GenerateThemeDeck. @@ -97,79 +94,14 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase{ * @return a {@link forge.CardList} object. */ public final ItemPoolView getThemeDeck(final String themeName, final int size) { - final ItemPool tDeck = new ItemPool(CardPrinted.class); - - final ArrayList groups = new ArrayList(); - - final Map cardCounts = new HashMap(); - String s = ""; - int bLandPercentage = 0; - boolean testing = false; // read theme file final String tFileName = "res/quest/themes/" + themeName + ".thm"; - final File tFile = new File(tFileName); - if (!tFile.exists()) { - throw new RuntimeException("GenerateThemeDeck : getThemeDeck -- file not found -- filename is " - + tFile.getAbsolutePath()); - } - - try { - this.in = new BufferedReader(new FileReader(tFile)); - } catch (final Exception ex) { - ErrorViewer.showError(ex, "File \"%s\" exception", tFile.getAbsolutePath()); - throw new RuntimeException("GenerateThemeDeck : getThemeDeck -- file exception -- filename is " - + tFile.getPath()); - } - - s = this.readLine(); - while (!s.equals("End")) { - if (s.startsWith("[Group")) { - final Grp g = new Grp(); - - final String[] ss = s.replaceAll("[\\[\\]]", "").split(" "); - for (final String element : ss) { - if (element.startsWith("Percentage")) { - final String p = element.substring("Percentage".length() + 1); - g.percentage = Integer.parseInt(p); - } - if (element.startsWith("MaxCnt")) { - final String m = element.substring("MaxCnt".length() + 1); - g.maxCnt = Integer.parseInt(m); - } - } - - s = this.readLine(); - while (!s.equals("[/Group]")) { - g.cardnames.add(s); - cardCounts.put(s, 0); - - s = this.readLine(); - } - - groups.add(g); - } - - if (s.startsWith("BasicLandPercentage")) { - bLandPercentage = Integer.parseInt(s.substring("BasicLandPercentage".length() + 1)); - } - - if (s.equals("Testing")) { - testing = true; - } - - s = this.readLine(); - } - - try { - this.in.close(); - } catch (final IOException ex) { - ErrorViewer.showError(ex, "File \"%s\" exception", tFile.getAbsolutePath()); - throw new RuntimeException("GenerateThemeDeck : getThemeDeck -- file exception -- filename is " - + tFile.getPath()); - } - + List lines = FileUtil.readFile(tFileName); + + final List groups = readGroups(lines); + String tmpDeck = ""; // begin assigning cards to the deck @@ -194,7 +126,7 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase{ } if (lc > size) { throw new RuntimeException("GenerateThemeDeck : getThemeDeck -- looped too much -- filename is " - + tFile.getAbsolutePath()); + + tFileName); } final int n = cardCounts.get(s); @@ -206,9 +138,9 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase{ } int numBLands = 0; - if (bLandPercentage > 0) { // if theme explicitly defines this - final float p = (float) (bLandPercentage * .01); - numBLands = (int) (p * size); + + if (basicLandPercentage > 0) { // if theme explicitly defines this + numBLands = (int) (size * basicLandPercentage / 100f); } else { // otherwise, just fill in the rest of the deck with basic // lands numBLands = size - tDeck.countAll(); @@ -216,11 +148,11 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase{ tmpDeck += "numBLands:" + numBLands + "\n"; - addBasicLand(tDeck, numBLands); + addBasicLand(numBLands); tmpDeck += "DeckSize:" + tDeck.countAll() + "\n"; - adjustDeckSize(tDeck, size); + adjustDeckSize(size); tmpDeck += "DeckSize:" + tDeck.countAll() + "\n"; if (testing) { @@ -230,26 +162,6 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase{ return tDeck; } - /** - *

- * readLine. - *

- * - * @return a {@link java.lang.String} object. - */ - private String readLine() { - // makes the checked exception, into an unchecked runtime exception - try { - String s = this.in.readLine(); - if (s != null) { - s = s.trim(); - } - return s; - } catch (final Exception ex) { - ErrorViewer.showError(ex); - throw new RuntimeException("GenerateThemeDeck : readLine error"); - } - } // readLine(Card) private class Grp { @@ -262,4 +174,49 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase{ /** The Percentage. */ private int percentage; } + + + private List readGroups(List lines) { + final List groups = new ArrayList(); + + Grp g = null; + for(String s: lines) { + if ( s.equals("End") ) + break; + + if (s.startsWith("[Group")) { + g = new Grp(); + final String[] ss = s.replaceAll("[\\[\\]]", "").split(" "); + for (final String element : ss) { + if (element.startsWith("Percentage")) { + final String p = element.substring("Percentage".length() + 1); + g.percentage = Integer.parseInt(p); + } + if (element.startsWith("MaxCnt")) { + final String m = element.substring("MaxCnt".length() + 1); + g.maxCnt = Integer.parseInt(m); + } + } + groups.add(g); + + continue; + } + + if (s.equals("[/Group]")) { + g = null; + } + + if (s.startsWith("BasicLandPercentage")) { + basicLandPercentage = Integer.parseInt(s.substring("BasicLandPercentage".length() + 1)); + } else if (s.equals("Testing")) { + testing = true; + } else if ( g != null ) { + g.cardnames.add(s); + cardCounts.put(s, 0); + } + + } + return groups; + + } } diff --git a/src/main/java/forge/game/phase/CombatUtil.java b/src/main/java/forge/game/phase/CombatUtil.java index 83dc834ad5a..602c14b22d7 100644 --- a/src/main/java/forge/game/phase/CombatUtil.java +++ b/src/main/java/forge/game/phase/CombatUtil.java @@ -41,7 +41,6 @@ import forge.Player; import forge.PlayerUtil; import forge.PlayerZone; import forge.Singletons; -import forge.Constant.Color; import forge.Constant.Zone; import forge.card.TriggerReplacementBase; import forge.card.abilityfactory.AbilityFactory; diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java index 5b198423fa4..29e49e9be30 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuConstructed.java @@ -24,7 +24,6 @@ import javax.swing.SwingWorker; import org.apache.commons.lang3.ArrayUtils; import forge.AllZone; -import forge.CardList; import forge.Command; import forge.Constant; import forge.PlayerType; diff --git a/src/main/java/forge/model/FModel.java b/src/main/java/forge/model/FModel.java index ecfba1adfb6..fe9a8859251 100644 --- a/src/main/java/forge/model/FModel.java +++ b/src/main/java/forge/model/FModel.java @@ -23,7 +23,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; -import java.util.ArrayList; import java.util.List; import arcane.util.MultiplexOutputStream; @@ -31,7 +30,6 @@ import forge.AllZone; import forge.ComputerAIGeneral; import forge.ComputerAIInput; import forge.Constant; -import forge.ConstantStringArrayList; import forge.GameAction; import forge.Singletons; import forge.card.BoosterData; @@ -183,61 +181,50 @@ public enum FModel { if (!Constant.CardTypes.LOADED[0]) { final List typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt"); - ArrayList tList = null; - - Constant.CardTypes.CARD_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.SUPER_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.BASIC_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.LAND_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.CREATURE_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.INSTANT_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.SORCERY_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.ENCHANTMENT_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.ARTIFACT_TYPES[0] = new ConstantStringArrayList(); - Constant.CardTypes.WALKER_TYPES[0] = new ConstantStringArrayList(); + List tList = null; if (typeListFile.size() > 0) { for (int i = 0; i < typeListFile.size(); i++) { final String s = typeListFile.get(i); if (s.equals("[CardTypes]")) { - tList = Constant.CardTypes.CARD_TYPES[0].getList(); + tList = Constant.CardTypes.CARD_TYPES; } else if (s.equals("[SuperTypes]")) { - tList = Constant.CardTypes.SUPER_TYPES[0].getList(); + tList = Constant.CardTypes.SUPER_TYPES; } else if (s.equals("[BasicTypes]")) { - tList = Constant.CardTypes.BASIC_TYPES[0].getList(); + tList = Constant.CardTypes.BASIC_TYPES; } else if (s.equals("[LandTypes]")) { - tList = Constant.CardTypes.LAND_TYPES[0].getList(); + tList = Constant.CardTypes.LAND_TYPES; } else if (s.equals("[CreatureTypes]")) { - tList = Constant.CardTypes.CREATURE_TYPES[0].getList(); + tList = Constant.CardTypes.CREATURE_TYPES; } else if (s.equals("[InstantTypes]")) { - tList = Constant.CardTypes.INSTANT_TYPES[0].getList(); + tList = Constant.CardTypes.INSTANT_TYPES; } else if (s.equals("[SorceryTypes]")) { - tList = Constant.CardTypes.SORCERY_TYPES[0].getList(); + tList = Constant.CardTypes.SORCERY_TYPES; } else if (s.equals("[EnchantmentTypes]")) { - tList = Constant.CardTypes.ENCHANTMENT_TYPES[0].getList(); + tList = Constant.CardTypes.ENCHANTMENT_TYPES; } else if (s.equals("[ArtifactTypes]")) { - tList = Constant.CardTypes.ARTIFACT_TYPES[0].getList(); + tList = Constant.CardTypes.ARTIFACT_TYPES; } else if (s.equals("[WalkerTypes]")) { - tList = Constant.CardTypes.WALKER_TYPES[0].getList(); + tList = Constant.CardTypes.WALKER_TYPES; } else if (s.length() > 1) { @@ -264,13 +251,12 @@ public enum FModel { if (!Constant.Keywords.LOADED[0]) { final List nskwListFile = FileUtil.readFile("res/gamedata/NonStackingKWList.txt"); - Constant.Keywords.NON_STACKING_LIST[0] = new ConstantStringArrayList(); if (nskwListFile.size() > 1) { for (int i = 0; i < nskwListFile.size(); i++) { final String s = nskwListFile.get(i); if (s.length() > 1) { - Constant.Keywords.NON_STACKING_LIST[0].getList().add(s); + Constant.Keywords.NON_STACKING_LIST.add(s); } } }