diff --git a/src/forge/Counters.java b/src/forge/Counters.java index 47e3f323a88..7edc0231b30 100644 --- a/src/forge/Counters.java +++ b/src/forge/Counters.java @@ -53,4 +53,8 @@ public enum Counters { public String getName() { return name; } + public static Counters getType(String name) + { + return Enum.valueOf(Counters.class, name.replace("/", "").replaceAll("\\+", "p").replaceAll("\\-", "m").toUpperCase()); + } } diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index 57b9446e12b..86c2a3367ba 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -8,7 +8,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; -import java.util.List; import java.util.Random; import java.util.Map.Entry; @@ -2195,23 +2194,23 @@ public class GameAction { else throw new RuntimeException("GameAction : destroy() invalid card.getOwner() - " + c + " " + c.getOwner()); - play.remove(c); if(c.getKeyword().contains("Persist") && c.getCounters(Counters.M1M1) == 0) persist = true; - //tokens don't go into the graveyard - //TODO: must change this if any cards have effects that trigger "when creatures go to the graveyard" - if(!c.isToken()) - //resets the card, untaps the card, removes anything "extra", resets attack and defense - moveToGraveyard(c); - - - c.destroy(); if(c.isEquipped()){ // when equipped creature goes to the grave here. // Deathrender & Oathkeeper, Takeno's Daisho have similar triggers to Skullclamp skullClamp_destroy(c); c.unEquipAllCards(); } + //tokens don't go into the graveyard + //TODO: must change this if any cards have effects that trigger "when creatures go to the graveyard" + if(!c.isToken()) + //resets the card, untaps the card, removes anything "extra", resets attack and defense + moveToGraveyard(c); + else play.remove(c); + + c.destroy(); + //destroy card effects: PlayerZone comp = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer); @@ -3927,32 +3926,51 @@ public class GameAction { if (c.getController().equals(Constant.Player.Human)) { - List selection1 = AllZone.Display.getChoicesOptional("Select permanent(s) computer controls", cperms.toArray()); - List selection2 = AllZone.Display.getChoicesOptional("Select permanent(s) you control", hperms.toArray()); - - String[] choices = {"Human", "Computer"}; - List playerSelection = AllZone.Display.getChoicesOptional("Select player(s)", choices); - - for(int m = 0; m < selection1.size(); m++) { - Card crd = selection1.get(m); - for(Counters c_1:Counters.values()) - if(crd.getCounters(c_1) != 0) crd.addCounter(c_1, 1); - } + cperms.addAll(hperms.toArray()); + final CardList unchosen = cperms; + AllZone.InputControl.setInput(new Input() { + private static final long serialVersionUID = -1779224307654698954L; - for(int m = 0; m < selection2.size(); m++) { - Card crd = selection2.get(m); - for(Counters c_1:Counters.values()) - if(crd.getCounters(c_1) != 0) crd.addCounter(c_1, 1); - } - - for (int i=0;i 0) - AllZone.Human_PoisonCounter.addPoisonCounters(1); - if (s.equals("Computer") && AllZone.Computer_PoisonCounter.getPoisonCounters() > 0) - AllZone.Computer_PoisonCounter.addPoisonCounters(1); - } + @Override + public void showMessage() { + AllZone.Display.showMessage("Choose permanents and/or players"); + ButtonUtil.enableOnlyOK(); + } + + @Override + public void selectButtonOK() { + stop(); + } + + @Override + public void selectCard(Card card, PlayerZone zone) + { + if(!unchosen.contains(card)) return; + unchosen.remove(card); + ArrayList choices = new ArrayList(); + for(Counters c_1:Counters.values()) + if(card.getCounters(c_1) != 0) choices.add(c_1.getName()); + if (choices.size() > 0) + card.addCounter(Counters.getType((choices.size() == 1 ? choices.get(0) : AllZone.Display.getChoice("Select counter type", choices.toArray()).toString())), 1); + } + boolean selComputer = false; + boolean selHuman = false; + @Override + public void selectPlayer(String player){ + if (player.equals("Human") && selHuman == false) + { + selHuman = true; + if (AllZone.Human_PoisonCounter.getPoisonCounters() > 0) + AllZone.Human_PoisonCounter.addPoisonCounters(1); + } + if (player.equals("Computer") && selComputer == false) + { + selComputer = true; + if (AllZone.Computer_PoisonCounter.getPoisonCounters() > 0) + AllZone.Computer_PoisonCounter.addPoisonCounters(1); + } + } + }); } else //comp {