mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
chaos booster draft implementation first check-in
This commit is contained in:
parent
8685c67679
commit
e3b84eaab5
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue