This commit is contained in:
jendave
2011-08-12 09:17:12 +00:00
parent 4b6e1e1d05
commit b3b64c6635
5 changed files with 40 additions and 44 deletions

View File

@@ -131,9 +131,10 @@ public class Generate2ColorDeck {
CardListFilter clrF = new CardListFilter() { CardListFilter clrF = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
for (int i = 0; i < notColors.size(); i++) { 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 false;
} }
}
return true; return true;
} }
}; };
@@ -218,8 +219,9 @@ public class Generate2ColorDeck {
c = Cr12.get(r.nextInt(Cr12.size())); c = Cr12.get(r.nextInt(Cr12.size()));
lc++; lc++;
} }
if (lc > 100) if (lc > 100) {
throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- Cr12"); throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- Cr12");
}
tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer())); tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer()));
int n = CardCounts.get(c.getName()); int n = CardCounts.get(c.getName());
@@ -235,8 +237,9 @@ public class Generate2ColorDeck {
c = Sp12.get(r.nextInt(Sp12.size())); c = Sp12.get(r.nextInt(Sp12.size()));
lc++; lc++;
} }
if (lc > 100) if (lc > 100) {
throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- Sp12"); throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- Sp12");
}
tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer())); tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer()));
int n = CardCounts.get(c.getName()); int n = CardCounts.get(c.getName());
@@ -249,8 +252,9 @@ public class Generate2ColorDeck {
if (LandsPercentage > 0) { if (LandsPercentage > 0) {
p = (float) ((float) LandsPercentage * .01); p = (float) ((float) LandsPercentage * .01);
numLands = (int) (p * (float) Size); 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(); numLands = Size - tDeck.size();
}
tmpDeck += "numLands:" + numLands + "\n"; tmpDeck += "numLands:" + numLands + "\n";
@@ -263,8 +267,9 @@ public class Generate2ColorDeck {
s = DL.get(r.nextInt(DL.size())); s = DL.get(r.nextInt(DL.size()));
lc++; lc++;
} }
if (lc > 20) if (lc > 20) {
throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- DL"); throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- DL");
}
tDeck.add(AllZone.getCardFactory().getCard(s, AllZone.getHumanPlayer())); tDeck.add(AllZone.getCardFactory().getCard(s, AllZone.getHumanPlayer()));
int n = CardCounts.get(s); int n = CardCounts.get(s);
@@ -291,18 +296,23 @@ public class Generate2ColorDeck {
for (int j = 0; j < mc.length(); j++) { for (int j = 0; j < mc.length(); j++) {
char c = mc.charAt(j); char c = mc.charAt(j);
if (c == 'W') if (c == 'W') {
ClrCnts[0].Count++; ClrCnts[0].Count++;
else if (c == 'U') }
else if (c == 'U') {
ClrCnts[1].Count++; ClrCnts[1].Count++;
else if (c == 'B') }
else if (c == 'B') {
ClrCnts[2].Count++; ClrCnts[2].Count++;
else if (c == 'R') }
else if (c == 'R') {
ClrCnts[3].Count++; ClrCnts[3].Count++;
else if (c == 'G') }
else if (c == 'G') {
ClrCnts[4].Count++; ClrCnts[4].Count++;
} }
} }
}
// total of all ClrCnts // total of all ClrCnts
int totalColor = 0; int totalColor = 0;
@@ -322,11 +332,12 @@ public class Generate2ColorDeck {
// just to prevent a null exception by the deck size fixing code // just to prevent a null exception by the deck size fixing code
CardCounts.put(ClrCnts[i].Color, nLand); CardCounts.put(ClrCnts[i].Color, nLand);
for (int j = 0; j <= nLand; j++) for (int j = 0; j <= nLand; j++) {
tDeck.add(AllZone.getCardFactory().getCard(ClrCnts[i].Color, AllZone.getComputerPlayer())); tDeck.add(AllZone.getCardFactory().getCard(ClrCnts[i].Color, AllZone.getComputerPlayer()));
} }
} }
} }
}
tmpDeck += "DeckSize:" + tDeck.size() + "\n"; tmpDeck += "DeckSize:" + tDeck.size() + "\n";
// fix under-sized or over-sized decks, due to integer arithmetic // fix under-sized or over-sized decks, due to integer arithmetic
@@ -341,8 +352,9 @@ public class Generate2ColorDeck {
c = tDeck.get(r.nextInt(tDeck.size())); c = tDeck.get(r.nextInt(tDeck.size()));
lc++; lc++;
} }
if (lc > Size) if (lc > Size) {
throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- undersize"); throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- 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())); tDeck.add(AllZone.getCardFactory().getCard(c.getName(), AllZone.getComputerPlayer()));
@@ -355,8 +367,9 @@ public class Generate2ColorDeck {
for (int i = 0; i < diff; i++) { for (int i = 0; i < diff; i++) {
Card c = tDeck.get(r.nextInt(tDeck.size())); 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())); c = tDeck.get(r.nextInt(tDeck.size()));
}
tDeck.remove(c); tDeck.remove(c);
tmpDeck += "Removed:" + c.getName() + "\n"; tmpDeck += "Removed:" + c.getName() + "\n";
@@ -364,8 +377,9 @@ public class Generate2ColorDeck {
} }
tmpDeck += "DeckSize:" + tDeck.size() + "\n"; tmpDeck += "DeckSize:" + tDeck.size() + "\n";
if (ForgeProps.getProperty("showdeck/2color", "false").equals("true")) if (ForgeProps.getProperty("showdeck/2color", "false").equals("true")) {
ErrorViewer.showError(tmpDeck); ErrorViewer.showError(tmpDeck);
}
return tDeck; return tDeck;
} }

