spjspj - Update Rich Man draft to allow Random packs

This commit is contained in:
spjspj 2016-05-15 23:52:13 +10:00
parent 5ee4b5193e
commit f9e363fb30
7 changed files with 77 additions and 36 deletions

View file

@ -86,6 +86,8 @@ public class NewTournamentDialog extends MageDialog {
private final List<JComboBox> packs = new ArrayList<>(); private final List<JComboBox> packs = new ArrayList<>();
private final int CONSTRUCTION_TIME_MIN = 6; private final int CONSTRUCTION_TIME_MIN = 6;
private final int CONSTRUCTION_TIME_MAX = 30; private final int CONSTRUCTION_TIME_MAX = 30;
private boolean isRandom = false;
private boolean isRichMan = false;
private boolean automaticChange = false; private boolean automaticChange = false;
@ -315,7 +317,6 @@ public class NewTournamentDialog extends MageDialog {
spnConstructTime.setToolTipText("The time players have to build their deck."); spnConstructTime.setToolTipText("The time players have to build their deck.");
player1Panel.setPreferredSize(new java.awt.Dimension(400, 44)); player1Panel.setPreferredSize(new java.awt.Dimension(400, 44));
pnlOtherPlayers.setBorder(javax.swing.BorderFactory.createEtchedBorder()); pnlOtherPlayers.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1, 2, 0)); pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
@ -549,10 +550,15 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom()); tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
if (tournamentType.isCubeBooster()) { if (tournamentType.isCubeBooster()) {
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString()); tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
} else if (tournamentType.isRandom()) { } else if (tournamentType.isRandom() || tournamentType.isRichMan()) {
this.isRandom = tournamentType.isRandom();
this.isRichMan = tournamentType.isRichMan();
tOptions.getLimitedOptions().getSetCodes().clear(); tOptions.getLimitedOptions().getSetCodes().clear();
ArrayList<String> selected = randomPackSelector.getSelectedPacks(); ArrayList<String> selected = randomPackSelector.getSelectedPacks();
int maxPacks = 3 * (players.size() + 1); int maxPacks = 3 * (players.size() + 1);
if (tournamentType.isRichMan()) {
maxPacks = 36;
}
if (selected.size() > maxPacks ){ if (selected.size() > maxPacks ){
StringBuilder infoString = new StringBuilder("More sets were selected than needed. "); StringBuilder infoString = new StringBuilder("More sets were selected than needed. ");
infoString.append(maxPacks); infoString.append(maxPacks);
@ -675,7 +681,9 @@ public class NewTournamentDialog extends MageDialog {
createPlayers((Integer) spnNumPlayers.getValue() - 1); createPlayers((Integer) spnNumPlayers.getValue() - 1);
if (tournamentType.isLimited()) { if (tournamentType.isLimited()) {
if (tournamentType.isRandom()){ this.isRandom = tournamentType.isRandom();
this.isRichMan = tournamentType.isRichMan();
if (this.isRandom || this.isRichMan){
createRandomPacks(); createRandomPacks();
}else{ }else{
createPacks(tournamentType.getNumBoosters()); createPacks(tournamentType.getNumBoosters());
@ -719,7 +727,7 @@ public class NewTournamentDialog extends MageDialog {
this.lblPacks.setVisible(false); this.lblPacks.setVisible(false);
this.pnlPacks.setVisible(false); this.pnlPacks.setVisible(false);
this.pnlRandomPacks.setVisible(false); this.pnlRandomPacks.setVisible(false);
} else if (tournamentType.isRandom()){ } else if (tournamentType.isRandom() || tournamentType.isRichMan()){
this.lblDraftCube.setVisible(false); this.lblDraftCube.setVisible(false);
this.cbDraftCube.setVisible(false); this.cbDraftCube.setVisible(false);
this.lblPacks.setVisible(true); this.lblPacks.setVisible(true);
@ -745,7 +753,7 @@ public class NewTournamentDialog extends MageDialog {
private void createRandomPacks() { private void createRandomPacks() {
if (pnlRandomPacks.getComponentCount() == 0) { if (pnlRandomPacks.getComponentCount() == 0) {
if (randomPackSelector == null) { if (randomPackSelector == null) {
randomPackSelector = new RandomPacksSelectorDialog(); randomPackSelector = new RandomPacksSelectorDialog(isRandom, isRichMan);
randomPackSelector.setLocationRelativeTo(this); randomPackSelector.setLocationRelativeTo(this);
} }
txtRandomPacks = new JTextArea(); txtRandomPacks = new JTextArea();
@ -787,6 +795,7 @@ public class NewTournamentDialog extends MageDialog {
} }
private void showRandomPackSelectorDialog() { private void showRandomPackSelectorDialog() {
randomPackSelector.setType(isRandom, isRichMan);
randomPackSelector.showDialog(); randomPackSelector.showDialog();
StringBuilder packList = new StringBuilder(); StringBuilder packList = new StringBuilder();
for (String str : randomPackSelector.getSelectedPacks()) { for (String str : randomPackSelector.getSelectedPacks()) {
@ -945,7 +954,7 @@ public class NewTournamentDialog extends MageDialog {
if (tournamentType.isDraft()) { if (tournamentType.isDraft()) {
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, "4")); numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, "4"));
setTournamentOptions(numPlayers); setTournamentOptions(numPlayers);
if (!tournamentType.isRandom()){ if (!(tournamentType.isRandom() || tournamentType.isRichMan())){
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, "")); loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, ""));
} }

View file

@ -22,15 +22,30 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
* Creates new form RandomPacksSelectorDialog * Creates new form RandomPacksSelectorDialog
*/ */
private boolean boxesCreated; private boolean boxesCreated;
private boolean isRandomDraft;
private boolean isRichManDraft;
private String title = "";
public final static String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided."); public final static String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
public RandomPacksSelectorDialog() { public RandomPacksSelectorDialog(boolean isRandomDraft, boolean isRichManDraft) {
initComponents(); initComponents();
setType(isRandomDraft, isRichManDraft);
this.pnlApply.setToolTipText(randomDraftDescription); this.pnlApply.setToolTipText(randomDraftDescription);
this.pnlSelect.setToolTipText(randomDraftDescription); this.pnlSelect.setToolTipText(randomDraftDescription);
boxesCreated = false; boxesCreated = false;
} }
public void setType(boolean isRandomDraft, boolean isRichManDraft) {
this.isRandomDraft = isRandomDraft;
this.isRichManDraft = isRichManDraft;
if (this.isRandomDraft) {
title = "Random Booster Draft Packs Selector";
} else if (this.isRichManDraft) {
title = "Rich Man Booster Draft Packs Selector";
}
setTitle(title);
}
public void showDialog() { public void showDialog() {
createCheckboxes(); createCheckboxes();
pnlPacks.setVisible(true); pnlPacks.setVisible(true);
@ -103,7 +118,7 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
btnApply = new javax.swing.JButton(); btnApply = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle("Random Booster Draft Packs Selector"); setTitle(title);
setModal(true); setModal(true);
setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE); setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
setPreferredSize(new java.awt.Dimension(600, 450)); setPreferredSize(new java.awt.Dimension(600, 450));
@ -138,7 +153,11 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
pnlApply.setLayout(new javax.swing.BoxLayout(pnlApply, javax.swing.BoxLayout.LINE_AXIS)); pnlApply.setLayout(new javax.swing.BoxLayout(pnlApply, javax.swing.BoxLayout.LINE_AXIS));
btnApply.setText("Apply"); btnApply.setText("Apply");
btnApply.setToolTipText("At least two packs must be selected"); if (isRandomDraft) {
btnApply.setToolTipText("At least 2 packs must be selected");
} else if (isRichManDraft) {
btnApply.setToolTipText("At least 1 pack must be selected");
}
btnApply.addActionListener(new java.awt.event.ActionListener() { btnApply.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnApplyActionPerformed(evt); btnApplyActionPerformed(evt);
@ -189,8 +208,10 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
}//GEN-LAST:event_formWindowClosing }//GEN-LAST:event_formWindowClosing
public void doApply() { public void doApply() {
if (getSelectedPacks().size() < 2) { if (getSelectedPacks().size() < 2 && isRandomDraft) {
JOptionPane.showMessageDialog(this, "At least 2 sets must be selected", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this, "At least 2 sets must be selected", "Error", JOptionPane.ERROR_MESSAGE);
} else if (getSelectedPacks().size() < 1 && isRichManDraft) {
JOptionPane.showMessageDialog(this, "At least 1 set must be selected", "Error", JOptionPane.ERROR_MESSAGE);
} else { } else {
this.setVisible(false); this.setVisible(false);
} }

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.view; package mage.view;
import java.io.Serializable; import java.io.Serializable;
@ -36,6 +35,7 @@ import mage.game.tournament.TournamentType;
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class TournamentTypeView implements Serializable { public class TournamentTypeView implements Serializable {
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
private final String name; private final String name;
@ -47,7 +47,7 @@ public class TournamentTypeView implements Serializable {
private final boolean cubeBooster; private final boolean cubeBooster;
private final boolean elimination; private final boolean elimination;
private final boolean random; private final boolean random;
private final boolean richMan;
public TournamentTypeView(TournamentType tournamentType) { public TournamentTypeView(TournamentType tournamentType) {
this.name = tournamentType.getName(); this.name = tournamentType.getName();
@ -59,6 +59,7 @@ public class TournamentTypeView implements Serializable {
this.cubeBooster = tournamentType.isCubeBooster(); this.cubeBooster = tournamentType.isCubeBooster();
this.elimination = tournamentType.isElimination(); this.elimination = tournamentType.isElimination();
this.random = tournamentType.isRandom(); this.random = tournamentType.isRandom();
this.richMan = tournamentType.isRichMan();
} }
@Override @Override
@ -98,7 +99,11 @@ public class TournamentTypeView implements Serializable {
return elimination; return elimination;
} }
public boolean isRandom(){ public boolean isRandom() {
return random; return random;
} }
public boolean isRichMan() {
return richMan;
}
} }

View file

@ -44,7 +44,8 @@ public class RichManDraftEliminationTournamentType extends TournamentType {
this.limited = true; this.limited = true;
this.cubeBooster = false; this.cubeBooster = false;
this.elimination = true; this.elimination = true;
this.isRandom = true; this.isRandom = false;
this.isRichMan = true;
} }
} }

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.game.tournament; package mage.game.tournament;
import java.io.Serializable; import java.io.Serializable;
@ -45,8 +44,10 @@ public class TournamentType implements Serializable {
protected boolean limited; // or construced protected boolean limited; // or construced
protected boolean elimination; // or Swiss protected boolean elimination; // or Swiss
protected boolean isRandom; protected boolean isRandom;
protected boolean isRichMan = false; // or Rich Man Draft
protected TournamentType() {} protected TournamentType() {
}
@Override @Override
public String toString() { public String toString() {
@ -85,8 +86,12 @@ public class TournamentType implements Serializable {
return cubeBooster; return cubeBooster;
} }
public boolean isRandom(){ public boolean isRandom() {
return this.isRandom; return this.isRandom;
} }
public boolean isRichMan() {
return this.isRichMan;
}
} }