mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
877106c2ad
5 changed files with 31 additions and 15 deletions
|
@ -49,6 +49,7 @@ import javax.swing.JOptionPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
import mage.cards.decks.Deck;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.cards.repository.ExpansionInfo;
|
import mage.cards.repository.ExpansionInfo;
|
||||||
import mage.cards.repository.ExpansionRepository;
|
import mage.cards.repository.ExpansionRepository;
|
||||||
|
@ -58,6 +59,7 @@ import mage.constants.MatchTimeLimit;
|
||||||
import mage.constants.MultiplayerAttackOption;
|
import mage.constants.MultiplayerAttackOption;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
import mage.constants.SkillLevel;
|
import mage.constants.SkillLevel;
|
||||||
|
import mage.game.GameException;
|
||||||
import mage.game.draft.DraftOptions;
|
import mage.game.draft.DraftOptions;
|
||||||
import mage.game.draft.DraftOptions.TimingOption;
|
import mage.game.draft.DraftOptions.TimingOption;
|
||||||
import mage.game.tournament.LimitedOptions;
|
import mage.game.tournament.LimitedOptions;
|
||||||
|
@ -559,7 +561,15 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
if (tournamentType.isCubeBooster()) {
|
if (tournamentType.isCubeBooster()) {
|
||||||
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
||||||
if (!(cubeFromDeckFilename.equals(""))) {
|
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()) {
|
} else if (tournamentType.isRandom() || tournamentType.isRichMan()) {
|
||||||
this.isRandom = tournamentType.isRandom();
|
this.isRandom = tournamentType.isRandom();
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package mage.tournament.cubes;
|
package mage.tournament.cubes;
|
||||||
|
|
||||||
|
import mage.cards.decks.Deck;
|
||||||
import mage.cards.decks.DeckCardInfo;
|
import mage.cards.decks.DeckCardInfo;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
|
@ -39,14 +40,17 @@ import mage.game.draft.DraftCube;
|
||||||
*/
|
*/
|
||||||
public class CubeFromDeck extends DraftCube {
|
public class CubeFromDeck extends DraftCube {
|
||||||
|
|
||||||
public CubeFromDeck(String chosenDckFile) {
|
public CubeFromDeck(Deck cubeFromDeck) {
|
||||||
super("Cube From Deck");
|
super("Cube From Deck");
|
||||||
|
|
||||||
DeckCardLists cards = DeckImporterUtil.importDeck(chosenDckFile);
|
DeckCardLists cards = null;
|
||||||
|
if (cubeFromDeck != null) {
|
||||||
|
cards = cubeFromDeck.getDeckCardLists();
|
||||||
|
}
|
||||||
|
|
||||||
if (cards != null) {
|
if (cards != null) {
|
||||||
for (DeckCardInfo card : cards.getCards()) {
|
for (DeckCardInfo card : cards.getCards()) {
|
||||||
cubeCards.add(new CardIdentity(card.getCardName(), card.getSetCode()));
|
cubeCards.add(new CardIdentity(card.getCardName(), ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.lang.reflect.Constructor;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.draft.DraftCube;
|
import mage.game.draft.DraftCube;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
@ -67,13 +68,13 @@ public class CubeFactory {
|
||||||
return draftCube;
|
return draftCube;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DraftCube createDeckDraftCube(String draftCubeName, String chosenDckFile) {
|
public DraftCube createDeckDraftCube(String draftCubeName, Deck cubeFromDeck) {
|
||||||
|
|
||||||
DraftCube draftCube;
|
DraftCube draftCube;
|
||||||
Constructor<?> con;
|
Constructor<?> con;
|
||||||
try {
|
try {
|
||||||
con = draftCubes.get(draftCubeName).getConstructor(new Class[]{String.class});
|
con = draftCubes.get(draftCubeName).getConstructor(new Class[]{Deck.class});
|
||||||
draftCube = (DraftCube)con.newInstance(new Object[] {chosenDckFile});
|
draftCube = (DraftCube)con.newInstance(new Object[] {cubeFromDeck});
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.fatal("CubeFactory error", ex);
|
logger.fatal("CubeFactory error", ex);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class TournamentFactory {
|
||||||
if (tournament.getTournamentType().isCubeBooster()) {
|
if (tournament.getTournamentType().isCubeBooster()) {
|
||||||
DraftCube draftCube = null;
|
DraftCube draftCube = null;
|
||||||
|
|
||||||
if (tournament.getOptions().getLimitedOptions().getCubeFromDeckFilename().length() != 0) {
|
if (tournament.getOptions().getLimitedOptions().getCubeFromDeck() != null) {
|
||||||
draftCube = CubeFactory.getInstance().createDeckDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName(), tournament.getOptions().getLimitedOptions().getCubeFromDeckFilename());
|
draftCube = CubeFactory.getInstance().createDeckDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName(), tournament.getOptions().getLimitedOptions().getCubeFromDeck());
|
||||||
} else {
|
} else {
|
||||||
draftCube = CubeFactory.getInstance().createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName());
|
draftCube = CubeFactory.getInstance().createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ package mage.game.tournament;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.draft.DraftCube;
|
import mage.game.draft.DraftCube;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +46,7 @@ public class LimitedOptions implements Serializable {
|
||||||
protected DraftCube draftCube;
|
protected DraftCube draftCube;
|
||||||
protected int numberBoosters;
|
protected int numberBoosters;
|
||||||
protected boolean isRandom;
|
protected boolean isRandom;
|
||||||
protected String cubeFromDeckFilename = "";
|
protected Deck cubeFromDeck = null;
|
||||||
|
|
||||||
public List<String> getSetCodes() {
|
public List<String> getSetCodes() {
|
||||||
return sets;
|
return sets;
|
||||||
|
@ -67,12 +68,12 @@ public class LimitedOptions implements Serializable {
|
||||||
this.draftCubeName = draftCubeName;
|
this.draftCubeName = draftCubeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCubeFromDeckFilename(String cubeFromDeckFilename) {
|
public void setCubeFromDeck(Deck cubeFromDeck) {
|
||||||
this.cubeFromDeckFilename = cubeFromDeckFilename;
|
this.cubeFromDeck = cubeFromDeck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCubeFromDeckFilename() {
|
public Deck getCubeFromDeck() {
|
||||||
return cubeFromDeckFilename;
|
return cubeFromDeck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DraftCube getDraftCube() {
|
public DraftCube getDraftCube() {
|
||||||
|
|
Loading…
Reference in a new issue