mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
New feature: "Chaos Remixed" booster draft (#10328)
* Fix error in draft pick logger that was failing on chaos drafts with fewer than 3 sets * Implement Remixed Booster Draft * Add debug test * minor cleanup * Cleanup unnecessary checks * Fix elimination tournament type * Add note for future improvement
This commit is contained in:
parent
6d4e353867
commit
4cc9329b15
20 changed files with 437 additions and 47 deletions
|
|
@ -55,6 +55,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private static final int CONSTRUCTION_TIME_MAX = 30;
|
||||
private boolean isRandom = false;
|
||||
private boolean isRichMan = false;
|
||||
private boolean isRemixed = false;
|
||||
private String cubeFromDeckFilename = "";
|
||||
private String jumpstartPacksFilename = "";
|
||||
private boolean automaticChange = false;
|
||||
|
|
@ -679,11 +680,11 @@ public class NewTournamentDialog extends MageDialog {
|
|||
|
||||
// CHECKS
|
||||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||
if (tournamentType.isRandom() || tournamentType.isRichMan()) {
|
||||
if (tOptions.getLimitedOptions().getSetCodes().size() < tournamentType.getNumBoosters()) {
|
||||
if (tournamentType.isRandom() || tournamentType.isRichMan() || tournamentType.isRemixed()) {
|
||||
if (tOptions.getLimitedOptions().getSetCodes().size() < 1) {
|
||||
JOptionPane.showMessageDialog(
|
||||
MageFrame.getDesktop(),
|
||||
String.format("Warning, you must select %d packs for the pool", tournamentType.getNumBoosters()),
|
||||
"Warning, you must select at least one set for the pool",
|
||||
"Warning",
|
||||
JOptionPane.WARNING_MESSAGE
|
||||
);
|
||||
|
|
@ -916,7 +917,8 @@ public class NewTournamentDialog extends MageDialog {
|
|||
if (tournamentType.isLimited()) {
|
||||
this.isRandom = tournamentType.isRandom();
|
||||
this.isRichMan = tournamentType.isRichMan();
|
||||
if (this.isRandom || this.isRichMan) {
|
||||
this.isRemixed = tournamentType.isRemixed();
|
||||
if (this.isRandom || this.isRichMan || this.isRemixed) {
|
||||
createRandomPacks();
|
||||
} else {
|
||||
createPacks(tournamentType.getNumBoosters());
|
||||
|
|
@ -960,7 +962,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
this.lblPacks.setVisible(false);
|
||||
this.pnlPacks.setVisible(false);
|
||||
this.pnlRandomPacks.setVisible(false);
|
||||
} else if (tournamentType.isRandom() || tournamentType.isRichMan()) {
|
||||
} else if (tournamentType.isRandom() || tournamentType.isRichMan() || tournamentType.isRemixed()) {
|
||||
this.lblDraftCube.setVisible(false);
|
||||
this.cbDraftCube.setVisible(false);
|
||||
this.lblPacks.setVisible(true);
|
||||
|
|
@ -1031,7 +1033,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
pnlRandomPacks.add(txtRandomPacks);
|
||||
JButton btnSelectRandomPacks = new JButton();
|
||||
btnSelectRandomPacks.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
btnSelectRandomPacks.setText("Select packs to be included in the pool");
|
||||
btnSelectRandomPacks.setText("Select sets to be included in the pool");
|
||||
btnSelectRandomPacks.setToolTipText(RandomPacksSelectorDialog.randomDraftDescription);
|
||||
btnSelectRandomPacks.addActionListener(evt -> showRandomPackSelectorDialog());
|
||||
pnlRandomPacks.add(btnSelectRandomPacks);
|
||||
|
|
@ -1044,8 +1046,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
|
||||
private void showRandomPackSelectorDialog() {
|
||||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||
randomPackSelector.showDialog(isRandom, isRichMan, tournamentType.getNumBoosters());
|
||||
randomPackSelector.showDialog(isRandom, isRichMan, isRemixed);
|
||||
this.txtRandomPacks.setText(String.join(";", randomPackSelector.getSelectedPacks()));
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
|
|
@ -1248,6 +1249,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
if (tournamentType.isLimited()) {
|
||||
tOptions.getLimitedOptions().setConstructionTime((Integer) this.spnConstructTime.getValue() * 60);
|
||||
tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
|
||||
tOptions.getLimitedOptions().setIsRemixed(tournamentType.isRemixed());
|
||||
tOptions.getLimitedOptions().setIsRichMan(tournamentType.isRichMan());
|
||||
tOptions.getLimitedOptions().setIsJumpstart(tournamentType.isJumpstart());
|
||||
|
||||
|
|
@ -1283,6 +1285,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
} else if (tournamentType.isRandom() || tournamentType.isRichMan()) {
|
||||
this.isRandom = tournamentType.isRandom();
|
||||
this.isRichMan = tournamentType.isRichMan();
|
||||
this.isRemixed = tournamentType.isRemixed();
|
||||
tOptions.getLimitedOptions().getSetCodes().clear();
|
||||
java.util.List<String> selected = randomPackSelector.getSelectedPacks();
|
||||
Collections.shuffle(selected);
|
||||
|
|
@ -1299,6 +1302,12 @@ public class NewTournamentDialog extends MageDialog {
|
|||
} else {
|
||||
tOptions.getLimitedOptions().getSetCodes().addAll(selected);
|
||||
}
|
||||
} else if (tournamentType.isRemixed()) {
|
||||
this.isRandom = tournamentType.isRandom();
|
||||
this.isRichMan = tournamentType.isRichMan();
|
||||
this.isRemixed = tournamentType.isRemixed();
|
||||
tOptions.getLimitedOptions().getSetCodes().clear();
|
||||
tOptions.getLimitedOptions().getSetCodes().addAll(randomPackSelector.getSelectedPacks());
|
||||
} else {
|
||||
for (JPanel panel : packPanels) {
|
||||
JComboBox combo = findComboInComponent(panel);
|
||||
|
|
@ -1383,7 +1392,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT + versionStr, "4"));
|
||||
prepareTourneyView(numPlayers);
|
||||
|
||||
if (tournamentType.isRandom() || tournamentType.isRichMan()) {
|
||||
if (tournamentType.isRandom() || tournamentType.isRichMan() || tournamentType.isRemixed()) {
|
||||
loadRandomPacks(version);
|
||||
} else {
|
||||
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT + versionStr, ""));
|
||||
|
|
@ -1444,7 +1453,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
if (deckFile != null && !deckFile.isEmpty()) {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, deckFile);
|
||||
}
|
||||
if (tOptions.getLimitedOptions().getIsRandom() || tOptions.getLimitedOptions().getIsRichMan()) {
|
||||
if (tOptions.getLimitedOptions().getIsRandom() || tOptions.getLimitedOptions().getIsRichMan() || tOptions.getLimitedOptions().getIsRemixed()) {
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT + versionStr, String.join(";", this.randomPackSelector.getSelectedPacks()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
|||
* Creates new form RandomPacksSelectorDialog
|
||||
*/
|
||||
private boolean boxesCreated;
|
||||
private int needSetsAmount;
|
||||
public static final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||
|
||||
public RandomPacksSelectorDialog() {
|
||||
|
|
@ -28,21 +27,22 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
|||
boxesCreated = false;
|
||||
}
|
||||
|
||||
private void setType(boolean isRandomDraft, boolean isRichManDraft, int needSetsAmount) {
|
||||
this.needSetsAmount = needSetsAmount;
|
||||
String title = "";
|
||||
private void setType(boolean isRandomDraft, boolean isRichManDraft, boolean isRemixedDraft) {
|
||||
String title;
|
||||
if (isRandomDraft) {
|
||||
title = "Random Booster Draft Packs Selector";
|
||||
} else if (isRichManDraft) {
|
||||
title = "Rich Man Booster Draft Packs Selector";
|
||||
} else if (isRemixedDraft) {
|
||||
title = "Chaos Remixed Draft Set Selector";
|
||||
} else {
|
||||
title = "Booster Draft Packs Selector";
|
||||
}
|
||||
setTitle(title);
|
||||
}
|
||||
|
||||
public void showDialog(boolean isRandomDraft, boolean isRichManDraft, int needSetsAmount) {
|
||||
setType(isRandomDraft, isRichManDraft, needSetsAmount);
|
||||
public void showDialog(boolean isRandomDraft, boolean isRichManDraft, boolean isRemixedDraft) {
|
||||
setType(isRandomDraft, isRichManDraft, isRemixedDraft);
|
||||
createCheckboxes();
|
||||
pnlPacks.setVisible(true);
|
||||
pnlPacks.revalidate();
|
||||
|
|
@ -204,8 +204,8 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
|||
}//GEN-LAST:event_formWindowClosing
|
||||
|
||||
public void doApply() {
|
||||
if (getSelectedPacks().size() < needSetsAmount) {
|
||||
JOptionPane.showMessageDialog(this, String.format("At least %d sets must be selected", needSetsAmount), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
if (getSelectedPacks().size() < 1) {
|
||||
JOptionPane.showMessageDialog(this, "At least one set must be selected", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@
|
|||
|
||||
public void updateDraft(DraftView draftView) {
|
||||
if (draftView.getSets().size() != 3) {
|
||||
// Random draft
|
||||
// Random draft - TODO: can we access the type of draft here?
|
||||
this.txtPack1.setText("Random Boosters");
|
||||
this.txtPack2.setText("Random Boosters");
|
||||
this.txtPack3.setText("Random Boosters");
|
||||
|
|
@ -171,6 +171,7 @@
|
|||
int left = draftView.getPlayers().size() - right;
|
||||
int height = left * 18;
|
||||
lblTableImage.setSize(new Dimension(lblTableImage.getWidth(), height));
|
||||
// TODO: Can we fix this for Rich Draft where there is no direction?
|
||||
Image tableImage = ImageHelper.getImageFromResources(draftView.getBoosterNum() % 2 == 1 ? "/draft/table_left.png" : "/draft/table_right.png");
|
||||
BufferedImage resizedTable = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(tableImage, BufferedImage.TYPE_INT_ARGB), lblTableImage.getWidth(), lblTableImage.getHeight());
|
||||
lblTableImage.setIcon(new ImageIcon(resizedTable));
|
||||
|
|
@ -431,10 +432,11 @@
|
|||
}
|
||||
|
||||
private String getCurrentSetCode() {
|
||||
if (!setCodes.isEmpty()) {
|
||||
// TODO: Record set codes for random drafts correctly
|
||||
if (setCodes.size() >= packNo) {
|
||||
return setCodes.get(packNo - 1);
|
||||
} else {
|
||||
return "";
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue