Merge remote-tracking branch 'upstream/master'

This commit is contained in:
drmDev 2016-07-25 09:31:54 -04:00
commit 877106c2ad
5 changed files with 31 additions and 15 deletions

View file

@ -49,6 +49,7 @@ import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.SpinnerNumberModel;
import javax.swing.filechooser.FileFilter;
import mage.cards.decks.Deck;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository;
@ -58,6 +59,7 @@ import mage.constants.MatchTimeLimit;
import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.constants.SkillLevel;
import mage.game.GameException;
import mage.game.draft.DraftOptions;
import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
@ -559,7 +561,15 @@ public class NewTournamentDialog extends MageDialog {
if (tournamentType.isCubeBooster()) {
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
if (!(cubeFromDeckFilename.equals(""))) {
tOptions.getLimitedOptions().setCubeFromDeckFilename(cubeFromDeckFilename);
Deck cubeFromDeck = new Deck();
try {
cubeFromDeck = Deck.load(DeckImporterUtil.importDeck(cubeFromDeckFilename), true, true);
} catch (GameException e1) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
}
if (cubeFromDeck != null) {
tOptions.getLimitedOptions().setCubeFromDeck(cubeFromDeck);
}
}
} else if (tournamentType.isRandom() || tournamentType.isRichMan()) {
this.isRandom = tournamentType.isRandom();

View file

@ -27,6 +27,7 @@
*/
package mage.tournament.cubes;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardInfo;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.importer.DeckImporterUtil;
@ -39,14 +40,17 @@ import mage.game.draft.DraftCube;
*/
public class CubeFromDeck extends DraftCube {
public CubeFromDeck(String chosenDckFile) {
public CubeFromDeck(Deck cubeFromDeck) {
super("Cube From Deck");
DeckCardLists cards = DeckImporterUtil.importDeck(chosenDckFile);
DeckCardLists cards = null;
if (cubeFromDeck != null) {
cards = cubeFromDeck.getDeckCardLists();
}
if (cards != null) {
for (DeckCardInfo card : cards.getCards()) {
cubeCards.add(new CardIdentity(card.getCardName(), card.getSetCode()));
cubeCards.add(new CardIdentity(card.getCardName(), ""));
}
}
}

View file

@ -31,6 +31,7 @@ import java.lang.reflect.Constructor;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import mage.cards.decks.Deck;
import mage.game.draft.DraftCube;
import org.apache.log4j.Logger;
@ -67,13 +68,13 @@ public class CubeFactory {
return draftCube;
}
public DraftCube createDeckDraftCube(String draftCubeName, String chosenDckFile) {
public DraftCube createDeckDraftCube(String draftCubeName, Deck cubeFromDeck) {
DraftCube draftCube;
Constructor<?> con;
try {
con = draftCubes.get(draftCubeName).getConstructor(new Class[]{String.class});
draftCube = (DraftCube)con.newInstance(new Object[] {chosenDckFile});
con = draftCubes.get(draftCubeName).getConstructor(new Class[]{Deck.class});
draftCube = (DraftCube)con.newInstance(new Object[] {cubeFromDeck});
} catch (Exception ex) {
logger.fatal("CubeFactory error", ex);
return null;

View file

@ -81,8 +81,8 @@ public class TournamentFactory {
if (tournament.getTournamentType().isCubeBooster()) {
DraftCube draftCube = null;
if (tournament.getOptions().getLimitedOptions().getCubeFromDeckFilename().length() != 0) {
draftCube = CubeFactory.getInstance().createDeckDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName(), tournament.getOptions().getLimitedOptions().getCubeFromDeckFilename());
if (tournament.getOptions().getLimitedOptions().getCubeFromDeck() != null) {
draftCube = CubeFactory.getInstance().createDeckDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName(), tournament.getOptions().getLimitedOptions().getCubeFromDeck());
} else {
draftCube = CubeFactory.getInstance().createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName());
}

View file

@ -31,6 +31,7 @@ package mage.game.tournament;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mage.cards.decks.Deck;
import mage.game.draft.DraftCube;
/**
@ -45,7 +46,7 @@ public class LimitedOptions implements Serializable {
protected DraftCube draftCube;
protected int numberBoosters;
protected boolean isRandom;
protected String cubeFromDeckFilename = "";
protected Deck cubeFromDeck = null;
public List<String> getSetCodes() {
return sets;
@ -67,12 +68,12 @@ public class LimitedOptions implements Serializable {
this.draftCubeName = draftCubeName;
}
public void setCubeFromDeckFilename(String cubeFromDeckFilename) {
this.cubeFromDeckFilename = cubeFromDeckFilename;
public void setCubeFromDeck(Deck cubeFromDeck) {
this.cubeFromDeck = cubeFromDeck;
}
public String getCubeFromDeckFilename() {
return cubeFromDeckFilename;
public Deck getCubeFromDeck() {
return cubeFromDeck;
}
public DraftCube getDraftCube() {