From d40abbb3762ed8dd50f52468e13c001ee65084d1 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 03:31:50 +0000 Subject: [PATCH] Moved input_targetValid code into CardFactoryUtil --- src/forge/CardFactory.java | 10 +++++----- src/forge/CardFactoryUtil.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index dc72c03af71..4b5dcca7be8 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -172,7 +172,6 @@ public class CardFactory implements NewConstants { ArrayList a = c.getIntrinsicKeyword(); for(int i = 0; i < a.size(); i++) if(a.get(i).toString().contains(": add ")) return i; - return -1; } @@ -2434,7 +2433,8 @@ public class CardFactory implements NewConstants { } }; //SpDstryTgt - Input InGetTarget = new Input() { + Input InGetTarget = CardFactoryUtil.input_targetValid(spDstryTgt, Tgts, Selec); + /*new Input() { private static final long serialVersionUID = -142142142142L; @Override @@ -2442,18 +2442,18 @@ public class CardFactory implements NewConstants { CardList allCards = new CardList(); allCards.addAll(AllZone.Human_Play.getCards()); allCards.addAll(AllZone.Computer_Play.getCards()); - allCards.filter(new CardListFilter() { + / *allCards.filter(new CardListFilter() { public boolean addCard(Card c) { return (CardFactoryUtil.canTarget(card, c)); } - }); + });* ///Input_targetSpecific already checks for this CardList choices = allCards.getValidCards(Tgts); boolean free = false; if(this.isFree()) free = true; stopSetNext(CardFactoryUtil.input_targetSpecific(spDstryTgt, choices, Selec, true, free)); } - };//InGetTarget + };*///InGetTarget //card.clearSpellAbility(); spDstryTgt.setBeforePayMana(InGetTarget); diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 207a05f3564..0dcd81d035f 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -1471,6 +1471,24 @@ public class CardFactoryUtil { return desc; }//soul_desc() + public static Input input_targetValid(final SpellAbility sa, final String[] Tgts, final String message) + { + return new Input() { + private static final long serialVersionUID = -142142142142L; + + @Override + public void showMessage() { + CardList allCards = new CardList(); + allCards.addAll(AllZone.Human_Play.getCards()); + allCards.addAll(AllZone.Computer_Play.getCards()); + + CardList choices = allCards.getValidCards(Tgts); + boolean free = false; + if(this.isFree()) free = true; + stopSetNext(CardFactoryUtil.input_targetSpecific(sa, choices, message, true, free)); + } + }; + }//input_targetValid //CardList choices are the only cards the user can successful select public static Input input_targetSpecific(final SpellAbility spell, final CardList choices, final String message, final boolean targeted, final boolean free) { return input_targetSpecific(spell, choices, message, Command.Blank, targeted, free);