removed unused classes,

removed literals for basic lands
This commit is contained in:
Maxmtg
2013-06-16 22:26:38 +00:00
parent 5506af61ab
commit 58a333ef99
18 changed files with 66 additions and 543 deletions

2
.gitattributes vendored
View File

@@ -14483,7 +14483,6 @@ src/main/java/forge/game/event/package-info.java -text
src/main/java/forge/game/limited/BoosterDeckBuilder.java -text
src/main/java/forge/game/limited/BoosterDraft.java svneol=native#text/plain
src/main/java/forge/game/limited/BoosterDraftAI.java svneol=native#text/plain
src/main/java/forge/game/limited/CCnt.java svneol=native#text/plain
src/main/java/forge/game/limited/CardRankingComparator.java -text
src/main/java/forge/game/limited/CustomLimited.java svneol=native#text/plain
src/main/java/forge/game/limited/DeckColors.java svneol=native#text/plain
@@ -14554,7 +14553,6 @@ src/main/java/forge/gui/UnsortedListModel.java -text
src/main/java/forge/gui/WrapLayout.java -text
src/main/java/forge/gui/deckeditor/CDeckEditorUI.java -text
src/main/java/forge/gui/deckeditor/DeckImport.java -text
src/main/java/forge/gui/deckeditor/MenuCommon.java svneol=native#text/plain
src/main/java/forge/gui/deckeditor/SEditorIO.java -text
src/main/java/forge/gui/deckeditor/SEditorUtil.java -text
src/main/java/forge/gui/deckeditor/SFilterUtil.java -text

View File

@@ -18,8 +18,6 @@
package forge;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
@@ -87,7 +85,8 @@ public final class Constant {
public static final String SNOW = "snow";
/** The Basic lands. */
public static final List<String> BASIC_LANDS = Collections.unmodifiableList(Arrays.asList("Plains", "Island", "Swamp", "Mountain", "Forest"));
public static final List<String> BASIC_LANDS = ImmutableList.of("Plains", "Island", "Swamp", "Mountain", "Forest");
public static final List<String> SNOW_LANDS = ImmutableList.of("Snow-Covered Plains", "Snow-Covered Island", "Snow-Covered Swamp", "Snow-Covered Mountain", "Snow-Covered Forest");
}
/**

View File

@@ -344,7 +344,6 @@ public final class CardDb implements ICardDatabase {
}
}
public Predicate<? super PaperCard> wasPrintedInSets(List<String> setCodes) {
return new PredicateExistsInSets(setCodes);
}

View File

@@ -31,10 +31,12 @@ import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import forge.Constant;
import forge.Singletons;
import forge.game.GameFormat;
import forge.util.Aggregates;
import forge.util.FileSection;
import forge.util.FileUtil;
import forge.util.storage.StorageReaderFolder;
@@ -327,18 +329,15 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
};
}
/**
* TODO: Write javadoc for this method.
* @return
*/
public final static CardEdition getRandomSetWithAllBasicLands(Iterable<CardEdition> allEditions) {
return Aggregates.random(Iterables.filter(allEditions, CardEdition.Predicates.hasBasicLands));
}
public int getCntBoosterPictures() {
return boosterArts;
}
/**
* TODO: Write javadoc for this method.
* @return
*/
public SealedProductTemplate getBoosterTemplate() {
return boosterTpl;
}

View File

