1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-06 17:00:12 -09:00

* GUI: fixed that users can select empty timing option in new tourney dialog;

This commit is contained in:
Oleg Agafonov 2021-07-26 14:42:42 +04:00
parent d3f2b537fb
commit f334b81de6
3 changed files with 23 additions and 4 deletions
Mage.Client/src/main/java/mage/client/dialog
Mage.Server/src/main/java/mage/server
Mage/src/main/java/mage/game/draft

View file

@ -86,7 +86,10 @@ public class NewTournamentDialog extends MageDialog {
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values())); cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values())); cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values()));
cbDraftCube.setModel(new DefaultComboBoxModel(SessionHandler.getDraftCubes())); cbDraftCube.setModel(new DefaultComboBoxModel(SessionHandler.getDraftCubes()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values())); cbDraftTiming.setModel(new DefaultComboBoxModel(Arrays.stream(TimingOption.values())
.filter(o -> !o.equals(TimingOption.NONE))
.toArray())
);
// update player types // update player types
int i = 2; int i = 2;
for (TournamentPlayerPanel tournamentPlayerPanel : players) { for (TournamentPlayerPanel tournamentPlayerPanel : players) {
@ -682,6 +685,13 @@ public class NewTournamentDialog extends MageDialog {
return; return;
} }
} }
if (tournamentType.isDraft() && tOptions.getLimitedOptions() instanceof DraftOptions) {
DraftOptions draftOptions = (DraftOptions) tOptions.getLimitedOptions();
if (draftOptions.getTiming() == TimingOption.NONE) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Warning, you must select draft timing option", "Warning", JOptionPane.WARNING_MESSAGE);
return;
}
}
// save last settings // save last settings
onSaveSettings(0, tOptions); onSaveSettings(0, tOptions);

View file

@ -200,12 +200,14 @@ public class MageServerImpl implements MageServer {
return null; return null;
} }
User user = _user.get(); User user = _user.get();
// check if user can create another table // check if user can create another table
int notStartedTables = user.getNumberOfNotStartedTables(); int notStartedTables = user.getNumberOfNotStartedTables();
if (notStartedTables > 1) { if (notStartedTables > 1) {
user.showUserMessage("Create table", "You have already " + notStartedTables + " not started tables. You can't create another."); user.showUserMessage("Create table", "You have already " + notStartedTables + " not started tables. You can't create another.");
throw new MageException("No message"); throw new MageException("No message");
} }
// check AI players max // check AI players max
String maxAiOpponents = managerFactory.configSettings().getMaxAiOpponents(); String maxAiOpponents = managerFactory.configSettings().getMaxAiOpponents();
if (maxAiOpponents != null) { if (maxAiOpponents != null) {
@ -221,6 +223,7 @@ public class MageServerImpl implements MageServer {
throw new MageException("No message"); throw new MageException("No message");
} }
} }
// check if the user satisfies the quitRatio requirement. // check if the user satisfies the quitRatio requirement.
int quitRatio = options.getQuitRatio(); int quitRatio = options.getQuitRatio();
if (quitRatio < user.getTourneyQuitRatio()) { if (quitRatio < user.getTourneyQuitRatio()) {
@ -229,6 +232,7 @@ public class MageServerImpl implements MageServer {
user.showUserMessage("Create tournament", message); user.showUserMessage("Create tournament", message);
throw new MageException("No message"); throw new MageException("No message");
} }
// check if the user satisfies the minimumRating requirement. // check if the user satisfies the minimumRating requirement.
int minimumRating = options.getMinimumRating(); int minimumRating = options.getMinimumRating();
int userRating; int userRating;

View file

@ -22,11 +22,11 @@ public class DraftOptions extends LimitedOptions implements Serializable {
REGULAR("x1.5", "Regular (x1.5)", 1.5, REGULAR("x1.5", "Regular (x1.5)", 1.5,
Arrays.asList(113, 105, 98, 90, 83, 75, 68, 60, 35, 30, 25, 20, 15, 10, 8) Arrays.asList(113, 105, 98, 90, 83, 75, 68, 60, 35, 30, 25, 20, 15, 10, 8)
), ),
PROFI("x1.0", "Professional (x1.0)", 1.0, PROFESSIONAL("x1.0", "Professional (x1.0)", 1.0,
Arrays.asList(75, 70, 65, 60, 55, 50, 45, 40, 30, 25, 20, 15, 12, 10, 7) Arrays.asList(75, 70, 65, 60, 55, 50, 45, 40, 30, 25, 20, 15, 12, 10, 7)
), ),
NONE("ERROR", "", 0, NONE("ERROR", "", 0,
Arrays.asList(0) Arrays.asList(1)
); );
private final String shortName; private final String shortName;
@ -57,7 +57,12 @@ public class DraftOptions extends LimitedOptions implements Serializable {
if (cardNum > 15) { if (cardNum > 15) {
cardNum = 15; cardNum = 15;
} }
return times.get(cardNum - 1);
if (times.size() <= cardNum) {
return times.get(cardNum - 1);
} else {
return times.get(times.size() - 1);
}
} }
@Override @Override