mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
GuiUtils.getChoice renamed to clear and simple names
added possibility to pass List<T> as options (to avoid useless list -> array -> list conversions)
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -11179,7 +11179,7 @@ src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java svneol=nati
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java -text svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryCharm.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryCleanup.java svneol=native#text/plain
|
||||
|
||||
@@ -2759,7 +2759,7 @@ public class CombatUtil {
|
||||
if (lib.size() > 0) {
|
||||
final CardList cl = new CardList();
|
||||
cl.add(lib.get(0));
|
||||
GuiUtils.getChoiceOptional("Top card", cl.toArray());
|
||||
GuiUtils.chooseOneOrNone("Top card", cl.toArray());
|
||||
final Card top = lib.get(0);
|
||||
if (top.isCreature()) {
|
||||
player.gainLife(top.getBaseDefense(), c);
|
||||
@@ -3021,7 +3021,7 @@ public class CombatUtil {
|
||||
final Card crd = enchantments.get(j);
|
||||
target[j] = crd;
|
||||
}
|
||||
final Object check = GuiUtils.getChoiceOptional(
|
||||
final Object check = GuiUtils.chooseOneOrNone(
|
||||
"Select enchantment to enchant exalted creature", target);
|
||||
if (check != null) {
|
||||
enchantment = ((Card) check);
|
||||
|
||||
@@ -215,7 +215,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable {
|
||||
}
|
||||
|
||||
if (player.isHuman()) {
|
||||
final Object o = GuiUtils.getChoiceOptional(
|
||||
final Object o = GuiUtils.chooseOneOrNone(
|
||||
"Select target creature for Wall of Reverence life gain", creats.toArray());
|
||||
if (o != null) {
|
||||
final Card c = (Card) o;
|
||||
|
||||
@@ -1123,7 +1123,7 @@ public class GameAction {
|
||||
crd = list.get(0);
|
||||
} else {
|
||||
if (c.getController().isHuman()) {
|
||||
crd = GuiUtils.getChoiceOptional("Select totem armor to destroy", list.toArray());
|
||||
crd = GuiUtils.chooseOneOrNone("Select totem armor to destroy", list.toArray());
|
||||
} else {
|
||||
crd = list.get(0);
|
||||
}
|
||||
@@ -1306,7 +1306,7 @@ public class GameAction {
|
||||
crd = list.get(0);
|
||||
} else {
|
||||
if (c.getController().isHuman()) {
|
||||
crd = GuiUtils.getChoiceOptional("Select totem armor to destroy", list.toArray());
|
||||
crd = GuiUtils.chooseOneOrNone("Select totem armor to destroy", list.toArray());
|
||||
} else {
|
||||
crd = list.get(0);
|
||||
}
|
||||
@@ -1413,7 +1413,7 @@ public class GameAction {
|
||||
} else if (choices.size() == 1) {
|
||||
choice = choices.get(0);
|
||||
} else {
|
||||
choice = (String) GuiUtils.getChoiceOptional("Choose", choices.toArray());
|
||||
choice = (String) GuiUtils.chooseOneOrNone("Choose", choices.toArray());
|
||||
}
|
||||
|
||||
if (choice == null) {
|
||||
@@ -1451,7 +1451,7 @@ public class GameAction {
|
||||
} else if (choices.size() == 1) {
|
||||
sa = choices.get(0);
|
||||
} else {
|
||||
sa = (SpellAbility) GuiUtils.getChoiceOptional("Choose", choices.toArray());
|
||||
sa = (SpellAbility) GuiUtils.chooseOneOrNone("Choose", choices.toArray());
|
||||
}
|
||||
|
||||
if (sa == null) {
|
||||
@@ -1592,12 +1592,12 @@ public class GameAction {
|
||||
if (originalCard.getController().isHuman()) {
|
||||
|
||||
final int chosenAmount = (Integer) GuiUtils
|
||||
.getChoice("Exile how many cards?", choiceList.toArray());
|
||||
.chooseOne("Exile how many cards?", choiceList.toArray());
|
||||
System.out.println("Delve for " + chosenAmount);
|
||||
final CardList choices = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard);
|
||||
final CardList chosen = new CardList();
|
||||
for (int i = 0; i < chosenAmount; i++) {
|
||||
final Card nowChosen = GuiUtils.getChoiceOptional("Exile which card?", choices.toArray());
|
||||
final Card nowChosen = GuiUtils.chooseOneOrNone("Exile which card?", choices.toArray());
|
||||
|
||||
if (nowChosen == null) {
|
||||
// User canceled,abort delving.
|
||||
@@ -1674,7 +1674,7 @@ public class GameAction {
|
||||
ManaCost newCost = new ManaCost(originalCost.toString());
|
||||
Object tapForConvoke = null;
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(),
|
||||
tapForConvoke = GuiUtils.chooseOneOrNone("Tap for Convoke? " + newCost.toString(),
|
||||
choices.toArray());
|
||||
} else {
|
||||
// TODO: AI to choose a creature to tap would go here
|
||||
@@ -1689,7 +1689,7 @@ public class GameAction {
|
||||
String chosenColor = usableColors.get(0);
|
||||
if (usableColors.size() > 1) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
chosenColor = (String) GuiUtils.getChoice("Convoke for which color?",
|
||||
chosenColor = (String) GuiUtils.chooseOne("Convoke for which color?",
|
||||
usableColors.toArray());
|
||||
} else {
|
||||
// TODO: AI for choosing which color to
|
||||
@@ -1717,7 +1717,7 @@ public class GameAction {
|
||||
}
|
||||
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(),
|
||||
tapForConvoke = GuiUtils.chooseOneOrNone("Tap for Convoke? " + newCost.toString(),
|
||||
choices.toArray());
|
||||
} else {
|
||||
// TODO: AI to choose a creature to tap would go
|
||||
|
||||
@@ -137,7 +137,7 @@ public final class GameActionUtil {
|
||||
}
|
||||
|
||||
} // while
|
||||
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray());
|
||||
GuiUtils.chooseOneOrNone("Revealed cards:", revealed.toArray());
|
||||
|
||||
if (cascadedCard != null) {
|
||||
|
||||
@@ -268,7 +268,7 @@ public final class GameActionUtil {
|
||||
rippledCards[i] = crd;
|
||||
}
|
||||
} // for
|
||||
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray());
|
||||
GuiUtils.chooseOneOrNone("Revealed cards:", revealed.toArray());
|
||||
for (int i = 0; i < rippleMax; i++) {
|
||||
if (rippledCards[i] != null) {
|
||||
|
||||
@@ -463,7 +463,7 @@ public final class GameActionUtil {
|
||||
|
||||
final boolean flip = MyRandom.getRandom().nextBoolean();
|
||||
if (caller.isHuman()) {
|
||||
choice = GuiUtils.getChoice(source.getName() + " - Call coin flip", choices);
|
||||
choice = GuiUtils.chooseOne(source.getName() + " - Call coin flip", choices);
|
||||
} else {
|
||||
choice = choices[MyRandom.getRandom().nextInt(2)];
|
||||
}
|
||||
@@ -505,7 +505,7 @@ public final class GameActionUtil {
|
||||
|
||||
Object q = null;
|
||||
|
||||
q = GuiUtils.getChoiceOptional("Use " + c + " Landfall?", choices);
|
||||
q = GuiUtils.chooseOneOrNone("Use " + c + " Landfall?", choices);
|
||||
|
||||
return (q != null) && q.equals("Yes");
|
||||
}
|
||||
@@ -524,7 +524,7 @@ public final class GameActionUtil {
|
||||
public void resolve() {
|
||||
String color = "";
|
||||
|
||||
final Object o = GuiUtils.getChoice("Choose mana color", Constant.Color.ONLY_COLORS);
|
||||
final Object o = GuiUtils.chooseOne("Choose mana color", Constant.Color.ONLY_COLORS);
|
||||
color = InputPayManaCostUtil.getShortColorString((String) o);
|
||||
|
||||
final AbilityMana abMana = new AbilityMana(c, "0", color) {
|
||||
|
||||
@@ -1469,7 +1469,7 @@ public final class GuiDisplayUtil {
|
||||
*/
|
||||
public static void devModeTutor() {
|
||||
final CardList lib = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
|
||||
final Object o = GuiUtils.getChoiceOptional("Choose a card", lib.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Choose a card", lib.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
} else {
|
||||
@@ -1487,12 +1487,12 @@ public final class GuiDisplayUtil {
|
||||
*/
|
||||
public static void devModeAddCounter() {
|
||||
final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
final Object o = GuiUtils.getChoiceOptional("Add counters to which card?", play.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Add counters to which card?", play.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
} else {
|
||||
final Card c = (Card) o;
|
||||
final Counters counter = GuiUtils.getChoiceOptional("Which type of counter?", Counters.values());
|
||||
final Counters counter = GuiUtils.chooseOneOrNone("Which type of counter?", Counters.values());
|
||||
if (null == counter) {
|
||||
return;
|
||||
} else {
|
||||
@@ -1500,7 +1500,7 @@ public final class GuiDisplayUtil {
|
||||
for (int j = 0; j < 99; j++) {
|
||||
integers[j] = Integer.valueOf(j);
|
||||
}
|
||||
final Integer i = GuiUtils.getChoiceOptional("How many counters?", integers);
|
||||
final Integer i = GuiUtils.chooseOneOrNone("How many counters?", integers);
|
||||
if (null == i) {
|
||||
return;
|
||||
} else {
|
||||
@@ -1519,7 +1519,7 @@ public final class GuiDisplayUtil {
|
||||
*/
|
||||
public static void devModeTapPerm() {
|
||||
final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
final Object o = GuiUtils.getChoiceOptional("Choose a permanent", play.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
} else {
|
||||
@@ -1537,7 +1537,7 @@ public final class GuiDisplayUtil {
|
||||
*/
|
||||
public static void devModeUntapPerm() {
|
||||
final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
final Object o = GuiUtils.getChoiceOptional("Choose a permanent", play.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
} else {
|
||||
@@ -1566,7 +1566,7 @@ public final class GuiDisplayUtil {
|
||||
*/
|
||||
public static void devModeSetLife() {
|
||||
final List<Player> players = AllZone.getPlayersInGame();
|
||||
final Object o = GuiUtils.getChoiceOptional("Set life for which player?", players.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Set life for which player?", players.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
} else {
|
||||
@@ -1575,7 +1575,7 @@ public final class GuiDisplayUtil {
|
||||
for (int j = 0; j < 99; j++) {
|
||||
integers[j] = Integer.valueOf(j);
|
||||
}
|
||||
final Integer i = GuiUtils.getChoiceOptional("Set life to what?", integers);
|
||||
final Integer i = GuiUtils.chooseOneOrNone("Set life to what?", integers);
|
||||
if (null == i) {
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -135,9 +135,9 @@ public class HumanPlayer extends Player {
|
||||
public final boolean dredge() {
|
||||
boolean dredged = false;
|
||||
final String[] choices = { "Yes", "No" };
|
||||
final Object o = GuiUtils.getChoice("Do you want to dredge?", choices);
|
||||
final Object o = GuiUtils.chooseOne("Do you want to dredge?", choices);
|
||||
if (o.equals("Yes")) {
|
||||
final Card c = GuiUtils.getChoice("Select card to dredge", this.getDredge().toArray());
|
||||
final Card c = GuiUtils.chooseOne("Select card to dredge", this.getDredge().toArray());
|
||||
// rule 702.49a
|
||||
if (this.getDredgeNumber(c) <= AllZone.getHumanPlayer().getZone(Zone.Library).size()) {
|
||||
|
||||
@@ -198,7 +198,7 @@ public class HumanPlayer extends Player {
|
||||
s += "s";
|
||||
}
|
||||
|
||||
final Object o = GuiUtils.getChoice("Do you want to put the " + s
|
||||
final Object o = GuiUtils.chooseOne("Do you want to put the " + s
|
||||
+ " on the top or bottom of your library?", new Object[] { "top", "bottom" });
|
||||
libPos = o.toString();
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class HumanPlayer extends Player {
|
||||
protected final void doScry(final CardList topN, final int n) {
|
||||
int num = n;
|
||||
for (int i = 0; i < num; i++) {
|
||||
final Object o = GuiUtils.getChoiceOptional("Put on bottom of library.", topN.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Put on bottom of library.", topN.toArray());
|
||||
if (o != null) {
|
||||
final Card c = (Card) o;
|
||||
topN.remove(c);
|
||||
@@ -223,7 +223,7 @@ public class HumanPlayer extends Player {
|
||||
num = topN.size();
|
||||
for (int i = 0; i < num; i++) {
|
||||
Object o;
|
||||
o = GuiUtils.getChoice("Put on top of library.", topN.toArray());
|
||||
o = GuiUtils.chooseOne("Put on top of library.", topN.toArray());
|
||||
if (o != null) {
|
||||
final Card c = (Card) o;
|
||||
topN.remove(c);
|
||||
@@ -246,7 +246,7 @@ public class HumanPlayer extends Player {
|
||||
String choice = "";
|
||||
final String[] choices = { "top", "bottom" };
|
||||
Singletons.getControl().getControlMatch().setCard(c);
|
||||
choice = GuiUtils.getChoice(c.getName() + " - Top or bottom of Library", choices);
|
||||
choice = GuiUtils.chooseOne(c.getName() + " - Top or bottom of Library", choices);
|
||||
|
||||
if (choice.equals("bottom")) {
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(c);
|
||||
|
||||
@@ -1384,7 +1384,7 @@ public class MagicStack extends MyObservable {
|
||||
} else {
|
||||
while (activePlayerSAs.size() > 1) {
|
||||
|
||||
final SpellAbility next = (SpellAbility) GuiUtils.getChoice(
|
||||
final SpellAbility next = (SpellAbility) GuiUtils.chooseOne(
|
||||
"Choose which spell or ability to put on the stack next.", activePlayerSAs.toArray());
|
||||
|
||||
activePlayerSAs.remove(next);
|
||||
|
||||
@@ -1276,7 +1276,7 @@ public abstract class Player extends GameEntity {
|
||||
}
|
||||
}
|
||||
if (reveal) {
|
||||
GuiUtils.getChoice("Revealing the first card drawn", drawn.toArray());
|
||||
GuiUtils.chooseOne("Revealing the first card drawn", drawn.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -837,7 +837,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -939,7 +939,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1039,7 +1039,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1136,7 +1136,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1221,7 +1221,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1320,7 +1320,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1412,7 +1412,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1498,7 +1498,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1582,7 +1582,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1687,7 +1687,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1771,7 +1771,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -1858,7 +1858,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
private void revealTopCard(final String title) {
|
||||
if (peek[0] != prevCardShown[0]) {
|
||||
GuiUtils.getChoice(title, peek[0]);
|
||||
GuiUtils.chooseOne(title, peek[0]);
|
||||
prevCardShown[0] = peek[0];
|
||||
}
|
||||
} // revealTopCard()
|
||||
@@ -2046,7 +2046,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
}
|
||||
} // for loop
|
||||
if (cardsToReveal.size() > 0) {
|
||||
GuiUtils.getChoice("Revealed cards", cardsToReveal.toArray());
|
||||
GuiUtils.chooseOne("Revealed cards", cardsToReveal.toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2090,7 +2090,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
|
||||
if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) {
|
||||
if (player.isHuman()) {
|
||||
final Object o = GuiUtils.getChoiceOptional("Pick a creature to return to hand",
|
||||
final Object o = GuiUtils.chooseOneOrNone("Pick a creature to return to hand",
|
||||
graveyardCreatures.toArray());
|
||||
if (o != null) {
|
||||
final Card card = (Card) o;
|
||||
@@ -2499,7 +2499,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
||||
final Card crd = enchantmentsInLibrary.get(j);
|
||||
target[j] = crd;
|
||||
}
|
||||
final Object check = GuiUtils.getChoiceOptional("Select Curse to attach", target);
|
||||
final Object check = GuiUtils.chooseOneOrNone("Select Curse to attach", target);
|
||||
if (check != null) {
|
||||
enchantment = ((Card) check);
|
||||
}
|
||||
|
||||
@@ -1213,7 +1213,7 @@ public class AbilityFactoryAttach {
|
||||
}
|
||||
}
|
||||
|
||||
final Object o = GuiUtils.getChoice(source + " - Select a player to attach to.", players.toArray());
|
||||
final Object o = GuiUtils.chooseOne(source + " - Select a player to attach to.", players);
|
||||
if (o instanceof Player) {
|
||||
AbilityFactoryAttach.handleAura(source, (Player) o, false);
|
||||
//source.enchantEntity((Player) o);
|
||||
@@ -1223,7 +1223,7 @@ public class AbilityFactoryAttach {
|
||||
CardList list = AllZoneUtil.getCardsIn(tgt.getZone());
|
||||
list = list.getValidCards(tgt.getValidTgts(), aura.getActivatingPlayer(), source);
|
||||
|
||||
final Object o = GuiUtils.getChoice(source + " - Select a card to attach to.", list.toArray());
|
||||
final Object o = GuiUtils.chooseOne(source + " - Select a card to attach to.", list.toArray());
|
||||
if (o instanceof Card) {
|
||||
AbilityFactoryAttach.handleAura(source, (Card) o, gainControl);
|
||||
//source.enchantEntity((Card) o);
|
||||
|
||||
@@ -870,13 +870,13 @@ public final class AbilityFactoryChangeZone {
|
||||
// moving onto
|
||||
// choosing
|
||||
// a card{
|
||||
GuiUtils.getChoiceOptional(af.getHostCard().getName() + " - Looking at Library",
|
||||
GuiUtils.chooseOneOrNone(af.getHostCard().getName() + " - Looking at Library",
|
||||
player.getCardsIn(Zone.Library).toArray());
|
||||
}
|
||||
|
||||
// Look at opponents hand before moving onto choosing a card
|
||||
if (origin.contains(Zone.Hand) && player.isComputer()) {
|
||||
GuiUtils.getChoiceOptional(af.getHostCard().getName() + " - Looking at Opponent's Hand", player
|
||||
GuiUtils.chooseOneOrNone(af.getHostCard().getName() + " - Looking at Opponent's Hand", player
|
||||
.getCardsIn(Zone.Hand).toArray());
|
||||
}
|
||||
fetchList = AbilityFactory.filterListByType(fetchList, params.get("ChangeType"), sa);
|
||||
@@ -900,11 +900,11 @@ public final class AbilityFactoryChangeZone {
|
||||
if (params.containsKey("AtRandom")) {
|
||||
o = CardUtil.getRandom(fetchList.toArray());
|
||||
} else if (params.containsKey("Mandatory")) {
|
||||
o = GuiUtils.getChoice("Select a card", fetchList.toArray());
|
||||
o = GuiUtils.chooseOne("Select a card", fetchList.toArray());
|
||||
} else if (params.containsKey("Defined")) {
|
||||
o = fetchList.get(0);
|
||||
} else {
|
||||
o = GuiUtils.getChoiceOptional("Select a card", fetchList.toArray());
|
||||
o = GuiUtils.chooseOneOrNone("Select a card", fetchList.toArray());
|
||||
}
|
||||
|
||||
if (o != null) {
|
||||
@@ -916,7 +916,7 @@ public final class AbilityFactoryChangeZone {
|
||||
// do not shuffle the library once we have placed a fetched
|
||||
// card on top.
|
||||
if (params.containsKey("Reveal")) {
|
||||
GuiUtils.getChoice(card + " - Revealed card: ", c);
|
||||
GuiUtils.chooseOne(card + " - Revealed card: ", c);
|
||||
}
|
||||
if (origin.contains(Zone.Library) && (i < 1)) {
|
||||
player.shuffle();
|
||||
@@ -1166,9 +1166,9 @@ public final class AbilityFactoryChangeZone {
|
||||
if (!Zone.Battlefield.equals(destination) && !"Card".equals(type) && !defined) {
|
||||
final String picked = af.getHostCard().getName() + " - Computer picked:";
|
||||
if (fetched.size() > 0) {
|
||||
GuiUtils.getChoice(picked, fetched.toArray());
|
||||
GuiUtils.chooseOne(picked, fetched.toArray());
|
||||
} else {
|
||||
GuiUtils.getChoice(picked, new String[] { "<Nothing>" });
|
||||
GuiUtils.chooseOne(picked, new String[] { "<Nothing>" });
|
||||
}
|
||||
}
|
||||
} // end changeHiddenOriginResolveAI
|
||||
|
||||
@@ -1,190 +1,190 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.abilityfactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.gui.GuiUtils;
|
||||
|
||||
// Charm specific params:
|
||||
// Choices - a ","-delimited list of SVars containing ability choices
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbilityFactory_Charm class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
*/
|
||||
public final class AbilityFactoryCharm {
|
||||
|
||||
private AbilityFactoryCharm() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* createAbilityCharm.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static SpellAbility createAbilityCharm(final AbilityFactory af) {
|
||||
final SpellAbility abCharm = new AbilityActivated(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||
private static final long serialVersionUID = -4038591081733095021L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return AbilityFactoryCharm.charmCanPlayAI(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AbilityFactoryCharm.charmResolve(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription() {
|
||||
return AbilityFactoryCharm.charmStackDescription(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doTrigger(final boolean mandatory) {
|
||||
return AbilityFactoryCharm.charmCanPlayAI(af, this);
|
||||
}
|
||||
}; // Ability_Activated
|
||||
|
||||
return abCharm;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* createSpellCharm.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static SpellAbility createSpellCharm(final AbilityFactory af) {
|
||||
final SpellAbility spCharm = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||
private static final long serialVersionUID = -7297235470289087240L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return AbilityFactoryCharm.charmCanPlayAI(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AbilityFactoryCharm.charmResolve(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription() {
|
||||
return AbilityFactoryCharm.charmStackDescription(af, this);
|
||||
}
|
||||
};
|
||||
|
||||
return spCharm;
|
||||
}
|
||||
|
||||
private static String charmStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (sa instanceof AbilitySub) {
|
||||
sb.append(" ");
|
||||
} else {
|
||||
sb.append(sa.getSourceCard()).append(" - ");
|
||||
}
|
||||
// end standard begin
|
||||
|
||||
// nothing stack specific for Charm
|
||||
|
||||
// begin standard post
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
sb.append(abSub.getStackDescription());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static boolean charmCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||
// TODO - enable Charms for the AI
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void charmResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||
// nothing to do. Ability_Subs are set up in
|
||||
// GameAction.playSpellAbility(),
|
||||
// and that Ability_Sub.resolve() is called from AbilityFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the up charm s as.
|
||||
*
|
||||
* @param sa
|
||||
* the new up charm s as
|
||||
*/
|
||||
public static void setupCharmSAs(final SpellAbility sa) {
|
||||
// make Charm choices
|
||||
if (sa.isCharm()) {
|
||||
final ArrayList<SpellAbility> choices = new ArrayList<SpellAbility>();
|
||||
choices.addAll(sa.getCharmChoices());
|
||||
for (int i = 0; i < choices.size(); i++) {
|
||||
if (!sa.canPlay()) {
|
||||
choices.remove(sa);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < sa.getCharmNumber(); i++) {
|
||||
Object o;
|
||||
if (i < sa.getMinCharmNumber()) {
|
||||
o = GuiUtils.getChoice("Choose a mode", choices.toArray());
|
||||
} else {
|
||||
o = GuiUtils.getChoiceOptional("Choose a mode", choices.toArray());
|
||||
}
|
||||
if (null == o) {
|
||||
break;
|
||||
}
|
||||
final AbilitySub chosen = (AbilitySub) o;
|
||||
sa.addCharmChoice(chosen);
|
||||
choices.remove(chosen);
|
||||
|
||||
// walk down the SpellAbility tree and add to the child
|
||||
// Ability_Sub
|
||||
SpellAbility child = sa;
|
||||
while (child.getSubAbility() != null) {
|
||||
child = child.getSubAbility();
|
||||
}
|
||||
child.setSubAbility(chosen);
|
||||
if (chosen.getActivatingPlayer() == null) {
|
||||
chosen.setActivatingPlayer(child.getActivatingPlayer());
|
||||
}
|
||||
chosen.setParent(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end class AbilityFactory_Charm
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card.abilityfactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.gui.GuiUtils;
|
||||
|
||||
// Charm specific params:
|
||||
// Choices - a ","-delimited list of SVars containing ability choices
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbilityFactory_Charm class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
*/
|
||||
public final class AbilityFactoryCharm {
|
||||
|
||||
private AbilityFactoryCharm() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* createAbilityCharm.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static SpellAbility createAbilityCharm(final AbilityFactory af) {
|
||||
final SpellAbility abCharm = new AbilityActivated(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||
private static final long serialVersionUID = -4038591081733095021L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return AbilityFactoryCharm.charmCanPlayAI(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AbilityFactoryCharm.charmResolve(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription() {
|
||||
return AbilityFactoryCharm.charmStackDescription(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doTrigger(final boolean mandatory) {
|
||||
return AbilityFactoryCharm.charmCanPlayAI(af, this);
|
||||
}
|
||||
}; // Ability_Activated
|
||||
|
||||
return abCharm;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* createSpellCharm.
|
||||
* </p>
|
||||
*
|
||||
* @param af
|
||||
* a {@link forge.card.abilityfactory.AbilityFactory} object.
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static SpellAbility createSpellCharm(final AbilityFactory af) {
|
||||
final SpellAbility spCharm = new Spell(af.getHostCard(), af.getAbCost(), af.getAbTgt()) {
|
||||
private static final long serialVersionUID = -7297235470289087240L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return AbilityFactoryCharm.charmCanPlayAI(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AbilityFactoryCharm.charmResolve(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription() {
|
||||
return AbilityFactoryCharm.charmStackDescription(af, this);
|
||||
}
|
||||
};
|
||||
|
||||
return spCharm;
|
||||
}
|
||||
|
||||
private static String charmStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (sa instanceof AbilitySub) {
|
||||
sb.append(" ");
|
||||
} else {
|
||||
sb.append(sa.getSourceCard()).append(" - ");
|
||||
}
|
||||
// end standard begin
|
||||
|
||||
// nothing stack specific for Charm
|
||||
|
||||
// begin standard post
|
||||
final AbilitySub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
sb.append(abSub.getStackDescription());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static boolean charmCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||
// TODO - enable Charms for the AI
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void charmResolve(final AbilityFactory af, final SpellAbility sa) {
|
||||
// nothing to do. Ability_Subs are set up in
|
||||
// GameAction.playSpellAbility(),
|
||||
// and that Ability_Sub.resolve() is called from AbilityFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the up charm s as.
|
||||
*
|
||||
* @param sa
|
||||
* the new up charm s as
|
||||
*/
|
||||
public static void setupCharmSAs(final SpellAbility sa) {
|
||||
// make Charm choices
|
||||
if (sa.isCharm()) {
|
||||
final ArrayList<SpellAbility> choices = new ArrayList<SpellAbility>();
|
||||
choices.addAll(sa.getCharmChoices());
|
||||
for (int i = 0; i < choices.size(); i++) {
|
||||
if (!sa.canPlay()) {
|
||||
choices.remove(sa);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < sa.getCharmNumber(); i++) {
|
||||
Object o;
|
||||
if (i < sa.getMinCharmNumber()) {
|
||||
o = GuiUtils.chooseOne("Choose a mode", choices.toArray());
|
||||
} else {
|
||||
o = GuiUtils.chooseOneOrNone("Choose a mode", choices.toArray());
|
||||
}
|
||||
if (null == o) {
|
||||
break;
|
||||
}
|
||||
final AbilitySub chosen = (AbilitySub) o;
|
||||
sa.addCharmChoice(chosen);
|
||||
choices.remove(chosen);
|
||||
|
||||
// walk down the SpellAbility tree and add to the child
|
||||
// Ability_Sub
|
||||
SpellAbility child = sa;
|
||||
while (child.getSubAbility() != null) {
|
||||
child = child.getSubAbility();
|
||||
}
|
||||
child.setSubAbility(chosen);
|
||||
if (chosen.getActivatingPlayer() == null) {
|
||||
chosen.setActivatingPlayer(child.getActivatingPlayer());
|
||||
}
|
||||
chosen.setParent(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end class AbilityFactory_Charm
|
||||
|
||||
@@ -309,7 +309,7 @@ public final class AbilityFactoryChoose {
|
||||
while (!valid) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
final Object o = GuiUtils
|
||||
.getChoice("Choose a card type", CardUtil.getCardTypes().toArray());
|
||||
.chooseOne("Choose a card type", CardUtil.getCardTypes().toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ public final class AbilityFactoryChoose {
|
||||
for (final String s : invalidTypes) {
|
||||
validChoices.remove(s);
|
||||
}
|
||||
final Object o = GuiUtils.getChoice("Choose a creature type", validChoices.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Choose a creature type", validChoices.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public final class AbilityFactoryChoose {
|
||||
if (!CardUtil.isACreatureType(chosen) || invalidTypes.contains(chosen)) {
|
||||
chosen = "Sliver";
|
||||
}
|
||||
GuiUtils.getChoice("Computer picked: ", chosen);
|
||||
GuiUtils.chooseOne("Computer picked: ", chosen);
|
||||
chosenType = chosen;
|
||||
}
|
||||
if (CardUtil.isACreatureType(chosenType) && !invalidTypes.contains(chosenType)) {
|
||||
@@ -384,7 +384,7 @@ public final class AbilityFactoryChoose {
|
||||
boolean valid = false;
|
||||
while (!valid) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
final Object o = GuiUtils.getChoice("Choose a basic land type", CardUtil.getBasicTypes()
|
||||
final Object o = GuiUtils.chooseOne("Choose a basic land type", CardUtil.getBasicTypes()
|
||||
.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
@@ -404,7 +404,7 @@ public final class AbilityFactoryChoose {
|
||||
while (!valid) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
final Object o = GuiUtils
|
||||
.getChoice("Choose a land type", CardUtil.getLandTypes().toArray());
|
||||
.chooseOne("Choose a land type", CardUtil.getLandTypes().toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
}
|
||||
@@ -650,11 +650,11 @@ public final class AbilityFactoryChoose {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
if (params.containsKey("OrColors")) {
|
||||
final List<String> o = GuiUtils.getChoices("Choose a color or colors",
|
||||
final List<String> o = GuiUtils.chooseOneOrMany("Choose a color or colors",
|
||||
Constant.Color.ONLY_COLORS);
|
||||
card.setChosenColor(new ArrayList<String>(o));
|
||||
} else {
|
||||
final Object o = GuiUtils.getChoice("Choose a color", Constant.Color.ONLY_COLORS);
|
||||
final Object o = GuiUtils.chooseOne("Choose a color", Constant.Color.ONLY_COLORS);
|
||||
if (null == o) {
|
||||
return;
|
||||
}
|
||||
@@ -701,7 +701,7 @@ public final class AbilityFactoryChoose {
|
||||
if (chosen.equals("")) {
|
||||
chosen = Constant.Color.GREEN;
|
||||
}
|
||||
GuiUtils.getChoice("Computer picked: ", chosen);
|
||||
GuiUtils.chooseOne("Computer picked: ", chosen);
|
||||
final ArrayList<String> colorTemp = new ArrayList<String>();
|
||||
colorTemp.add(chosen);
|
||||
card.setChosenColor(colorTemp);
|
||||
@@ -942,7 +942,7 @@ public final class AbilityFactoryChoose {
|
||||
final String message = "Randomly chosen number: " + chosen;
|
||||
JOptionPane.showMessageDialog(null, message, "" + card, JOptionPane.PLAIN_MESSAGE);
|
||||
} else {
|
||||
final Object o = GuiUtils.getChoice("Choose a number", choices);
|
||||
final Object o = GuiUtils.chooseOne("Choose a number", choices);
|
||||
if (null == o) {
|
||||
return;
|
||||
}
|
||||
@@ -1176,7 +1176,7 @@ public final class AbilityFactoryChoose {
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
final Object o = GuiUtils.getChoice("Choose a player", choices.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Choose a player", choices.toArray());
|
||||
if (null == o) {
|
||||
return;
|
||||
}
|
||||
@@ -1496,7 +1496,7 @@ public final class AbilityFactoryChoose {
|
||||
if (chosen == "") {
|
||||
chosen = "Morphling";
|
||||
}
|
||||
GuiUtils.getChoice("Computer picked: ", chosen);
|
||||
GuiUtils.chooseOne("Computer picked: ", chosen);
|
||||
host.setNamedCard(chosen);
|
||||
ok = true;
|
||||
}
|
||||
@@ -1729,7 +1729,7 @@ public final class AbilityFactoryChoose {
|
||||
final CardList cl = land.getType(type);
|
||||
if (cl.size() > 0) {
|
||||
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type;
|
||||
final Object o = GuiUtils.getChoice(prompt, cl.toArray());
|
||||
final Object o = GuiUtils.chooseOne(prompt, cl.toArray());
|
||||
if (null != o) {
|
||||
final Card c = (Card) o;
|
||||
chosen.add(c);
|
||||
@@ -1949,7 +1949,7 @@ public final class AbilityFactoryChoose {
|
||||
|
||||
for (final Player p : tgtPlayers) {
|
||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||
String choice = (String) GuiUtils.getChoice("Choose one", choices.values().toArray());
|
||||
String choice = (String) GuiUtils.chooseOne("Choose one", choices.values().toArray());
|
||||
AbilityFactory afChoice = new AbilityFactory();
|
||||
final SpellAbility chosenSA = afChoice.getAbility(host.getSVar(choices.inverse().get(choice)), host);
|
||||
|
||||
|
||||
@@ -696,7 +696,7 @@ public final class AbilityFactoryClash {
|
||||
|
||||
// first, separate the cards into piles
|
||||
if (separator.isHuman()) {
|
||||
final List<Card> l = GuiUtils.getChoicesOptional("Put into pile 1 (multi-select)", pool.toArray());
|
||||
final List<Card> l = GuiUtils.chooseNoneOrMany("Put into pile 1 (multi-select)", pool.toArray());
|
||||
for (final Card c : l) {
|
||||
pile1.add(c);
|
||||
}
|
||||
@@ -753,7 +753,7 @@ public final class AbilityFactoryClash {
|
||||
// make sure Pile 1 or Pile 2 is clicked on
|
||||
boolean chosen = false;
|
||||
while (!chosen) {
|
||||
final Object o = GuiUtils.getChoice("Choose a pile", disp);
|
||||
final Object o = GuiUtils.chooseOne("Choose a pile", disp);
|
||||
final Card c = (Card) o;
|
||||
if (c.getName().equals("Pile 1")) {
|
||||
chosen = true;
|
||||
|
||||
@@ -743,7 +743,7 @@ public final class AbilityFactoryCopy {
|
||||
if (tgtSpells.size() == 1) {
|
||||
chosenSA = tgtSpells.get(0);
|
||||
} else if (sa.getActivatingPlayer().isHuman()) {
|
||||
chosenSA = (SpellAbility) GuiUtils.getChoice("Select a spell to copy", tgtSpells.toArray());
|
||||
chosenSA = (SpellAbility) GuiUtils.chooseOne("Select a spell to copy", tgtSpells.toArray());
|
||||
} else {
|
||||
chosenSA = tgtSpells.get(0);
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ public class AbilityFactoryCounters {
|
||||
for (int j = 0; j <= counterAmount; j++) {
|
||||
integers[j] = Integer.valueOf(j);
|
||||
}
|
||||
final Integer i = GuiUtils.getChoiceOptional("How many counters?", integers);
|
||||
final Integer i = GuiUtils.chooseOneOrNone("How many counters?", integers);
|
||||
if (null == i) {
|
||||
return;
|
||||
} else {
|
||||
@@ -1125,7 +1125,7 @@ public class AbilityFactoryCounters {
|
||||
}
|
||||
if (typeChoices.size() > 1) {
|
||||
String prompt = "Select type counters to remove";
|
||||
o = GuiUtils.getChoice(prompt, typeChoices.toArray());
|
||||
o = GuiUtils.chooseOne(prompt, typeChoices.toArray());
|
||||
}
|
||||
else {
|
||||
o = typeChoices.get(0);
|
||||
@@ -1141,7 +1141,7 @@ public class AbilityFactoryCounters {
|
||||
choices.add("" + i);
|
||||
}
|
||||
String prompt = "Select the number of " + chosenType.getName() + " counters to remove";
|
||||
o = GuiUtils.getChoice(prompt, choices.toArray());
|
||||
o = GuiUtils.chooseOne(prompt, choices.toArray());
|
||||
chosenAmount = Integer.parseInt((String) o);
|
||||
}
|
||||
}
|
||||
@@ -1177,7 +1177,7 @@ public class AbilityFactoryCounters {
|
||||
choices.add("" + i);
|
||||
}
|
||||
final String prompt = "Select the number of " + type + " counters to remove";
|
||||
final Object o = GuiUtils.getChoice(prompt, choices.toArray());
|
||||
final Object o = GuiUtils.chooseOne(prompt, choices.toArray());
|
||||
counterAmount = Integer.parseInt((String) o);
|
||||
}
|
||||
}
|
||||
@@ -1436,7 +1436,7 @@ public class AbilityFactoryCounters {
|
||||
}
|
||||
if (choices.size() > 0) {
|
||||
card.addCounter(
|
||||
Counters.getType((choices.size() == 1 ? choices.get(0) : GuiUtils.getChoice(
|
||||
Counters.getType((choices.size() == 1 ? choices.get(0) : GuiUtils.chooseOne(
|
||||
"Select counter type", choices.toArray()).toString())), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ public class AbilityFactoryMana {
|
||||
else {
|
||||
colorMenu = Constant.Color.ONLY_COLORS;
|
||||
}
|
||||
Object o = GuiUtils.getChoice("Select Mana to Produce", colorMenu);
|
||||
Object o = GuiUtils.chooseOne("Select Mana to Produce", colorMenu);
|
||||
if (o == null) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("AbilityFactoryMana::manaResolve() - Human color mana choice is empty for ");
|
||||
@@ -337,7 +337,7 @@ public class AbilityFactoryMana {
|
||||
chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn(
|
||||
Zone.Hand));
|
||||
}
|
||||
GuiUtils.getChoice("Computer picked: ", chosen);
|
||||
GuiUtils.chooseOne("Computer picked: ", chosen);
|
||||
abMana.setExpressChoice(InputPayManaCostUtil.getShortColorString(chosen));
|
||||
}
|
||||
if (abMana.getExpressChoice().isEmpty()) {
|
||||
@@ -806,7 +806,7 @@ public class AbilityFactoryMana {
|
||||
baseMana = InputPayManaCostUtil.getShortColorString(colors.get(0));
|
||||
} else {
|
||||
if (player.isHuman()) {
|
||||
final Object o = GuiUtils.getChoiceOptional("Select Mana to Produce", colors.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Select Mana to Produce", colors.toArray());
|
||||
if (o == null) {
|
||||
// User hit cancel
|
||||
abMana.setCanceled(true);
|
||||
|
||||
@@ -2054,7 +2054,7 @@ public class AbilityFactoryPermanentState {
|
||||
if (AllZoneUtil.isCardInPlay(tgtC) && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
final String[] tapOrUntap = new String[] { "Tap", "Untap" };
|
||||
final Object z = GuiUtils.getChoiceOptional("Tap or Untap " + tgtC + "?", tapOrUntap);
|
||||
final Object z = GuiUtils.chooseOneOrNone("Tap or Untap " + tgtC + "?", tapOrUntap);
|
||||
if (null == z) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ public final class AbilityFactoryPlay {
|
||||
Card tgtCard = tgtCards.get(0);
|
||||
if (tgtCards.size() > 1) {
|
||||
if (controller.isHuman()) {
|
||||
tgtCard = (Card) GuiUtils.getChoice("Select a card to play", tgtCards.toArray());
|
||||
tgtCard = (Card) GuiUtils.chooseOne("Select a card to play", tgtCards.toArray());
|
||||
} else {
|
||||
// AI
|
||||
tgtCards = tgtCards.filter(new CardListFilter() {
|
||||
@@ -420,7 +420,7 @@ public final class AbilityFactoryPlay {
|
||||
if (sas.size() == 1) {
|
||||
tgtSA = sas.get(0);
|
||||
} else if (sa.getActivatingPlayer().isHuman()) {
|
||||
tgtSA = (SpellAbility) GuiUtils.getChoice("Select a spell to cast", sas.toArray());
|
||||
tgtSA = (SpellAbility) GuiUtils.chooseOne("Select a spell to cast", sas.toArray());
|
||||
} else {
|
||||
tgtSA = sas.get(0);
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ public final class AbilityFactoryProtection {
|
||||
final ArrayList<String> gains = new ArrayList<String>();
|
||||
if (isChoice) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
final Object o = GuiUtils.getChoice("Choose a protection", choices.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Choose a protection", choices.toArray());
|
||||
|
||||
if (null == o) {
|
||||
return;
|
||||
@@ -1084,7 +1084,7 @@ public final class AbilityFactoryProtection {
|
||||
final ArrayList<String> gains = new ArrayList<String>();
|
||||
if (isChoice) {
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
final Object o = GuiUtils.getChoice("Choose a protection", choices.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Choose a protection", choices.toArray());
|
||||
|
||||
if (null == o) {
|
||||
return;
|
||||
|
||||
@@ -397,7 +397,7 @@ public final class AbilityFactoryReveal {
|
||||
boolean cardsRevealed = false;
|
||||
|
||||
if (params.containsKey("Reveal")) {
|
||||
GuiUtils.getChoice("Revealing cards from library", top.toArray());
|
||||
GuiUtils.chooseOne("Revealing cards from library", top.toArray());
|
||||
cardsRevealed = true;
|
||||
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
|
||||
// - for when it exists
|
||||
@@ -407,18 +407,18 @@ public final class AbilityFactoryReveal {
|
||||
question += c + " ";
|
||||
}
|
||||
if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) {
|
||||
GuiUtils.getChoice(host + "Revealing cards from library", top.toArray());
|
||||
GuiUtils.chooseOne(host + "Revealing cards from library", top.toArray());
|
||||
// Singletons.getModel().getGameAction().revealToCopmuter(top.toArray());
|
||||
cardsRevealed = true;
|
||||
} else if (p.isComputer() && (top.get(0).isInstant() || top.get(0).isSorcery())) {
|
||||
GuiUtils.getChoice(host + "Revealing cards from library", top.toArray());
|
||||
GuiUtils.chooseOne(host + "Revealing cards from library", top.toArray());
|
||||
cardsRevealed = true;
|
||||
}
|
||||
} else if (params.containsKey("RevealValid")) {
|
||||
final String revealValid = params.get("RevealValid");
|
||||
final CardList toReveal = top.getValidCards(revealValid, host.getController(), host);
|
||||
if (!toReveal.isEmpty()) {
|
||||
GuiUtils.getChoice("Revealing cards from library", toReveal.toArray());
|
||||
GuiUtils.chooseOne("Revealing cards from library", toReveal.toArray());
|
||||
if (params.containsKey("RememberRevealed")) {
|
||||
for (final Card one : toReveal) {
|
||||
host.addRemembered(one);
|
||||
@@ -429,7 +429,7 @@ public final class AbilityFactoryReveal {
|
||||
// - for when it exists
|
||||
} else if (choser.isHuman()) {
|
||||
// show the user the revealed cards
|
||||
GuiUtils.getChoice("Looking at cards from library", top.toArray());
|
||||
GuiUtils.chooseOne("Looking at cards from library", top.toArray());
|
||||
cardsRevealed = true;
|
||||
}
|
||||
|
||||
@@ -499,9 +499,9 @@ public final class AbilityFactoryReveal {
|
||||
prompt = "Chose a card to put on top of the ";
|
||||
}
|
||||
if (anyNumber || optional) {
|
||||
chosen = GuiUtils.getChoiceOptional(prompt + destZone1, valid.toArray());
|
||||
chosen = GuiUtils.chooseOneOrNone(prompt + destZone1, valid.toArray());
|
||||
} else {
|
||||
chosen = GuiUtils.getChoice(prompt + destZone1, valid.toArray());
|
||||
chosen = GuiUtils.chooseOne(prompt + destZone1, valid.toArray());
|
||||
}
|
||||
if ((chosen == null) || chosen.getName().equals("[No valid cards]")) {
|
||||
break;
|
||||
@@ -552,7 +552,7 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
}
|
||||
if (changeValid.length() > 0) {
|
||||
GuiUtils.getChoice("Computer picked: ", chosen);
|
||||
GuiUtils.chooseOne("Computer picked: ", chosen);
|
||||
}
|
||||
valid.remove(chosen);
|
||||
}
|
||||
@@ -579,7 +579,7 @@ public final class AbilityFactoryReveal {
|
||||
if (libraryPosition2 == -1) {
|
||||
prompt = "Put the rest on the bottom of the library in any order";
|
||||
}
|
||||
chosen = GuiUtils.getChoice(prompt, rest.toArray());
|
||||
chosen = GuiUtils.chooseOne(prompt, rest.toArray());
|
||||
} else {
|
||||
chosen = rest.get(0);
|
||||
}
|
||||
@@ -975,7 +975,7 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
|
||||
if (revealed.size() > 0) {
|
||||
GuiUtils.getChoice(p + " revealed: ", revealed.toArray());
|
||||
GuiUtils.chooseOne(p + " revealed: ", revealed.toArray());
|
||||
}
|
||||
|
||||
// TODO Allow Human to choose the order
|
||||
@@ -1327,7 +1327,7 @@ public final class AbilityFactoryReveal {
|
||||
final CardList hand = p.getCardsIn(Zone.Hand);
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
if (hand.size() > 0) {
|
||||
GuiUtils.getChoice(p + "'s hand", hand.toArray());
|
||||
GuiUtils.chooseOne(p + "'s hand", hand.toArray());
|
||||
} else {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(p).append("'s hand is empty!");
|
||||
@@ -1916,7 +1916,7 @@ public final class AbilityFactoryReveal {
|
||||
suffix = "th";
|
||||
}
|
||||
final String title = "Put " + i + suffix + " from the top: ";
|
||||
final Object o = GuiUtils.getChoiceOptional(title, topCards.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone(title, topCards.toArray());
|
||||
if (o == null) {
|
||||
break;
|
||||
}
|
||||
@@ -2215,7 +2215,7 @@ public final class AbilityFactoryReveal {
|
||||
final CardList revealed = new CardList();
|
||||
if (params.containsKey("Random")) {
|
||||
revealed.add(CardUtil.getRandom(handChoices.toArray()));
|
||||
GuiUtils.getChoice("Revealed card(s)", revealed.toArray());
|
||||
GuiUtils.chooseOne("Revealed card(s)", revealed.toArray());
|
||||
} else {
|
||||
CardList valid = new CardList(handChoices);
|
||||
int max = 1;
|
||||
@@ -2226,7 +2226,7 @@ public final class AbilityFactoryReveal {
|
||||
max = valid.size();
|
||||
}
|
||||
revealed.addAll(AbilityFactoryReveal.getRevealedList(sa.getActivatingPlayer(), valid, max));
|
||||
GuiUtils.getChoice("Revealed card(s)", revealed.toArray());
|
||||
GuiUtils.chooseOne("Revealed card(s)", revealed.toArray());
|
||||
}
|
||||
|
||||
if (params.containsKey("RememberRevealed")) {
|
||||
@@ -2254,7 +2254,7 @@ public final class AbilityFactoryReveal {
|
||||
|
||||
for (int i = 0; i < validamount; i++) {
|
||||
if (player.isHuman()) {
|
||||
final Object o = GuiUtils.getChoiceOptional("Choose card(s) to reveal", valid.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Choose card(s) to reveal", valid.toArray());
|
||||
if (o != null) {
|
||||
chosen.add((Card) o);
|
||||
valid.remove((Card) o);
|
||||
|
||||
@@ -532,9 +532,9 @@ public class AbilityFactorySacrifice {
|
||||
}
|
||||
Object o;
|
||||
if (optional) {
|
||||
o = GuiUtils.getChoiceOptional("Select a card to sacrifice", list.toArray());
|
||||
o = GuiUtils.chooseOneOrNone("Select a card to sacrifice", list.toArray());
|
||||
} else {
|
||||
o = GuiUtils.getChoice("Select a card to sacrifice", list.toArray());
|
||||
o = GuiUtils.chooseOne("Select a card to sacrifice", list.toArray());
|
||||
}
|
||||
if (o != null) {
|
||||
final Card c = (Card) o;
|
||||
|
||||
@@ -569,7 +569,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
} else {
|
||||
final CardList drawn = p.drawCards(numCards);
|
||||
if (params.containsKey("Reveal")) {
|
||||
GuiUtils.getChoice("Revealing drawn cards", drawn.toArray());
|
||||
GuiUtils.chooseOne("Revealing drawn cards", drawn.toArray());
|
||||
}
|
||||
if (params.containsKey("RememberDrawn")) {
|
||||
for (final Card c : drawn) {
|
||||
@@ -1201,7 +1201,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
if (p.isHuman()) {
|
||||
// "reveal to computer" for information gathering
|
||||
} else {
|
||||
GuiUtils.getChoiceOptional("Revealed computer hand", dPHand.toArray());
|
||||
GuiUtils.chooseOneOrNone("Revealed computer hand", dPHand.toArray());
|
||||
}
|
||||
|
||||
String valid = params.get("DiscardValid");
|
||||
@@ -1269,7 +1269,7 @@ public class AbilityFactoryZoneAffecting {
|
||||
if (mode.startsWith("Reveal")) {
|
||||
final CardList dCs = new CardList();
|
||||
dCs.add(dC);
|
||||
GuiUtils.getChoiceOptional("Computer has chosen", dCs.toArray());
|
||||
GuiUtils.chooseOneOrNone("Computer has chosen", dCs.toArray());
|
||||
}
|
||||
discarded.add(dC);
|
||||
p.discard(dC, sa);
|
||||
@@ -1278,17 +1278,17 @@ public class AbilityFactoryZoneAffecting {
|
||||
} else {
|
||||
// human
|
||||
if (mode.startsWith("Reveal")) {
|
||||
GuiUtils.getChoiceOptional("Revealed " + p + " hand", dPHand.toArray());
|
||||
GuiUtils.chooseOneOrNone("Revealed " + p + " hand", dPHand.toArray());
|
||||
}
|
||||
|
||||
for (int i = 0; i < numCards; i++) {
|
||||
if (dPChHand.size() > 0) {
|
||||
Card dC = null;
|
||||
if (params.containsKey("Optional")) {
|
||||
dC = GuiUtils.getChoiceOptional("Choose a card to be discarded",
|
||||
dC = GuiUtils.chooseOneOrNone("Choose a card to be discarded",
|
||||
dPChHand.toArray());
|
||||
} else {
|
||||
dC = GuiUtils.getChoice("Choose a card to be discarded",
|
||||
dC = GuiUtils.chooseOne("Choose a card to be discarded",
|
||||
dPChHand.toArray());
|
||||
} if (dC != null) {
|
||||
dPChHand.remove(dC);
|
||||
|
||||
@@ -559,7 +559,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
imageName = "B 1 1 Thrull";
|
||||
color = "B";
|
||||
} else if (player.isHuman()) {
|
||||
final Object q = GuiUtils.getChoiceOptional("Select type of creature", choices);
|
||||
final Object q = GuiUtils.chooseOneOrNone("Select type of creature", choices);
|
||||
if (q != null) {
|
||||
if (q.equals("Citizen")) {
|
||||
type = "Citizen";
|
||||
@@ -684,7 +684,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
chooseGrave.addAll(grave);
|
||||
}
|
||||
|
||||
final Object o = GuiUtils.getChoice("Choose first creature to exile", chooseGrave.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Choose first creature to exile", chooseGrave.toArray());
|
||||
if (o != null) {
|
||||
CardList newGrave;
|
||||
final Card c = (Card) o;
|
||||
@@ -697,7 +697,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
newGrave = newGrave.getType("Creature");
|
||||
newGrave.remove(c);
|
||||
|
||||
final Object o2 = GuiUtils.getChoice("Choose second creature to exile", newGrave.toArray());
|
||||
final Object o2 = GuiUtils.chooseOne("Choose second creature to exile", newGrave.toArray());
|
||||
if (o2 != null) {
|
||||
final Card c2 = (Card) o2;
|
||||
newGrave.remove(c2);
|
||||
@@ -989,7 +989,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
}
|
||||
}
|
||||
} // while
|
||||
GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray());
|
||||
GuiUtils.chooseOneOrNone("Revealed cards:", revealed.toArray());
|
||||
for (final Card revealedCard : revealed) {
|
||||
Singletons.getModel().getGameAction().moveToBottomOfLibrary(revealedCard);
|
||||
}
|
||||
@@ -1066,7 +1066,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
if (i == 4) {
|
||||
title = "Put fourth from top of library: ";
|
||||
}
|
||||
final Object o = GuiUtils.getChoiceOptional(title, lands.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone(title, lands.toArray());
|
||||
if (o == null) {
|
||||
break;
|
||||
}
|
||||
@@ -1190,7 +1190,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
for (int j = 0; j <= num; j++) {
|
||||
choices[j] = "" + j;
|
||||
}
|
||||
final String answer = (GuiUtils.getChoiceOptional("Life to pay:", choices));
|
||||
final String answer = (GuiUtils.chooseOneOrNone("Life to pay:", choices));
|
||||
lifeToPay = Integer.parseInt(answer);
|
||||
} else {
|
||||
// not implemented for Compy
|
||||
@@ -1264,7 +1264,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
|
||||
// Then look at the exiled cards and put them on
|
||||
// top of your library in any order.
|
||||
while (this.exiled.size() > 0) {
|
||||
final Object o = GuiUtils.getChoice("Put a card on top of your library.",
|
||||
final Object o = GuiUtils.chooseOne("Put a card on top of your library.",
|
||||
this.exiled.toArray());
|
||||
final Card c1 = (Card) o;
|
||||
Singletons.getModel().getGameAction().moveToLibrary(c1);
|
||||
|
||||
@@ -125,7 +125,7 @@ class CardFactoryAuras {
|
||||
public void resolve() {
|
||||
// Only query player, AI will have decided already.
|
||||
if (card.getController().isHuman()) {
|
||||
newType[0] = GuiUtils.getChoice("Select land type.", "Plains", "Island", "Swamp", "Mountain",
|
||||
newType[0] = GuiUtils.chooseOne("Select land type.", "Plains", "Island", "Swamp", "Mountain",
|
||||
"Forest");
|
||||
}
|
||||
Singletons.getModel().getGameAction().moveToPlay(card);
|
||||
|
||||
@@ -271,7 +271,7 @@ public class CardFactoryCreatures {
|
||||
final String[] choices = { "3/3", "2/2 with flying", "1/6 with defender" };
|
||||
|
||||
if (card.getController().isHuman()) {
|
||||
choice = GuiUtils.getChoice("Choose one", choices);
|
||||
choice = GuiUtils.chooseOne("Choose one", choices);
|
||||
} else {
|
||||
choice = choices[MyRandom.getRandom().nextInt(3)];
|
||||
}
|
||||
@@ -630,7 +630,7 @@ public class CardFactoryCreatures {
|
||||
if (card.getController().isHuman()) {
|
||||
final String[] colors = Constant.Color.ONLY_COLORS;
|
||||
|
||||
final Object o = GuiUtils.getChoice("Choose color", colors);
|
||||
final Object o = GuiUtils.chooseOne("Choose color", colors);
|
||||
color[0] = (String) o;
|
||||
} else {
|
||||
// AI chooses the color that appears in the keywords of
|
||||
@@ -831,7 +831,7 @@ public class CardFactoryCreatures {
|
||||
int lifeGain = 0;
|
||||
if (card.getController().isHuman()) {
|
||||
final String[] choices = { "white", "blue", "black", "red", "green" };
|
||||
final Object o = GuiUtils.getChoiceOptional("Select Color: ", choices);
|
||||
final Object o = GuiUtils.chooseOneOrNone("Select Color: ", choices);
|
||||
Log.debug("Treva, the Renewer", "Color:" + o);
|
||||
lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor((String) o);
|
||||
|
||||
@@ -874,7 +874,7 @@ public class CardFactoryCreatures {
|
||||
final CardList cl = new CardList();
|
||||
cl.add(lib.get(0));
|
||||
|
||||
GuiUtils.getChoiceOptional("Top card", cl.toArray());
|
||||
GuiUtils.chooseOneOrNone("Top card", cl.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1178,7 +1178,7 @@ public class CardFactoryCreatures {
|
||||
list = list.getType("Enchantment");
|
||||
|
||||
if (list.size() > 0) {
|
||||
final Object objectSelected = GuiUtils.getChoiceOptional("Choose an enchantment",
|
||||
final Object objectSelected = GuiUtils.chooseOneOrNone("Choose an enchantment",
|
||||
list.toArray());
|
||||
|
||||
if (objectSelected != null) {
|
||||
@@ -1520,7 +1520,7 @@ public class CardFactoryCreatures {
|
||||
|
||||
if (card.getController().isHuman()) {
|
||||
if (creats.size() > 0) {
|
||||
final List<Card> selection = GuiUtils.getChoicesOptional("Select creatures to sacrifice",
|
||||
final List<Card> selection = GuiUtils.chooseNoneOrMany("Select creatures to sacrifice",
|
||||
creats.toArray());
|
||||
|
||||
numCreatures[0] = selection.size();
|
||||
@@ -1600,7 +1600,7 @@ public class CardFactoryCreatures {
|
||||
life[i] = String.valueOf(i);
|
||||
}
|
||||
|
||||
final Object o = GuiUtils.getChoice("Nameless Race - pay X life", life);
|
||||
final Object o = GuiUtils.chooseOne("Nameless Race - pay X life", life);
|
||||
final String answer = (String) o;
|
||||
int loseLife = 0;
|
||||
try {
|
||||
@@ -2125,7 +2125,7 @@ public class CardFactoryCreatures {
|
||||
public void showMessage() {
|
||||
final String message = "Select a creature in a graveyard";
|
||||
final CardList choices = AllZoneUtil.getCardsIn(Zone.Graveyard);
|
||||
final Object o = GuiUtils.getChoiceOptional(message, choices.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone(message, choices.toArray());
|
||||
if (null == o) {
|
||||
this.stop();
|
||||
} else {
|
||||
@@ -2179,9 +2179,9 @@ public class CardFactoryCreatures {
|
||||
hand.remove(random);
|
||||
}
|
||||
if (!revealed.isEmpty()) {
|
||||
GuiUtils.getChoice("Revealed at random", revealed.toArray());
|
||||
GuiUtils.chooseOne("Revealed at random", revealed.toArray());
|
||||
} else {
|
||||
GuiUtils.getChoice("Revealed at random", new String[] { "Nothing to reveal" });
|
||||
GuiUtils.chooseOne("Revealed at random", new String[] { "Nothing to reveal" });
|
||||
}
|
||||
|
||||
for (final Card c : revealed) {
|
||||
|
||||
@@ -290,7 +290,7 @@ public class CardFactoryInstants {
|
||||
final CardList libraryList = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
|
||||
final CardList selectedCards = new CardList();
|
||||
|
||||
Object o = GuiUtils.getChoiceOptional("Select first card", libraryList.toArray());
|
||||
Object o = GuiUtils.chooseOneOrNone("Select first card", libraryList.toArray());
|
||||
if (o != null) {
|
||||
final Card c1 = (Card) o;
|
||||
libraryList.remove(c1);
|
||||
@@ -298,7 +298,7 @@ public class CardFactoryInstants {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
o = GuiUtils.getChoiceOptional("Select second card", libraryList.toArray());
|
||||
o = GuiUtils.chooseOneOrNone("Select second card", libraryList.toArray());
|
||||
if (o != null) {
|
||||
final Card c2 = (Card) o;
|
||||
libraryList.remove(c2);
|
||||
@@ -306,7 +306,7 @@ public class CardFactoryInstants {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
o = GuiUtils.getChoiceOptional("Select third card", libraryList.toArray());
|
||||
o = GuiUtils.chooseOneOrNone("Select third card", libraryList.toArray());
|
||||
if (o != null) {
|
||||
final Card c3 = (Card) o;
|
||||
libraryList.remove(c3);
|
||||
@@ -354,7 +354,7 @@ public class CardFactoryInstants {
|
||||
|
||||
// NOTE: Using getChoiceOptional() results in a null error
|
||||
// when you click on Cancel.
|
||||
final Object o = GuiUtils.getChoice("Select card to give to computer", selectedCards.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Select card to give to computer", selectedCards.toArray());
|
||||
|
||||
final Card choice = (Card) o;
|
||||
|
||||
@@ -401,7 +401,7 @@ public class CardFactoryInstants {
|
||||
|
||||
if (player.isHuman()) {
|
||||
for (int i = 0; i < x; i++) {
|
||||
final Object o = GuiUtils.getChoice("Remove from game", graveList.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Remove from game", graveList.toArray());
|
||||
if (o == null) {
|
||||
break;
|
||||
}
|
||||
@@ -553,7 +553,7 @@ public class CardFactoryInstants {
|
||||
}
|
||||
|
||||
for (int i = 0; (i < 3) && !choices.isEmpty(); i++) {
|
||||
final Object o = GuiUtils.getChoice(this.prompt[i], choices.toArray());
|
||||
final Object o = GuiUtils.chooseOne(this.prompt[i], choices.toArray());
|
||||
final Card c1 = (Card) o;
|
||||
if (i == 0) {
|
||||
Singletons.getModel().getGameAction().moveToHand(c1);
|
||||
@@ -640,12 +640,12 @@ public class CardFactoryInstants {
|
||||
@Override
|
||||
public void resolve() {
|
||||
final String[] choices = new String[] { "Artifact", "Creature", "Land" };
|
||||
final Object o = GuiUtils.getChoice("Select permanent type", choices);
|
||||
final Object o = GuiUtils.chooseOne("Select permanent type", choices);
|
||||
final String cardType = (String) o;
|
||||
final CardList list = this.getTargetPlayer().getCardsIn(Zone.Battlefield).getType(cardType);
|
||||
|
||||
final String[] tapOrUntap = new String[] { "Tap", "Untap" };
|
||||
final Object z = GuiUtils.getChoice("Tap or Untap?", tapOrUntap);
|
||||
final Object z = GuiUtils.chooseOne("Tap or Untap?", tapOrUntap);
|
||||
final boolean tap = (z.equals("Tap")) ? true : false;
|
||||
|
||||
for (final Card c : list) {
|
||||
|
||||
@@ -606,7 +606,7 @@ class CardFactoryLands {
|
||||
for (int j = 0; j <= num[0]; j++) {
|
||||
choices[j] = "" + j;
|
||||
}
|
||||
final String answer = (GuiUtils.getChoiceOptional("Storage counters to remove", choices));
|
||||
final String answer = (GuiUtils.chooseOneOrNone("Storage counters to remove", choices));
|
||||
if (answer == null) {
|
||||
this.stop();
|
||||
return;
|
||||
@@ -616,7 +616,7 @@ class CardFactoryLands {
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Number of ").append(primary).append(" to add");
|
||||
final String splitNum = (GuiUtils.getChoiceOptional(sb.toString(), choices));
|
||||
final String splitNum = (GuiUtils.chooseOneOrNone(sb.toString(), choices));
|
||||
if (splitNum == null) {
|
||||
this.stop();
|
||||
return;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class CardFactoryPlaneswalkers {
|
||||
final int convertedManaTopCard = CardUtil.getConvertedManaCost(topCard.getManaCost());
|
||||
final CardList showTop = new CardList();
|
||||
showTop.add(topCard);
|
||||
GuiUtils.getChoiceOptional("Revealed top card: ", showTop.toArray());
|
||||
GuiUtils.chooseOneOrNone("Revealed top card: ", showTop.toArray());
|
||||
|
||||
// now, move it to player's hand
|
||||
Singletons.getModel().getGameAction().moveToHand(topCard);
|
||||
|
||||
@@ -285,12 +285,12 @@ public class CardFactorySorceries {
|
||||
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
msg.append("Revealing top ").append(count).append(" cards of library: ");
|
||||
GuiUtils.getChoice(msg.toString(), cards.toArray());
|
||||
GuiUtils.chooseOne(msg.toString(), cards.toArray());
|
||||
// Human chooses
|
||||
if (card.getController().isComputer()) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (!stop) {
|
||||
choice = GuiUtils.getChoiceOptional("Choose cards to put into the first pile: ",
|
||||
choice = GuiUtils.chooseOneOrNone("Choose cards to put into the first pile: ",
|
||||
cards.toArray());
|
||||
if (choice != null) {
|
||||
pile1.add(choice);
|
||||
@@ -400,7 +400,7 @@ public class CardFactorySorceries {
|
||||
|
||||
final int numChosen = chosen.size();
|
||||
for (int i = 0; i < numChosen; i++) {
|
||||
final Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ",
|
||||
final Object check = GuiUtils.chooseOneOrNone("Select spells to play in reverse order: ",
|
||||
chosen.toArray());
|
||||
if (check == null) {
|
||||
break;
|
||||
@@ -1369,7 +1369,7 @@ public class CardFactorySorceries {
|
||||
final int num = CardFactoryUtil.getNumberOfManaSymbolsByColor("U", topCards);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Revealed cards - ").append(num).append(" U mana symbols");
|
||||
GuiUtils.getChoiceOptional(sb.toString(), topCards.toArray());
|
||||
GuiUtils.chooseOneOrNone(sb.toString(), topCards.toArray());
|
||||
|
||||
// opponent moves this many cards to graveyard
|
||||
opp.mill(num);
|
||||
@@ -1747,7 +1747,7 @@ public class CardFactorySorceries {
|
||||
}
|
||||
});
|
||||
|
||||
final Object check = GuiUtils.getChoiceOptional("Select target creature with CMC < X",
|
||||
final Object check = GuiUtils.chooseOneOrNone("Select target creature with CMC < X",
|
||||
grave.toArray());
|
||||
if (check != null) {
|
||||
final Card c = (Card) check;
|
||||
@@ -1837,7 +1837,7 @@ public class CardFactorySorceries {
|
||||
for (int i = 0; i <= card.getController().getLife(); i++) {
|
||||
choices.add("" + i);
|
||||
}
|
||||
final Object o = GuiUtils.getChoice("Choose X", choices.toArray());
|
||||
final Object o = GuiUtils.chooseOne("Choose X", choices.toArray());
|
||||
// everything stops here if user cancelled
|
||||
if (o == null) {
|
||||
this.stop();
|
||||
@@ -1927,7 +1927,7 @@ public class CardFactorySorceries {
|
||||
|
||||
private ArrayList<String> chooseTwo(final ArrayList<String> choices) {
|
||||
final ArrayList<String> out = new ArrayList<String>();
|
||||
Object o = GuiUtils.getChoiceOptional("Choose Two", choices.toArray());
|
||||
Object o = GuiUtils.chooseOneOrNone("Choose Two", choices.toArray());
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -1935,7 +1935,7 @@ public class CardFactorySorceries {
|
||||
out.add((String) o);
|
||||
card.addSpellChoice((String) o);
|
||||
choices.remove(out.get(0));
|
||||
o = GuiUtils.getChoiceOptional("Choose Two", choices.toArray());
|
||||
o = GuiUtils.chooseOneOrNone("Choose Two", choices.toArray());
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -2014,7 +2014,7 @@ public class CardFactorySorceries {
|
||||
// Sacrifice an artifact
|
||||
CardList arts = p.getCardsIn(Constant.Zone.Battlefield);
|
||||
arts = arts.filter(CardListFilter.ARTIFACTS);
|
||||
final Object toSac = GuiUtils.getChoiceOptional("Sacrifice an artifact", arts.toArray());
|
||||
final Object toSac = GuiUtils.chooseOneOrNone("Sacrifice an artifact", arts.toArray());
|
||||
if (toSac != null) {
|
||||
final Card c = (Card) toSac;
|
||||
baseCMC = CardUtil.getConvertedManaCost(c);
|
||||
@@ -2025,9 +2025,9 @@ public class CardFactorySorceries {
|
||||
|
||||
// Search your library for an artifact
|
||||
final CardList lib = p.getCardsIn(Zone.Library);
|
||||
GuiUtils.getChoiceOptional("Looking at Library", lib.toArray());
|
||||
GuiUtils.chooseOneOrNone("Looking at Library", lib.toArray());
|
||||
final CardList libArts = lib.filter(CardListFilter.ARTIFACTS);
|
||||
final Object o = GuiUtils.getChoiceOptional("Search for artifact", libArts.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Search for artifact", libArts.toArray());
|
||||
if (o != null) {
|
||||
newArtifact[0] = (Card) o;
|
||||
} else {
|
||||
|
||||
@@ -807,7 +807,7 @@ public class CardFactoryUtil {
|
||||
this.stop();
|
||||
}
|
||||
Singletons.getControl().getControlMatch().showMessage("Select target Spell: ");
|
||||
final Card choice = GuiUtils.getChoiceOptional("Choose a Spell", choices.toArray());
|
||||
final Card choice = GuiUtils.chooseOneOrNone("Choose a Spell", choices.toArray());
|
||||
if (choice != null) {
|
||||
spell.setTargetCard(choice);
|
||||
this.done();
|
||||
@@ -1130,7 +1130,7 @@ public class CardFactoryUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
final Object o = GuiUtils.getChoiceOptional("Select a card", sameType.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Select a card", sameType.toArray());
|
||||
if (o != null) {
|
||||
// ability.setTargetCard((Card)o);
|
||||
|
||||
@@ -1209,7 +1209,7 @@ public class CardFactoryUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
final Object o = GuiUtils.getChoiceOptional("Select a card", sameCost.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Select a card", sameCost.toArray());
|
||||
if (o != null) {
|
||||
// ability.setTargetCard((Card)o);
|
||||
|
||||
@@ -1665,7 +1665,7 @@ public class CardFactoryUtil {
|
||||
question.append(manacost).append(" or less from your graveyard to your hand?");
|
||||
|
||||
if (GameActionUtil.showYesNoDialog(sourceCard, question.toString())) {
|
||||
final Object o = GuiUtils.getChoiceOptional("Select a card", sameCost.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Select a card", sameCost.toArray());
|
||||
if (o != null) {
|
||||
|
||||
final Card c1 = (Card) o;
|
||||
@@ -5146,7 +5146,7 @@ public class CardFactoryUtil {
|
||||
card.clearDevoured();
|
||||
if (card.getController().isHuman()) {
|
||||
if (creats.size() > 0) {
|
||||
final List<Card> selection = GuiUtils.getChoicesOptional(
|
||||
final List<Card> selection = GuiUtils.chooseNoneOrMany(
|
||||
"Select creatures to sacrifice", creats.toArray());
|
||||
|
||||
numCreatures[0] = selection.size();
|
||||
|
||||
@@ -328,7 +328,7 @@ public class CostExile extends CostPartWithList {
|
||||
}
|
||||
|
||||
final Object o = GuiUtils
|
||||
.getChoiceOptional("Exile from " + part.getFrom(), this.typeList.toArray());
|
||||
.chooseOneOrNone("Exile from " + part.getFrom(), this.typeList.toArray());
|
||||
|
||||
if (o != null) {
|
||||
final Card c = (Card) o;
|
||||
|
||||
@@ -125,7 +125,7 @@ public class CostReveal extends CostPartWithList {
|
||||
*/
|
||||
@Override
|
||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||
GuiUtils.getChoiceOptional("Revealed cards:", this.getList().toArray());
|
||||
GuiUtils.chooseOneOrNone("Revealed cards:", this.getList().toArray());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -276,7 +276,7 @@ public class CostUtil {
|
||||
for (int i = 0; i < choiceArray.length; i++) {
|
||||
choiceArray[i] = i;
|
||||
}
|
||||
final Object o = GuiUtils.getChoice(card.toString() + " - Choose a Value for X", choiceArray);
|
||||
final Object o = GuiUtils.chooseOne(card.toString() + " - Choose a Value for X", choiceArray);
|
||||
final int chosenX = (Integer) o;
|
||||
card.setSVar("ChosenX", "Number$" + Integer.toString(chosenX));
|
||||
|
||||
@@ -302,7 +302,7 @@ public class CostUtil {
|
||||
for (int i = 0; i < choiceArray.length; i++) {
|
||||
choiceArray[i] = i;
|
||||
}
|
||||
final Object o = GuiUtils.getChoice(card.toString() + " - Choose a Value for Y", choiceArray);
|
||||
final Object o = GuiUtils.chooseOne(card.toString() + " - Choose a Value for Y", choiceArray);
|
||||
final int chosenY = (Integer) o;
|
||||
card.setSVar("ChosenY", "Number$" + Integer.toString(chosenY));
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ public class ManaPool {
|
||||
Object o;
|
||||
|
||||
if (this.owner.isHuman()) {
|
||||
o = GuiUtils.getChoiceOptional("Pay Mana from Mana Pool", alChoice.toArray());
|
||||
o = GuiUtils.chooseOneOrNone("Pay Mana from Mana Pool", alChoice.toArray());
|
||||
} else {
|
||||
o = alChoice.get(0); // owner is computer
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ReplacementHandler {
|
||||
|
||||
if (possibleReplacers.size() > 1) {
|
||||
if (decider.isHuman()) {
|
||||
chosenRE = (ReplacementEffect) GuiUtils.getChoice("Choose which replacement effect to apply.",
|
||||
chosenRE = (ReplacementEffect) GuiUtils.chooseOne("Choose which replacement effect to apply.",
|
||||
possibleReplacers.toArray());
|
||||
} else {
|
||||
// AI logic for choosing which replacement effect to apply
|
||||
|
||||
@@ -417,7 +417,7 @@ public class TargetSelection {
|
||||
// is there a more elegant way of doing this?
|
||||
choicesWithDone.add(dummy);
|
||||
}
|
||||
final Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray());
|
||||
final Object check = GuiUtils.chooseOneOrNone(message, choicesWithDone.toArray());
|
||||
if (check != null) {
|
||||
final Card c = (Card) check;
|
||||
if (c.equals(dummy)) {
|
||||
@@ -460,7 +460,7 @@ public class TargetSelection {
|
||||
if (choices.length == 0) {
|
||||
select.setCancel(true);
|
||||
} else {
|
||||
final String madeChoice = GuiUtils.getChoiceOptional(message, choices);
|
||||
final String madeChoice = GuiUtils.chooseOneOrNone(message, choices);
|
||||
|
||||
if (madeChoice != null) {
|
||||
tgt.addTarget(map.get(madeChoice));
|
||||
|
||||
@@ -13,6 +13,8 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.PlayerType;
|
||||
@@ -26,6 +28,7 @@ import forge.game.GameNew;
|
||||
import forge.game.GameType;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.data.QuestEvent;
|
||||
import forge.quest.data.QuestEventManager;
|
||||
import forge.util.IStorage;
|
||||
import forge.view.home.ViewConstructed;
|
||||
|
||||
@@ -330,17 +333,17 @@ public class ControlConstructed {
|
||||
|
||||
private String[] getEventNames() {
|
||||
final List<String> eventNames = new ArrayList<String>();
|
||||
eventNames.clear();
|
||||
|
||||
for (final QuestEvent e : Singletons.getModel().getQuestEventManager().getAllChallenges()) {
|
||||
final QuestEventManager qm = Singletons.getModel().getQuestEventManager();
|
||||
|
||||
for (final QuestEvent e : qm.getAllChallenges()) {
|
||||
eventNames.add(e.getEventDeck().getName());
|
||||
}
|
||||
|
||||
for (final QuestEvent e : Singletons.getModel().getQuestEventManager().getAllDuels()) {
|
||||
for (final QuestEvent e : qm.getAllDuels()) {
|
||||
eventNames.add(e.getEventDeck().getName());
|
||||
}
|
||||
|
||||
return oa2sa(eventNames.toArray());
|
||||
return eventNames.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -161,7 +161,7 @@ public class ControlDraft {
|
||||
draftTypes.add("Custom");
|
||||
|
||||
final String prompt = "Choose Draft Format:";
|
||||
final Object o = GuiUtils.getChoice(prompt, draftTypes.toArray());
|
||||
final Object o = GuiUtils.chooseOne(prompt, draftTypes.toArray());
|
||||
|
||||
if (o.toString().equals(draftTypes.get(0))) {
|
||||
draft.showGui(new BoosterDraft(CardPoolLimitation.Full));
|
||||
|
||||
@@ -151,7 +151,7 @@ public class ControlSealed {
|
||||
sealedTypes.add("Custom");
|
||||
|
||||
final String prompt = "Choose Sealed Deck Format:";
|
||||
final Object o = GuiUtils.getChoice(prompt, sealedTypes.toArray());
|
||||
final Object o = GuiUtils.chooseOne(prompt, sealedTypes.toArray());
|
||||
|
||||
SealedDeck sd = null;
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ public class InputPayManaCostUtil {
|
||||
for (final AbilityMana am : abilities) {
|
||||
ability.put(am.toString(), am);
|
||||
}
|
||||
chosen = (AbilityMana) GuiUtils.getChoice("Choose mana ability", abilities.toArray());
|
||||
chosen = GuiUtils.chooseOne("Choose mana ability", abilities);
|
||||
}
|
||||
|
||||
// save off color needed for use by any mana and reflected mana
|
||||
|
||||
@@ -261,7 +261,7 @@ public class ControlField {
|
||||
final ArrayList<Card> choices2 = new ArrayList<Card>();
|
||||
|
||||
if (choices.isEmpty()) {
|
||||
GuiUtils.getChoiceOptional(this.title, new String[] { "no cards" });
|
||||
GuiUtils.chooseOneOrNone(this.title, new String[] { "no cards" });
|
||||
} else {
|
||||
for (int i = 0; i < choices.size(); i++) {
|
||||
final Card crd = choices.get(i);
|
||||
@@ -276,7 +276,7 @@ public class ControlField {
|
||||
}
|
||||
}
|
||||
// System.out.println("Face down cards replaced: "+choices2);
|
||||
final Card choice = (Card) GuiUtils.getChoiceOptional(this.title, choices2.toArray());
|
||||
final Card choice = (Card) GuiUtils.chooseOneOrNone(this.title, choices2.toArray());
|
||||
if (choice != null) {
|
||||
this.doAction(choice);
|
||||
/*
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ControlWinLose {
|
||||
|
||||
Constant.Runtime.COMPUTER_DECK[0] = cDeck;
|
||||
|
||||
List<Card> o = GuiUtils.getChoicesOptional("Select cards to add to your deck", compAntes.toArray());
|
||||
List<Card> o = GuiUtils.chooseNoneOrMany("Select cards to add to your deck", compAntes.toArray());
|
||||
if (null != o) {
|
||||
for (Card c : o) {
|
||||
hDeck.getMain().add(c);
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
||||
|
||||
case Block: // Draft from cards by block or set
|
||||
|
||||
final Object o = GuiUtils.getChoice("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{}));
|
||||
final Object o = GuiUtils.chooseOne("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{}));
|
||||
final CardBlock block = (CardBlock) o;
|
||||
|
||||
final CardEdition[] cardSets = block.getSets();
|
||||
@@ -119,7 +119,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
||||
}
|
||||
|
||||
if (sets.length > 1) {
|
||||
final Object p = GuiUtils.getChoice("Choose Set Combination", setCombos.toArray());
|
||||
final Object p = GuiUtils.chooseOne("Choose Set Combination", setCombos.toArray());
|
||||
final String[] pp = p.toString().split("/");
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
this.product.add(new UnOpenedProduct(Singletons.getModel().getBoosters().get(pp[i])));
|
||||
@@ -142,7 +142,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
||||
JOptionPane
|
||||
.showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE);
|
||||
} else {
|
||||
final CustomLimited draft = (CustomLimited) GuiUtils.getChoice("Choose Custom Draft",
|
||||
final CustomLimited draft = (CustomLimited) GuiUtils.chooseOne("Choose Custom Draft",
|
||||
myDrafts.toArray());
|
||||
this.setupCustomDraft(draft);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SealedDeck {
|
||||
this.getLandSetCode()[0] = CardDb.instance().getCard("Plains").getEdition();
|
||||
} else if (sealedType.equals("Block")) {
|
||||
|
||||
final Object o = GuiUtils.getChoice("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{}));
|
||||
final Object o = GuiUtils.chooseOne("Choose Block", UtilFunctions.iteratorToArray(Singletons.getModel().getBlocks().iterator(), new CardBlock[]{}));
|
||||
final CardBlock block = (CardBlock) o;
|
||||
|
||||
final CardEdition[] cardSets = block.getSets();
|
||||
@@ -102,7 +102,7 @@ public class SealedDeck {
|
||||
}
|
||||
|
||||
if (sets.length > 1) {
|
||||
final Object p = GuiUtils.getChoice("Choose Set Combination", setCombos.toArray());
|
||||
final Object p = GuiUtils.chooseOne("Choose Set Combination", setCombos.toArray());
|
||||
|
||||
final String[] pp = p.toString().split("/");
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
@@ -147,7 +147,7 @@ public class SealedDeck {
|
||||
JOptionPane.showMessageDialog(null, "No custom sealed files found.", "",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
} else {
|
||||
final CustomLimited draft = (CustomLimited) GuiUtils.getChoice("Choose Custom Sealed Pool",
|
||||
final CustomLimited draft = (CustomLimited) GuiUtils.chooseOne("Choose Custom Sealed Pool",
|
||||
customs.toArray());
|
||||
|
||||
final BoosterGenerator bpCustom = new BoosterGenerator(draft.getCardPool());
|
||||
|
||||
@@ -249,7 +249,7 @@ public final class GuiUtils {
|
||||
* getChoices.
|
||||
* @see #getChoices(String, int, int, Object...)
|
||||
*/
|
||||
public static <T> T getChoiceOptional(final String message, final T... choices) {
|
||||
public static <T> T chooseOneOrNone(final String message, final T... choices) {
|
||||
if ((choices == null) || (choices.length == 0)) {
|
||||
return null;
|
||||
}
|
||||
@@ -271,12 +271,18 @@ public final class GuiUtils {
|
||||
* a T object.
|
||||
* @return a T object.
|
||||
*/
|
||||
public static <T> T getChoice(final String message, final T... choices) {
|
||||
public static <T> T chooseOne(final String message, final T... choices) {
|
||||
final List<T> choice = GuiUtils.getChoices(message, 1, 1, choices);
|
||||
assert choice.size() == 1;
|
||||
return choice.get(0);
|
||||
} // getChoice()
|
||||
|
||||
public static <T> T chooseOne(final String message, final List<T> choices) {
|
||||
final List<T> choice = GuiUtils.getChoices(message, 1, 1, choices);
|
||||
assert choice.size() == 1;
|
||||
return choice.get(0);
|
||||
}
|
||||
|
||||
// returned Object will never be null
|
||||
/**
|
||||
* <p>
|
||||
@@ -291,7 +297,7 @@ public final class GuiUtils {
|
||||
* a T object.
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public static <T> List<T> getChoicesOptional(final String message, final T... choices) {
|
||||
public static <T> List<T> chooseNoneOrMany(final String message, final T... choices) {
|
||||
return GuiUtils.getChoices(message, 0, choices.length, choices);
|
||||
} // getChoice()
|
||||
|
||||
@@ -309,7 +315,7 @@ public final class GuiUtils {
|
||||
* a T object.
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public static <T> List<T> getChoices(final String message, final T... choices) {
|
||||
public static <T> List<T> chooseOneOrMany(final String message, final T... choices) {
|
||||
return GuiUtils.getChoices(message, 1, choices.length, choices);
|
||||
} // getChoice()
|
||||
|
||||
@@ -331,8 +337,18 @@ public final class GuiUtils {
|
||||
* a T object.
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public static <T> List<T> getChoices(final String message, final int min, final int max, final T... choices) {
|
||||
private static <T> List<T> getChoices(final String message, final int min, final int max, final T... choices) {
|
||||
final ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
|
||||
return getChoices(c);
|
||||
}
|
||||
|
||||
private static <T> List<T> getChoices(final String message, final int min, final int max, final List<T> choices) {
|
||||
final ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
|
||||
return getChoices(c);
|
||||
}
|
||||
|
||||
private static <T> List<T> getChoices(final ListChooser<T> c)
|
||||
{
|
||||
final JList list = c.getJList();
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
|
||||
@@ -78,8 +78,8 @@ public class ListChooser<T> {
|
||||
// initialized before; listeners may be added to it
|
||||
private JList jList;
|
||||
// Temporarily stored for event handlers during show
|
||||
private JDialog d;
|
||||
private JOptionPane p;
|
||||
private JDialog dialog;
|
||||
private JOptionPane optionPane;
|
||||
private Action ok, cancel;
|
||||
|
||||
/**
|
||||
@@ -304,23 +304,12 @@ public class ListChooser<T> {
|
||||
this.jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
}
|
||||
|
||||
this.p = new JOptionPane(new Object[] { message, new JScrollPane(this.jList) }, JOptionPane.QUESTION_MESSAGE,
|
||||
this.optionPane = new JOptionPane(new Object[] { message, new JScrollPane(this.jList) }, JOptionPane.QUESTION_MESSAGE,
|
||||
JOptionPane.DEFAULT_OPTION, null, options, options[0]);
|
||||
this.jList.getSelectionModel().addListSelectionListener(new SelListener());
|
||||
this.jList.addMouseListener(new DblListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getChoices.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<T> getChoices() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JList used in the list chooser. this is useful for
|
||||
* registering listeners before showing the dialog.
|
||||
@@ -348,14 +337,14 @@ public class ListChooser<T> {
|
||||
}
|
||||
Integer value;
|
||||
do {
|
||||
this.d = this.p.createDialog(this.p.getParent(), this.title);
|
||||
this.dialog = this.optionPane.createDialog(this.optionPane.getParent(), this.title);
|
||||
if (this.minChoices != 0) {
|
||||
this.d.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
this.dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
}
|
||||
|
||||
this.jList.setSelectedIndex(index0);
|
||||
|
||||
this.d.addWindowFocusListener(new WindowFocusListener() {
|
||||
this.dialog.addWindowFocusListener(new WindowFocusListener() {
|
||||
@Override
|
||||
public void windowGainedFocus(final WindowEvent e) {
|
||||
ListChooser.this.jList.grabFocus();
|
||||
@@ -365,9 +354,9 @@ public class ListChooser<T> {
|
||||
public void windowLostFocus(final WindowEvent e) {
|
||||
}
|
||||
});
|
||||
this.d.setVisible(true);
|
||||
this.d.dispose();
|
||||
value = (Integer) this.p.getValue();
|
||||
this.dialog.setVisible(true);
|
||||
this.dialog.dispose();
|
||||
value = (Integer) this.optionPane.getValue();
|
||||
if ((value == null) || (value != JOptionPane.OK_OPTION)) {
|
||||
this.jList.clearSelection();
|
||||
// can't stop closing by ESC, so repeat if cancelled
|
||||
@@ -390,7 +379,7 @@ public class ListChooser<T> {
|
||||
if (!this.called) {
|
||||
throw new IllegalStateException("not yet shown");
|
||||
}
|
||||
return (Integer) this.p.getValue() == JOptionPane.OK_OPTION;
|
||||
return (Integer) this.optionPane.getValue() == JOptionPane.OK_OPTION;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,22 +387,11 @@ public class ListChooser<T> {
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Integer> getSelectedIndices() {
|
||||
public int[] getSelectedIndices() {
|
||||
if (!this.called) {
|
||||
throw new IllegalStateException("not yet shown");
|
||||
}
|
||||
final int[] indices = this.jList.getSelectedIndices();
|
||||
return new AbstractList<Integer>() {
|
||||
@Override
|
||||
public int size() {
|
||||
return indices.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer get(final int index) {
|
||||
return indices[index];
|
||||
}
|
||||
};
|
||||
return this.jList.getSelectedIndices();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,7 +430,7 @@ public class ListChooser<T> {
|
||||
}
|
||||
return this.jList.getSelectedIndex();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the (first) selected value, or null.
|
||||
*
|
||||
@@ -473,7 +451,7 @@ public class ListChooser<T> {
|
||||
*/
|
||||
private void commit() {
|
||||
if (this.ok.isEnabled()) {
|
||||
this.p.setValue(JOptionPane.OK_OPTION);
|
||||
this.optionPane.setValue(JOptionPane.OK_OPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,7 +482,7 @@ public class ListChooser<T> {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
ListChooser.this.p.setValue(this.value);
|
||||
ListChooser.this.optionPane.setValue(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public class MenuBase<T extends DeckBase> extends JMenuBar {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Object o = GuiUtils.getChoiceOptional("Open Deck", choices.toArray());
|
||||
final Object o = GuiUtils.chooseOneOrNone("Open Deck", choices.toArray());
|
||||
return o == null ? null : o.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public enum CSubmenuDraft implements ICSubmenu {
|
||||
draftTypes.add("Custom");
|
||||
|
||||
final String prompt = "Choose Draft Format:";
|
||||
final Object o = GuiUtils.getChoice(prompt, draftTypes.toArray());
|
||||
final Object o = GuiUtils.chooseOne(prompt, draftTypes.toArray());
|
||||
|
||||
if (o.toString().equals(draftTypes.get(0))) {
|
||||
draft.showGui(new BoosterDraft(CardPoolLimitation.Full));
|
||||
|
||||
@@ -135,7 +135,7 @@ public enum CSubmenuSealed implements ICSubmenu {
|
||||
sealedTypes.add("Custom");
|
||||
|
||||
final String prompt = "Choose Sealed Deck Format:";
|
||||
final Object o = GuiUtils.getChoice(prompt, sealedTypes.toArray());
|
||||
final Object o = GuiUtils.chooseOne(prompt, sealedTypes.toArray());
|
||||
|
||||
SealedDeck sd = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user