mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
Merge origin/master
This commit is contained in:
commit
72347ed59f
13 changed files with 106 additions and 84 deletions
|
@ -118,7 +118,7 @@
|
|||
</Group>
|
||||
</Group>
|
||||
<Component id="player1Panel" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="pnlChaosPacks" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="pnlRandomPacks" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -169,7 +169,7 @@
|
|||
<Group type="102" attributes="0">
|
||||
<Component id="pnlPacks" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="pnlChaosPacks" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="pnlRandomPacks" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
|
||||
|
@ -511,13 +511,14 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="pnlChaosPacks">
|
||||
<Container class="javax.swing.JPanel" name="pnlRandomPacks">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
|
||||
<EtchetBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||
|
|
|
@ -80,12 +80,12 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private UUID roomId;
|
||||
private final Session session;
|
||||
private String lastSessionId;
|
||||
private JList chaosList = new JList();
|
||||
private JList randomList = new JList();
|
||||
private final List<TournamentPlayerPanel> players = new ArrayList<>();
|
||||
private final List<JComboBox> packs = new ArrayList<>();
|
||||
private final List<String> chaosPacks = new ArrayList<>();
|
||||
private final int CONSTRUCTION_TIME_MIN = 6;
|
||||
private final int CONSTRUCTION_TIME_MAX = 30;
|
||||
private final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||
|
||||
private boolean automaticChange = false;
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
pnlOtherPlayers = new javax.swing.JPanel();
|
||||
btnOk = new javax.swing.JButton();
|
||||
btnCancel = new javax.swing.JButton();
|
||||
pnlChaosPacks = new javax.swing.JPanel();
|
||||
pnlRandomPacks = new javax.swing.JPanel();
|
||||
|
||||
setTitle("New Tournament");
|
||||
|
||||
|
@ -341,8 +341,9 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
});
|
||||
|
||||
pnlChaosPacks.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
pnlChaosPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
|
||||
pnlRandomPacks.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
pnlRandomPacks.setToolTipText("");
|
||||
pnlRandomPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
@ -426,7 +427,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)))))
|
||||
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(pnlChaosPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(pnlRandomPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
|
@ -469,7 +470,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(pnlPacks, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(pnlChaosPacks, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(pnlRandomPacks, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
|
@ -529,18 +530,19 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
if (tournamentType.isLimited()) {
|
||||
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
|
||||
tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
|
||||
if (tournamentType.isCubeBooster()) {
|
||||
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
||||
} else if (tournamentType.isChaos()){
|
||||
for (Integer pack: chaosList.getSelectedIndices()){
|
||||
String packStr = (String)chaosList.getModel().getElementAt(pack);
|
||||
} else if (tournamentType.isRandom()) {
|
||||
for (Object pack : randomList.getSelectedValuesList()) {
|
||||
String packStr = (String) pack;
|
||||
String code = packStr.substring(0, 3);
|
||||
tOptions.getLimitedOptions().getSetCodes().add(code);
|
||||
}
|
||||
if (tOptions.getLimitedOptions().getSetCodes().size() < 2){
|
||||
// At least two sets must be chosen.
|
||||
return;
|
||||
}
|
||||
if (tOptions.getLimitedOptions().getSetCodes().size() < 2) {
|
||||
// At least two sets must be chosen.
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
for (JComboBox pack: packs) {
|
||||
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
|
||||
|
@ -653,8 +655,8 @@ public class NewTournamentDialog extends MageDialog {
|
|||
createPlayers((Integer) spnNumPlayers.getValue() - 1);
|
||||
|
||||
if (tournamentType.isLimited()) {
|
||||
if (tournamentType.isChaos()){
|
||||
createChaosPacks();
|
||||
if (tournamentType.isRandom()){
|
||||
createRandomPacks();
|
||||
}else{
|
||||
createPacks(tournamentType.getNumBoosters());
|
||||
}
|
||||
|
@ -696,19 +698,19 @@ public class NewTournamentDialog extends MageDialog {
|
|||
this.cbDraftCube.setVisible(true);
|
||||
this.lblPacks.setVisible(false);
|
||||
this.pnlPacks.setVisible(false);
|
||||
this.pnlChaosPacks.setVisible(false);
|
||||
} else if (tournamentType.isChaos()){
|
||||
this.pnlRandomPacks.setVisible(false);
|
||||
} else if (tournamentType.isRandom()){
|
||||
this.lblDraftCube.setVisible(false);
|
||||
this.cbDraftCube.setVisible(false);
|
||||
this.lblPacks.setVisible(true);
|
||||
this.pnlChaosPacks.setVisible(true);
|
||||
this.pnlRandomPacks.setVisible(true);
|
||||
this.pnlPacks.setVisible(false);
|
||||
} else {
|
||||
this.lblDraftCube.setVisible(false);
|
||||
this.cbDraftCube.setVisible(false);
|
||||
this.lblPacks.setVisible(true);
|
||||
this.pnlPacks.setVisible(true);
|
||||
this.pnlChaosPacks.setVisible(false);
|
||||
this.pnlRandomPacks.setVisible(false);
|
||||
}
|
||||
} else {
|
||||
// construced
|
||||
|
@ -716,21 +718,24 @@ public class NewTournamentDialog extends MageDialog {
|
|||
this.cbDraftCube.setVisible(false);
|
||||
this.pnlPacks.setVisible(false);
|
||||
this.pnlPacks.setVisible(false);
|
||||
this.pnlChaosPacks.setVisible(false);
|
||||
this.pnlRandomPacks.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void createChaosPacks() {
|
||||
if (pnlChaosPacks.getComponentCount() == 0 ){
|
||||
DefaultListModel chaosListModel = new DefaultListModel();
|
||||
chaosList = new JList(chaosListModel);
|
||||
private void createRandomPacks() {
|
||||
if (pnlRandomPacks.getComponentCount() == 0) {
|
||||
|
||||
DefaultListModel randomListModel = new DefaultListModel();
|
||||
randomList = new JList(randomListModel);
|
||||
randomList.setToolTipText(randomDraftDescription);
|
||||
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||
for (ExpansionInfo expansion: allExpansions){
|
||||
for (ExpansionInfo expansion : allExpansions) {
|
||||
String exp = expansion.getCode() + " - " + expansion.getName();
|
||||
chaosListModel.addElement(exp);
|
||||
randomListModel.addElement(exp);
|
||||
}
|
||||
chaosList.setSelectionModel(new DefaultListSelectionModel() {
|
||||
randomList.setSelectionModel(new DefaultListSelectionModel() {
|
||||
private boolean mGestureStarted;
|
||||
|
||||
@Override
|
||||
public void setSelectionInterval(int index0, int index1) {
|
||||
// Toggle only one element while the user is dragging the mouse
|
||||
|
@ -760,16 +765,24 @@ private void createChaosPacks() {
|
|||
}
|
||||
}
|
||||
});
|
||||
chaosList.setSelectionInterval(0, chaosListModel.size()-1);
|
||||
JScrollPane list1scr = new JScrollPane(chaosList);
|
||||
chaosList.setVisibleRowCount(4);
|
||||
pnlChaosPacks.add(list1scr);
|
||||
|
||||
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, "");
|
||||
if (randomPrefs.length() > 0) {
|
||||
for (String exp : randomPrefs.split(";")) {
|
||||
randomList.setSelectedValue(exp, false);
|
||||
}
|
||||
} else {
|
||||
randomList.setSelectionInterval(0, randomListModel.size() - 1);
|
||||
}
|
||||
JScrollPane list1scr = new JScrollPane(randomList);
|
||||
randomList.setVisibleRowCount(4);
|
||||
pnlRandomPacks.add(list1scr);
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
|
||||
private void createPacks(int numPacks) {
|
||||
while (packs.size() > numPacks) {
|
||||
pnlPacks.remove(packs.get(packs.size() - 1));
|
||||
|
@ -916,7 +929,7 @@ private void createChaosPacks() {
|
|||
if (tournamentType.isDraft()) {
|
||||
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, "4"));
|
||||
setTournamentOptions(numPlayers);
|
||||
if (!tournamentType.isChaos()){
|
||||
if (!tournamentType.isRandom()){
|
||||
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, ""));
|
||||
}
|
||||
|
||||
|
@ -985,12 +998,20 @@ private void createChaosPacks() {
|
|||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, Integer.toString(tOptions.getPlayerTypes().size()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING, draftOptions.getTiming().name());
|
||||
}
|
||||
}
|
||||
if (tOptions.getTournamentType().startsWith("Booster")) {
|
||||
String deckFile = this.player1Panel.getDeckFile();
|
||||
if (deckFile != null && !deckFile.isEmpty()) {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile);
|
||||
}
|
||||
|
||||
if (tOptions.getLimitedOptions().getIsRandom()){
|
||||
// save random boosters to prefs
|
||||
StringBuilder packlist = new StringBuilder();
|
||||
for (Object pack: randomList.getSelectedValuesList()){
|
||||
packlist.append((String)pack);
|
||||
packlist.append(";");
|
||||
}
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, packlist.toString());
|
||||
}
|
||||
}
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, (tOptions.isWatchingAllowed()?"Yes":"No"));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS, (tOptions.getMatchOptions().isRollbackTurnsAllowed()?"Yes":"No"));
|
||||
|
@ -1031,11 +1052,11 @@ private void createChaosPacks() {
|
|||
private javax.swing.JLabel lblPlayer1;
|
||||
private javax.swing.JLabel lblTournamentType;
|
||||
private mage.client.table.NewPlayerPanel player1Panel;
|
||||
private javax.swing.JPanel pnlChaosPacks;
|
||||
private javax.swing.JPanel pnlDraftOptions;
|
||||
private javax.swing.JPanel pnlOtherPlayers;
|
||||
private javax.swing.JPanel pnlPacks;
|
||||
private javax.swing.JPanel pnlPlayers;
|
||||
private javax.swing.JPanel pnlRandomPacks;
|
||||
private javax.swing.JSpinner spnConstructTime;
|
||||
private javax.swing.JSpinner spnFreeMulligans;
|
||||
private javax.swing.JSpinner spnNumPlayers;
|
||||
|
|
|
@ -190,6 +190,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_NEW_TOURNAMENT_NUMBER_OF_WINS = "newTournamentNumberOfWins";
|
||||
public static final String KEY_NEW_TOURNAMENT_PACKS_SEALED = "newTournamentPacksSealed";
|
||||
public static final String KEY_NEW_TOURNAMENT_PACKS_DRAFT = "newTournamentPacksDraft";
|
||||
public static final String KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT = "newTournamentPacksRandomDraft";
|
||||
public static final String KEY_NEW_TOURNAMENT_PLAYERS_SEALED = "newTournamentPlayersSealed";
|
||||
public static final String KEY_NEW_TOURNAMENT_PLAYERS_DRAFT = "newTournamentPlayersDraft";
|
||||
public static final String KEY_NEW_TOURNAMENT_DRAFT_TIMING = "newTournamentDraftTiming";
|
||||
|
|
|
@ -153,10 +153,10 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
|
||||
public void updateDraft(DraftView draftView) {
|
||||
if (draftView.getSets().size() != 3){
|
||||
// Chaos draft
|
||||
this.txtPack1.setText("???");
|
||||
this.txtPack2.setText("???");
|
||||
this.txtPack3.setText("???");
|
||||
// Random draft
|
||||
this.txtPack1.setText("Random Boosters");
|
||||
this.txtPack2.setText("Random Boosters");
|
||||
this.txtPack3.setText("Random Boosters");
|
||||
}else{
|
||||
this.txtPack1.setText(draftView.getSets().get(0));
|
||||
this.txtPack2.setText(draftView.getSets().get(1));
|
||||
|
|
|
@ -46,7 +46,7 @@ public class TournamentTypeView implements Serializable {
|
|||
private final boolean limited;
|
||||
private final boolean cubeBooster;
|
||||
private final boolean elimination;
|
||||
private final boolean chaos;
|
||||
private final boolean random;
|
||||
|
||||
|
||||
public TournamentTypeView(TournamentType tournamentType) {
|
||||
|
@ -58,7 +58,7 @@ public class TournamentTypeView implements Serializable {
|
|||
this.limited = tournamentType.isLimited();
|
||||
this.cubeBooster = tournamentType.isCubeBooster();
|
||||
this.elimination = tournamentType.isElimination();
|
||||
this.chaos = tournamentType.isChaos();
|
||||
this.random = tournamentType.isRandom();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,7 +98,7 @@ public class TournamentTypeView implements Serializable {
|
|||
return elimination;
|
||||
}
|
||||
|
||||
public boolean isChaos(){
|
||||
return chaos;
|
||||
public boolean isRandom(){
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,23 +32,23 @@ import mage.constants.TournamentPlayerState;
|
|||
import mage.game.draft.DraftOptions;
|
||||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.tournament.TournamentPlayer;
|
||||
import mage.game.draft.ChaosBoosterDraft;
|
||||
import mage.game.draft.RandomBoosterDraft;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftEliminationTournament extends BoosterDraftEliminationTournament {
|
||||
public class RandomBoosterDraftEliminationTournament extends BoosterDraftEliminationTournament {
|
||||
|
||||
public ChaosBoosterDraftEliminationTournament(TournamentOptions options) {
|
||||
public RandomBoosterDraftEliminationTournament(TournamentOptions options) {
|
||||
super(options);
|
||||
currentStep = TournamentStep.START;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void draft() {
|
||||
draft = new ChaosBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
|
||||
draft = new RandomBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
|
||||
for (TournamentPlayer player: players.values()) {
|
||||
draft.addPlayer(player.getPlayer());
|
||||
player.setState(TournamentPlayerState.DRAFTING);
|
|
@ -34,10 +34,10 @@ import mage.game.tournament.TournamentType;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftEliminationTournamentType extends TournamentType {
|
||||
public class RandomBoosterDraftEliminationTournamentType extends TournamentType {
|
||||
|
||||
public ChaosBoosterDraftEliminationTournamentType() {
|
||||
this.name = "Booster Draft Elimination (Chaos)";
|
||||
public RandomBoosterDraftEliminationTournamentType() {
|
||||
this.name = "Booster Draft Elimination (Random)";
|
||||
this.maxPlayers = 16;
|
||||
this.minPlayers = 4;
|
||||
this.numBoosters = 3;
|
||||
|
@ -45,7 +45,7 @@ public class ChaosBoosterDraftEliminationTournamentType extends TournamentType {
|
|||
this.limited = true;
|
||||
this.cubeBooster = false;
|
||||
this.elimination = false;
|
||||
this.isChaos = true;
|
||||
this.isRandom = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -32,23 +32,23 @@ import mage.constants.TournamentPlayerState;
|
|||
import mage.game.draft.DraftOptions;
|
||||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.tournament.TournamentPlayer;
|
||||
import mage.game.draft.ChaosBoosterDraft;
|
||||
import mage.game.draft.RandomBoosterDraft;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftSwissTournament extends BoosterDraftSwissTournament {
|
||||
public class RandomBoosterDraftSwissTournament extends BoosterDraftSwissTournament {
|
||||
|
||||
public ChaosBoosterDraftSwissTournament(TournamentOptions options) {
|
||||
public RandomBoosterDraftSwissTournament(TournamentOptions options) {
|
||||
super(options);
|
||||
currentStep = TournamentStep.START;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void draft() {
|
||||
draft = new ChaosBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
|
||||
draft = new RandomBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
|
||||
for (TournamentPlayer player: players.values()) {
|
||||
draft.addPlayer(player.getPlayer());
|
||||
player.setState(TournamentPlayerState.DRAFTING);
|
|
@ -34,10 +34,10 @@ import mage.game.tournament.TournamentType;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftSwissTournamentType extends TournamentType {
|
||||
public class RandomBoosterDraftSwissTournamentType extends TournamentType {
|
||||
|
||||
public ChaosBoosterDraftSwissTournamentType() {
|
||||
this.name = "Booster Draft Swiss (Chaos)";
|
||||
public RandomBoosterDraftSwissTournamentType() {
|
||||
this.name = "Booster Draft Swiss (Random)";
|
||||
this.maxPlayers = 16;
|
||||
this.minPlayers = 4;
|
||||
this.numBoosters = 3;
|
||||
|
@ -45,7 +45,7 @@ public class ChaosBoosterDraftSwissTournamentType extends TournamentType {
|
|||
this.limited = true;
|
||||
this.cubeBooster = false;
|
||||
this.elimination = false;
|
||||
this.isChaos = true;
|
||||
this.isRandom = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -55,10 +55,10 @@
|
|||
<tournamentType name="Constructed Swiss" jar="mage-tournament-constructed.jar" className="mage.tournament.ConstructedSwissTournament" typeName="mage.tournament.ConstructedSwissTournamentType"/>
|
||||
<tournamentType name="Booster Draft Elimination" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Booster Draft Elimination (Cube)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationCubeTournamentType"/>
|
||||
<tournamentType name="Booster Draft Elimination (Chaos)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.ChaosBoosterDraftEliminationTournament" typeName="mage.tournament.ChaosBoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Booster Draft Elimination (Random)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.RandomBoosterDraftEliminationTournament" typeName="mage.tournament.RandomBoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Booster Draft Swiss" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissTournamentType"/>
|
||||
<tournamentType name="Booster Draft Swiss (Cube)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissCubeTournamentType"/>
|
||||
<tournamentType name="Booster Draft Swiss (Chaos)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.ChaosBoosterDraftSwissTournament" typeName="mage.tournament.ChaosBoosterDraftSwissTournamentType"/>
|
||||
<tournamentType name="Booster Draft Swiss (Random)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.RandomBoosterDraftSwissTournament" typeName="mage.tournament.RandomBoosterDraftSwissTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination (Cube)" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationCubeTournamentType"/>
|
||||
<tournamentType name="Sealed Swiss" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedSwissTournament" typeName="mage.tournament.SealedSwissTournamentType"/>
|
||||
|
|
|
@ -32,20 +32,19 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import mage.cards.ExpansionSet;
|
||||
import java.util.Collections;
|
||||
import java.lang.RuntimeException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BrodyLodmell_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraft extends BoosterDraft {
|
||||
public class RandomBoosterDraft extends BoosterDraft {
|
||||
|
||||
List<ExpansionSet> allSets;
|
||||
List<ExpansionSet> usedBoosters;
|
||||
public ChaosBoosterDraft(DraftOptions options, List<ExpansionSet> sets) {
|
||||
List<ExpansionSet> useBoosters;
|
||||
public RandomBoosterDraft(DraftOptions options, List<ExpansionSet> sets) {
|
||||
super(options, sets);
|
||||
if (sets.isEmpty()){
|
||||
throw new RuntimeException("At least one set must be selected for chaos booster draft");
|
||||
throw new RuntimeException("At least one set must be selected for random booster draft");
|
||||
}
|
||||
allSets = new ArrayList<>(sets);
|
||||
resetBoosters();
|
||||
|
@ -81,16 +80,16 @@ public class ChaosBoosterDraft extends BoosterDraft {
|
|||
}
|
||||
|
||||
private ExpansionSet getNextBooster() {
|
||||
if (0 == usedBoosters.size()){
|
||||
if (0 == useBoosters.size()){
|
||||
resetBoosters();
|
||||
}
|
||||
ExpansionSet theBooster = usedBoosters.get(0);
|
||||
usedBoosters.remove(theBooster);
|
||||
ExpansionSet theBooster = useBoosters.get(0);
|
||||
useBoosters.remove(theBooster);
|
||||
return theBooster;
|
||||
}
|
||||
|
||||
private void resetBoosters(){
|
||||
usedBoosters = new ArrayList<>(allSets);
|
||||
Collections.shuffle(usedBoosters);
|
||||
useBoosters = new ArrayList<>(allSets);
|
||||
Collections.shuffle(useBoosters);
|
||||
}
|
||||
}
|
|
@ -44,7 +44,7 @@ public class LimitedOptions implements Serializable {
|
|||
protected String draftCubeName;
|
||||
protected DraftCube draftCube;
|
||||
protected int numberBoosters;
|
||||
protected boolean isChaos;
|
||||
protected boolean isRandom;
|
||||
|
||||
public List<String> getSetCodes() {
|
||||
return sets;
|
||||
|
@ -82,10 +82,10 @@ public class LimitedOptions implements Serializable {
|
|||
this.numberBoosters = numberBoosters;
|
||||
}
|
||||
|
||||
public boolean getIsChaos(){
|
||||
return isChaos;
|
||||
public boolean getIsRandom(){
|
||||
return isRandom;
|
||||
}
|
||||
public void setIsChaos(boolean isChaos){
|
||||
this.isChaos = isChaos;
|
||||
public void setIsRandom(boolean isRandom){
|
||||
this.isRandom = isRandom;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TournamentType implements Serializable {
|
|||
protected boolean draft; // or sealed
|
||||
protected boolean limited; // or construced
|
||||
protected boolean elimination; // or Swiss
|
||||
protected boolean isChaos;
|
||||
protected boolean isRandom;
|
||||
|
||||
protected TournamentType() {}
|
||||
|
||||
|
@ -85,8 +85,8 @@ public class TournamentType implements Serializable {
|
|||
return cubeBooster;
|
||||
}
|
||||
|
||||
public boolean isChaos(){
|
||||
return this.isChaos;
|
||||
public boolean isRandom(){
|
||||
return this.isRandom;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue