- Added the option "no nonland duplicates" to the generate deck menu in the main screen.

This commit is contained in:
Sloth
2011-11-14 16:24:10 +00:00
parent 9e0e205aec
commit b7d3c075a0
8 changed files with 1363 additions and 1308 deletions

2
.gitattributes vendored
View File

@@ -10767,7 +10767,7 @@ src/main/java/forge/quest/package-info.java svneol=native#text/plain
src/main/java/forge/view/FView.java svneol=native#text/plain
src/main/java/forge/view/package-info.java svneol=native#text/plain
src/main/java/forge/view/swing/ApplicationView.java svneol=native#text/plain
src/main/java/forge/view/swing/GuiHomeScreen.java -text svneol=native#text/plain
src/main/java/forge/view/swing/GuiHomeScreen.java svneol=native#text/plain
src/main/java/forge/view/swing/Main.java svneol=native#text/plain
src/main/java/forge/view/swing/OldGuiNewGame.java svneol=native#text/plain
src/main/java/forge/view/swing/SplashFrame.java -text

View File

@@ -119,6 +119,7 @@ NewGame/options/font=Benutze LAF Schriften
NewGame/options/cardOverlay=Benutze Mana und Text
NewGame/options/cardScale=Karten vergr<67>ssern
NewGame/options/generate/title=Deckgenerator
NewGame/options/generate/singletons=Keine doppelten au<61>er L<>ndern
NewGame/options/generate/removeSmall=1/1 und 0/X Kreaturen entfernen
NewGame/options/generate/removeArtifacts=Artefakte entfernen
NewGame/help/title=Hilfe

View File

@@ -157,6 +157,7 @@ NewGame/options/font=Use LAF Fonts
NewGame/options/cardOverlay=Use mana and text card overlay
NewGame/options/cardScale=Scale card images larger than original
NewGame/options/generate/title=Generate Deck
NewGame/options/generate/singletons=No nonland duplicates
NewGame/options/generate/removeSmall=Remove 1/1 and 0/X Creatures
NewGame/options/generate/removeArtifacts=Remove Artifacts
NewGame/help/title=Help

View File

@@ -13,6 +13,7 @@ import forge.CardListFilter;
import forge.Constant;
import forge.MyRandom;
import forge.PlayerType;
import forge.Singletons;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
@@ -32,6 +33,7 @@ public class Generate2ColorDeck {
private ArrayList<String> notColors = null;
private ArrayList<String> dL = null;
private Map<String, Integer> cardCounts = null;
private int maxDuplicates = 4;
/**
* <p>
@@ -62,6 +64,10 @@ public class Generate2ColorDeck {
this.notColors.add("red");
this.notColors.add("green");
if(Singletons.getModel().getPreferences().isDeckGenSingletons()) {
maxDuplicates = 1;
}
if (clr1.equals("AI")) {
// choose first color
this.color1 = this.notColors.get(this.r.nextInt(5));
@@ -165,7 +171,7 @@ public class Generate2ColorDeck {
};
// select cards to build card pools using a mana curve
for (int i = 4; i > 0; i--) {
for (int i = 5; i > 0; i--) {
final CardList cr1CMC = cr1.filter(cmcF);
final CardList cr2CMC = cr2.filter(cmcF);
final CardList sp1CMC = sp1.filter(cmcF);
@@ -218,7 +224,7 @@ public class Generate2ColorDeck {
Card c = cr12.get(this.r.nextInt(cr12.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > 3) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
c = cr12.get(this.r.nextInt(cr12.size()));
lc++;
}
@@ -236,7 +242,7 @@ public class Generate2ColorDeck {
Card c = sp12.get(this.r.nextInt(sp12.size()));
lc = 0;
while ((this.cardCounts.get(c.getName()) > 3) || (lc > 100)) {
while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) {
c = sp12.get(this.r.nextInt(sp12.size()));
lc++;
}

View File

@@ -60,6 +60,9 @@ public class ForgePreferences extends Preferences {
/** The scale larger than original. */
private boolean scaleLargerThanOriginal;
/** The deck gen rmv artifacts. */
private boolean deckGenSingletons;
/** The deck gen rmv artifacts. */
private boolean deckGenRmvArtifacts;
@@ -151,6 +154,7 @@ public class ForgePreferences extends Preferences {
this.setMaxStackSize(this.getInt("stack.max.size", 3));
this.setScaleLargerThanOriginal(this.getBoolean("card.scale.larger.than.original", true));
this.setDeckGenSingletons(this.getBoolean("deck.gen.singletons", false));
this.setDeckGenRmvArtifacts(this.getBoolean("deck.gen.rmv.artifacts", false));
this.setDeckGenRmvSmall(this.getBoolean("deck.gen.rmv.small", false));
@@ -202,6 +206,7 @@ public class ForgePreferences extends Preferences {
listeners.savePreferences();
}
this.set("deck.gen.singletons", this.isDeckGenSingletons());
this.set("deck.gen.rmv.artifacts", this.isDeckGenRmvArtifacts());
this.set("deck.gen.rmv.small", this.isDeckGenRmvSmall());
@@ -548,6 +553,14 @@ public class ForgePreferences extends Preferences {
this.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's name.
}
public boolean isDeckGenSingletons() {
return deckGenSingletons;
}
public void setDeckGenSingletons(boolean deckSingletons) {
this.deckGenSingletons = deckSingletons;
}
/**
* @return the deckGenRmvArtifacts
*/

View File

@@ -857,6 +857,8 @@ public final class NewConstants {
/** The TITLE. */
public static final String TITLE = "%s/NewGame/options/generate/title";
public static final String SINGLETONS = "%s/NewGame/options/generate/singletons";
/** The REMOV e_ small. */
public static final String REMOVE_SMALL = "%s/NewGame/options/generate/removeSmall";

View File

@@ -179,9 +179,11 @@ public class GuiHomeScreen {
private final JButton cmdSize = new JButton("Choose Card Size");
private final JCheckBox chkScale = new JCheckBox("Scale Card Image Larger");
private final JButton cmdStack = new JButton("Choose Stack Offset");
private final JCheckBox chkSingletons = new JCheckBox("No Nonland Duplicates");
private final JCheckBox chkRemoveArtifacts = new JCheckBox("Remove Artifacts");
private final JCheckBox chkRemoveSmall = new JCheckBox("Remove Small Creatures");
// Utilities Panel
private final JPanel pnlUtilities = new JPanel();
private final JButton cmdDownloadLQSetPics = new JButton("Download LQ Set Pics");
@@ -728,6 +730,17 @@ public class GuiHomeScreen {
final JLabel lblGenGraphs = new JLabel("<html><u>Deck Generation Settings</u></html>");
lblGenGraphs.setHorizontalAlignment(SwingConstants.CENTER);
this.pnlSettingsA.add(lblGenGraphs);
this.chkSingletons.setOpaque(false);
this.chkSingletons.setBackground(this.clrScrollBackground);
this.chkSingletons.setSelected(Singletons.getModel().getPreferences().isDeckGenSingletons());
this.chkSingletons.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
Singletons.getModel().getPreferences()
.setDeckGenSingletons(GuiHomeScreen.this.chkSingletons.isSelected());
}
});
this.pnlSettingsA.add(this.chkSingletons);
this.chkRemoveArtifacts.setOpaque(false);
this.chkRemoveArtifacts.setBackground(this.clrScrollBackground);
this.chkRemoveArtifacts.setSelected(Singletons.getModel().getPreferences().isDeckGenRmvArtifacts());

View File

@@ -137,8 +137,9 @@ public class OldGuiNewGame extends JFrame {
/** The foil random check box. */
private static JCheckBox foilRandomCheckBox = new JCheckBox("", true);
// GenerateConstructedDeck.get2Colors() and GenerateSealedDeck.get2Colors()
// use these two variables
private static JCheckBoxMenuItem singletons = new JCheckBoxMenuItem(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.SINGLETONS));
/** Constant <code>removeSmallCreatures</code>. */
private static JCheckBoxMenuItem removeSmallCreatures = new JCheckBoxMenuItem(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.REMOVE_SMALL));
@@ -260,6 +261,24 @@ public class OldGuiNewGame extends JFrame {
// new stuff
final JMenu generatedDeck = new JMenu(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.TITLE));
generatedDeck.add(OldGuiNewGame.singletons);
OldGuiNewGame.singletons.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
Singletons.getModel().getPreferences()
.setDeckGenSingletons(OldGuiNewGame.singletons.isSelected());
}
});
generatedDeck.add(OldGuiNewGame.removeSmallCreatures);
OldGuiNewGame.removeSmallCreatures.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
Singletons.getModel().getPreferences()
.setDeckGenRmvSmall(OldGuiNewGame.removeSmallCreatures.isSelected());
}
});
generatedDeck.add(OldGuiNewGame.removeSmallCreatures);
OldGuiNewGame.removeSmallCreatures.addActionListener(new ActionListener() {
@Override