+ *
+ * @return the combined draft values of cards in the main deck
+ */
+ public double getDraftValue() {
+
+ double value = 0;
+ double divider = 0;
+
+ ReadDraftRankings ranker = new ReadDraftRankings();
+
+ if (this.getMain().isEmpty()) {
+ return 0;
+ }
+
+ double best = 1.0;
+
+ for (int i = 0; i < this.getMain().toForgeCardList().size(); i++) {
+ CardPrinted evalCard = this.getMain().toFlatList().get(i);
+ if (ranker.getRanking(evalCard.getName(), evalCard.getEdition()) != null) {
+ double add = ranker.getRanking(evalCard.getName(), evalCard.getEdition());
+ // System.out.println(this.getMain().toFlatList().get(i).getName() + " is worth " + add);
+ value += add;
+ divider += 1.0;
+ if (best > add) {
+ best = add;
+ }
+ }
+ }
+
+ if (divider == 0 || value == 0) {
+ return 0;
+ }
+
+ value /= divider;
+
+ return (20.0 / (best + (2 * value)));
+ }
+
+
public static final Lambda1 FN_NAME_SELECTOR = new Lambda1() {
@Override
public String apply(Deck arg1) {
diff --git a/src/main/java/forge/deck/DeckGroup.java b/src/main/java/forge/deck/DeckGroup.java
index 123cd8f65a5..83153e125a7 100644
--- a/src/main/java/forge/deck/DeckGroup.java
+++ b/src/main/java/forge/deck/DeckGroup.java
@@ -18,6 +18,8 @@
package forge.deck;
import java.util.ArrayList;
+import java.util.TreeMap;
+// import java.lang.Double;
import java.util.List;
@@ -42,7 +44,7 @@ public class DeckGroup extends DeckBase {
private static final long serialVersionUID = -1628725522049635829L;
private Deck humanDeck;
- private final List aiDecks = new ArrayList();
+ private List aiDecks = new ArrayList();
/**
* Gets the human deck.
@@ -71,6 +73,35 @@ public class DeckGroup extends DeckBase {
this.humanDeck = humanDeck;
}
+ /**
+ * Evaluate and 'rank' the ai decks.
+ *
+ *
+ */
+ public final void rankAiDecks() {
+ if (this.aiDecks.size() < 2) {
+ return;
+ }
+
+ // double [] draftValues = new double [this.aiDecks.size()];
+ TreeMap draftData = new TreeMap();
+
+ for (int i = 0; i < this.aiDecks.size(); i++) {
+ // draftValues[i] = this.aiDecks.get(i).getDraftValue();
+ draftData.put(new Double(this.aiDecks.get(i).getDraftValue()), this.aiDecks.get(i));
+ // System.out.println("\nAI Deck " + i + "(" + this.aiDecks.get(i) + ") has draft value:" + this.aiDecks.get(i).getDraftValue() + "\n\n");
+ }
+
+ List sortedData = new ArrayList(draftData.values());
+
+ for (int j = 0; j < sortedData.size(); j++) {
+ Deck getDeck = sortedData.get(j);
+ }
+
+ this.aiDecks = sortedData;
+
+ }
+
@Override
protected void cloneFieldsTo(final DeckBase clone) {
super.cloneFieldsTo(clone);
diff --git a/src/main/java/forge/game/limited/GauntletMini.java b/src/main/java/forge/game/limited/GauntletMini.java
new file mode 100644
index 00000000000..2ad91faad92
--- /dev/null
+++ b/src/main/java/forge/game/limited/GauntletMini.java
@@ -0,0 +1,208 @@
+/*
+ * 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 .
+ */
+package forge.game.limited;
+
+import javax.swing.SwingUtilities;
+import javax.swing.SwingWorker;
+
+import forge.Constant;
+import forge.AllZone;
+import forge.Command;
+import forge.Singletons;
+import forge.control.FControl;
+import forge.deck.Deck;
+import forge.deck.DeckBase;
+import forge.deck.DeckGroup;
+import forge.game.GameNew;
+import forge.game.GameType;
+import forge.gui.GuiUtils;
+import forge.gui.SOverlayUtils;
+import forge.gui.deckeditor.CDeckEditorUI;
+import forge.gui.deckeditor.controllers.ACEditorBase;
+import forge.gui.deckeditor.controllers.CEditorLimited;
+import forge.gui.framework.ICDoc;
+import forge.gui.toolbox.FSkin;
+import forge.item.CardPrinted;
+import forge.item.ItemPool;
+import forge.properties.ForgeProps;
+import forge.properties.NewConstants;
+import forge.util.TextUtil;
+
+/**
+ *
+ * GauntletMini class.
+ *
+ *
+ * @author Forge
+ * @version $Id: GauntletMini.java $
+ * @since 1.2.xx
+ */
+public class GauntletMini {
+
+ private int rounds;
+ private Deck humanDeck;
+ private int currentRound;
+ private int wins;
+ private int losses;
+
+ // private final String humanName;
+ /**
+ * TODO: Write javadoc for Constructor.
+ */
+ public void gauntletMini() {
+ currentRound = 1;
+ wins = 0;
+ losses = 0;
+ // humanName = hName;
+ }
+
+ /**
+ * TODO: Write javadoc.
+ * @param gameRounds
+ * the number of rounds in the mini tournament
+ */
+
+ public void setRounds(int gameRounds) {
+ rounds = gameRounds;
+ }
+
+ /**
+ * TODO: Write javadoc.
+ * @param hDeck
+ * the human deck for this tournament
+ */
+ public void setHumanDeck(Deck hDeck) {
+ humanDeck = hDeck;
+ }
+
+ /**
+ * TODO: Write javadoc.
+ */
+ public void resetCurrentRound() {
+ wins = 0;
+ losses = 0;
+ Constant.Runtime.HUMAN_DECK[0] = humanDeck;
+ Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(humanDeck.getName()).getAiDecks().get(0);
+ currentRound = 1;
+ }
+
+
+ /**
+ * TODO: Write javadoc.
+ */
+ public void nextRound() {
+
+ // System.out.println("Moving from round " + currentRound + " to round " + currentRound + 1 + " of " + rounds);
+ if (currentRound >= rounds) {
+ currentRound = rounds;
+ return;
+ }
+
+ Constant.Runtime.HUMAN_DECK[0] = humanDeck;
+ Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(humanDeck.getName()).getAiDecks().get(currentRound);
+ currentRound += 1;
+
+ }
+
+ /**
+ * TODO: Write javadoc for this method.
+ * @param args
+ */
+ public void launch() {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ SOverlayUtils.startGameOverlay();
+ SOverlayUtils.showOverlay();
+ }
+ });
+
+ final SwingWorker