mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Prevent starting a game with less than two players
This commit is contained in:
@@ -288,10 +288,6 @@ public abstract class GameLobby {
|
|||||||
|
|
||||||
/** Returns a runnable to start a match with the applied variants if allowed. */
|
/** Returns a runnable to start a match with the applied variants if allowed. */
|
||||||
public Runnable startGame() {
|
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());
|
final List<LobbySlot> activeSlots = Lists.newArrayListWithCapacity(getNumberOfSlots());
|
||||||
for (final LobbySlot slot : data.slots) {
|
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) {
|
for (final LobbySlot slot : activeSlots) {
|
||||||
if (!slot.isReady() && slot.getType() != LobbySlotType.OPEN) {
|
if (!slot.isReady() && slot.getType() != LobbySlotType.OPEN) {
|
||||||
SOptionPane.showMessageDialog(String.format("Player %s is not ready", slot.getName()));
|
SOptionPane.showMessageDialog(String.format("Player %s is not ready", slot.getName()));
|
||||||
|
|||||||
Reference in New Issue
Block a user