- 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/FView.java svneol=native#text/plain
src/main/java/forge/view/package-info.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/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/Main.java svneol=native#text/plain
src/main/java/forge/view/swing/OldGuiNewGame.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 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/cardOverlay=Benutze Mana und Text
NewGame/options/cardScale=Karten vergr<67>ssern NewGame/options/cardScale=Karten vergr<67>ssern
NewGame/options/generate/title=Deckgenerator 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/removeSmall=1/1 und 0/X Kreaturen entfernen
NewGame/options/generate/removeArtifacts=Artefakte entfernen NewGame/options/generate/removeArtifacts=Artefakte entfernen
NewGame/help/title=Hilfe 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/cardOverlay=Use mana and text card overlay
NewGame/options/cardScale=Scale card images larger than original NewGame/options/cardScale=Scale card images larger than original
NewGame/options/generate/title=Generate Deck 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/removeSmall=Remove 1/1 and 0/X Creatures
NewGame/options/generate/removeArtifacts=Remove Artifacts NewGame/options/generate/removeArtifacts=Remove Artifacts
NewGame/help/title=Help NewGame/help/title=Help

View File

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

View File

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

View File

@@ -856,6 +856,8 @@ public final class NewConstants {
/** The TITLE. */ /** The TITLE. */
public static final String TITLE = "%s/NewGame/options/generate/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. */ /** The REMOV e_ small. */
public static final String REMOVE_SMALL = "%s/NewGame/options/generate/removeSmall"; public static final String REMOVE_SMALL = "%s/NewGame/options/generate/removeSmall";

File diff suppressed because it is too large Load Diff

View File

@@ -137,8 +137,9 @@ public class OldGuiNewGame extends JFrame {
/** The foil random check box. */ /** The foil random check box. */
private static JCheckBox foilRandomCheckBox = new JCheckBox("", true); private static JCheckBox foilRandomCheckBox = new JCheckBox("", true);
// GenerateConstructedDeck.get2Colors() and GenerateSealedDeck.get2Colors() private static JCheckBoxMenuItem singletons = new JCheckBoxMenuItem(
// use these two variables ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.SINGLETONS));
/** Constant <code>removeSmallCreatures</code>. */ /** Constant <code>removeSmallCreatures</code>. */
private static JCheckBoxMenuItem removeSmallCreatures = new JCheckBoxMenuItem( private static JCheckBoxMenuItem removeSmallCreatures = new JCheckBoxMenuItem(
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.REMOVE_SMALL)); ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.REMOVE_SMALL));
@@ -259,7 +260,25 @@ public class OldGuiNewGame extends JFrame {
// new stuff // new stuff
final JMenu generatedDeck = new JMenu(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.TITLE)); 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); generatedDeck.add(OldGuiNewGame.removeSmallCreatures);
OldGuiNewGame.removeSmallCreatures.addActionListener(new ActionListener() { OldGuiNewGame.removeSmallCreatures.addActionListener(new ActionListener() {
@Override @Override