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

View File

@@ -55,9 +55,9 @@ public class GenerateConstructedDeck {
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());
}
return deck;
}
@@ -76,7 +76,7 @@ public class GenerateConstructedDeck {
land = AllZone.getCardFactory().getCard(map.get(color2).toString(), AllZone.getComputerPlayer());
list.add(land);
}
}//addLand()
} //addLand()
/**
* Creates a CardList from the set of all cards that meets the criteria
@@ -85,12 +85,12 @@ public class GenerateConstructedDeck {
*
* @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
*/
private CardList getCards() {
return filterBadCards(AllZone.getCardFactory());
}//getCards()
} //getCards()
/**
* <p>get2ColorDeck.</p>
@@ -104,9 +104,9 @@ public class GenerateConstructedDeck {
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++)
for (int i = 0; i < 34 && i < deck.size(); i++) {
out.add(deck.get(i));
}
return out;
}
@@ -136,7 +136,7 @@ public class GenerateConstructedDeck {
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
//weird like Sarcomite Myr which is a colored artifact
return c.isArtifact() &&
CardUtil.getColors(c).contains(Constant.Color.Colorless) &&
!OldGuiNewGame.removeArtifacts.isSelected();
@@ -190,5 +190,5 @@ public class GenerateConstructedDeck {
});
return out;
}//filterBadCards()
} //filterBadCards()
}

View File

@@ -101,21 +101,11 @@ public class GenerateConstructedMultiColorDeck {
public CardList generate5ColorDeck() {
CardList deck;
/*
int check;
do{
deck = get5ColorDeck();
check = deck.getType("Creature").size();
}while(check < 15 || 25 < check);
*/
deck = get5ColorDeck();
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());
return deck;

View File

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

View File

@@ -844,14 +844,6 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
dispose();
} // 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>
* genDecks.
@@ -859,9 +851,9 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
*
* @param p
* a {@link java.lang.String} object.
* TODO: jendave to refactor deck generation
*/
private void genDecks(final PlayerType playerType) {
// TODO: jendave to refactor deck generation
Deck d = null;
ArrayList<String> decks = new ArrayList<String>();