mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Allow desktop to play 2-6 multiplayer (not network) draft games
This commit is contained in:
@@ -31,6 +31,8 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Collections;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the draft submenu in the home UI.
|
* Controls the draft submenu in the home UI.
|
||||||
@@ -86,6 +88,7 @@ public enum CSubmenuDraft implements ICDoc {
|
|||||||
view.getRadSingle().addActionListener(radioAction);
|
view.getRadSingle().addActionListener(radioAction);
|
||||||
|
|
||||||
view.getRadAll().addActionListener(radioAction);
|
view.getRadAll().addActionListener(radioAction);
|
||||||
|
view.getRadMultiple().addActionListener(radioAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -117,7 +120,7 @@ public enum CSubmenuDraft implements ICDoc {
|
|||||||
|
|
||||||
private void startGame(final GameType gameType) {
|
private void startGame(final GameType gameType) {
|
||||||
final Localizer localizer = Localizer.getInstance();
|
final Localizer localizer = Localizer.getInstance();
|
||||||
final boolean gauntlet = !VSubmenuDraft.SINGLETON_INSTANCE.isSingleSelected();
|
final boolean gauntlet = VSubmenuDraft.SINGLETON_INSTANCE.isGauntlet();
|
||||||
final DeckProxy humanDeck = VSubmenuDraft.SINGLETON_INSTANCE.getLstDecks().getSelectedItem();
|
final DeckProxy humanDeck = VSubmenuDraft.SINGLETON_INSTANCE.getLstDecks().getSelectedItem();
|
||||||
|
|
||||||
if (humanDeck == null) {
|
if (humanDeck == null) {
|
||||||
@@ -154,17 +157,34 @@ public enum CSubmenuDraft implements ICDoc {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Restore Zero Indexing
|
List<Deck> aiDecks = Lists.newArrayList();
|
||||||
final int aiIndex = Integer.parseInt(duelType)-1;
|
if (VSubmenuDraft.SINGLETON_INSTANCE.isSingleSelected()) {
|
||||||
final Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
|
// Restore Zero Indexing
|
||||||
if (aiDeck == null) {
|
final int aiIndex = Integer.parseInt(duelType)-1;
|
||||||
throw new IllegalStateException("Draft: Computer deck is null!");
|
final Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
|
||||||
|
if (aiDeck == null) {
|
||||||
|
throw new IllegalStateException("Draft: Computer deck is null!");
|
||||||
|
}
|
||||||
|
aiDecks.add(aiDeck);
|
||||||
|
} else {
|
||||||
|
final int numOpponents = Integer.parseInt(duelType);
|
||||||
|
|
||||||
|
List<Deck> randomOpponents = Lists.newArrayList(opponentDecks.getAiDecks());
|
||||||
|
Collections.shuffle(randomOpponents);
|
||||||
|
aiDecks = randomOpponents.subList(0, numOpponents);
|
||||||
|
for(Deck d : aiDecks) {
|
||||||
|
if (d == null) {
|
||||||
|
throw new IllegalStateException("Draft: Computer deck is null!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<RegisteredPlayer> starter = new ArrayList<>();
|
final List<RegisteredPlayer> starter = new ArrayList<>();
|
||||||
final RegisteredPlayer human = new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
|
final RegisteredPlayer human = new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
|
||||||
starter.add(human);
|
starter.add(human);
|
||||||
starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));
|
for(Deck aiDeck : aiDecks) {
|
||||||
|
starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));
|
||||||
|
}
|
||||||
for (final RegisteredPlayer pl : starter) {
|
for (final RegisteredPlayer pl : starter) {
|
||||||
pl.assignConspiracies();
|
pl.assignConspiracies();
|
||||||
}
|
}
|
||||||
@@ -219,10 +239,15 @@ public enum CSubmenuDraft implements ICDoc {
|
|||||||
// 1-7 instead of 0-6
|
// 1-7 instead of 0-6
|
||||||
combo.addItem(String.valueOf(indx));
|
combo.addItem(String.valueOf(indx));
|
||||||
}
|
}
|
||||||
} else {
|
} else if (VSubmenuDraft.SINGLETON_INSTANCE.isGauntlet()) {
|
||||||
// Gauntlet/Tournament
|
// Gauntlet/Tournament
|
||||||
combo.addItem("Gauntlet");
|
combo.addItem("Gauntlet");
|
||||||
//combo.addItem("Tournament");
|
//combo.addItem("Tournament");
|
||||||
|
} else {
|
||||||
|
combo.addItem("2");
|
||||||
|
combo.addItem("3");
|
||||||
|
combo.addItem("4");
|
||||||
|
combo.addItem("5");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public enum VSubmenuDraft implements IVSubmenu<CSubmenuDraft> {
|
|||||||
private final DeckManager lstDecks = new DeckManager(GameType.Draft, CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture());
|
private final DeckManager lstDecks = new DeckManager(GameType.Draft, CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture());
|
||||||
|
|
||||||
private final JRadioButton radSingle = new FRadioButton(localizer.getMessage("lblPlayAnOpponent"));
|
private final JRadioButton radSingle = new FRadioButton(localizer.getMessage("lblPlayAnOpponent"));
|
||||||
|
private final JRadioButton radMultiple = new FRadioButton(localizer.getMessage("lblPlayMultipleOpponents"));
|
||||||
private final JRadioButton radAll = new FRadioButton(localizer.getMessage("lblPlayAll7opponents"));
|
private final JRadioButton radAll = new FRadioButton(localizer.getMessage("lblPlayAll7opponents"));
|
||||||
|
|
||||||
private final JComboBox<String> cbOpponent = new JComboBox<>();
|
private final JComboBox<String> cbOpponent = new JComboBox<>();
|
||||||
@@ -77,6 +78,7 @@ public enum VSubmenuDraft implements IVSubmenu<CSubmenuDraft> {
|
|||||||
|
|
||||||
final JXButtonPanel grpPanel = new JXButtonPanel();
|
final JXButtonPanel grpPanel = new JXButtonPanel();
|
||||||
grpPanel.add(radSingle, "w 200px!, h 30px!");
|
grpPanel.add(radSingle, "w 200px!, h 30px!");
|
||||||
|
grpPanel.add(radMultiple, "w 200px!, h 30px!");
|
||||||
grpPanel.add(radAll, "w 200px!, h 30px!");
|
grpPanel.add(radAll, "w 200px!, h 30px!");
|
||||||
radSingle.setSelected(true);
|
radSingle.setSelected(true);
|
||||||
grpPanel.add(cbOpponent, "w 200px!, h 30px!");
|
grpPanel.add(cbOpponent, "w 200px!, h 30px!");
|
||||||
@@ -124,6 +126,9 @@ public enum VSubmenuDraft implements IVSubmenu<CSubmenuDraft> {
|
|||||||
public boolean isSingleSelected() {
|
public boolean isSingleSelected() {
|
||||||
return radSingle.isSelected();
|
return radSingle.isSelected();
|
||||||
}
|
}
|
||||||
|
public boolean isGauntlet() {
|
||||||
|
return radAll.isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
/** @return {@link forge.itemmanager.DeckManager} */
|
/** @return {@link forge.itemmanager.DeckManager} */
|
||||||
public DeckManager getLstDecks() {
|
public DeckManager getLstDecks() {
|
||||||
@@ -132,6 +137,7 @@ public enum VSubmenuDraft implements IVSubmenu<CSubmenuDraft> {
|
|||||||
|
|
||||||
public JComboBox<String> getCbOpponent() { return cbOpponent; }
|
public JComboBox<String> getCbOpponent() { return cbOpponent; }
|
||||||
public JRadioButton getRadSingle() { return radSingle; }
|
public JRadioButton getRadSingle() { return radSingle; }
|
||||||
|
public JRadioButton getRadMultiple() { return radMultiple; }
|
||||||
public JRadioButton getRadAll() { return radAll; }
|
public JRadioButton getRadAll() { return radAll; }
|
||||||
|
|
||||||
//========== Overridden from IVDoc
|
//========== Overridden from IVDoc
|
||||||
|
|||||||
@@ -364,7 +364,8 @@ lblSHORTCUT_CARD_ZOOM=Match: zoom the currently selected card
|
|||||||
lblBoosterDraft=Booster Draft
|
lblBoosterDraft=Booster Draft
|
||||||
lblHeaderBoosterDraft=Sanctioned Format: Booster Draft
|
lblHeaderBoosterDraft=Sanctioned Format: Booster Draft
|
||||||
lblPlayAnOpponent=Play an opponent
|
lblPlayAnOpponent=Play an opponent
|
||||||
lblPlayAll7opponents=Play all 7 opponents
|
lblPlayMultipleOpponents=Play multiple opponents
|
||||||
|
lblPlayAll7opponents=Play all opponents
|
||||||
lblBuildorselectadeck=Build or select a deck
|
lblBuildorselectadeck=Build or select a deck
|
||||||
lblDraftText1=In Draft mode, three booster packs are rotated around eight players.
|
lblDraftText1=In Draft mode, three booster packs are rotated around eight players.
|
||||||
lblDraftText2=Build a deck from the cards you choose. The AI will do the same.
|
lblDraftText2=Build a deck from the cards you choose. The AI will do the same.
|
||||||
|
|||||||
Reference in New Issue
Block a user