mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Deck generator takes boolean forAi.
DeckChooser layout changed to take less height Constructed: minimizing difference between human and AI temporary removed 'spectate ai vs ai'
This commit is contained in:
@@ -11,8 +11,6 @@ import java.util.Random;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@@ -23,7 +21,6 @@ import forge.deck.generate.Generate5ColorDeck;
|
||||
import forge.deck.generate.GenerateColoredDeckBase;
|
||||
import forge.deck.generate.GenerateMonoColorDeck;
|
||||
import forge.deck.generate.GenerateThemeDeck;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPoolView;
|
||||
@@ -57,7 +54,7 @@ public class DeckgenUtil {
|
||||
* @param selection {@link java.lang.String} array
|
||||
* @return {@link forge.deck.Deck}
|
||||
*/
|
||||
public static Deck buildColorDeck(final String[] selection, PlayerType pt) {
|
||||
public static Deck buildColorDeck(final String[] selection, boolean forAi) {
|
||||
|
||||
final Deck deck;
|
||||
String deckName = null;
|
||||
@@ -75,7 +72,7 @@ public class DeckgenUtil {
|
||||
deckName = "5 colors";
|
||||
}
|
||||
|
||||
ItemPoolView<CardPrinted> cards = gen == null ? null : gen.getDeck(60, pt);
|
||||
ItemPoolView<CardPrinted> cards = gen == null ? null : gen.getDeck(60, forAi);
|
||||
|
||||
if(null == deckName)
|
||||
deckName = Lang.joinHomogenous(Arrays.asList(selection));
|
||||
@@ -123,7 +120,7 @@ public class DeckgenUtil {
|
||||
}
|
||||
|
||||
/** @return {@link forge.deck.Deck} */
|
||||
public static Deck getRandomColorDeck(PlayerType pt) {
|
||||
public static Deck getRandomColorDeck(boolean forAi) {
|
||||
final int[] colorCount = new int[] {1, 2, 3, 5};
|
||||
final int count = colorCount[MyRandom.getRandom().nextInt(colorCount.length)];
|
||||
final String[] selection = new String[count];
|
||||
@@ -131,7 +128,7 @@ public class DeckgenUtil {
|
||||
// A simulated selection of "random 1" will trigger the AI selection process.
|
||||
for (int i = 0; i < count; i++) { selection[i] = "Random 1"; }
|
||||
|
||||
return DeckgenUtil.buildColorDeck(selection, pt);
|
||||
return DeckgenUtil.buildColorDeck(selection, forAi);
|
||||
}
|
||||
|
||||
/** @return {@link forge.deck.Deck} */
|
||||
@@ -168,33 +165,25 @@ public class DeckgenUtil {
|
||||
return allQuestDecks.get(rand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns random selection of colors from a nine-value list
|
||||
* (BGRUW, rand 1-4) within Forge support limitations (only 2, 3, 5 color deckgen).
|
||||
* Used for random color deck generation.
|
||||
* @return int[] */
|
||||
public static int[] randomSelectColors() {
|
||||
// Color select algorithm
|
||||
int x = -1;
|
||||
// HACK because 1 and 4 color decks are not supported yet. :(
|
||||
while (x == -1 || x == 1 || x == 4) {
|
||||
x = (int) Math.ceil(Math.random() * 5);
|
||||
}
|
||||
final Integer colorCount = x;
|
||||
final int maxCount = 9;
|
||||
Integer[] selectedIndices = new Integer[colorCount];
|
||||
public static int[] randomSelectColors(int maxColors) {
|
||||
int nColors = MyRandom.getRandom().nextInt(3) + 1;
|
||||
int[] result = new int[nColors];
|
||||
for(int i = 0; i < nColors; i++) {
|
||||
int next = MyRandom.getRandom().nextInt(maxColors);
|
||||
|
||||
x = -1;
|
||||
for (int i = 0; i < colorCount; i++) {
|
||||
while (x == -1) {
|
||||
x = (int) Math.floor(Math.random() * maxCount);
|
||||
if (Arrays.asList(selectedIndices).contains(x)) { x = -1; }
|
||||
else { selectedIndices[i] = x; }
|
||||
boolean isUnique = true;
|
||||
for(int j = 0; j < i; j++) {
|
||||
if(result[j] == next) {
|
||||
isUnique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
x = -1;
|
||||
if(isUnique)
|
||||
result[i] = next;
|
||||
else
|
||||
i--; // try over with this number
|
||||
}
|
||||
|
||||
return ArrayUtils.toPrimitive(selectedIndices);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @param lst0 {@link javax.swing.JList} */
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.common.collect.Lists;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPoolView;
|
||||
|
||||
@@ -87,8 +86,9 @@ public class Generate2ColorDeck extends GenerateColoredDeckBase {
|
||||
}
|
||||
|
||||
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final PlayerType pt) {
|
||||
addCreaturesAndSpells(size, cmcRelativeWeights, pt);
|
||||
@Override
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final boolean forAi) {
|
||||
addCreaturesAndSpells(size, cmcRelativeWeights, forAi);
|
||||
|
||||
// Add lands
|
||||
int numLands = Math.round(size * getLandsPercentage());
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.common.collect.Lists;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPoolView;
|
||||
import forge.util.MyRandom;
|
||||
@@ -96,19 +95,9 @@ public class Generate3ColorDeck extends GenerateColoredDeckBase {
|
||||
colors = ColorSet.fromMask(combo);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* get3ColorDeck.
|
||||
* </p>
|
||||
*
|
||||
* @param size
|
||||
* a int.
|
||||
* @param pt
|
||||
* the pt
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final PlayerType pt) {
|
||||
addCreaturesAndSpells(size, cmcLevels, pt);
|
||||
@Override
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final boolean forAi) {
|
||||
addCreaturesAndSpells(size, cmcLevels, forAi);
|
||||
|
||||
// Add lands
|
||||
int numLands = Math.round(size * getLandsPercentage());
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.ColorSet;
|
||||
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPoolView;
|
||||
|
||||
@@ -58,19 +57,10 @@ public class Generate5ColorDeck extends GenerateColoredDeckBase {
|
||||
colors = ColorSet.fromMask(0).inverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* get3ColorDeck.
|
||||
* </p>
|
||||
*
|
||||
* @param deckSize
|
||||
* a int.
|
||||
* @param playerType
|
||||
* a PlayerType
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final PlayerType pt) {
|
||||
addCreaturesAndSpells(size, cmcLevels, pt);
|
||||
|
||||
@Override
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final boolean forAi) {
|
||||
addCreaturesAndSpells(size, cmcLevels, forAi);
|
||||
|
||||
// Add lands
|
||||
int numLands = Math.round(size * getLandsPercentage());
|
||||
|
||||
@@ -38,7 +38,6 @@ import forge.card.CardRulesPredicates;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPool;
|
||||
@@ -75,10 +74,10 @@ public abstract class GenerateColoredDeckBase {
|
||||
tDeck = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||
}
|
||||
|
||||
protected void addCreaturesAndSpells(int size, List<ImmutablePair<FilterCMC, Integer>> cmcLevels, PlayerType pt) {
|
||||
protected void addCreaturesAndSpells(int size, List<ImmutablePair<FilterCMC, Integer>> cmcLevels, boolean forAi) {
|
||||
tmpDeck.append("Building deck of ").append(size).append("cards\n");
|
||||
|
||||
final Iterable<CardPrinted> cards = selectCardsOfMatchingColorForPlayer(pt);
|
||||
final Iterable<CardPrinted> cards = selectCardsOfMatchingColorForPlayer(forAi);
|
||||
// build subsets based on type
|
||||
|
||||
final Iterable<CardPrinted> creatures = Iterables.filter(cards, Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, CardPrinted.FN_GET_RULES));
|
||||
@@ -95,7 +94,7 @@ public abstract class GenerateColoredDeckBase {
|
||||
tmpDeck.append(String.format("Current deck size: %d... should be %f%n", tDeck.countAll(), size * (getCreatPercentage() + getSpellPercentage())));
|
||||
}
|
||||
|
||||
public ItemPoolView<CardPrinted> getDeck(final int size, final PlayerType pt) {
|
||||
public ItemPoolView<CardPrinted> getDeck(final int size, final boolean forAi) {
|
||||
return null; // all but theme deck do override this method
|
||||
}
|
||||
|
||||
@@ -231,11 +230,11 @@ public abstract class GenerateColoredDeckBase {
|
||||
}
|
||||
}
|
||||
|
||||
protected Iterable<CardPrinted> selectCardsOfMatchingColorForPlayer(PlayerType pt) {
|
||||
protected Iterable<CardPrinted> selectCardsOfMatchingColorForPlayer(boolean forAi) {
|
||||
|
||||
// start with all cards
|
||||
// remove cards that generated decks don't like
|
||||
Predicate<CardRules> canPlay = pt == PlayerType.HUMAN ? GenerateDeckUtil.HUMAN_CAN_PLAY : GenerateDeckUtil.AI_CAN_PLAY;
|
||||
Predicate<CardRules> canPlay = forAi ? GenerateDeckUtil.HUMAN_CAN_PLAY : GenerateDeckUtil.AI_CAN_PLAY;
|
||||
Predicate<CardRules> hasColor = new GenerateDeckUtil.MatchColorIdentity(colors);
|
||||
|
||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS)) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.common.collect.Lists;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.generate.GenerateDeckUtil.FilterCMC;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPoolView;
|
||||
|
||||
@@ -78,8 +77,9 @@ public class GenerateMonoColorDeck extends GenerateColoredDeckBase {
|
||||
}
|
||||
|
||||
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final PlayerType pt) {
|
||||
addCreaturesAndSpells(size, cmcLevels, pt);
|
||||
@Override
|
||||
public final ItemPoolView<CardPrinted> getDeck(final int size, final boolean forAi) {
|
||||
addCreaturesAndSpells(size, cmcLevels, forAi);
|
||||
|
||||
// Add lands
|
||||
int numLands = (int) (getLandsPercentage() * size);
|
||||
|
||||
@@ -11,7 +11,6 @@ import forge.deck.DeckBase;
|
||||
import forge.deck.generate.Generate2ColorDeck;
|
||||
import forge.deck.generate.Generate3ColorDeck;
|
||||
import forge.deck.generate.Generate5ColorDeck;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.deckeditor.CDeckEditorUI;
|
||||
import forge.gui.deckeditor.SEditorIO;
|
||||
import forge.gui.deckeditor.views.VDeckgen;
|
||||
@@ -105,16 +104,13 @@ public enum CDeckgen implements ICDoc {
|
||||
|
||||
switch (colorCount0) {
|
||||
case 2:
|
||||
genConstructed.getMain().addAll(
|
||||
(new Generate2ColorDeck(null, null)).getDeck(60, PlayerType.HUMAN));
|
||||
genConstructed.getMain().addAll((new Generate2ColorDeck(null, null)).getDeck(60, false));
|
||||
break;
|
||||
case 3:
|
||||
genConstructed.getMain().addAll(
|
||||
(new Generate3ColorDeck(null, null, null)).getDeck(60, PlayerType.HUMAN));
|
||||
genConstructed.getMain().addAll((new Generate3ColorDeck(null, null, null)).getDeck(60, false));
|
||||
break;
|
||||
case 5:
|
||||
genConstructed.getMain().addAll(
|
||||
(new Generate5ColorDeck()).getDeck(60, PlayerType.HUMAN));
|
||||
genConstructed.getMain().addAll((new Generate5ColorDeck()).getDeck(60, false));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import forge.game.GameType;
|
||||
import forge.game.MatchController;
|
||||
import forge.game.PlayerStartConditions;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gauntlet.GauntletData;
|
||||
import forge.gauntlet.GauntletIO;
|
||||
import forge.gui.SOverlayUtils;
|
||||
@@ -119,7 +118,7 @@ public enum CSubmenuGauntletQuick implements ICDoc {
|
||||
for (int i = 0; i < numOpponents; i++) {
|
||||
randType = (int) Math.round(Math.random() * (lstDecktypes.size() - 1));
|
||||
if (lstDecktypes.get(randType).equals(DeckTypes.COLORS)) {
|
||||
tempDeck = DeckgenUtil.getRandomColorDeck(PlayerType.COMPUTER);
|
||||
tempDeck = DeckgenUtil.getRandomColorDeck(true);
|
||||
lstEventNames.add("Random colors deck");
|
||||
}
|
||||
else if (lstDecktypes.get(randType).equals(DeckTypes.THEMES)) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gauntlet.GauntletIO;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
@@ -51,7 +50,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu<CSubmenuGauntletBuild> {
|
||||
private final JPanel pnlStrut = new JPanel();
|
||||
private final JPanel pnlDirections = new JPanel();
|
||||
|
||||
private final FDeckChooser lstLeft = new FDeckChooser("Deck", PlayerType.HUMAN);
|
||||
private final FDeckChooser lstLeft = new FDeckChooser("Deck", false);
|
||||
private final JList lstRight = new FList();
|
||||
|
||||
private final JScrollPane scrRight = new FScrollPane(lstRight,
|
||||
|
||||
@@ -10,7 +10,6 @@ import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -48,7 +47,7 @@ public enum VSubmenuGauntletContests implements IVSubmenu<CSubmenuGauntletContes
|
||||
private final JPanel pnlLoad = new JPanel(new MigLayout("insets 0, gap 0, wrap"));
|
||||
|
||||
private final ContestGauntletLister gauntletList = new ContestGauntletLister();
|
||||
private final FDeckChooser lstDecks = new FDeckChooser("Deck", PlayerType.HUMAN);
|
||||
private final FDeckChooser lstDecks = new FDeckChooser("Deck", false);
|
||||
|
||||
private final JScrollPane scrLeft = new FScrollPane(gauntletList,
|
||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
@@ -11,7 +11,6 @@ import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -57,7 +56,7 @@ public enum VSubmenuGauntletQuick implements IVSubmenu<CSubmenuGauntletQuick> {
|
||||
private final JCheckBox boxColorDecks = new FCheckBox("Fully random color Decks");
|
||||
private final JCheckBox boxThemeDecks = new FCheckBox("Semi-random theme Decks");
|
||||
|
||||
private final FDeckChooser lstDecks = new FDeckChooser("Deck", PlayerType.HUMAN);
|
||||
private final FDeckChooser lstDecks = new FDeckChooser("Deck", false);
|
||||
private final QuickGauntletLister gauntletList = new QuickGauntletLister();
|
||||
|
||||
private final JLabel lblOptions = new FLabel.Builder().fontSize(16)
|
||||
|
||||
@@ -51,8 +51,8 @@ public enum CSubmenuConstructed implements ICDoc {
|
||||
@Override
|
||||
public void initialize() {
|
||||
final ForgePreferences prefs = Singletons.getModel().getPreferences();
|
||||
view.getDcAi().initialize();
|
||||
view.getDcHuman().initialize();
|
||||
view.getDcLeft().initialize();
|
||||
view.getDcRight().initialize();
|
||||
|
||||
// Checkbox event handling
|
||||
view.getBtnStart().addActionListener(new ActionListener() {
|
||||
@@ -84,8 +84,7 @@ public enum CSubmenuConstructed implements ICDoc {
|
||||
view.getCbRemoveSmall().addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
prefs.setPref(
|
||||
FPref.DECKGEN_NOSMALL, String.valueOf(view.getCbRemoveSmall().isSelected()));
|
||||
prefs.setPref(FPref.DECKGEN_NOSMALL, String.valueOf(view.getCbRemoveSmall().isSelected()));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
@@ -101,33 +100,34 @@ public enum CSubmenuConstructed implements ICDoc {
|
||||
* @param gameType
|
||||
*/
|
||||
private void startGame(final GameType gameType) {
|
||||
PlayerStartConditions humanPsc = view.getDcHuman().getDeck();
|
||||
String humanDeckErrorMessage = gameType.getDecksFormat().getDeckConformanceProblem(humanPsc.getOriginalDeck());
|
||||
if (null != humanDeckErrorMessage) {
|
||||
JOptionPane.showMessageDialog(null, "Your deck " + humanDeckErrorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerStartConditions aiDeck = view.getDcAi().getDeck();
|
||||
String aiDeckErrorMessage = gameType.getDecksFormat().getDeckConformanceProblem(aiDeck.getOriginalDeck());
|
||||
if (null != aiDeckErrorMessage) {
|
||||
JOptionPane.showMessageDialog(null, "AI deck " + aiDeckErrorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
SOverlayUtils.startGameOverlay();
|
||||
SOverlayUtils.showOverlay();
|
||||
|
||||
|
||||
PlayerStartConditions pscLeft = view.getDcLeft().getDeck();
|
||||
PlayerStartConditions pscRight = view.getDcRight().getDeck();
|
||||
|
||||
String humanDeckErrorMessage = gameType.getDecksFormat().getDeckConformanceProblem(pscRight.getOriginalDeck());
|
||||
if (null != humanDeckErrorMessage) {
|
||||
JOptionPane.showMessageDialog(null, "Right-side deck " + humanDeckErrorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String aiDeckErrorMessage = gameType.getDecksFormat().getDeckConformanceProblem(pscLeft.getOriginalDeck());
|
||||
if (null != aiDeckErrorMessage) {
|
||||
JOptionPane.showMessageDialog(null, "Left-side deck " + aiDeckErrorMessage, "Invalid deck", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
Lobby lobby = Singletons.getControl().getLobby();
|
||||
LobbyPlayer firstPlayer = view.getCbSpectate().isSelected() ? lobby.getAiPlayer() : lobby.getGuiPlayer();
|
||||
LobbyPlayer rightPlayer = view.isRightPlayerAi() ? lobby.getAiPlayer() : lobby.getGuiPlayer();
|
||||
LobbyPlayer leftPlayer = view.isLeftPlayerAi() ? lobby.getAiPlayer() : lobby.getGuiPlayer();
|
||||
|
||||
List<Pair<LobbyPlayer, PlayerStartConditions>> players = new ArrayList<Pair<LobbyPlayer, PlayerStartConditions>>();
|
||||
players.add(ImmutablePair.of(firstPlayer, humanPsc));
|
||||
players.add(ImmutablePair.of(lobby.getAiPlayer(), aiDeck));
|
||||
|
||||
players.add(ImmutablePair.of(rightPlayer, pscRight));
|
||||
players.add(ImmutablePair.of(leftPlayer, pscLeft));
|
||||
final MatchController mc = new MatchController(gameType, players);
|
||||
|
||||
SOverlayUtils.startGameOverlay();
|
||||
SOverlayUtils.showOverlay();
|
||||
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -5,7 +5,6 @@ import javax.swing.JCheckBox;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -35,31 +34,32 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
/** */
|
||||
private final LblHeader lblTitle = new LblHeader("Sanctioned Format: Constructed");
|
||||
|
||||
private final JPanel pnlStart = new JPanel(new MigLayout("insets 0, gap 0, wrap 3"));
|
||||
private final JPanel pnlStart;
|
||||
|
||||
private final StartButton btnStart = new StartButton();
|
||||
|
||||
private final JCheckBox cbSingletons = new FCheckBox("Singleton Mode");
|
||||
private final JCheckBox cbArtifacts = new FCheckBox("Remove Artifacts");
|
||||
private final JCheckBox cbRemoveSmall = new FCheckBox("Remove Small Creatures");
|
||||
private final JCheckBox cbAiVsAi = new FCheckBox("Spectate AI vs AI match");
|
||||
|
||||
private final FDeckChooser dcHuman = new FDeckChooser("Select your deck:", PlayerType.HUMAN);
|
||||
private final FDeckChooser dcAi = new FDeckChooser("Select AI deck:", PlayerType.COMPUTER);
|
||||
private final FDeckChooser dcLeft = new FDeckChooser("Select AI deck:", true);
|
||||
private final FDeckChooser dcRight = new FDeckChooser("Select your deck:", false);
|
||||
|
||||
|
||||
private VSubmenuConstructed() {
|
||||
|
||||
lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||
|
||||
|
||||
pnlStart = new JPanel(new MigLayout("insets 0, gap 0, wrap 2"));
|
||||
final String strCheckboxConstraints = "pushy, gap 0 20px 0 0";
|
||||
final String strCheckboxConstraintsTop = "pushy, gap 0 20px 20px 0";
|
||||
//final String strCheckboxConstraintsTop = "pushy, gap 0 20px 20px 0";
|
||||
pnlStart.setOpaque(false);
|
||||
pnlStart.add(cbSingletons, strCheckboxConstraintsTop);
|
||||
pnlStart.add(cbAiVsAi, strCheckboxConstraintsTop);
|
||||
pnlStart.add(btnStart, "span 1 2, growx, pushx, align center");
|
||||
pnlStart.add(cbSingletons, strCheckboxConstraints);
|
||||
pnlStart.add(btnStart, "growx, pushx, align center, sy 3");
|
||||
//pnlStart.add(cbAiVsAi, strCheckboxConstraintsTop);
|
||||
pnlStart.add(cbArtifacts, strCheckboxConstraints);
|
||||
pnlStart.add(cbRemoveSmall, strCheckboxConstraints);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -71,12 +71,12 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
return EMenuGroup.SANCTIONED;
|
||||
}
|
||||
|
||||
public final FDeckChooser getDcHuman() {
|
||||
return dcHuman;
|
||||
public final FDeckChooser getDcRight() {
|
||||
return dcRight;
|
||||
}
|
||||
|
||||
public final FDeckChooser getDcAi() {
|
||||
return dcAi;
|
||||
public final FDeckChooser getDcLeft() {
|
||||
return dcLeft;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,11 +106,11 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblTitle, "w 80%!, h 40px!, gap 0 0 15px 15px, span 2, ax right");
|
||||
|
||||
dcAi.populate();
|
||||
dcHuman.populate();
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(dcAi, "w 44%!, gap 0 0 20px 20px, growy, pushy");
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(dcHuman, "w 44%!, gap 4% 4% 20px 20px, growy, pushy");
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStart, "span 2, gap 0 0 2.5%! 3.5%!, ax center");
|
||||
dcLeft.populate();
|
||||
dcRight.populate();
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(dcLeft, "w 44%!, gap 0 0 20px 20px, growy, pushy");
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(dcRight, "w 44%!, gap 4% 4% 20px 20px, growy, pushy");
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStart, "span 2, gap 0 0 2.0%! 3.5%!, ax center");
|
||||
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().revalidate();
|
||||
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().repaintSelf();
|
||||
@@ -139,9 +139,13 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbSpectate() {
|
||||
return cbAiVsAi;
|
||||
public boolean isLeftPlayerAi() {
|
||||
return true;
|
||||
}
|
||||
public boolean isRightPlayerAi() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//========== Overridden from IVDoc
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import javax.swing.ScrollPaneConstants;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -122,7 +121,7 @@ public enum VSubmenuArchenemy implements IVSubmenu<CSubmenuArchenemy> {
|
||||
FPanel tempPanel = new FPanel();
|
||||
tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center"));
|
||||
|
||||
FDeckChooser tempChooser = new FDeckChooser("Select deck:", i == 0 ? PlayerType.HUMAN : PlayerType.COMPUTER);
|
||||
FDeckChooser tempChooser = new FDeckChooser("Select deck:", i != 0);
|
||||
tempChooser.initialize();
|
||||
|
||||
deckChoosers.add(tempChooser);
|
||||
|
||||
@@ -15,7 +15,6 @@ import javax.swing.ScrollPaneConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -125,7 +124,7 @@ public enum VSubmenuPlanechase implements IVSubmenu<CSubmenuPlanechase> {
|
||||
tempPanel = new FPanel();
|
||||
tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center"));
|
||||
|
||||
tempChooser = new FDeckChooser("Select deck:", i == 0 ? PlayerType.HUMAN : PlayerType.COMPUTER);
|
||||
tempChooser = new FDeckChooser("Select deck:", i != 0);
|
||||
tempChooser.initialize();
|
||||
|
||||
deckChoosers.add(tempChooser);
|
||||
|
||||
@@ -17,7 +17,6 @@ import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
@@ -171,7 +170,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
||||
tempPanel = new FPanel();
|
||||
tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center"));
|
||||
|
||||
tempChooser = new FDeckChooser("Select deck:", i == 0 ? PlayerType.HUMAN : PlayerType.COMPUTER);
|
||||
tempChooser = new FDeckChooser("Select deck:", i != 0);
|
||||
tempChooser.initialize();
|
||||
|
||||
tempList = new FList();
|
||||
|
||||
@@ -26,7 +26,6 @@ import forge.deck.Deck;
|
||||
import forge.deck.DeckgenUtil;
|
||||
import forge.deck.generate.GenerateThemeDeck;
|
||||
import forge.game.PlayerStartConditions;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.QuestEvent;
|
||||
import forge.quest.QuestEventChallenge;
|
||||
@@ -46,10 +45,10 @@ public class FDeckChooser extends JPanel {
|
||||
private final JScrollPane scrDecks =
|
||||
new FScrollPane(lstDecks, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
private final FLabel lblDecklist = new FLabel.Builder().text("Double click a non-random deck for its decklist.").fontSize(12).build();
|
||||
private final FLabel lblDecklist = new FLabel.Builder().text("Double click any non-random deck for its decklist.").fontSize(12).build();
|
||||
|
||||
private final JPanel pnlRadios = new JPanel(new MigLayout("insets 0, gap 0, wrap"));
|
||||
private final PlayerType playerType;
|
||||
private final JPanel pnlRadios = new JPanel(new MigLayout("insets 0, gap 0, wrap 2"));
|
||||
private boolean isAi;
|
||||
|
||||
private final MouseAdapter madDecklist = new MouseAdapter() {
|
||||
@Override
|
||||
@@ -62,12 +61,12 @@ public class FDeckChooser extends JPanel {
|
||||
}
|
||||
};
|
||||
|
||||
public FDeckChooser(String titleText, PlayerType pt) {
|
||||
public FDeckChooser(String titleText, boolean forAi) {
|
||||
setOpaque(false);
|
||||
playerType = pt;
|
||||
isAi = forAi;
|
||||
|
||||
// Radio button group
|
||||
final String strRadioConstraints = "w 100%!, h 30px!";
|
||||
final String strRadioConstraints = "h 28px!";
|
||||
JXButtonPanel grpRadios = new JXButtonPanel();
|
||||
grpRadios.add(radCustom, strRadioConstraints);
|
||||
grpRadios.add(radQuests, strRadioConstraints);
|
||||
@@ -75,10 +74,9 @@ public class FDeckChooser extends JPanel {
|
||||
grpRadios.add(radThemes, strRadioConstraints);
|
||||
|
||||
pnlRadios.setOpaque(false);
|
||||
pnlRadios.add(new FLabel.Builder().text(titleText).fontStyle(Font.BOLD).fontSize(16).build());
|
||||
pnlRadios.add(lblDecklist, "h 20px!, gap 0 0 0 10px");
|
||||
pnlRadios.add(grpRadios, "w 100%");
|
||||
pnlRadios.add(btnRandom, "w 200px!, h 30px!, gap 0 0 10px 0, ax center");
|
||||
pnlRadios.add(new FLabel.Builder().text(titleText).fontStyle(Font.BOLD).fontSize(16).build(), "sx 2");
|
||||
pnlRadios.add(grpRadios, "pushx, growx");
|
||||
pnlRadios.add(btnRandom, "w 160px!, h 30px!, gap 10px 0 0 0, ax center, ay bottom");
|
||||
}
|
||||
|
||||
private void _listen(final JRadioButton btn, final Runnable onSelect) {
|
||||
@@ -102,26 +100,25 @@ public class FDeckChooser extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
public JList getLstDecks() { return lstDecks; }
|
||||
public FLabel getBtnRandom() { return btnRandom; }
|
||||
public JRadioButton getRadColors() { return radColors; }
|
||||
public JRadioButton getRadThemes() { return radThemes; }
|
||||
public JRadioButton getRadCustom() { return radCustom; }
|
||||
public JRadioButton getRadQuests() { return radQuests; }
|
||||
private JList getLstDecks() { return lstDecks; }
|
||||
private FLabel getBtnRandom() { return btnRandom; }
|
||||
private JRadioButton getRadColors() { return radColors; }
|
||||
private JRadioButton getRadThemes() { return radThemes; }
|
||||
private JRadioButton getRadCustom() { return radCustom; }
|
||||
private JRadioButton getRadQuests() { return radQuests; }
|
||||
|
||||
/** Handles all control for "colors" radio button click. */
|
||||
private void updateColors() {
|
||||
final JList lst = getLstDecks();
|
||||
lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
|
||||
lst.setListData(new String[] {"Random 1", "Random 2", "Random 3",
|
||||
"Random 4", "Black", "Blue", "Green", "Red", "White"});
|
||||
lst.setListData(new String[] {"Random 1", "Random 2", "Random 3", "Black", "Blue", "Green", "Red", "White"});
|
||||
lst.setName(DeckgenUtil.DeckTypes.COLORS.toString());
|
||||
lst.removeMouseListener(madDecklist);
|
||||
lst.addMouseListener(madDecklist);
|
||||
|
||||
getBtnRandom().setCommand(new Command() {
|
||||
@Override public void run() { lst.setSelectedIndices(DeckgenUtil.randomSelectColors()); } });
|
||||
@Override public void run() { lst.setSelectedIndices(DeckgenUtil.randomSelectColors(8)); } });
|
||||
|
||||
// Init basic two color deck
|
||||
lst.setSelectedIndices(new int[]{0, 1});
|
||||
@@ -220,7 +217,7 @@ public class FDeckChooser extends JPanel {
|
||||
|
||||
Deck deck = null;
|
||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.COLORS.toString()) && DeckgenUtil.colorCheck(selection)) {
|
||||
deck = DeckgenUtil.buildColorDeck(selection, getPlayerType());
|
||||
deck = DeckgenUtil.buildColorDeck(selection, isAi);
|
||||
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.THEMES.toString())) {
|
||||
deck = DeckgenUtil.buildThemeDeck(selection);
|
||||
} else if (lst0.getName().equals(DeckgenUtil.DeckTypes.CUSTOM.toString())) {
|
||||
@@ -230,14 +227,12 @@ public class FDeckChooser extends JPanel {
|
||||
return PlayerStartConditions.fromDeck(deck);
|
||||
}
|
||||
|
||||
private PlayerType getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
|
||||
public void populate() {
|
||||
this.setLayout(new MigLayout("insets 0, gap 0, flowy, ax right"));
|
||||
|
||||
this.add(pnlRadios, "w 100%!, gap 0 0 20px 20px");
|
||||
this.add(pnlRadios, "w 100%!, gap 0 0 0 12px");
|
||||
this.add(scrDecks, "w 100%!, growy, pushy");
|
||||
this.add(lblDecklist, "w 100%!, h 20px!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Generate2ColorDeckTest {
|
||||
@Test(enabled = false)
|
||||
public void generate2ColorDeckTest1() {
|
||||
final Generate2ColorDeck gen = new Generate2ColorDeck("white", "blue");
|
||||
final ItemPoolView<CardPrinted> cardList = gen.getDeck(60, null);
|
||||
final ItemPoolView<CardPrinted> cardList = gen.getDeck(60, false);
|
||||
Assert.assertNotNull(cardList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Generate3ColorDeckTest {
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void generate3ColorDeckTest1() {
|
||||
final Generate3ColorDeck gen = new Generate3ColorDeck("white", "blue", "black");
|
||||
final ItemPoolView<CardPrinted> cardList = gen.getDeck(60, null);
|
||||
final ItemPoolView<CardPrinted> cardList = gen.getDeck(60, false);
|
||||
Assert.assertNotNull(cardList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Generate5ColorDeckTest {
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void generate5ColorDeckTest1() {
|
||||
final Generate5ColorDeck gen = new Generate5ColorDeck();
|
||||
final ItemPoolView<CardPrinted> cardList = gen.getDeck(60, null);
|
||||
final ItemPoolView<CardPrinted> cardList = gen.getDeck(60, false);
|
||||
Assert.assertNotNull(cardList);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user