View File

@@ -55,9 +55,9 @@ public class GenerateConstructedDeck {
addLand(deck); addLand(deck);
if (deck.size() != 60) if (deck.size() != 60) {
throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size()); throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size());
}
return deck; return deck;
} }
@@ -76,7 +76,7 @@ public class GenerateConstructedDeck {
land = AllZone.getCardFactory().getCard(map.get(color2).toString(), AllZone.getComputerPlayer()); land = AllZone.getCardFactory().getCard(map.get(color2).toString(), AllZone.getComputerPlayer());
list.add(land); list.add(land);
} }
}//addLand() } //addLand()
/** /**
* Creates a CardList from the set of all cards that meets the criteria * Creates a CardList from the set of all cards that meets the criteria
@@ -85,12 +85,12 @@ public class GenerateConstructedDeck {
* *
* @see #filterBadCards(Iterable) * @see #filterBadCards(Iterable)
* *
* @return a subset of carsd <= the set of all cards; might be empty, but * @return a subset of cards <= the set of all cards; might be empty, but
* never null * never null
*/ */
private CardList getCards() { private CardList getCards() {
return filterBadCards(AllZone.getCardFactory()); return filterBadCards(AllZone.getCardFactory());
}//getCards() } //getCards()
/** /**
* <p>get2ColorDeck.</p> * <p>get2ColorDeck.</p>
@@ -104,9 +104,9 @@ public class GenerateConstructedDeck {
deck.shuffle(); deck.shuffle();
//trim deck size down to 34 cards, presumes 26 land, for a total of 60 cards //trim deck size down to 34 cards, presumes 26 land, for a total of 60 cards
for (int i = 0; i < 34 && i < deck.size(); i++) for (int i = 0; i < 34 && i < deck.size(); i++) {
out.add(deck.get(i)); out.add(deck.get(i));
}
return out; return out;
} }
@@ -136,7 +136,7 @@ public class GenerateConstructedDeck {
CardList artifact = in.filter(new CardListFilter() { CardList artifact = in.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
//is this really a colorless artifact and not something //is this really a colorless artifact and not something
//wierd like Sarcomite Myr which is a colored artifact //weird like Sarcomite Myr which is a colored artifact
return c.isArtifact() && return c.isArtifact() &&
CardUtil.getColors(c).contains(Constant.Color.Colorless) && CardUtil.getColors(c).contains(Constant.Color.Colorless) &&
!OldGuiNewGame.removeArtifacts.isSelected(); !OldGuiNewGame.removeArtifacts.isSelected();
@@ -190,5 +190,5 @@ public class GenerateConstructedDeck {
}); });
return out; return out;
}//filterBadCards() } //filterBadCards()
} }

View File

@@ -101,21 +101,11 @@ public class GenerateConstructedMultiColorDeck {
public CardList generate5ColorDeck() { public CardList generate5ColorDeck() {
CardList deck; CardList deck;
/*
int check;
do{
deck = get5ColorDeck();
check = deck.getType("Creature").size();
}while(check < 15 || 25 < check);
*/
deck = get5ColorDeck(); deck = get5ColorDeck();
addLand(deck, 5); addLand(deck, 5);
if (deck.size() != 61) if (deck.size() != 60)
throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size()); throw new RuntimeException("GenerateConstructedDeck() : generateDeck() error, deck size it not 60, deck size is " + deck.size());
return deck; return deck;

View File

@@ -46,7 +46,7 @@ public class GenerateThemeDeck {
+ file.getAbsolutePath()); + file.getAbsolutePath());
if (!file.isDirectory()) if (!file.isDirectory())
throw new RuntimeException("GenerateThemeDeck : getThemeNames error -- not a direcotry -- " throw new RuntimeException("GenerateThemeDeck : getThemeNames error -- not a directory -- "
+ file.getAbsolutePath()); + file.getAbsolutePath());
String[] fileList = file.list(); String[] fileList = file.list();

View File

@@ -844,14 +844,6 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
dispose(); dispose();
} // startButton_actionPerformed() } // startButton_actionPerformed()
/*
* private Deck generateSealedDeck() { GenerateSealedDeck gen = new
* GenerateSealedDeck(); CardList name = gen.generateDeck(); Deck deck = new
* Deck(Constant.GameType.Sealed);
*
* for(int i = 0; i < 40; i++) deck.addMain(name.get(i).getName()); return
* deck; }
*/
/** /**
* <p> * <p>
* genDecks. * genDecks.
@@ -859,9 +851,9 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
* *
* @param p * @param p
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* TODO: jendave to refactor deck generation
*/ */
private void genDecks(final PlayerType playerType) { private void genDecks(final PlayerType playerType) {
// TODO: jendave to refactor deck generation
Deck d = null; Deck d = null;
ArrayList<String> decks = new ArrayList<String>(); ArrayList<String> decks = new ArrayList<String>();