* 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

View file

@ -86,7 +86,10 @@ public class NewTournamentDialog extends MageDialog {
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbSkillLevel.setModel(new DefaultComboBoxModel(SkillLevel.values()));
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
int i = 2;
for (TournamentPlayerPanel tournamentPlayerPanel : players) {
@ -682,6 +685,13 @@ public class NewTournamentDialog extends MageDialog {
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
onSaveSettings(0, tOptions);

View file

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

View file

@ -22,11 +22,11 @@ public class DraftOptions extends LimitedOptions implements Serializable {
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)
),
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)
),
NONE("ERROR", "", 0,
Arrays.asList(0)
Arrays.asList(1)
);
private final String shortName;
@ -57,7 +57,12 @@ public class DraftOptions extends LimitedOptions implements Serializable {
if (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