mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
allow multiple color selections in AF_ChooseColor via a "OrColors$" parameter. Please note, the chioce dialog for colors is multi-select (like, pick one, ctrl+click to pick another, etc...)
This commit is contained in:
@@ -163,7 +163,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
private String echoCost = "";
|
||||
private String madnessCost = "";
|
||||
private String chosenType = "";
|
||||
private String chosenColor = "";
|
||||
//private String chosenColor = "";
|
||||
private ArrayList<String> chosenColor = new ArrayList<String>();
|
||||
private String namedCard = "";
|
||||
private int chosenNumber;
|
||||
private Player chosenPlayer;
|
||||
@@ -1427,18 +1428,18 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
/**
|
||||
* <p>Getter for the field <code>chosenColor</code>.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
* @return an ArrayList<String> object.
|
||||
*/
|
||||
public final String getChosenColor() {
|
||||
public final ArrayList<String> getChosenColor() {
|
||||
return chosenColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>chosenColor</code>.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
* @param s an ArrayList<String> object.
|
||||
*/
|
||||
public final void setChosenColor(final String s) {
|
||||
public final void setChosenColor(final ArrayList<String> s) {
|
||||
chosenColor = s;
|
||||
}
|
||||
|
||||
|
||||
@@ -477,8 +477,8 @@ public final class AbilityFactory_Animate {
|
||||
if (params.containsKey("Colors")) {
|
||||
String colors = params.get("Colors");
|
||||
if (colors.equals("ChosenColor")) {
|
||||
tmpDesc = CardUtil.getShortColorsString(
|
||||
new ArrayList<String>(Arrays.asList(host.getChosenColor().split(","))));
|
||||
|
||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
||||
} else {
|
||||
tmpDesc = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(","))));
|
||||
}
|
||||
@@ -1012,8 +1012,7 @@ public final class AbilityFactory_Animate {
|
||||
if (params.containsKey("Colors")) {
|
||||
String colors = params.get("Colors");
|
||||
if (colors.equals("ChosenColor")) {
|
||||
tmpDesc = CardUtil.getShortColorsString(
|
||||
new ArrayList<String>(Arrays.asList(host.getChosenColor().split(","))));
|
||||
tmpDesc = CardUtil.getShortColorsString(host.getChosenColor());
|
||||
} else {
|
||||
tmpDesc = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(","))));
|
||||
}
|
||||
|
||||
@@ -20,11 +20,10 @@ import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
@@ -488,6 +487,7 @@ public class AbilityFactory_Choose {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
private static String chooseColorStackDescription(final AbilityFactory af, final SpellAbility sa) {
|
||||
HashMap<String, String> params = af.getMapParams();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (!(sa instanceof Ability_Sub)) {
|
||||
@@ -510,7 +510,11 @@ public class AbilityFactory_Choose {
|
||||
for (Player p : tgtPlayers) {
|
||||
sb.append(p).append(" ");
|
||||
}
|
||||
sb.append("chooses a color.");
|
||||
sb.append("chooses a color");
|
||||
if (params.containsKey("OrColors")) {
|
||||
sb.append(" or colors");
|
||||
}
|
||||
sb.append(".");
|
||||
|
||||
Ability_Sub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
@@ -586,13 +590,36 @@ public class AbilityFactory_Choose {
|
||||
|
||||
for (Player p : tgtPlayers) {
|
||||
if (tgt == null || p.canTarget(sa)) {
|
||||
List<String> colors = new ArrayList<String>(Arrays.asList(Constant.Color.onlyColors));
|
||||
if (sa.getActivatingPlayer().isHuman()) {
|
||||
Object o = GuiUtils.getChoice("Choose a color", Constant.Color.onlyColors);
|
||||
if (null == o) {
|
||||
return;
|
||||
if (params.containsKey("OrColors")) {
|
||||
//ArrayList<String> chosenColors = new ArrayList<String>();
|
||||
//boolean done = false;
|
||||
//while (!done) {
|
||||
List<String> o = GuiUtils.getChoices("Choose a color or colors", colors.toArray(new String[0]));
|
||||
/*if (null == o) {
|
||||
done = true;
|
||||
}
|
||||
else {
|
||||
String thisColor = (String) o;
|
||||
chosenColors.add(thisColor);
|
||||
colors.remove(thisColor);
|
||||
card.setChosenColor(chosenColors);
|
||||
}
|
||||
*/
|
||||
card.setChosenColor(new ArrayList<String>(o));
|
||||
//}
|
||||
}
|
||||
else {
|
||||
Object o = GuiUtils.getChoice("Choose a color", Constant.Color.onlyColors);
|
||||
if (null == o) {
|
||||
return;
|
||||
}
|
||||
String choice = (String) o;
|
||||
ArrayList<String> tmpColors = new ArrayList<String>();
|
||||
tmpColors.add(choice);
|
||||
card.setChosenColor(tmpColors);
|
||||
}
|
||||
String choice = (String) o;
|
||||
card.setChosenColor(choice);
|
||||
} else {
|
||||
String chosen = "";
|
||||
if (params.containsKey("AILogic")) {
|
||||
@@ -615,7 +642,9 @@ public class AbilityFactory_Choose {
|
||||
chosen = Constant.Color.Green;
|
||||
}
|
||||
GuiUtils.getChoice("Computer picked: ", chosen);
|
||||
card.setChosenColor(chosen);
|
||||
ArrayList<String> colorTemp = new ArrayList<String>();
|
||||
colorTemp.add(chosen);
|
||||
card.setChosenColor(colorTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,8 @@ public class AbilityFactory_Mana {
|
||||
|
||||
String baseMana = abMana.mana();
|
||||
if (baseMana.equals("Chosen")){
|
||||
baseMana = Input_PayManaCostUtil.getShortColorString(card.getChosenColor());
|
||||
//this will only support 1 chosen color for now.
|
||||
baseMana = Input_PayManaCostUtil.getShortColorString(card.getChosenColor().get(0));
|
||||
}
|
||||
|
||||
if (params.containsKey("Bonus")) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import forge.card.spellability.*;
|
||||
import forge.gui.GuiUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -1811,7 +1812,13 @@ public final class AbilityFactory_Reveal {
|
||||
}
|
||||
|
||||
if (tgtPlayers.size() > 0) {
|
||||
sb.append(tgtPlayers.get(0)).append(" reveals a card ");
|
||||
sb.append(tgtPlayers.get(0)).append(" reveals ");
|
||||
if (params.containsKey("AnyNumber")) {
|
||||
sb.append("any number of cards ");
|
||||
}
|
||||
else {
|
||||
sb.append("a card ");
|
||||
}
|
||||
if (params.containsKey("Random")) {
|
||||
sb.append("at random ");
|
||||
}
|
||||
@@ -1930,15 +1937,92 @@ public final class AbilityFactory_Reveal {
|
||||
if (tgt == null || p.canTarget(sa)) {
|
||||
CardList handChoices = p.getCardsIn(Zone.Hand);
|
||||
if (handChoices.size() > 0) {
|
||||
Card random = CardUtil.getRandom(handChoices.toArray());
|
||||
if (params.containsKey("RememberRevealed")) {
|
||||
host.addRemembered(random);
|
||||
CardList revealed = new CardList();
|
||||
if (params.containsKey("Random")) {
|
||||
revealed.add(CardUtil.getRandom(handChoices.toArray()));
|
||||
GuiUtils.getChoice("Revealed card(s)", revealed.toArray());
|
||||
}
|
||||
else if (params.containsKey("AnyNumber")) {
|
||||
CardList valid = new CardList(handChoices);
|
||||
if (params.containsKey("RevealValid")) {
|
||||
valid = valid.getValidCards(params.get("RevealValid"), p, host);
|
||||
}
|
||||
revealed.addAll(getRevealedList(host, sa, valid));
|
||||
}
|
||||
GuiUtils.getChoice("Random card", new CardList(random).toArray());
|
||||
}
|
||||
|
||||
if (params.containsKey("RememberRevealed")) {
|
||||
for(Card rem : revealed) {
|
||||
host.addRemembered(rem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static CardList getRevealedList(final Card card, final SpellAbility sa, final CardList valid) {
|
||||
final CardList revealed = new CardList();
|
||||
if (sa.getActivatingPlayer().isComputer()) {
|
||||
//not really implemented for computer
|
||||
//would need GuiUtils.getChoice("Revealed card(s)", revealed.toArray());
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
return revealed;
|
||||
}
|
||||
|
||||
/*
|
||||
private static CardList getRevealedList(final Card card, final SpellAbility sa, final CardList valid) {
|
||||
final CardList revealed = new CardList();
|
||||
if (sa.getActivatingPlayer().isComputer()) {
|
||||
//not really implemented for computer
|
||||
//would need GuiUtils.getChoice("Revealed card(s)", revealed.toArray());
|
||||
}
|
||||
else {
|
||||
AllZone.getInputControl().setInput(new Input() {
|
||||
private static final long serialVersionUID = 3851585340769670736L;
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
//in case hand is empty, don't do anything
|
||||
if (card.getController().getCardsIn(Zone.Hand).size() == 0) stop();
|
||||
|
||||
AllZone.getDisplay().showMessage(card.getName() + " - Reveal a card. Revealed " + revealed.size() + " so far. Click OK when done.");
|
||||
ButtonUtil.enableOnlyOK();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(Card c, PlayerZone zone) {
|
||||
if (zone.is(Constant.Zone.Hand) && valid.contains(c) && !revealed.contains(c)) {
|
||||
revealed.add(c);
|
||||
|
||||
//in case no more cards in hand to reveal
|
||||
if (revealed.size() == card.getController().getCardsIn(Zone.Hand).size()) {
|
||||
done();
|
||||
}
|
||||
else {
|
||||
showMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectButtonOK() {
|
||||
done();
|
||||
}
|
||||
|
||||
void done() {
|
||||
stop();
|
||||
GuiUtils.getChoice("Revealed card(s)", revealed.toArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return revealed;
|
||||
}
|
||||
*/
|
||||
|
||||
} //end class AbilityFactory_Reveal
|
||||
|
||||
@@ -367,7 +367,8 @@ public class AbilityFactory_Token extends AbilityFactory {
|
||||
String[] substitutedColors = Arrays.copyOf(tokenColors, tokenColors.length);
|
||||
for (int i = 0; i < substitutedColors.length; i++) {
|
||||
if (substitutedColors[i].equals("ChosenColor")) {
|
||||
substitutedColors[i] = host.getChosenColor();
|
||||
//this currently only supports 1 chosen color
|
||||
substitutedColors[i] = host.getChosenColor().get(0);
|
||||
}
|
||||
}
|
||||
String colorDesc = "";
|
||||
|
||||
@@ -787,7 +787,9 @@ public class CardFactory_Creatures {
|
||||
}
|
||||
}
|
||||
}
|
||||
card.setChosenColor(color[0]);
|
||||
ArrayList<String> colors = new ArrayList<String>();
|
||||
colors.add(color[0]);
|
||||
card.setChosenColor(colors);
|
||||
String s = CardUtil.getShortColor(color[0]);
|
||||
|
||||
timeStamp[0] = AllZone.getColorChanger().addColorChanges(s, card, true, true);
|
||||
@@ -1547,7 +1549,9 @@ public class CardFactory_Creatures {
|
||||
|
||||
Object o = GuiUtils.getChoice("Choose color", colors);
|
||||
color = (String) o;
|
||||
card.setChosenColor(color);
|
||||
ArrayList<String> colorTemp = new ArrayList<String>();
|
||||
colorTemp.add(color);
|
||||
card.setChosenColor(colorTemp);
|
||||
} else {
|
||||
CardList list = new CardList();
|
||||
list.addAll(AllZone.getHumanPlayer().getCardsIn(Zone.Library));
|
||||
@@ -1555,10 +1559,20 @@ public class CardFactory_Creatures {
|
||||
|
||||
if (list.size() > 0) {
|
||||
String color = CardFactoryUtil.getMostProminentColor(list);
|
||||
if (!color.equals("")) card.setChosenColor(color);
|
||||
else card.setChosenColor("black");
|
||||
if (!color.equals("")) {
|
||||
ArrayList<String> colorTemp = new ArrayList<String>();
|
||||
colorTemp.add(color);
|
||||
card.setChosenColor(colorTemp);
|
||||
}
|
||||
else {
|
||||
ArrayList<String> colorTemp = new ArrayList<String>();
|
||||
colorTemp.add("black");
|
||||
card.setChosenColor(colorTemp);
|
||||
}
|
||||
} else {
|
||||
card.setChosenColor("black");
|
||||
ArrayList<String> colorTemp = new ArrayList<String>();
|
||||
colorTemp.add("black");
|
||||
card.setChosenColor(colorTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,9 +237,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
}
|
||||
|
||||
//chosen color
|
||||
if (card.getChosenColor() != "") {
|
||||
if (!card.getChosenColor().isEmpty()) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
area.append("(chosen color: ");
|
||||
area.append("(chosen colors: ");
|
||||
area.append(card.getChosenColor());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user