Prevent starting a game with less than two players

This commit is contained in:
drdev
2015-06-13 18:52:05 +00:00
parent 08580f3178
commit 09762eb50c

View File

@@ -288,10 +288,6 @@ public abstract class GameLobby {
/** Returns a runnable to start a match with the applied variants if allowed. */
public Runnable startGame() {
if (!isEnoughTeams()) {
SOptionPane.showMessageDialog("There are not enough teams! Please adjust team allocations.");
return null;
}
final List<LobbySlot> activeSlots = Lists.newArrayListWithCapacity(getNumberOfSlots());
for (final LobbySlot slot : data.slots) {
@@ -300,6 +296,16 @@ public abstract class GameLobby {
}
}
if (activeSlots.size() < 2) {
SOptionPane.showMessageDialog("At least two players are required to start a game.");
return null;
}
if (!isEnoughTeams()) {
SOptionPane.showMessageDialog("There are not enough teams! Please adjust team allocations.");
return null;
}
for (final LobbySlot slot : activeSlots) {
if (!slot.isReady() && slot.getType() != LobbySlotType.OPEN) {
SOptionPane.showMessageDialog(String.format("Player %s is not ready", slot.getName()));