Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public void setPlayerChangeListener(final IPlayerChangeListener listener) {
}

void setReady(final int index, final boolean ready) {
if (ready && decks[index] == null && !vntMomirBasic.isSelected() && !vntMoJhoSto.isSelected()) {
if (ready && decks[index] == null && !lobby.hasAutoGeneratedVariant()) {
SOptionPane.showErrorDialog("Select a deck before readying!");
update(false);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ void setReady(final int index, final boolean ready) {
}
if (ready) {
updateDeck(index);
if (decks[index] == null) {
if (decks[index] == null && !lobby.hasAutoGeneratedVariant()) {
FOptionPane.showErrorDialog(Forge.getLocalizer().getMessage("msgSelectAdeckBeforeReadying"));
update(false);
return;
Expand Down
59 changes: 29 additions & 30 deletions forge-gui/src/main/java/forge/gamemodes/match/GameLobby.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ public boolean hasVariant(final GameType variant) {
return data.appliedVariants.contains(variant);
}

public boolean hasAutoGeneratedVariant() {
for (final GameType variant : data.appliedVariants) {
if (variant.isAutoGenerated()) {
return true;
}
}
return false;
}

public int getNumberOfSlots() {
return data.slots.size();
}
Expand Down Expand Up @@ -355,23 +364,6 @@ public Runnable startGame() {
return null;
}

for (final LobbySlot slot : activeSlots) {
if (!slot.isReady()) {
SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPlayerIsNotReady", slot.getName()));
return null;
}
if (slot.getDeck() == null) {
SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPleaseSpecifyPlayerDeck", slot.getName()));
return null;
}
if (hasVariant(GameType.Commander) || hasVariant(GameType.Oathbreaker) || hasVariant(GameType.TinyLeaders) || hasVariant(GameType.Brawl)) {
if (!slot.getDeck().has(DeckSection.Commander)) {
SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPlayerDoesntHaveCommander", slot.getName()));
return null;
}
}
}

final Set<GameType> variantTypes = data.appliedVariants;

GameType autoGenerateVariant = null;
Expand All @@ -394,6 +386,23 @@ public Runnable startGame() {
}
}

for (final LobbySlot slot : activeSlots) {
if (!slot.isReady()) {
SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPlayerIsNotReady", slot.getName()));
return null;
}
if (slot.getDeck() == null && autoGenerateVariant == null) {
SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPleaseSpecifyPlayerDeck", slot.getName()));
return null;
}
if (hasVariant(GameType.Commander) || hasVariant(GameType.Oathbreaker) || hasVariant(GameType.TinyLeaders) || hasVariant(GameType.Brawl)) {
if (!slot.getDeck().has(DeckSection.Commander)) {
SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPlayerDoesntHaveCommander", slot.getName()));
return null;
}
}
}

final boolean checkLegality = FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY);

//Auto-generated decks don't need to be checked here
Expand Down Expand Up @@ -438,6 +447,9 @@ public Runnable startGame() {
}

Deck deck = slot.getDeck();
if (autoGenerateVariant != null) {
deck = autoGenerateVariant.autoGenerateDeck(null);
}
RegisteredPlayer rp = new RegisteredPlayer(deck);

if (!variantTypes.isEmpty()) {
Expand All @@ -455,19 +467,6 @@ public Runnable startGame() {
}
}
}
else if (autoGenerateVariant != null) {
Deck autoDeck = autoGenerateVariant.autoGenerateDeck(rp);
deck = new Deck();
for (DeckSection d : DeckSection.values()) {
if (autoDeck.has(d)) {
deck.getOrCreate(d).clear();
deck.get(d).addAll(autoDeck.get(d));
}
}
}

// Initialise variables for other variants
deck = deck == null ? rp.getDeck() : deck;

final CardPool avatarPool = deck.get(DeckSection.Avatar);

Expand Down
Loading