diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 919b3a11ef0..fabdc89a28c 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -476,6 +476,40 @@ public class CardFactoryUtil { return target; }//input_sacrifice() + public static Input input_sacrificePermanents(final int nCards) { + Input target = new Input() { + private static final long serialVersionUID = -8149416676562317629L; + int n = 0; + + @Override + public void showMessage() { + + AllZone.Display.showMessage("Select a permanent to sacrifice (" +(nCards-n) +" left)"); + ButtonUtil.disableAll(); + } + + @Override + public void selectCard(Card card, PlayerZone zone) { + if(zone.equals(AllZone.Human_Play) && !card.getName().equals("Mana Pool")) { + AllZone.GameAction.sacrifice(card); + n++; + + //in case no more {type}s in play + CardList list = new CardList(AllZone.Human_Play.getCards()); + list = list.filter(new CardListFilter(){ + public boolean addCard(Card c) + { + return c.isPermanent() && !c.getName().equals("Mana Pool"); + } + }); + if(n == nCards || list.size() == 0) stop(); + else + showMessage(); + } + } + }; + return target; + }//input_sacrificePermanents() public static Input input_sacrificePermanents(final int nCards, final String type) { Input target = new Input() { diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index b7d03296156..079bdf5f5d5 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -3,6 +3,8 @@ package forge; import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class CombatUtil { @@ -777,6 +779,40 @@ public class CombatUtil { if( /*AllZone.Phase.getPhase().equals("Declare Blockers") ||*/ AllZone.Phase.getPhase().equals(Constant.Phase.Combat_Declare_Attackers_InstantAbility)) { + //Annihilator: + ArrayList kws = c.getKeyword(); + Pattern p = Pattern.compile("Annihilator [0-9]+"); + Matcher m; + for (String key : kws) + { + m = p.matcher(key); + if (m.find()) + { + String k[] = key.split(" "); + final int a = Integer.valueOf(k[1]); + final Card crd = c; + + final Ability ability = new Ability(c, "0") + { + public void resolve() + { + if (crd.getController().equals(Constant.Player.Human)) + { + //comp sacks + } + else + { + AllZone.InputControl.setInput(CardFactoryUtil.input_sacrificePermanents(a)); + } + + } + }; + ability.setStackDescription(""); + AllZone.Stack.add(ability); + } + } + //Annihilator + //Beastmaster Ascension if(!c.getCreatureAttackedThisCombat()) { PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController()); @@ -848,6 +884,9 @@ public class CombatUtil { AllZone.Stack.add(ability); }//Raging Ravine + // + + if(c.getName().equals("Zhang He, Wei General") && !c.getCreatureAttackedThisCombat()) { final PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());