mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Adding in Jumpstart Custom
This commit is contained in:
parent
c381ea7716
commit
1e428105d5
9 changed files with 223 additions and 84 deletions
|
|
@ -1,5 +1,13 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.swing.*;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckFileFilter;
|
||||
import mage.cards.decks.importer.DeckImporter;
|
||||
|
|
@ -26,13 +34,6 @@ import mage.view.TableView;
|
|||
import mage.view.TournamentTypeView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* App GUI: create new TOURNEY
|
||||
*
|
||||
|
|
@ -55,6 +56,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private boolean isRandom = false;
|
||||
private boolean isRichMan = false;
|
||||
private String cubeFromDeckFilename = "";
|
||||
private String jumpstartPacksFilename = "";
|
||||
private boolean automaticChange = false;
|
||||
|
||||
public NewTournamentDialog() {
|
||||
|
|
@ -659,6 +661,12 @@ public class NewTournamentDialog extends MageDialog {
|
|||
|
||||
private void cbTournamentTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTournamentTypeActionPerformed
|
||||
prepareTourneyView((Integer) this.spnNumPlayers.getValue());
|
||||
|
||||
jumpstartPacksFilename = "";
|
||||
if (cbTournamentType.getSelectedItem().toString().matches(".*Jumpstart.*Custom.*")) {
|
||||
jumpstartPacksFilename = playerLoadJumpstartPacks();
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_cbTournamentTypeActionPerformed
|
||||
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
|
|
@ -777,6 +785,24 @@ public class NewTournamentDialog extends MageDialog {
|
|||
return "";
|
||||
}
|
||||
|
||||
protected String playerLoadJumpstartPacks() {
|
||||
if (fcSelectDeck == null) {
|
||||
fcSelectDeck = new JFileChooser();
|
||||
fcSelectDeck.setAcceptAllFileFilterUsed(false);
|
||||
fcSelectDeck.addChoosableFileFilter(new DeckFileFilter("txt", "Jumpstart Packs (*.txt)"));
|
||||
}
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
if (!lastFolder.isEmpty()) {
|
||||
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
|
||||
}
|
||||
int ret = fcSelectDeck.showDialog(this, "Select Jumpstart Packs file");
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
return (file.getPath());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void cbDraftCubeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDraftCubeActionPerformed
|
||||
cubeFromDeckFilename = "";
|
||||
if (cbDraftCube.getSelectedItem().toString().equals("Cube From Deck")) {
|
||||
|
|
@ -951,7 +977,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
|
||||
private void loadRandomPacks(int version) {
|
||||
String versionStr = prepareVersionStr(version, false);
|
||||
List<String> packList;
|
||||
java.util.List<String> packList;
|
||||
String packNames;
|
||||
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT + versionStr, "");
|
||||
if (!randomPrefs.isEmpty()) {
|
||||
|
|
@ -1202,6 +1228,18 @@ public class NewTournamentDialog extends MageDialog {
|
|||
tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
|
||||
tOptions.getLimitedOptions().setIsRichMan(tournamentType.isRichMan());
|
||||
tOptions.getLimitedOptions().setIsJumpstart(tournamentType.isJumpstart());
|
||||
|
||||
if (tournamentType.isJumpstart()) {
|
||||
if (!(jumpstartPacksFilename.isEmpty())) {
|
||||
String jumpstartPacksData = "";
|
||||
try {
|
||||
jumpstartPacksData = new String(Files.readAllBytes(Paths.get(jumpstartPacksFilename)));
|
||||
} catch (IOException e2) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e2.getMessage(), "Error loading Jumpstart Packs data", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
tOptions.getLimitedOptions().setJumpstartPacks(jumpstartPacksData);
|
||||
}
|
||||
}
|
||||
if (tournamentType.isCubeBooster()) {
|
||||
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
||||
if (!(cubeFromDeckFilename.isEmpty())) {
|
||||
|
|
@ -1220,7 +1258,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
this.isRandom = tournamentType.isRandom();
|
||||
this.isRichMan = tournamentType.isRichMan();
|
||||
tOptions.getLimitedOptions().getSetCodes().clear();
|
||||
List<String> selected = randomPackSelector.getSelectedPacks();
|
||||
java.util.List<String> selected = randomPackSelector.getSelectedPacks();
|
||||
Collections.shuffle(selected);
|
||||
int maxPacks = 3 * (players.size() + 1);
|
||||
if (tournamentType.isRichMan()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue