mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Merge pull request #1048 from brodee/master
Chaos booster draft implementation
This commit is contained in:
commit
0a3c081ded
12 changed files with 462 additions and 14 deletions
|
@ -118,6 +118,7 @@
|
|||
</Group>
|
||||
</Group>
|
||||
<Component id="player1Panel" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="pnlChaosPacks" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -168,6 +169,8 @@
|
|||
<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"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
|
||||
<Component id="cbAllowSpectators" alignment="3" max="32767" attributes="0"/>
|
||||
|
@ -188,7 +191,7 @@
|
|||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="player1Panel" pref="64" max="32767" attributes="0"/>
|
||||
<Component id="player1Panel" pref="61" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="pnlPlayers" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
|
@ -470,7 +473,7 @@
|
|||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="pnlOtherPlayers" alignment="0" pref="7" max="32767" attributes="0"/>
|
||||
<Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
|
@ -508,5 +511,20 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="pnlChaosPacks">
|
||||
<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>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||
<Property name="columns" type="int" value="1"/>
|
||||
<Property name="horizontalGap" type="int" value="2"/>
|
||||
<Property name="rows" type="int" value="0"/>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
|
|
@ -39,8 +39,13 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.DefaultListSelectionModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import static javax.swing.ListSelectionModel.SINGLE_SELECTION;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
|
@ -75,8 +80,10 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private UUID roomId;
|
||||
private final Session session;
|
||||
private String lastSessionId;
|
||||
private JList chaosList = 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;
|
||||
|
||||
|
@ -171,6 +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();
|
||||
|
||||
setTitle("New Tournament");
|
||||
|
||||
|
@ -316,7 +324,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
);
|
||||
pnlPlayersLayout.setVerticalGroup(
|
||||
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 7, Short.MAX_VALUE)
|
||||
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
btnOk.setText("OK");
|
||||
|
@ -333,6 +341,9 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
});
|
||||
|
||||
pnlChaosPacks.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
pnlChaosPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
|
@ -414,7 +425,8 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addComponent(lblPassword)
|
||||
.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(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))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
|
@ -457,6 +469,8 @@ 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)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cbAllowSpectators, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
|
@ -464,7 +478,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addComponent(lblNumRounds))
|
||||
.addComponent(lblNbrPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(spnNumPlayers)
|
||||
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
|
||||
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblPlayer1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
|
@ -472,7 +486,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addComponent(lblConstructionTime)
|
||||
.addComponent(chkRollbackTurnsAllowed)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
|
||||
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
|
@ -517,6 +531,16 @@ public class NewTournamentDialog extends MageDialog {
|
|||
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
for (JComboBox pack: packs) {
|
||||
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
|
||||
|
@ -629,7 +653,11 @@ public class NewTournamentDialog extends MageDialog {
|
|||
createPlayers((Integer) spnNumPlayers.getValue() - 1);
|
||||
|
||||
if (tournamentType.isLimited()) {
|
||||
createPacks(tournamentType.getNumBoosters());
|
||||
if (tournamentType.isChaos()){
|
||||
createChaosPacks();
|
||||
}else{
|
||||
createPacks(tournamentType.getNumBoosters());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -668,11 +696,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.lblDraftCube.setVisible(false);
|
||||
this.cbDraftCube.setVisible(false);
|
||||
this.lblPacks.setVisible(true);
|
||||
this.pnlChaosPacks.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);
|
||||
}
|
||||
} else {
|
||||
// construced
|
||||
|
@ -680,9 +716,60 @@ public class NewTournamentDialog extends MageDialog {
|
|||
this.cbDraftCube.setVisible(false);
|
||||
this.pnlPacks.setVisible(false);
|
||||
this.pnlPacks.setVisible(false);
|
||||
this.pnlChaosPacks.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void createChaosPacks() {
|
||||
if (pnlChaosPacks.getComponentCount() == 0 ){
|
||||
DefaultListModel chaosListModel = new DefaultListModel();
|
||||
chaosList = new JList(chaosListModel);
|
||||
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||
for (ExpansionInfo expansion: allExpansions){
|
||||
String exp = expansion.getCode() + " - " + expansion.getName();
|
||||
chaosListModel.addElement(exp);
|
||||
}
|
||||
chaosList.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
|
||||
if (!mGestureStarted) {
|
||||
if (isSelectedIndex(index0)) {
|
||||
super.removeSelectionInterval(index0, index1);
|
||||
} else {
|
||||
if (getSelectionMode() == SINGLE_SELECTION) {
|
||||
super.setSelectionInterval(index0, index1);
|
||||
} else {
|
||||
super.addSelectionInterval(index0, index1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Disable toggling till the adjusting is over, or keep it
|
||||
// enabled in case setSelectionInterval was called directly.
|
||||
mGestureStarted = getValueIsAdjusting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueIsAdjusting(boolean isAdjusting) {
|
||||
super.setValueIsAdjusting(isAdjusting);
|
||||
|
||||
if (isAdjusting == false) {
|
||||
// Enable toggling
|
||||
mGestureStarted = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
chaosList.setSelectionInterval(0, chaosListModel.size()-1);
|
||||
JScrollPane list1scr = new JScrollPane(chaosList);
|
||||
chaosList.setVisibleRowCount(4);
|
||||
pnlChaosPacks.add(list1scr);
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void createPacks(int numPacks) {
|
||||
while (packs.size() > numPacks) {
|
||||
pnlPacks.remove(packs.get(packs.size() - 1));
|
||||
|
@ -829,7 +916,9 @@ public class NewTournamentDialog extends MageDialog {
|
|||
if (tournamentType.isDraft()) {
|
||||
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, "4"));
|
||||
setTournamentOptions(numPlayers);
|
||||
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, ""));
|
||||
if (!tournamentType.isChaos()){
|
||||
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, ""));
|
||||
}
|
||||
|
||||
String draftTiming = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING, "REGULAR");
|
||||
for (TimingOption timingOption : DraftOptions.TimingOption.values()) {
|
||||
|
@ -942,6 +1031,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
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;
|
||||
|
|
|
@ -152,9 +152,16 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void updateDraft(DraftView draftView) {
|
||||
this.txtPack1.setText(draftView.getSets().get(0));
|
||||
this.txtPack2.setText(draftView.getSets().get(1));
|
||||
this.txtPack3.setText(draftView.getSets().get(2));
|
||||
if (draftView.getSets().size() != 3){
|
||||
// Chaos draft
|
||||
this.txtPack1.setText("???");
|
||||
this.txtPack2.setText("???");
|
||||
this.txtPack3.setText("???");
|
||||
}else{
|
||||
this.txtPack1.setText(draftView.getSets().get(0));
|
||||
this.txtPack2.setText(draftView.getSets().get(1));
|
||||
this.txtPack3.setText(draftView.getSets().get(2));
|
||||
}
|
||||
this.chkPack1.setSelected(draftView.getBoosterNum() > 0);
|
||||
this.chkPack2.setSelected(draftView.getBoosterNum() > 1);
|
||||
this.chkPack3.setSelected(draftView.getBoosterNum() > 2);
|
||||
|
|
|
@ -36,7 +36,7 @@ import mage.game.tournament.TournamentType;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TournamentTypeView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
private final String name;
|
||||
private final int minPlayers;
|
||||
|
@ -46,6 +46,7 @@ public class TournamentTypeView implements Serializable {
|
|||
private final boolean limited;
|
||||
private final boolean cubeBooster;
|
||||
private final boolean elimination;
|
||||
private final boolean chaos;
|
||||
|
||||
|
||||
public TournamentTypeView(TournamentType tournamentType) {
|
||||
|
@ -57,6 +58,7 @@ public class TournamentTypeView implements Serializable {
|
|||
this.limited = tournamentType.isLimited();
|
||||
this.cubeBooster = tournamentType.isCubeBooster();
|
||||
this.elimination = tournamentType.isElimination();
|
||||
this.chaos = tournamentType.isChaos();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,4 +98,7 @@ public class TournamentTypeView implements Serializable {
|
|||
return elimination;
|
||||
}
|
||||
|
||||
public boolean isChaos(){
|
||||
return chaos;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.tournament;
|
||||
|
||||
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.tournament.TournamentOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftEliminationTournament extends BoosterDraftEliminationTournament {
|
||||
|
||||
public ChaosBoosterDraftEliminationTournament(TournamentOptions options) {
|
||||
super(options);
|
||||
currentStep = TournamentStep.START;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void draft() {
|
||||
draft = new ChaosBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
|
||||
for (TournamentPlayer player: players.values()) {
|
||||
draft.addPlayer(player.getPlayer());
|
||||
player.setState(TournamentPlayerState.DRAFTING);
|
||||
}
|
||||
tableEventSource.fireTableEvent(EventType.START_DRAFT, null, draft);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.tournament;
|
||||
|
||||
import mage.game.tournament.TournamentType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftEliminationTournamentType extends TournamentType {
|
||||
|
||||
public ChaosBoosterDraftEliminationTournamentType() {
|
||||
this.name = "Booster Draft Elimination (Chaos)";
|
||||
this.maxPlayers = 16;
|
||||
this.minPlayers = 4;
|
||||
this.numBoosters = 3;
|
||||
this.draft = true;
|
||||
this.limited = true;
|
||||
this.cubeBooster = false;
|
||||
this.elimination = false;
|
||||
this.isChaos = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.tournament;
|
||||
|
||||
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.tournament.TournamentOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftSwissTournament extends BoosterDraftSwissTournament {
|
||||
|
||||
public ChaosBoosterDraftSwissTournament(TournamentOptions options) {
|
||||
super(options);
|
||||
currentStep = TournamentStep.START;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void draft() {
|
||||
draft = new ChaosBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
|
||||
for (TournamentPlayer player: players.values()) {
|
||||
draft.addPlayer(player.getPlayer());
|
||||
player.setState(TournamentPlayerState.DRAFTING);
|
||||
}
|
||||
tableEventSource.fireTableEvent(EventType.START_DRAFT, null, draft);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.tournament;
|
||||
|
||||
import mage.game.tournament.TournamentType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ChaosBoosterDraftSwissTournamentType extends TournamentType {
|
||||
|
||||
public ChaosBoosterDraftSwissTournamentType() {
|
||||
this.name = "Booster Draft Swiss (Chaos)";
|
||||
this.maxPlayers = 16;
|
||||
this.minPlayers = 4;
|
||||
this.numBoosters = 3;
|
||||
this.draft = true;
|
||||
this.limited = true;
|
||||
this.cubeBooster = false;
|
||||
this.elimination = false;
|
||||
this.isChaos = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -55,8 +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 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="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"/>
|
||||
|
|
96
Mage/src/mage/game/draft/ChaosBoosterDraft.java
Normal file
96
Mage/src/mage/game/draft/ChaosBoosterDraft.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.game.draft;
|
||||
|
||||
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 {
|
||||
|
||||
List<ExpansionSet> allSets;
|
||||
List<ExpansionSet> usedBoosters;
|
||||
public ChaosBoosterDraft(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");
|
||||
}
|
||||
allSets = new ArrayList<>(sets);
|
||||
resetBoosters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
while (!isAbort() && boosterNum < numberBoosters) {
|
||||
openBooster();
|
||||
while (!isAbort() && pickCards()) {
|
||||
if (boosterNum % 2 == 1) {
|
||||
passLeft();
|
||||
} else {
|
||||
passRight();
|
||||
}
|
||||
fireUpdatePlayersEvent();
|
||||
}
|
||||
}
|
||||
resetBufferedCards();
|
||||
this.fireEndDraftEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openBooster() {
|
||||
if (boosterNum < numberBoosters) {
|
||||
for (DraftPlayer player: players.values()) {
|
||||
player.setBooster(getNextBooster().createBooster());
|
||||
}
|
||||
}
|
||||
boosterNum++;
|
||||
cardNum = 1;
|
||||
fireUpdatePlayersEvent();
|
||||
}
|
||||
|
||||
private ExpansionSet getNextBooster() {
|
||||
if (0 == usedBoosters.size()){
|
||||
resetBoosters();
|
||||
}
|
||||
ExpansionSet theBooster = usedBoosters.get(0);
|
||||
usedBoosters.remove(theBooster);
|
||||
return theBooster;
|
||||
}
|
||||
|
||||
private void resetBoosters(){
|
||||
usedBoosters = new ArrayList<>(allSets);
|
||||
Collections.shuffle(usedBoosters);
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ public class LimitedOptions implements Serializable {
|
|||
protected String draftCubeName;
|
||||
protected DraftCube draftCube;
|
||||
protected int numberBoosters;
|
||||
protected boolean isChaos;
|
||||
|
||||
public List<String> getSetCodes() {
|
||||
return sets;
|
||||
|
@ -80,5 +81,11 @@ public class LimitedOptions implements Serializable {
|
|||
public void setNumberBoosters(int numberBoosters) {
|
||||
this.numberBoosters = numberBoosters;
|
||||
}
|
||||
|
||||
|
||||
public boolean getIsChaos(){
|
||||
return isChaos;
|
||||
}
|
||||
public void setIsChaos(boolean isChaos){
|
||||
this.isChaos = isChaos;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +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 TournamentType() {}
|
||||
|
||||
|
@ -83,5 +84,9 @@ public class TournamentType implements Serializable {
|
|||
public boolean isCubeBooster() {
|
||||
return cubeBooster;
|
||||
}
|
||||
|
||||
|
||||
public boolean isChaos(){
|
||||
return this.isChaos;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue