From 659ac783feda4ef199f2b3786c654789c5973223 Mon Sep 17 00:00:00 2001 From: myk Date: Tue, 26 Mar 2013 05:01:42 +0000 Subject: [PATCH] add cards won via ante to deck in constructed matches --- CHANGES.txt | 6 +-- src/main/java/forge/gui/GuiChoose.java | 50 +++++++------------ src/main/java/forge/gui/ListChooser.java | 9 +--- .../java/forge/gui/match/ControlWinLose.java | 1 + 4 files changed, 23 insertions(+), 43 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3dd95ab88d6..8103baf8347 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,7 +9,7 @@ Release Notes ------------- - User data migration - -User data, like decks, saved gauntlets, and card pictures, is now stored in separate directories from the program data. When this version of Forge is first run, it will scan the program directory for all user data and automatically migrate all the files to their new homes. There are three defined user data directores: userDir, cacheDir, and cardPicsDir, and their locations depend on the standard paths for your operating system: +User data files, like decks, saved gauntlets, and card pictures, are now stored in new directories separate from the program data. When this version of Forge is first run, it will scan the program directory for all user data and automatically migrate the files to their new homes. There are three defined user data directores: userDir, cacheDir, and cardPicsDir, and their locations depend on the standard paths for your operating system: Windows: userDir=%APPDATA%/Forge/ @@ -24,9 +24,7 @@ User data, like decks, saved gauntlets, and card pictures, is now stored in sepa cardPicsDir is defined as /pics/cards/ by default. If you wish to use a non-default directory, please see the forge.profile.preferences.example file located in the Forge installation directory root. You can use this file to, for example, share the card pics directory with another program, such as Magic Workstation. If you are using the Mac OS X version of Forge then you will find the forge.profile.preferences.example file by right clicking or control clicking on the Forge.app icon. Select "Show Package Contents" from the contextual menu. A Finder window will open and will display a folder named Contents. Navigate to the folder: - -/Contents/Resources/Java/ - + /Contents/Resources/Java/ and you will find the file named forge.profile.preferences.example. diff --git a/src/main/java/forge/gui/GuiChoose.java b/src/main/java/forge/gui/GuiChoose.java index bdfe19f9dec..7009f07346c 100644 --- a/src/main/java/forge/gui/GuiChoose.java +++ b/src/main/java/forge/gui/GuiChoose.java @@ -89,41 +89,20 @@ public class GuiChoose { } // returned Object will never be null - /** - *

- * getChoices. - *

- * - * @param - * a T object. - * @param message - * a {@link java.lang.String} object. - * @param min - * a int. - * @param max - * a int. - * @param choices - * a T object. - * @return a {@link java.util.List} object. - */ public static List getChoices(final String message, final int min, final int max, final T[] choices) { - final ListChooser c = new ListChooser(message, min, max, choices); - return getChoices(c); + return getChoices(message, min, max, Arrays.asList(choices)); } public static List getChoices(final String message, final int min, final int max, final Collection choices) { - final ListChooser c = new ListChooser(message, min, max, choices); - return getChoices(c); - } - - // Nothing to choose here. Code uses this to just show a card. - public static Card show(final String message, final Card singleChoice) { - List choices = new ArrayList(); - choices.add(singleChoice); - return one(message, choices); - } - - private static List getChoices(final ListChooser c) { + if (null == choices || 0 == choices.size()) { + if (0 == min) { + return new ArrayList(); + } else { + throw new RuntimeException("choice required from empty list"); + } + } + + ListChooser c = new ListChooser(message, min, max, choices); final JList list = c.getJList(); list.addListSelectionListener(new ListSelectionListener() { @Override @@ -142,7 +121,14 @@ public class GuiChoose { c.show(); GuiUtils.clearPanelSelections(); return c.getSelectedValues(); - } // getChoice() + } + + // Nothing to choose here. Code uses this to just show a card. + public static Card show(final String message, final Card singleChoice) { + List choices = new ArrayList(); + choices.add(singleChoice); + return one(message, choices); + } public static List order(final String title, final String top, int remainingObjects, final List sourceChoices, List destChoices, Card referenceCard) { diff --git a/src/main/java/forge/gui/ListChooser.java b/src/main/java/forge/gui/ListChooser.java index 92a5dfe9de5..aa25d450207 100644 --- a/src/main/java/forge/gui/ListChooser.java +++ b/src/main/java/forge/gui/ListChooser.java @@ -24,7 +24,6 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowEvent; import java.awt.event.WindowFocusListener; import java.util.AbstractList; -import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -84,10 +83,6 @@ public class ListChooser { private JOptionPane optionPane; private Action ok, cancel; - public ListChooser(final String title, final int minChoices, final int maxChoices, final T[] list) { - this(title, minChoices, maxChoices, Arrays.asList(list)); - } - public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection list) { this.title = title; this.minChoices = minChoices; @@ -125,7 +120,7 @@ public class ListChooser { } /** @return boolean */ - public synchronized boolean show() { + public boolean show() { return show(list.get(0)); } @@ -135,7 +130,7 @@ public class ListChooser { * @param index0 index to select when shown * @return a boolean. */ - public synchronized boolean show(T item) { + public boolean show(T item) { if (this.called) { throw new IllegalStateException("Already shown"); } diff --git a/src/main/java/forge/gui/match/ControlWinLose.java b/src/main/java/forge/gui/match/ControlWinLose.java index 08b0d092680..0cba45494ff 100644 --- a/src/main/java/forge/gui/match/ControlWinLose.java +++ b/src/main/java/forge/gui/match/ControlWinLose.java @@ -141,6 +141,7 @@ public class ControlWinLose { cDeck.getMain().remove(toRemove); if ( cDeck != oDeck ) oDeck.getMain().remove(toRemove); + losses.add(toRemove); } }