from constants removed strange constantstringarray, removed some warnings.

This commit is contained in:
Maxmtg
2012-04-07 09:31:34 +00:00
parent d8e5a8011c
commit 1017b2d083
13 changed files with 130 additions and 243 deletions

1
.gitattributes vendored
View File

@@ -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

View File

@@ -453,7 +453,7 @@ public final class CardUtil {
final ArrayList<String> types = new ArrayList<String>();
// 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<String> getBasicTypes() {
final ArrayList<String> types = new ArrayList<String>();
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<String> getLandTypes() {
final ArrayList<String> types = new ArrayList<String>();
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<String> getCreatureTypes() {
final ArrayList<String> types = new ArrayList<String>();
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);
}
/**

View File

@@ -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<String> CARD_TYPES = new ArrayList<String>();
/** The super types. */
public static final ConstantStringArrayList[] SUPER_TYPES = new ConstantStringArrayList[1];
public static final List<String> SUPER_TYPES = new ArrayList<String>();
/** The basic types. */
public static final ConstantStringArrayList[] BASIC_TYPES = new ConstantStringArrayList[1];
public static final List<String> BASIC_TYPES = new ArrayList<String>();
/** The land types. */
public static final ConstantStringArrayList[] LAND_TYPES = new ConstantStringArrayList[1];
public static final List<String> LAND_TYPES = new ArrayList<String>();
/** The creature types. */
public static final ConstantStringArrayList[] CREATURE_TYPES = new ConstantStringArrayList[1];
public static final List<String> CREATURE_TYPES = new ArrayList<String>();
/** The instant types. */
public static final ConstantStringArrayList[] INSTANT_TYPES = new ConstantStringArrayList[1];
public static final List<String> INSTANT_TYPES = new ArrayList<String>();
/** The sorcery types. */
public static final ConstantStringArrayList[] SORCERY_TYPES = new ConstantStringArrayList[1];
public static final List<String> SORCERY_TYPES = new ArrayList<String>();
/** The enchantment types. */
public static final ConstantStringArrayList[] ENCHANTMENT_TYPES = new ConstantStringArrayList[1];
public static final List<String> ENCHANTMENT_TYPES = new ArrayList<String>();
/** The artifact types. */
public static final ConstantStringArrayList[] ARTIFACT_TYPES = new ConstantStringArrayList[1];
public static final List<String> ARTIFACT_TYPES = new ArrayList<String>();
/** The walker types. */
public static final ConstantStringArrayList[] WALKER_TYPES = new ConstantStringArrayList[1];
public static final List<String> WALKER_TYPES = new ArrayList<String>();
}
/**
@@ -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<String> NON_STACKING_LIST = new ArrayList<String>();
}
} // Constant

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package forge;
import java.util.ArrayList;
/**
* The Class Constant_StringArrayList.
*/
public class ConstantStringArrayList {
/** The list. */
private ArrayList<String> list = new ArrayList<String>();
/**
* Gets the list.
*
* @return the list
*/
public ArrayList<String> getList() {
return this.list;
}
/**
* Sets the list.
*
* @param list0
* the list to set
*/
public void setList(final ArrayList<String> list0) {
this.list = list0;
}
}

View File

@@ -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;
/**
* <p>

View File

@@ -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<CardPrinted> spells = CardRules.Predicates.Presets.isNonCreatureSpellForGenerator.select(cards, CardPrinted.FN_GET_RULES);
final ItemPool<CardPrinted> tDeck = new ItemPool<CardPrinted>(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());

View File

@@ -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<CardPrinted> creatures = CardRules.Predicates.Presets.IS_CREATURE.select(cards, CardPrinted.FN_GET_RULES);
final List<CardPrinted> spells = CardRules.Predicates.Presets.isNonCreatureSpellForGenerator.select(cards, CardPrinted.FN_GET_RULES);
final ItemPool<CardPrinted> tDeck = new ItemPool<CardPrinted>(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());

View File

@@ -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;
@@ -78,19 +77,16 @@ public class Generate5ColorDeck extends GenerateColoredDeckBase {
final List<CardPrinted> creatures = CardRules.Predicates.Presets.IS_CREATURE.select(cards, CardPrinted.FN_GET_RULES);
final List<CardPrinted> spells = CardRules.Predicates.Presets.isNonCreatureSpellForGenerator.select(cards, CardPrinted.FN_GET_RULES);
final ItemPool<CardPrinted> tDeck = new ItemPool<CardPrinted>(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());

View File

@@ -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<CardPrinted> 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>(CardPrinted.class);
}
protected void addSome(ItemPool<CardPrinted> tDeck, int cnt, List<CardPrinted> source) {
protected void addSome(int cnt, List<CardPrinted> 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<CardPrinted> tDeck, int cnt, List<String> source) {
protected int addSomeStr(int cnt, List<String> 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<CardPrinted> 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<CardPrinted> 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<CardRules> exceptBasicLand = Predicate.not(CardRules.Predicates.Presets.IS_BASIC_LAND);
@@ -164,7 +167,7 @@ public abstract class GenerateColoredDeckBase {
}
protected void addCmcAdjusted(ItemPool<CardPrinted> tDeck, List<CardPrinted> source, int cnt, List<FilterCMC> cmcLevels, int[] cmcAmounts) {
protected void addCmcAdjusted(List<CardPrinted> source, int cnt, List<FilterCMC> cmcLevels, int[] cmcAmounts) {
final List<CardPrinted> curved = new ArrayList<CardPrinted>();
@@ -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<CardPrinted> selectCardsOfMatchingColorForPlayer(PlayerType pt)
@@ -196,8 +199,11 @@ public abstract class GenerateColoredDeckBase {
protected static CCnt[] countLands(ItemPool<CardPrinted> 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?

View File

@@ -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,7 +38,8 @@ import forge.util.MyRandom;
* @version $Id$
*/
public class GenerateThemeDeck extends GenerateColoredDeckBase{
private BufferedReader in = null;
private int basicLandPercentage = 0;
private boolean testing = false;
/**
* <p>
@@ -97,78 +94,13 @@ public class GenerateThemeDeck extends GenerateColoredDeckBase{
* @return a {@link forge.CardList} object.
*/
public final ItemPoolView<CardPrinted> getThemeDeck(final String themeName, final int size) {
final ItemPool<CardPrinted> tDeck = new ItemPool<CardPrinted>(CardPrinted.class);
final ArrayList<Grp> groups = new ArrayList<Grp>();
final Map<String, Integer> cardCounts = new HashMap<String, Integer>();
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());
}
List<String> lines = FileUtil.readFile(tFileName);
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());
}
final List<Grp> groups = readGroups(lines);
String tmpDeck = "";
@@ -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;
}
/**
* <p>
* readLine.
* </p>
*
* @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<Grp> readGroups(List<String> lines) {
final List<Grp> groups = new ArrayList<Grp>();
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;
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<String> typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt");
ArrayList<String> 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<String> 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<String> 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);
}
}
}