@@ -1034,10 +1034,10 @@ public class CardFactoryUtil {
int n = 0;
final List<Card> someCards = new ArrayList<Card>();
someCards.addAll(player.getCardsIn(ZoneType.Battlefield));
final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" };
final List<String> basic = Constant.Color.BASIC_LANDS;
for (int i = 0; i < basic.length; i++) {
if (!CardLists.getType(someCards, basic[i]).isEmpty()) {
for (int i = 0; i < basic.size(); i++) {
if (!CardLists.getType(someCards, basic.get(i)).isEmpty()) {
n++;
}
}

View File

@@ -637,19 +637,6 @@ public final class GameActionUtil {
* @return the stLandManaAbilities
*/
public static void grantBasicLandsManaAbilities(Game game) {
/*
* for future use boolean naked =
* AllZoneUtil.isCardInPlay("Naked Singularity"); boolean twist =
* AllZoneUtil.isCardInPlay("Reality Twist"); //set up what they
* produce produces.put("Forest", naked || twist ? "B" : "G");
* produces.put("Island", naked == true ? "G" : "U"); if(naked)
* produces.put("Mountain", "U"); else if(twist)
* produces.put("Mountain", "W"); else produces.put("Mountain",
* "R"); produces.put("Plains", naked || twist ? "R" : "W");
* if(naked) produces.put("Swamp", "W"); else if(twist)
* produces.put("Swamp", "G"); else produces.put("Swamp", "B");
*/
List<Card> lands = game.getCardsIn(ZoneType.Battlefield);
lands = CardLists.filter(lands, Presets.LANDS);

View File

@@ -32,6 +32,7 @@ import javax.swing.JOptionPane;
import org.apache.commons.lang.ArrayUtils;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import forge.Card;
import forge.Constant.Preferences;
@@ -49,6 +50,7 @@ import forge.item.IPaperCard;
import forge.item.ItemPool;
import forge.item.ItemPoolView;
import forge.properties.NewConstants;
import forge.util.Aggregates;
import forge.util.FileUtil;
import forge.util.HttpUtil;
import forge.util.storage.IStorageView;
@@ -90,7 +92,7 @@ public final class BoosterDraft implements IBoosterDraft {
Supplier<List<PaperCard>> s = new UnOpenedProduct(SealedProductTemplate.genericBooster);
for (int i = 0; i < 3; i++) this.product.add(s);
IBoosterDraft.LAND_SET_CODE[0] = CardDb.instance().getCard("Plains").getEdition();
IBoosterDraft.LAND_SET_CODE[0] = CardEdition.getRandomSetWithAllBasicLands(Singletons.getModel().getEditions());
break;
case Block: case FantasyBlock: // Draft from cards by block or set
@@ -133,7 +135,7 @@ public final class BoosterDraft implements IBoosterDraft {
}
}
IBoosterDraft.LAND_SET_CODE[0] = block.getLandSet().getCode();
IBoosterDraft.LAND_SET_CODE[0] = block.getLandSet();
break;
case Custom:
@@ -169,7 +171,7 @@ public final class BoosterDraft implements IBoosterDraft {
this.product.add(toAdd);
}
IBoosterDraft.LAND_SET_CODE[0] = draft.getLandSetCode();
IBoosterDraft.LAND_SET_CODE[0] = Singletons.getModel().getEditions().get(draft.getLandSetCode());
}
/** Looks for res/draft/*.draft files, reads them, returns a list. */

View File

@@ -1,108 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.game.limited;
/**
* <p>
* CCnt class.
* </p>
*
* @author Forge
* @version $Id$
*/
class CCnt implements Comparable<CCnt> {
/** The Color. */
private String color;
/** The Count. */
private int count;
/**
* <p>
* Constructor for CCnt.
* </p>
*
* @param clr
* a {@link java.lang.String} object.
* @param cnt
* a int.
*/
/**
* <p>
* deckColors class.
* </p>
*
* @param clr
* a {@link java.lang.String} object.
* @param cnt
* a int.
*/
public CCnt(final String clr, final int cnt) {
this.setColor(clr);
this.setCount(cnt);
}
/**
* Gets the color.
*
* @return the color
*/
public String getColor() {
return this.color;
}
/**
* Sets the color.
*
* @param color0
* the color to set
*/
public void setColor(final String color0) {
this.color = color0;
}
/**
* Gets the count.
*
* @return the count
*/
public int getCount() {
return this.count;
}
/**
* Sets the count.
*
* @param count0
* the count to set
*/
public void setCount(final int count0) {
this.count = count0;
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(CCnt o) {
int compareCount = o.getCount();
return this.count - compareCount;
}
}

View File

@@ -24,7 +24,9 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import forge.Singletons;
import forge.card.CardDb;
import forge.card.CardEdition;
import forge.card.SealedProductTemplate;
import forge.deck.Deck;
import forge.deck.DeckBase;
@@ -65,7 +67,7 @@ public class CustomLimited extends DeckBase {
private transient ItemPoolView<PaperCard> cardPool;
/** The Land set code. */
private String landSetCode = CardDb.instance().getCard("Plains", true).getEdition();
private String landSetCode = CardEdition.getRandomSetWithAllBasicLands(Singletons.getModel().getEditions()).getCode();
private boolean singleton;

View File

@@ -17,6 +17,7 @@
*/
package forge.game.limited;
import forge.card.CardEdition;
import forge.deck.Deck;
import forge.item.PaperCard;
import forge.item.ItemPoolView;
@@ -68,7 +69,7 @@ public interface IBoosterDraft {
Deck[] getDecks(); // size 7, all the computers decks
/** Constant <code>LandSetCode="{}"</code>. */
String[] LAND_SET_CODE = { "" };
CardEdition[] LAND_SET_CODE = { null };
/**
* Called when drafting is over - to upload picks.

View File

@@ -1,7 +1,6 @@
package forge.game.limited;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -17,9 +16,12 @@ import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import forge.Constant;
import forge.Singletons;
import forge.Constant.Preferences;
import forge.card.CardAiHints;
import forge.card.CardDb;
import forge.card.CardEdition;
import forge.card.CardRules;
import forge.card.CardRulesPredicates;
import forge.card.ColorSet;
@@ -164,7 +166,7 @@ public class LimitedDeckBuilder {
addNonBasicLands();
// 11. Fill up with basic lands.
final CCnt[] clrCnts = calculateLandNeeds();
final int[] clrCnts = calculateLandNeeds();
if (landsNeeded > 0) {
addLands(clrCnts);
}
@@ -226,7 +228,7 @@ public class LimitedDeckBuilder {
* @param clrCnts
* color counts needed
*/
private void fixDeckSize(final CCnt[] clrCnts) {
private void fixDeckSize(final int[] clrCnts) {
while (deckList.size() > 40) {
System.out.println("WARNING: Fixing deck size, currently " + deckList.size() + " cards.");
final PaperCard c = deckList.get(MyRandom.getRandom().nextInt(deckList.size() - 1));
@@ -250,8 +252,8 @@ public class LimitedDeckBuilder {
} else {
// if no playable cards remain fill up with basic lands
for (int i = 0; i < 5; i++) {
if (clrCnts[i].getCount() > 0) {
final PaperCard cp = getBasicLand(clrCnts[i].getColor());
if (clrCnts[i] > 0) {
final PaperCard cp = getBasicLand(i);
deckList.add(cp);
System.out.println(" - Added " + cp.getName() + " as last resort.");
break;
@@ -267,9 +269,9 @@ public class LimitedDeckBuilder {
private void findBasicLandSets() {
Set<String> sets = new HashSet<String>();
for (PaperCard cp : aiPlayables) {
if (null != CardDb.instance().tryGetCard("Plains", cp.getEdition())) {
CardEdition ee = Singletons.getModel().getEditions().get(cp.edition);
if( !sets.contains(cp.getEdition()) && CardEdition.Predicates.hasBasicLands.apply(ee))
sets.add(cp.getEdition());
}
}
setsWithBasicLands.addAll(sets);
if (setsWithBasicLands.isEmpty()) {
@@ -282,12 +284,12 @@ public class LimitedDeckBuilder {
*
* @param clrCnts
*/
private void addLands(final CCnt[] clrCnts) {
private void addLands(final int[] clrCnts) {
// total of all ClrCnts
int totalColor = 0;
for (int i = 0; i < 5; i++) {
totalColor += clrCnts[i].getCount();
totalColor += clrCnts[i];
}
if (totalColor == 0) {
throw new RuntimeException("Add Lands to empty deck list!");
@@ -295,44 +297,20 @@ public class LimitedDeckBuilder {
// do not update landsNeeded until after the loop, because the
// calculation involves landsNeeded
int landsAdded = 0;
for (int i = 0; i < 5; i++) {
if (clrCnts[i].getCount() > 0) {
if (clrCnts[i] > 0) {
// calculate number of lands for each color
final float p = (float) clrCnts[i].getCount() / (float) totalColor;
final int nLand = (int) (landsNeeded * p); // desired truncation
// to int
final float p = (float) clrCnts[i] / (float) totalColor;
final int nLand = Math.round(landsNeeded * p); // desired truncation to int
if (Preferences.DEV_MODE) {
System.out.println("Basics[" + clrCnts[i].getColor() + "]: " + clrCnts[i].getCount() + "/"
+ totalColor + " = " + p + " = " + nLand);
System.out.printf("Basics[%s]: %d/%d = %f%% = %d cards", Constant.Color.BASIC_LANDS.get(i), clrCnts[i], totalColor, 100*p, nLand);
}
for (int j = 0; j < nLand; j++) {
deckList.add(getBasicLand(clrCnts[i].getColor()));
landsAdded++;
deckList.add(getBasicLand(i));
}
}
}
// Add extra lands to get up to the right number.
// Start with the smallest CCnt to "even out" a little.
landsNeeded -= landsAdded;
Arrays.sort(clrCnts);
int n = 0;
while (landsNeeded > 0) {
if (clrCnts[n].getCount() > 0) {
final PaperCard cp = getBasicLand(clrCnts[n].getColor());
deckList.add(cp);
landsNeeded--;
if (Preferences.DEV_MODE) {
System.out.println("AddBasics: " + cp.getName());
}
}
if (++n > 4) {
n = 0;
}
}
}
/**
@@ -341,14 +319,14 @@ public class LimitedDeckBuilder {
* @param basicLand
* @return card
*/
private PaperCard getBasicLand(String basicLand) {
private PaperCard getBasicLand(int basicLand) {
String set;
if (setsWithBasicLands.size() > 1) {
set = setsWithBasicLands.get(MyRandom.getRandom().nextInt(setsWithBasicLands.size() - 1));
} else {
set = setsWithBasicLands.get(0);
}
return CardDb.instance().getCard(basicLand, set);
return CardDb.instance().getCard(Constant.Color.BASIC_LANDS.get(basicLand), set);
}
/**
@@ -359,32 +337,19 @@ public class LimitedDeckBuilder {
*
* @return CCnt
*/
private CCnt[] calculateLandNeeds() {
final CCnt[] clrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0),
new CCnt("Mountain", 0), new CCnt("Forest", 0) };
private int[] calculateLandNeeds() {
final int[] clrCnts = { 0,0,0,0,0 };
// count each card color using mana costs
for (int i = 0; i < deckList.size(); i++) {
final ManaCost mc = deckList.get(i).getRules().getManaCost();
for (PaperCard cp : deckList) {
final ManaCost mc = cp.getRules().getManaCost();
// count each mana symbol in the mana cost
for (ManaCostShard shard : mc.getShards()) {
byte mask = shard.getColorMask();
if ((mask & MagicColor.WHITE) > 0 && colors.hasWhite()) {
clrCnts[0].setCount(clrCnts[0].getCount() + 1);
}
if ((mask & MagicColor.BLUE) > 0 && colors.hasBlue()) {
clrCnts[1].setCount(clrCnts[1].getCount() + 1);
}
if ((mask & MagicColor.BLACK) > 0 && colors.hasBlack()) {
clrCnts[2].setCount(clrCnts[2].getCount() + 1);
}
if ((mask & MagicColor.RED) > 0 && colors.hasRed()) {
clrCnts[3].setCount(clrCnts[3].getCount() + 1);
}
if ((mask & MagicColor.GREEN) > 0 && colors.hasGreen()) {
clrCnts[4].setCount(clrCnts[4].getCount() + 1);
for ( int i = 0 ; i < MagicColor.WUBRG.length; i++ ) {
byte c = MagicColor.WUBRG[i];
if ( shard.canBePaidWithManaOfColor(c) && colors.hasAnyColor(c))
clrCnts[i]++;
}
}
}

View File

@@ -6,6 +6,7 @@ import java.util.Map;
import com.esotericsoftware.minlog.Log;
import forge.Constant;
import forge.properties.NewConstants;
import forge.util.FileUtil;
@@ -90,10 +91,8 @@ public class ReadDraftRankings {
Double rank = null;
// Basic lands should be excluded from the evaluation --BBU
if (cardName.equals("Island") || cardName.equals("Forest") || cardName.equals("Swamp")
|| cardName.equals("Plains") || cardName.equals("Mountain")) {
if ( Constant.Color.BASIC_LANDS.contains(cardName))
return null;
}
if (draftRankings.containsKey(edition)) {
String safeName = cardName.replaceAll("-", " ").replaceAll("[^A-Za-z ]", "");

View File

@@ -28,7 +28,6 @@ import org.apache.commons.lang.ArrayUtils;
import forge.Singletons;
import forge.card.CardBlock;
import forge.card.CardDb;
import forge.card.CardEdition;
import forge.card.IUnOpenedProduct;
import forge.card.SealedProductTemplate;
@@ -72,7 +71,7 @@ public class SealedCardPoolGenerator {
// Choose number of boosters
chooseNumberOfBoosters(new UnOpenedProduct(SealedProductTemplate.genericBooster));
landSetCode = CardDb.instance().getCard("Plains").getEdition();
landSetCode = CardEdition.getRandomSetWithAllBasicLands(Singletons.getModel().getEditions()).getCode();
break;
case Block:

View File

@@ -1,313 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.gui.deckeditor;
/**
* <p>
* Gui_DeckEditor_Menu class.
* </p>
*
* @author Forge
* @version $Id$
*/
public final class MenuCommon {
/** Constant <code>serialVersionUID=-4037993759604768755L</code>. *
private static final long serialVersionUID = -4037993759604768755L;
/** Constant <code>previousDirectory</code>. *
private static File previousDirectory = null;
/**
* Menu for Deck Editor.
*
* @param ctrl
* the ctrl
* @param exit
* a Command
*
public MenuCommon(final DeckController<Deck> ctrl, final Command exit) {
super(ctrl, exit);
// this is added just to make save() and saveAs() work ok
// when first started up, just a silly patch
}
private void newRandomConstructed() {
if (!this.canLeaveCurrentDeck()) {
return;
}
final Deck randomDeck = new Deck();
// The only remaining reference to global variable!
randomDeck.getMain().addAllFlat(Predicate.not(CardRules.Predicates.Presets.IS_BASIC_LAND)
.random(CardDb.instance().getAllUniqueCards(), CardPrinted.FN_GET_RULES, 15 * 5));
randomDeck.getMain().add("Plains");
randomDeck.getMain().add("Island");
randomDeck.getMain().add("Swamp");
randomDeck.getMain().add("Mountain");
randomDeck.getMain().add("Forest");
randomDeck.getMain().add("Terramorphic Expanse");
this.getController().setModel(randomDeck);
}
private void newGenerateConstructed() {
if (!this.canLeaveCurrentDeck()) {
return;
}
final Deck genConstructed = new Deck();
genConstructed.getMain().addAll((new Generate2ColorDeck("AI", "AI")).get2ColorDeck(60, PlayerType.HUMAN));
this.getController().setModel(genConstructed);
}
private File getImportFilename() {
final JFileChooser chooser = new JFileChooser(MenuCommon.previousDirectory);
chooser.addChoosableFileFilter(DeckSerializer.DCK_FILTER);
final int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
final File file = chooser.getSelectedFile();
MenuCommon.previousDirectory = file.getParentFile();
return file;
}
return null;
} // openFileDialog()
private void importDeck() {
final File file = this.getImportFilename();
if (file == null) {
} else if (file.getName().endsWith(".dck")) {
try {
this.getController().setModel(Deck.fromFile(file));
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : importDeck() error, " + ex);
}
}
}
/**
* <p>
* exportDeck.
* </p>
*
private void exportDeck() {
final File filename = this.getExportFilename();
if (filename == null) {
return;
}
try {
DeckSerializer.writeDeck(this.getController().getModel(), filename);
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : exportDeck() error, " + ex);
}
}
private File getExportFilename() {
final JFileChooser save = new JFileChooser(MenuCommon.previousDirectory);
save.setDialogTitle("Export Deck Filename");
save.setDialogType(JFileChooser.SAVE_DIALOG);
save.setFileFilter(DeckSerializer.DCK_FILTER);
if (save.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
final File file = save.getSelectedFile();
final String check = file.getAbsolutePath();
MenuCommon.previousDirectory = file.getParentFile();
return check.endsWith(".dck") ? file : new File(check + ".dck");
}
return null;
}
/**
* <p>
* Generate Proxy for a Deck.
* </p>
*
private void generateProxies() {
final File filename = this.getProxiesFilename();
if (filename == null) {
return;
}
try {
DeckSerializer.writeDeckHtml(this.getController().getModel(), filename);
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : printProxies() error, " + ex);
}
}
private File getProxiesFilename() {
final JFileChooser save = new JFileChooser(MenuCommon.previousDirectory);
save.setDialogTitle("Proxy HTML Filename");
save.setDialogType(JFileChooser.SAVE_DIALOG);
save.setFileFilter(DeckSerializer.HTML_FILTER);
if (save.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
final File file = save.getSelectedFile();
final String check = file.getAbsolutePath();
MenuCommon.previousDirectory = file.getParentFile();
return check.endsWith(".html") ? file : new File(check + ".html");
}
return null;
}
// deck.setName(currentDeckName);
/*
* (non-Javadoc)
*
* @see forge.gui.deckeditor.MenuBase#getDefaultFileMenu()
*
@Override
protected JMenu getDefaultFileMenu() {
final JMenu fileMenu = super.getDefaultFileMenu();
final JMenuItem newRandomConstructed = new JMenuItem("New Deck - Generate Random Constructed Cardpool");
final JMenuItem newGenerateConstructed = new JMenuItem("New Deck - Generate Constructed Deck");
final JMenuItem importDeck = new JMenuItem("Import Deck...");
final JMenuItem exportDeck = new JMenuItem("Export Deck...");
// JMenuItem downloadDeck = new JMenuItem("Download Deck");
// newDraftItem = newDraft;
// newDraftItem.setEnabled(false);
// fileMenu.add(newSealed);
// fileMenu.add(newDraft);
fileMenu.addSeparator();
fileMenu.add(importDeck);
fileMenu.add(exportDeck);
final JMenuItem generateProxies = new JMenuItem("Generate Proxies...");
fileMenu.add(generateProxies);
// fileMenu.add(downloadDeck);
fileMenu.addSeparator();
fileMenu.add(newRandomConstructed);
fileMenu.add(newGenerateConstructed);
this.appendCloseMenuItemTo(fileMenu);
generateProxies.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ev) {
try {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MenuCommon.this.generateProxies();
}
});
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : generateProxies() error - " + ex);
}
}
});
// add listeners
exportDeck.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ev) {
try {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MenuCommon.this.exportDeck();
}
});
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : exportDeck() error - " + ex);
}
}
});
importDeck.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ev) {
try {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MenuCommon.this.importDeck();
}
});
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : importDeck() error - " + ex);
}
}
});
newRandomConstructed.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ev) {
try {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MenuCommon.this.newRandomConstructed();
}
});
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : newRandomConstructed() error - " + ex);
}
}
});
newGenerateConstructed.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ev) {
try {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MenuCommon.this.newGenerateConstructed();
}
});
} catch (final Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : newRandomConstructed() error - " + ex);
}
}
});
return fileMenu;
} // setupMenu()
*/
}

View File

@@ -5,6 +5,7 @@ import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import forge.Command;
import forge.Constant;
import forge.card.CardDb;
import forge.card.CardRulesPredicates;
import forge.deck.Deck;
@@ -83,11 +84,9 @@ public enum CDeckgen implements ICDoc {
Iterable<PaperCard> source = Iterables.filter(CardDb.instance().getUniqueCards(), notBasicLand);
randomDeck.getMain().addAllFlat(Aggregates.random(source, 15 * 5));
randomDeck.getMain().add("Plains", 1);
randomDeck.getMain().add("Island", 1);
randomDeck.getMain().add("Swamp", 1);
randomDeck.getMain().add("Mountain", 1);
randomDeck.getMain().add("Forest", 1);
for(String landName : Constant.Color.BASIC_LANDS) {
randomDeck.getMain().add(landName, 1);
}
randomDeck.getMain().add("Terramorphic Expanse", 1);
final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)

View File

@@ -20,8 +20,10 @@ package forge.gui.deckeditor.controllers;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import forge.Constant;
import forge.Singletons;
import forge.card.CardDb;
import forge.card.CardEdition;
import forge.control.FControl;
import forge.deck.CardPool;
import forge.deck.Deck;
@@ -172,13 +174,11 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
CardPool side = deck.getOrCreate(DeckSection.Sideboard);
side.addAll(this.getTableDeck().getCards());
final String landSet = IBoosterDraft.LAND_SET_CODE[0];
final CardEdition landSet = IBoosterDraft.LAND_SET_CODE[0];
final int landsCount = 20;
side.add(CardDb.instance().getCard("Forest", landSet), landsCount);
side.add(CardDb.instance().getCard("Mountain", landSet), landsCount);
side.add(CardDb.instance().getCard("Swamp", landSet), landsCount);
side.add(CardDb.instance().getCard("Island", landSet), landsCount);
side.add(CardDb.instance().getCard("Plains", landSet), landsCount);
for(String landName : Constant.Color.BASIC_LANDS) {
side.add(CardDb.instance().getCard(landName, landSet.getCode()), landsCount);
}
return deck;
} // getPlayersDeck()

View File

@@ -133,11 +133,9 @@ public final class QuestUtilCards {
if (!snowLandCodes.isEmpty()) {
String snowLandCode = Aggregates.random(snowLandCodes);
pool.add(db.getCard("Snow-Covered Forest", snowLandCode), nSnow);
pool.add(db.getCard("Snow-Covered Mountain", snowLandCode), nSnow);
pool.add(db.getCard("Snow-Covered Swamp", snowLandCode), nSnow);
pool.add(db.getCard("Snow-Covered Island", snowLandCode), nSnow);
pool.add(db.getCard("Snow-Covered Plains", snowLandCode), nSnow);
for(String landName : Constant.Color.SNOW_LANDS) {
pool.add(db.getCard(landName, snowLandCode), nSnow);
}
}
return pool;

View File

@@ -24,6 +24,7 @@ import java.util.Random;
import com.esotericsoftware.minlog.Log;
import forge.Constant;
import forge.properties.NewConstants;
import forge.util.FileUtil;
import forge.util.MyRandom;
@@ -93,11 +94,7 @@ public class ReadPriceList {
try {
int val = Integer.parseInt(price.trim());
if (!(name.equals("Plains") || name.equals("Island") || name.equals("Swamp")
|| name.equals("Mountain") || name.equals("Forest")
|| name.equals("Snow-Covered Plains") || name.equals("Snow-Covered Island")
|| name.equals("Snow-Covered Swamp") || name.equals("Snow-Covered Mountain") || name
.equals("Snow-Covered Forest"))) {
if (!(Constant.Color.BASIC_LANDS.contains(name) || Constant.Color.SNOW_LANDS.contains(name))) {
float ff = 0;
if (r.nextInt(100) < 90) {
ff = r.nextInt(10) * (float) .01;