diff --git a/.gitattributes b/.gitattributes
index c236176f0d4..262ada80781 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -9689,8 +9689,6 @@ src/main/java/forge/deck/DownloadDeck.java svneol=native#text/plain
src/main/java/forge/deck/generate/Generate2ColorDeck.java svneol=native#text/plain
src/main/java/forge/deck/generate/Generate3ColorDeck.java svneol=native#text/plain
src/main/java/forge/deck/generate/Generate5ColorDeck.java svneol=native#text/plain
-src/main/java/forge/deck/generate/GenerateConstructedDeck.java svneol=native#text/plain
-src/main/java/forge/deck/generate/GenerateConstructedMultiColorDeck.java svneol=native#text/plain
src/main/java/forge/deck/generate/GenerateThemeDeck.java svneol=native#text/plain
src/main/java/forge/deck/generate/package-info.java svneol=native#text/plain
src/main/java/forge/deck/package-info.java svneol=native#text/plain
diff --git a/src/main/java/forge/deck/generate/Generate5ColorDeck.java b/src/main/java/forge/deck/generate/Generate5ColorDeck.java
index 8d47bae5358..3e52a5be083 100644
--- a/src/main/java/forge/deck/generate/Generate5ColorDeck.java
+++ b/src/main/java/forge/deck/generate/Generate5ColorDeck.java
@@ -1,14 +1,19 @@
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.MyRandom;
+import forge.error.ErrorViewer;
+import forge.properties.ForgeProps;
+
/**
*
Generate3ColorDeck class.
*
@@ -22,12 +27,15 @@ public class Generate5ColorDeck {
private String color4 = "red";
private String color5 = "green";
private Random r = null;
- private Map ClrMap = null;
+ private Map clrMap = null;
private ArrayList notColors = null;
- private ArrayList DualLands = null;
- private ArrayList DL = null;
- private Map CardCounts = null;
+ private ArrayList dualLands = null;
+ private ArrayList dl = null;
+ private Map cardCounts = null;
+ /**
+ *
+ */
public Generate5ColorDeck() {
this("white", "blue", "black", "red", "green");
}
@@ -35,23 +43,25 @@ public class Generate5ColorDeck {
/**
* 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.
+ * @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(String Clr1, String Clr2, String Clr3, String Clr4, String Clr5) {
+ public Generate5ColorDeck(final String clr1, final String clr2,
+ final String clr3, final String clr4, final String clr5)
+ {
r = MyRandom.random;
- CardCounts = new HashMap();
+ cardCounts = new HashMap();
- ClrMap = new HashMap();
- ClrMap.put("white", "W");
- ClrMap.put("blue", "U");
- ClrMap.put("black", "B");
- ClrMap.put("red", "R");
- ClrMap.put("green", "G");
+ clrMap = new HashMap();
+ clrMap.put("white", "W");
+ clrMap.put("blue", "U");
+ clrMap.put("black", "B");
+ clrMap.put("red", "R");
+ clrMap.put("green", "G");
notColors = new ArrayList();
notColors.add("white");
@@ -60,33 +70,33 @@ public class Generate5ColorDeck {
notColors.add("red");
notColors.add("green");
- DualLands = new ArrayList();
- DualLands.add(new DLnd("Tundra", "WU"));
- DualLands.add(new DLnd("Hallowed Fountain", "WU"));
- DualLands.add(new DLnd("Underground Sea", "UB"));
- DualLands.add(new DLnd("Watery Grave", "UB"));
- DualLands.add(new DLnd("Badlands", "BR"));
- DualLands.add(new DLnd("Blood Crypt", "BR"));
- DualLands.add(new DLnd("Taiga", "RG"));
- DualLands.add(new DLnd("Stomping Ground", "RG"));
- DualLands.add(new DLnd("Savannah", "GW"));
- DualLands.add(new DLnd("Temple Garden", "GW"));
- DualLands.add(new DLnd("Scrubland", "WB"));
- DualLands.add(new DLnd("Godless Shrine", "WB"));
- DualLands.add(new DLnd("Volcanic Island", "UR"));
- DualLands.add(new DLnd("Steam Vents", "UR"));
- DualLands.add(new DLnd("Bayou", "BG"));
- DualLands.add(new DLnd("Overgrown Tomb", "BG"));
- DualLands.add(new DLnd("Plateau", "RW"));
- DualLands.add(new DLnd("Sacred Foundry", "RW"));
- DualLands.add(new DLnd("Tropical Island", "GU"));
- DualLands.add(new DLnd("Breeding Pool", "GU"));
+ dualLands = new ArrayList();
+ dualLands.add(new DLnd("Tundra", "WU"));
+ dualLands.add(new DLnd("Hallowed Fountain", "WU"));
+ dualLands.add(new DLnd("Underground Sea", "UB"));
+ dualLands.add(new DLnd("Watery Grave", "UB"));
+ dualLands.add(new DLnd("Badlands", "BR"));
+ dualLands.add(new DLnd("Blood Crypt", "BR"));
+ dualLands.add(new DLnd("Taiga", "RG"));
+ dualLands.add(new DLnd("Stomping Ground", "RG"));
+ dualLands.add(new DLnd("Savannah", "GW"));
+ dualLands.add(new DLnd("Temple Garden", "GW"));
+ dualLands.add(new DLnd("Scrubland", "WB"));
+ dualLands.add(new DLnd("Godless Shrine", "WB"));
+ dualLands.add(new DLnd("Volcanic Island", "UR"));
+ dualLands.add(new DLnd("Steam Vents", "UR"));
+ dualLands.add(new DLnd("Bayou", "BG"));
+ dualLands.add(new DLnd("Overgrown Tomb", "BG"));
+ dualLands.add(new DLnd("Plateau", "RW"));
+ dualLands.add(new DLnd("Sacred Foundry", "RW"));
+ dualLands.add(new DLnd("Tropical Island", "GU"));
+ dualLands.add(new DLnd("Breeding Pool", "GU"));
- color1 = Clr1;
- color2 = Clr2;
- color3 = Clr3;
- color4 = Clr4;
- color5 = Clr5;
+ color1 = clr1;
+ color2 = clr2;
+ color3 = clr3;
+ color4 = clr4;
+ color5 = clr5;
notColors.remove(color1);
notColors.remove(color2);
@@ -94,11 +104,11 @@ public class Generate5ColorDeck {
notColors.remove(color4);
notColors.remove(color5);
- DL = new ArrayList();
- for (int i = 0; i < DualLands.size(); i++) {
- DLnd d = DualLands.get(i);
- DL.add(d.Name);
- CardCounts.put(d.Name, 0);
+ dl = new ArrayList();
+ for (int i = 0; i < dualLands.size(); i++) {
+ DLnd d = dualLands.get(i);
+ dl.add(d.getName());
+ cardCounts.put(d.getName(), 0);
}
}
@@ -113,126 +123,128 @@ public class Generate5ColorDeck {
String tmpDeck = "";
CardList tDeck = new CardList();
- int LandsPercentage = 44;
- int CreatPercentage = 34;
- int SpellPercentage = 22;
+ int landsPercentage = 44;
+ int creatPercentage = 34;
+ int spellPercentage = 22;
// 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) {
+ CardList allCards = CardFilter.filter(AllZone.getCardFactory(), new CardListFilter() {
+ public boolean addCard(final Card c) {
return !(c.getSVar("RemAIDeck").equals("True") || c.getSVar("RemRandomDeck").equals("True"));
}
});
// reduce to cards that match the colors
- CardList CL1 = AllCards.getColor(color1);
- CardList CL2 = AllCards.getColor(color2);
- CardList CL3 = AllCards.getColor(color3);
- CardList CL4 = AllCards.getColor(color4);
- CardList CL5 = AllCards.getColor(color5);
+ CardList cL1 = allCards.getColor(color1);
+ CardList cL2 = allCards.getColor(color2);
+ CardList cL3 = allCards.getColor(color3);
+ CardList cL4 = allCards.getColor(color4);
+ CardList cL5 = allCards.getColor(color5);
// 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))))
+ if (c.getManaCost().contains(clrMap.get(notColors.get(i)))) {
return false;
+ }
}
return true;
}
};
- CL1 = CL1.filter(clrF);
- CL2 = CL2.filter(clrF);
- CL3 = CL3.filter(clrF);
- CL4 = CL4.filter(clrF);
- CL5 = CL5.filter(clrF);
+ cL1 = cL1.filter(clrF);
+ cL2 = cL2.filter(clrF);
+ cL3 = cL3.filter(clrF);
+ cL4 = cL4.filter(clrF);
+ cL5 = cL5.filter(clrF);
// build subsets based on type
- CardList Cr1 = CL1.getType("Creature");
- CardList Cr2 = CL2.getType("Creature");
- CardList Cr3 = CL3.getType("Creature");
- CardList Cr4 = CL4.getType("Creature");
- CardList Cr5 = CL5.getType("Creature");
+ CardList cr1 = cL1.getType("Creature");
+ CardList cr2 = cL2.getType("Creature");
+ CardList cr3 = cL3.getType("Creature");
+ CardList cr4 = cL4.getType("Creature");
+ CardList cr5 = cL5.getType("Creature");
- String ISE[] = {"Instant", "Sorcery", "Enchantment", "Planeswalker"};
- CardList Sp1 = CL1.getValidCards(ISE, null, null);
- CardList Sp2 = CL2.getValidCards(ISE, null, null);
- CardList Sp3 = CL3.getValidCards(ISE, null, null);
- CardList Sp4 = CL4.getValidCards(ISE, null, null);
- CardList Sp5 = CL5.getValidCards(ISE, null, null);
+ String[] ise = {"Instant", "Sorcery", "Enchantment", "Planeswalker"};
+ CardList sp1 = cL1.getValidCards(ise, null, null);
+ CardList sp2 = cL2.getValidCards(ise, null, null);
+ CardList sp3 = cL3.getValidCards(ise, null, null);
+ CardList sp4 = cL4.getValidCards(ise, null, null);
+ CardList sp5 = cL5.getValidCards(ise, null, null);
// final card pools
- CardList Cr12345 = new CardList();
- CardList Sp12345 = new CardList();
+ CardList cr12345 = new CardList();
+ CardList sp12345 = new CardList();
// used for mana curve in the card pool
- final int MinCMC[] = {1}, MaxCMC[] = {3};
+ final int[] minCMC = {1};
+ final int[] 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]);
+ return (cCMC >= minCMC[0]) && (cCMC <= maxCMC[0]);
}
};
// select cards to build card pools using a mana curve
for (int i = 3; i > 0; i--) {
- CardList Cr1CMC = Cr1.filter(cmcF);
- CardList Cr2CMC = Cr2.filter(cmcF);
- CardList Cr3CMC = Cr3.filter(cmcF);
- CardList Cr4CMC = Cr4.filter(cmcF);
- CardList Cr5CMC = Cr5.filter(cmcF);
+ CardList cr1CMC = cr1.filter(cmcF);
+ CardList cr2CMC = cr2.filter(cmcF);
+ CardList cr3CMC = cr3.filter(cmcF);
+ CardList cr4CMC = cr4.filter(cmcF);
+ CardList cr5CMC = cr5.filter(cmcF);
- CardList Sp1CMC = Sp1.filter(cmcF);
- CardList Sp2CMC = Sp2.filter(cmcF);
- CardList Sp3CMC = Sp3.filter(cmcF);
- CardList Sp4CMC = Sp4.filter(cmcF);
- CardList Sp5CMC = Sp5.filter(cmcF);
+ CardList sp1CMC = sp1.filter(cmcF);
+ CardList sp2CMC = sp2.filter(cmcF);
+ CardList sp3CMC = sp3.filter(cmcF);
+ CardList sp4CMC = sp4.filter(cmcF);
+ CardList sp5CMC = sp5.filter(cmcF);
for (int j = 0; j < i; j++) {
- Card c = Cr1CMC.get(r.nextInt(Cr1CMC.size()));
- Cr12345.add(c);
- CardCounts.put(c.getName(), 0);
+ Card c = cr1CMC.get(r.nextInt(cr1CMC.size()));
+ cr12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Cr2CMC.get(r.nextInt(Cr2CMC.size()));
- Cr12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = cr2CMC.get(r.nextInt(cr2CMC.size()));
+ cr12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Cr3CMC.get(r.nextInt(Cr3CMC.size()));
- Cr12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = cr3CMC.get(r.nextInt(cr3CMC.size()));
+ cr12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Cr4CMC.get(r.nextInt(Cr4CMC.size()));
- Cr12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = cr4CMC.get(r.nextInt(cr4CMC.size()));
+ cr12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Cr5CMC.get(r.nextInt(Cr5CMC.size()));
- Cr12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = cr5CMC.get(r.nextInt(cr5CMC.size()));
+ cr12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Sp1CMC.get(r.nextInt(Sp1CMC.size()));
- Sp12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = sp1CMC.get(r.nextInt(sp1CMC.size()));
+ sp12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Sp2CMC.get(r.nextInt(Sp2CMC.size()));
- Sp12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = sp2CMC.get(r.nextInt(sp2CMC.size()));
+ sp12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Sp3CMC.get(r.nextInt(Sp3CMC.size()));
- Sp12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = sp3CMC.get(r.nextInt(sp3CMC.size()));
+ sp12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Sp4CMC.get(r.nextInt(Sp4CMC.size()));
- Sp12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = sp4CMC.get(r.nextInt(sp4CMC.size()));
+ sp12345.add(c);
+ cardCounts.put(c.getName(), 0);
- c = Sp5CMC.get(r.nextInt(Sp5CMC.size()));
- Sp12345.add(c);
- CardCounts.put(c.getName(), 0);
+ c = sp5CMC.get(r.nextInt(sp5CMC.size()));
+ sp12345.add(c);
+ cardCounts.put(c.getName(), 0);
}
- MinCMC[0] += 2;
- MaxCMC[0] += 2;
+ minCMC[0] += 2;
+ maxCMC[0] += 2;
// resulting mana curve of the card pool
//18x 1 - 3
//12x 3 - 5
@@ -241,78 +253,82 @@ public class Generate5ColorDeck {
}
// shuffle card pools
- Cr12345.shuffle();
- Sp12345.shuffle();
+ cr12345.shuffle();
+ sp12345.shuffle();
// calculate card counts
- float p = (float) ((float) CreatPercentage * .01);
- int CreatCnt = (int) (p * (float) Size);
- tmpDeck += "Creature Count:" + CreatCnt + "\n";
+ float p = (float) ((float) creatPercentage * .01);
+ int creatCnt = (int) (p * (float) Size);
+ tmpDeck += "Creature Count:" + creatCnt + "\n";
- p = (float) ((float) SpellPercentage * .01);
- int SpellCnt = (int) (p * (float) Size);
- tmpDeck += "Spell Count:" + SpellCnt + "\n";
+ p = (float) ((float) spellPercentage * .01);
+ int spellCnt = (int) (p * (float) Size);
+ tmpDeck += "Spell Count:" + spellCnt + "\n";
// build deck from the card pools
- for (int i = 0; i < CreatCnt; i++) {
- Card c = Cr12345.get(r.nextInt(Cr12345.size()));
+ for (int i = 0; i < creatCnt; i++) {
+ Card c = cr12345.get(r.nextInt(cr12345.size()));
lc = 0;
- while (CardCounts.get(c.getName()) > 3 || lc > 100) {
- c = Cr12345.get(r.nextInt(Cr12345.size()));
+ while (cardCounts.get(c.getName()) > 3 || lc > 100) {
+ c = cr12345.get(r.nextInt(cr12345.size()));
lc++;
}
- if (lc > 100)
+ if (lc > 100) {
throw new RuntimeException("Generate5ColorDeck : get5ColorDeck -- looped too much -- Cr123");
+ }
tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer()));
- int n = CardCounts.get(c.getName());
- CardCounts.put(c.getName(), n + 1);
+ int n = cardCounts.get(c.getName());
+ cardCounts.put(c.getName(), n + 1);
tmpDeck += c.getName() + " " + c.getManaCost() + "\n";
}
- for (int i = 0; i < SpellCnt; i++) {
- Card c = Sp12345.get(r.nextInt(Sp12345.size()));
+ for (int i = 0; i < spellCnt; i++) {
+ Card c = sp12345.get(r.nextInt(sp12345.size()));
lc = 0;
- while (CardCounts.get(c.getName()) > 3 || lc > 100) {
- c = Sp12345.get(r.nextInt(Sp12345.size()));
+ while (cardCounts.get(c.getName()) > 3 || lc > 100) {
+ c = sp12345.get(r.nextInt(sp12345.size()));
lc++;
}
- if (lc > 100)
+ if (lc > 100) {
throw new RuntimeException("Generate5ColorDeck : get5ColorDeck -- looped too much -- Sp123");
+ }
tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer()));
- int n = CardCounts.get(c.getName());
- CardCounts.put(c.getName(), n + 1);
+ int n = cardCounts.get(c.getName());
+ cardCounts.put(c.getName(), n + 1);
tmpDeck += c.getName() + " " + c.getManaCost() + "\n";
}
// Add lands
int numLands = 0;
- if (LandsPercentage > 0) {
- p = (float) ((float) LandsPercentage * .01);
+ 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";
int nDLands = (numLands / 4);
for (int i = 0; i < nDLands; i++) {
- String s = DL.get(r.nextInt(DL.size()));
+ String s = dl.get(r.nextInt(dl.size()));
lc = 0;
- while (CardCounts.get(s) > 3 || lc > 20) {
- s = DL.get(r.nextInt(DL.size()));
+ while (cardCounts.get(s) > 3 || lc > 20) {
+ s = dl.get(r.nextInt(dl.size()));
lc++;
}
- if (lc > 20)
+ if (lc > 20) {
throw new RuntimeException("Generate5ColorDeck : get5ColorDeck -- looped too much -- DL");
+ }
tDeck.add(AllZone.getCardFactory().getCard(s, AllZone.getHumanPlayer()));
- int n = CardCounts.get(s);
- CardCounts.put(s, n + 1);
+ int n = cardCounts.get(s);
+ cardCounts.put(s, n + 1);
tmpDeck += s + "\n";
}
@@ -320,7 +336,7 @@ public class Generate5ColorDeck {
if (numLands > 0) // attempt to optimize basic land counts according to color representation
{
- CCnt ClrCnts[] = {new CCnt("Plains", 0),
+ CCnt[] clrCnts = {new CCnt("Plains", 0),
new CCnt("Island", 0),
new CCnt("Swamp", 0),
new CCnt("Mountain", 0),
@@ -335,39 +351,45 @@ public class Generate5ColorDeck {
for (int j = 0; j < mc.length(); j++) {
char c = mc.charAt(j);
- if (c == 'W')
- ClrCnts[0].Count++;
- else if (c == 'U')
- ClrCnts[1].Count++;
- else if (c == 'B')
- ClrCnts[2].Count++;
- else if (c == 'R')
- ClrCnts[3].Count++;
- else if (c == 'G')
- ClrCnts[4].Count++;
+ if (c == 'W') {
+ clrCnts[0].setCount(clrCnts[0].getCount() + 1);
+ }
+ else if (c == 'U') {
+ clrCnts[1].setCount(clrCnts[1].getCount() + 1);
+ }
+ else if (c == 'B') {
+ clrCnts[2].setCount(clrCnts[2].getCount() + 1);
+ }
+ else if (c == 'R') {
+ clrCnts[3].setCount(clrCnts[3].getCount() + 1);
+ }
+ else if (c == 'G') {
+ clrCnts[4].setCount(clrCnts[4].getCount() + 1);
+ }
}
}
// total of all ClrCnts
int totalColor = 0;
for (int i = 0; i < 5; i++) {
- totalColor += ClrCnts[i].Count;
- tmpDeck += ClrCnts[i].Color + ":" + ClrCnts[i].Count + "\n";
+ totalColor += clrCnts[i].getCount();
+ tmpDeck += clrCnts[i].getColor() + ":" + clrCnts[i].getCount() + "\n";
}
tmpDeck += "totalColor:" + totalColor + "\n";
for (int i = 0; i < 5; i++) {
- if (ClrCnts[i].Count > 0) { // calculate number of lands for each color
- p = (float) ClrCnts[i].Count / (float) totalColor;
+ 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].Color + ":" + nLand + "\n";
+ tmpDeck += "nLand-" + clrCnts[i].getColor() + ":" + nLand + "\n";
// just to prevent a null exception by the deck size fixing code
- CardCounts.put(ClrCnts[i].Color, nLand);
+ cardCounts.put(clrCnts[i].getColor(), nLand);
- for (int j = 0; j <= nLand; j++)
- tDeck.add(AllZone.getCardFactory().getCard(ClrCnts[i].Color, AllZone.getComputerPlayer()));
+ for (int j = 0; j <= nLand; j++) {
+ tDeck.add(AllZone.getCardFactory().getCard(clrCnts[i].getColor(), AllZone.getComputerPlayer()));
+ }
}
}
}
@@ -381,16 +403,17 @@ public class Generate5ColorDeck {
Card c = tDeck.get(r.nextInt(tDeck.size()));
lc = 0;
- while (CardCounts.get(c.getName()) > 3 || lc > Size) {
+ while (cardCounts.get(c.getName()) > 3 || lc > Size) {
c = tDeck.get(r.nextInt(tDeck.size()));
lc++;
}
- if (lc > Size)
+ if (lc > Size) {
throw new RuntimeException("Generate5ColorDeck : get5ColorDeck -- looped too much -- undersize");
+ }
- int n = CardCounts.get(c.getName());
+ int n = cardCounts.get(c.getName());
tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer()));
- CardCounts.put(c.getName(), n + 1);
+ cardCounts.put(c.getName(), n + 1);
tmpDeck += "Added:" + c.getName() + "\n";
}
} else if (tDeck.size() > Size) {
@@ -399,8 +422,9 @@ 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()));
+ }
tDeck.remove(c);
tmpDeck += "Removed:" + c.getName() + "\n";
@@ -408,28 +432,61 @@ public class Generate5ColorDeck {
}
tmpDeck += "DeckSize:" + tDeck.size() + "\n";
- if (ForgeProps.getProperty("showdeck/5color", "false").equals("true"))
+ if (ForgeProps.getProperty("showdeck/5color", "false").equals("true")) {
ErrorViewer.showError(tmpDeck);
+ }
return tDeck;
}
private class CCnt {
- public String Color;
- public int Count;
+ private String color;
+ private int count;
- public CCnt(String clr, int cnt) {
- Color = clr;
- Count = cnt;
+ public CCnt(final String clr, final int cnt) {
+ this.color = clr;
+ this.count = cnt;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getColor() {
+ return this.color;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getCount() {
+ return this.count;
+ }
+
+ /**
+ *
+ * @param color
+ */
+ public void setCount(int count) {
+ this.count = count;
}
}
private class DLnd {
- public String Name;
+ private String name;
//public String Mana;
- public DLnd(String nm, String mn) {
- Name = nm;
+ /**
+ *
+ * @return
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ public DLnd(final String nm, final String mn) {
+ this.name = nm;
//Mana = mn;
}
}
diff --git a/src/main/java/forge/deck/generate/GenerateConstructedDeck.java b/src/main/java/forge/deck/generate/GenerateConstructedDeck.java
deleted file mode 100644
index d6e485b5b5e..00000000000
--- a/src/main/java/forge/deck/generate/GenerateConstructedDeck.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package forge.deck.generate;
-
-import forge.*;
-import forge.view.swing.OldGuiNewGame;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * GenerateConstructedDeck class.
- *
- * @author Forge
- * @version $Id$
- */
-public class GenerateConstructedDeck {
- private String color1;
- private String color2;
-
- private Map map = new HashMap();
-
- /**
- * Constructor for GenerateConstructedDeck.
- */
- public GenerateConstructedDeck() {
- setupMap();
- }
-
- /**
- * setupMap.
- */
- private void setupMap() {
- map.put(Constant.Color.Black, "Swamp");
- map.put(Constant.Color.Blue, "Island");
- map.put(Constant.Color.Green, "Forest");
- map.put(Constant.Color.Red, "Mountain");
- map.put(Constant.Color.White, "Plains");
- }
-
- /**
- * generateDeck.
- *
- * @return a {@link forge.CardList} object.
- */
- public CardList generateDeck() {
- CardList deck;
-
- int check;
-
- do {
- deck = get2ColorDeck();
- check = deck.getType("Creature").size();
-
- } while (check < 16 || 24 < check);
-
- addLand(deck);
-
- if (deck.size() != 60) {
- throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size());
- }
- return deck;
- }
-
- //25 lands
- /**
- * addLand.
- *
- * @param list a {@link forge.CardList} object.
- */
- private void addLand(CardList list) {
- Card land;
- for (int i = 0; i < 13; i++) {
- land = AllZone.getCardFactory().getCard(map.get(color1).toString(), AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(map.get(color2).toString(), AllZone.getComputerPlayer());
- list.add(land);
- }
- } //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.
- *
- * @see #filterBadCards(Iterable)
- *
- * @return a subset of cards <= the set of all cards; might be empty, but
- * never null
- */
- private CardList getCards() {
- return filterBadCards(AllZone.getCardFactory());
- } //getCards()
-
- /**
- * get2ColorDeck.
- *
- * @return a {@link forge.CardList} object.
- */
- private CardList get2ColorDeck() {
- CardList deck = get2Colors(getCards());
-
- CardList out = new CardList();
- deck.shuffle();
-
- //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));
- }
- return out;
- }
-
- /**
- * get2Colors.
- *
- * @param in a {@link forge.CardList} object.
- * @return a {@link forge.CardList} object.
- */
- private CardList get2Colors(CardList in) {
- int a;
- int b;
-
- 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
-
- color1 = Constant.Color.onlyColors[a];
- color2 = Constant.Color.onlyColors[b];
-
- CardList out = new CardList();
- out.addAll(CardListUtil.getColor(in, color1));
- out.addAll(CardListUtil.getColor(in, color2));
- out.shuffle();
-
- CardList artifact = in.filter(new CardListFilter() {
- public boolean addCard(Card c) {
- //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) &&
- !OldGuiNewGame.removeArtifacts.isSelected();
- }
- });
- out.addAll(artifact);
-
- out = out.filter(new CardListFilter() {
- public boolean addCard(Card c) {
- if (c.isCreature() &&
- c.getNetAttack() <= 1 &&
- OldGuiNewGame.removeSmallCreatures.isSelected()) {
- return false;
- }
-
- return true;
- }
- });
-
- out = filterBadCards(out);
- return out;
- }
-
- /**
- * 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
- *
- * @return a subset of sequence <= sequence; might be empty, but never
- * null
- */
- private CardList filterBadCards(Iterable sequence) {
-
- final ArrayList goodLand = new ArrayList();
-
- CardList out = CardFilter.filter(sequence, new CardListFilter() {
- public boolean addCard(Card c) {
- ArrayList list = CardUtil.getColors(c);
- if (list.size() == 2) {
- if (!(list.contains(color1) && list.contains(color2)))
- return false;
- }
- return CardUtil.getColors(c).size() <= 2 && //only dual colored gold cards
- !c.isLand() && //no land
- !c.getSVar("RemRandomDeck").equals("True") &&
- !c.getSVar("RemAIDeck").equals("True") || //OR very important
- goodLand.contains(c.getName());
- }
- });
-
- return out;
- } //filterBadCards()
-}
diff --git a/src/main/java/forge/deck/generate/GenerateConstructedMultiColorDeck.java b/src/main/java/forge/deck/generate/GenerateConstructedMultiColorDeck.java
deleted file mode 100644
index 92dd0748eb9..00000000000
--- a/src/main/java/forge/deck/generate/GenerateConstructedMultiColorDeck.java
+++ /dev/null
@@ -1,429 +0,0 @@
-package forge.deck.generate;
-
-import forge.*;
-import forge.view.swing.OldGuiNewGame;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * GenerateConstructedMultiColorDeck class.
- *
- * @author Forge
- * @version $Id$
- */
-public class GenerateConstructedMultiColorDeck {
- private String color1;
- private String color2;
- private String color3;
- private String color4;
- private String color5;
-
- private Map map = new HashMap();
- private Map multiMap = new HashMap();
-
- /**
- * Constructor for GenerateConstructedMultiColorDeck.
- */
- public GenerateConstructedMultiColorDeck() {
- setupBasicLandMap();
- setupMultiMap();
- }
-
- /**
- * setupBasicLandMap.
- */
- private void setupBasicLandMap() {
- map.put(Constant.Color.Black, "Swamp");
- map.put(Constant.Color.Blue, "Island");
- map.put(Constant.Color.Green, "Forest");
- map.put(Constant.Color.Red, "Mountain");
- map.put(Constant.Color.White, "Plains");
- }
-
- /**
- * 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"});
- }
-
-
- /**
- * generate3ColorDeck.
- *
- * @return a {@link forge.CardList} object.
- */
- public CardList generate3ColorDeck() {
- CardList deck;
-
- int check;
-
- do {
- deck = get3ColorDeck();
- check = deck.getType("Creature").size();
-
- } while (check < 16 || 24 < check);
-
- addLand(deck, 3);
-
- if (deck.size() != 60)
- throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size());
-
- return deck;
- }
-
- /**
- * generate5ColorDeck.
- *
- * @return a {@link forge.CardList} object.
- */
- public 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());
-
- return deck;
- }
-
- /**
- * addLand.
- *
- * @param list a {@link forge.CardList} object.
- * @param colors a int.
- */
- private void addLand(CardList list, int colors) {
- if (colors == 3) {
- int numberBasic = 2;
- Card land;
- for (int i = 0; i < numberBasic; i++) {
-
- land = AllZone.getCardFactory().getCard(map.get(color1).toString(), AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(map.get(color2).toString(), AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(map.get(color3).toString(), AllZone.getComputerPlayer());
- list.add(land);
- }
-
- int numberDual = 4;
- for (int i = 0; i < numberDual; i++) {
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color2)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color3)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color2 + color3)[0], AllZone.getComputerPlayer());
- list.add(land);
- }
- for (int i = 0; i < 2; i++) {
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color2)[1], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color3)[1], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color2 + color3)[1], AllZone.getComputerPlayer());
- list.add(land);
- }
- } else if (colors == 5) {
- int numberBasic = 1;
- Card land;
- for (int i = 0; i < numberBasic; i++) {
-
- land = AllZone.getCardFactory().getCard(map.get(color1).toString(), AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(map.get(color2).toString(), AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(map.get(color3).toString(), AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(map.get(color4).toString(), AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(map.get(color5).toString(), AllZone.getComputerPlayer());
- list.add(land);
- }
-
-
- int numberDual = 2;
- for (int i = 0; i < numberDual; i++) {
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color2)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color3)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color4)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color1 + color5)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color2 + color3)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color2 + color4)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color2 + color5)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color3 + color4)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color3 + color5)[0], AllZone.getComputerPlayer());
- list.add(land);
-
- land = AllZone.getCardFactory().getCard(multiMap.get(color4 + color5)[0], AllZone.getComputerPlayer());
- list.add(land);
- }
-
- }
- }//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.
- *
- * @return a subset of all cards in the CardFactory database
- * which might be empty, but never null
- */
- private CardList getCards(int colors) {
- return filterBadCards(AllZone.getCardFactory(), colors);
- }//getCards()
-
- /**
- * get3ColorDeck.
- *
- * @return a {@link forge.CardList} object.
- */
- private CardList get3ColorDeck() {
- CardList deck = get3Colors(getCards(3));
-
- 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++)
- out.add(deck.get(i));
-
- return out;
- }
-
- /**
- * get5ColorDeck.
- *
- * @return a {@link forge.CardList} object.
- */
- private CardList get5ColorDeck() {
- CardList deck = get5Colors(getCards(5));
-
- 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++)
- out.add(deck.get(i));
-
- return out;
- }
-
- /**
- * get3Colors.
- *
- * @param in a {@link forge.CardList} object.
- * @return a {@link forge.CardList} object.
- */
- private CardList get3Colors(CardList in) {
- int a;
- int b;
- int c;
-
- a = CardUtil.getRandomIndex(Constant.Color.onlyColors);
- 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
-
- color1 = Constant.Color.onlyColors[a];
- color2 = Constant.Color.onlyColors[b];
- color3 = Constant.Color.onlyColors[c];
-
- CardList out = new CardList();
- out.addAll(CardListUtil.getColor(in, color1));
- out.addAll(CardListUtil.getColor(in, color2));
- out.addAll(CardListUtil.getColor(in, color3));
- 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) &&
- !OldGuiNewGame.removeArtifacts.isSelected();
- }
- });
- out.addAll(artifact);
-
- out = out.filter(new CardListFilter() {
- public boolean addCard(Card c) {
- if (c.isCreature() &&
- c.getNetAttack() <= 1 &&
- OldGuiNewGame.removeSmallCreatures.isSelected()) {
- return false;
- }
-
- return true;
- }
- });
-
- out = filterBadCards(out, 3);
- return out;
- }
-
- /**
- * get5Colors.
- *
- * @param in a {@link forge.CardList} object.
- * @return a {@link forge.CardList} object.
- */
- private CardList get5Colors(CardList in) {
-
- color1 = Constant.Color.Black;
- color2 = Constant.Color.Blue;
- color3 = Constant.Color.Green;
- color4 = Constant.Color.Red;
- color5 = Constant.Color.White;
-
- 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.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) &&
- !OldGuiNewGame.removeArtifacts.isSelected();
- }
- });
- out.addAll(artifact);
-
- out = out.filter(new CardListFilter() {
- public boolean addCard(Card c) {
- if (c.isCreature() &&
- c.getNetAttack() <= 1 &&
- OldGuiNewGame.removeSmallCreatures.isSelected()) {
- return false;
- }
-
- return true;
- }
- });
-
- out = filterBadCards(out, 3);
- 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
- *
- * @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(Iterable sequence, int colors) {
- final ArrayList goodLand = new ArrayList();
- //goodLand.add("Faerie Conclave");
- //goodLand.add("Forbidding Watchtower");
- //goodLand.add("Treetop Village");
-
- CardList out = new CardList();
- if (colors == 3) {
-
- out = CardFilter.filter(sequence, new CardListFilter() {
- public boolean addCard(Card c) {
- ArrayList list = CardUtil.getColors(c);
-
- if (list.size() == 3) {
- if (!list.contains(color1) || !list.contains(color2) || !list.contains(color3))
- return false;
- } else if (list.size() == 2) {
- if (!(list.contains(color1) && list.contains(color2)) &&
- !(list.contains(color1) && list.contains(color3)) &&
- !(list.contains(color2) && list.contains(color3)))
- return false;
- }
-
- return CardUtil.getColors(c).size() <= 3 &&
- !c.isLand() && //no land
- !c.getSVar("RemRandomDeck").equals("True") &&
- !c.getSVar("RemAIDeck").equals("True") || //OR very important
- goodLand.contains(c.getName());
- }
- });
- } else if (colors == 5) {
- out = CardFilter.filter(sequence, new CardListFilter() {
- public boolean addCard(Card c) {
- return CardUtil.getColors(c).size() >= 2 && //only get multicolored cards
- !c.isLand() && //no land
- !c.getSVar("RemRandomDeck").equals("True") &&
- !c.getSVar("RemAIDeck").equals("True") || //OR very important
- goodLand.contains(c.getName());
- }
- });
-
- }
-
- return out;
- }//filterBadCards()
-}