diff --git a/src/forge/AbilityFactory_Counters.java b/src/forge/AbilityFactory_Counters.java index 3ca35c5e9d4..3b322cc63f8 100644 --- a/src/forge/AbilityFactory_Counters.java +++ b/src/forge/AbilityFactory_Counters.java @@ -236,7 +236,7 @@ public class AbilityFactory_Counters { }); if (abTgt != null){ - list = list.getValidCards(abTgt.getValidTgts()); + list = list.getValidCards(abTgt.getValidTgts(),source.getController(),source); if (list.size() == 0) return false; diff --git a/src/forge/AbilityFactory_Fetch.java b/src/forge/AbilityFactory_Fetch.java index a43c38d161d..a7cb844b3b8 100644 --- a/src/forge/AbilityFactory_Fetch.java +++ b/src/forge/AbilityFactory_Fetch.java @@ -221,7 +221,7 @@ public class AbilityFactory_Fetch { private static CardList filterListByType(CardList list, HashMap params, String type){ if (params.containsKey(type)) - list = list.getValidCards(params.get(type).split(",")); + list = list.getValidCards(params.get(type).split(","),null,null); return list; } @@ -491,7 +491,7 @@ public class AbilityFactory_Fetch { tgt.resetTargets(); // target loop CardList list = AllZoneUtil.getPlayerGraveyard(AllZone.ComputerPlayer); - list = list.getValidCards(tgt.getValidTgts(), AllZone.ComputerPlayer); + list = list.getValidCards(tgt.getValidTgts(), AllZone.ComputerPlayer, af.getHostCard()); if (list.size() == 0) return false; diff --git a/src/forge/AbilityFactory_PermanentState.java b/src/forge/AbilityFactory_PermanentState.java index 615fcdd69b4..0076f545209 100644 --- a/src/forge/AbilityFactory_PermanentState.java +++ b/src/forge/AbilityFactory_PermanentState.java @@ -87,10 +87,10 @@ public class AbilityFactory_PermanentState { else{ CardList untapList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer); untapList = untapList.filter(AllZoneUtil.tapped); - untapList = untapList.getValidCards(tgt.getValidTgts(), source.getController()); + untapList = untapList.getValidCards(tgt.getValidTgts(), source.getController(), source); // filter out enchantments and planeswalkers, their tapped state doesn't matter. String[] tappablePermanents = {"Creature", "Land", "Artifact"}; - untapList = untapList.getValidCards(tappablePermanents); + untapList = untapList.getValidCards(tappablePermanents, source.getController(), source); if (untapList.size() == 0) return false; @@ -243,10 +243,10 @@ public class AbilityFactory_PermanentState { else{ CardList tapList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer); tapList = tapList.filter(AllZoneUtil.untapped); - tapList = tapList.getValidCards(tgt.getValidTgts(), source.getController()); + tapList = tapList.getValidCards(tgt.getValidTgts(), source.getController(), source); // filter out enchantments and planeswalkers, their tapped state doesn't matter. String[] tappablePermanents = {"Creature", "Land", "Artifact"}; - tapList = tapList.getValidCards(tappablePermanents); + tapList = tapList.getValidCards(tappablePermanents, source.getController(), source); if (tapList.size() == 0) return false; diff --git a/src/forge/Ability_Triggered.java b/src/forge/Ability_Triggered.java index bf8e7eae557..fa89c05d109 100644 --- a/src/forge/Ability_Triggered.java +++ b/src/forge/Ability_Triggered.java @@ -49,7 +49,7 @@ public class Ability_Triggered extends Ability implements Command { } public boolean triggerFor(Card c) { - return !(new CardList(c)).getValidCards(restrictions).isEmpty(); + return !(new CardList(c)).getValidCards(restrictions,c.getController(),c).isEmpty(); } public boolean triggerOnZoneChange(String sourceZone, String destinationZone) { diff --git a/src/forge/Card.java b/src/forge/Card.java index d95d553c7af..2712333fd78 100644 --- a/src/forge/Card.java +++ b/src/forge/Card.java @@ -2237,6 +2237,7 @@ public class Card extends MyObservable { return false; } + /* // This takes a player and a card argument for YouCtrl and Other public boolean isValidCard(String Restris[], Player You, Card source) { @@ -2351,16 +2352,16 @@ public class Card extends MyObservable { } } return isValidCard(Restriction); - } + }*/ // Takes an array of arguments like Permanent.Blue+withFlying, only one of them has to be true - public boolean isValidCard(final String Restrictions[]) { + public boolean isValidCard(final String Restrictions[], final Player You, final Card source) { if (getName().equals("Mana Pool") || isImmutable()) return false; for(int i = 0; i < Restrictions.length; i++) { - if(isValid(Restrictions[i])) return true; + if(isValid(Restrictions[i],You,source)) return true; } return false; @@ -2368,7 +2369,7 @@ public class Card extends MyObservable { // Takes an argument like Permanent.Blue+withFlying - public boolean isValid(final String Restriction) { + public boolean isValid(final String Restriction, final Player You, final Card source) { if (getName().equals("Mana Pool") || isImmutable()) return false; if (Restriction.equals("False")) return false; @@ -2386,13 +2387,13 @@ public class Card extends MyObservable { final String excR = incR[1]; String exR[] = excR.split("\\+"); // Exclusive Restrictions are ... for(int j = 0; j < exR.length; j++) - if(hasProperty(exR[j]) == false) return false; + if(hasProperty(exR[j],You,source) == false) return false; } return true; }//isValidCard(String Restriction) // Takes arguments like Blue or withFlying - public boolean hasProperty(String Property) { + public boolean hasProperty(String Property, Player You, Card source) { if (Property.contains("White") || // ... Card colors Property.contains("Blue") || Property.contains("Black") || @@ -2419,6 +2420,15 @@ public class Card extends MyObservable { if (!Property.startsWith("non") && (CardUtil.getColors(this).size() > 1 || isColorless())) return false; } + else if (Property.contains("YouCtrl") && !getController().isPlayer(You)) return false; + else if (Property.contains("YouDontCtrl") && getController().isPlayer(You)) return false; + + else if (Property.contains("Other") && this.equals(source)) return false; + else if (Property.contains("Self") && !this.equals(source)) return false; + + else if (Property.contains("Attached") && !this.equipping.contains(source) && !this.enchanting.contains(source)) return false; + + else if (Property.contains("with")) // ... Card keywords { if (Property.startsWith("without") && getKeyword().contains(Property.substring(7))) return false; @@ -2478,7 +2488,7 @@ public class Card extends MyObservable { } if (Property.substring(z).equals("X")) - x = CardFactoryUtil.xCount(this, getSVar("X")); + x = CardFactoryUtil.xCount(source, getSVar("X")); else x = Integer.parseInt(Property.substring(z)); @@ -2490,7 +2500,7 @@ public class Card extends MyObservable { { int number = 0; if (Property.substring(10,11).equals("X")) - number = CardFactoryUtil.xCount(this, getSVar("X")); + number = CardFactoryUtil.xCount(source, getSVar("X")); else number = Integer.parseInt(Property.substring(10,11)); diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 67517731939..f0f9259b757 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -975,7 +975,7 @@ public class CardFactory implements NewConstants { String dV = DiscardMethod.substring(dot + 1); String dValid[] = dV.split(","); - dPChHand = dPHand.getValidCards(dValid); + dPChHand = dPHand.getValidCards(dValid,card.getController(),card); } if (card.getController().equals(AllZone.ComputerPlayer)) @@ -1196,13 +1196,13 @@ public class CardFactory implements NewConstants { } String fc[] = {"Creature"}; - l = l.getValidCards(fc); + l = l.getValidCards(fc,card.getController(),card); if (Scope.length > 1) { String v = Scope[1]; if (v.length() > 0) - l = l.getValidCards(v.split(",")); + l = l.getValidCards(v.split(","),card.getController(),card); } return l; @@ -1458,13 +1458,13 @@ public class CardFactory implements NewConstants { } String fc[] = {"Creature"}; - l = l.getValidCards(fc); + l = l.getValidCards(fc,card.getController(),card); if (Scope.length > 1) { String v = Scope[1]; if (v.length() > 0) - l = l.getValidCards(v.split(",")); + l = l.getValidCards(v.split(","),card.getController(),card); } return l; @@ -2281,7 +2281,7 @@ public class CardFactory implements NewConstants { CardList human = new CardList(AllZone.Human_Play.getCards()); CardList computer = new CardList(AllZone.Computer_Play.getCards()); - human = human.getValidCards(Tgts); + human = human.getValidCards(Tgts,card.getController(),card); human = human.canBeDamagedBy(card); human = human.getNotKeyword("Indestructible"); human = human.filter(new CardListFilter() { @@ -2296,7 +2296,7 @@ public class CardFactory implements NewConstants { if (!DmgPlayer[0] && AllZone.ComputerPlayer.getLife() < 7) humanvalue += CardListUtil.sumAttack(human); // in Low Life Emergency (and not hurting itself) X = X + total power of human creatures - computer = computer.getValidCards(Tgts); + computer = computer.getValidCards(Tgts,card.getController(),card); computer = computer.canBeDamagedBy(card); computer = computer.getNotKeyword("Indestructible"); computer = computer.filter(new CardListFilter() { @@ -2321,7 +2321,7 @@ public class CardFactory implements NewConstants { CardList all = new CardList(); all.addAll(AllZone.Human_Play.getCards()); all.addAll(AllZone.Computer_Play.getCards()); - all = all.getValidCards(Tgts); + all = all.getValidCards(Tgts,card.getController(),card); for(int i = 0; i < all.size(); i++) { if(CardFactoryUtil.canDamage(card, all.get(i))) all.get(i).addDamage(ndam, card); @@ -2658,7 +2658,7 @@ public class CardFactory implements NewConstants { CardList getTargets() { CardList tmpList = new CardList(); tmpList.addAll(AllZone.Human_Play.getCards()); - tmpList = tmpList.getValidCards(Tgts); + tmpList = tmpList.getValidCards(Tgts,card.getController(),card); tmpList = tmpList.getTargetableCards(card); return tmpList; @@ -2815,7 +2815,7 @@ public class CardFactory implements NewConstants { CardList getTargets() { CardList tmpList = new CardList(); tmpList.addAll(AllZone.Human_Play.getCards()); - tmpList = tmpList.getValidCards(Tgts); + tmpList = tmpList.getValidCards(Tgts,card.getController(),card); tmpList = tmpList.getTargetableCards(card); return tmpList; @@ -2915,13 +2915,13 @@ public class CardFactory implements NewConstants { Random r = new Random(); CardList hCards = new CardList(AllZone.getZone(Constant.Zone.Play, AllZone.HumanPlayer).getCards()); - hCards = hCards.getValidCards(Tgts); + hCards = hCards.getValidCards(Tgts,card.getController(),card); hCards = hCards.getTargetableCards(card); if (hCards.size() > 0) return true; CardList cCards = new CardList(AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer).getCards()); - cCards = cCards.getValidCards(Tgts); + cCards = cCards.getValidCards(Tgts,card.getController(),card); cCards = cCards.getTargetableCards(card); if (cCards.size() == 0) return true; @@ -2971,9 +2971,9 @@ public class CardFactory implements NewConstants { CardList hCards = new CardList(AllZone.Human_Play.getCards()); CardList cCards = new CardList(AllZone.Computer_Play.getCards()); - hCards = hCards.getValidCards(Tgts); + hCards = hCards.getValidCards(Tgts,card.getController(),card); hCards = hCards.getTargetableCards(card); - cCards = cCards.getValidCards(Tgts); + cCards = cCards.getValidCards(Tgts,card.getController(),card); cCards = cCards.getTargetableCards(card); if(hCards.size() > 0 || cCards.size() > 0) @@ -3109,7 +3109,7 @@ public class CardFactory implements NewConstants { CardList human = new CardList(AllZone.Human_Play.getCards()); CardList computer = new CardList(AllZone.Computer_Play.getCards()); - human = human.getValidCards(Tgts); + human = human.getValidCards(Tgts,card.getController(),card); human = human.getNotKeyword("Indestructible"); int humanvalue = CardListUtil.sumCMC(human); humanvalue += human.size(); @@ -3117,7 +3117,7 @@ public class CardFactory implements NewConstants { humanvalue += human.getType("Land").size(); // X = total converted mana cost + number of permanents + number of lands + total power of tokens (Human) if (AllZone.ComputerPlayer.getLife() < 7) { humanvalue += CardListUtil.sumAttack(human); } // in Low Life Emergency X = X + total power of human creatures - computer = computer.getValidCards(Tgts); + computer = computer.getValidCards(Tgts,card.getController(),card); computer = computer.getNotKeyword("Indestructible"); int computervalue = CardListUtil.sumCMC(computer); computervalue += computer.size(); @@ -3134,7 +3134,7 @@ public class CardFactory implements NewConstants { CardList all = new CardList(); all.addAll(AllZone.Human_Play.getCards()); all.addAll(AllZone.Computer_Play.getCards()); - all = all.getValidCards(Tgts); + all = all.getValidCards(Tgts,card.getController(),card); CardListUtil.sortByIndestructible(all); CardListUtil.sortByDestroyEffect(all); @@ -3156,7 +3156,7 @@ public class CardFactory implements NewConstants { CardList afterAll = new CardList(); afterAll.addAll(AllZone.Human_Play.getCards()); afterAll.addAll(AllZone.Computer_Play.getCards()); - afterAll = afterAll.getValidCards(Tgts); + afterAll = afterAll.getValidCards(Tgts,card.getController(),card); ArrayList slD = new ArrayList(); for (int i=0; i 0) return true; CardList cCards = new CardList(AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer).getCards()); - cCards = cCards.getValidCards(Tgts); + cCards = cCards.getValidCards(Tgts,card.getController(),card); cCards = cCards.getTargetableCards(card); if (cCards.size() == 0) return true; @@ -3497,9 +3497,9 @@ public class CardFactory implements NewConstants { CardList hCards = new CardList(AllZone.Human_Play.getCards()); CardList cCards = new CardList(AllZone.Computer_Play.getCards()); - hCards = hCards.getValidCards(Tgts); + hCards = hCards.getValidCards(Tgts,card.getController(),card); hCards = hCards.getTargetableCards(card); - cCards = cCards.getValidCards(Tgts); + cCards = cCards.getValidCards(Tgts,card.getController(),card); cCards = cCards.getTargetableCards(card); if (hCards.size() > 0 || cCards.size() > 0) @@ -3612,7 +3612,7 @@ public class CardFactory implements NewConstants { CardList human = new CardList(AllZone.Human_Play.getCards()); CardList computer = new CardList(AllZone.Computer_Play.getCards()); - human = human.getValidCards(Tgts); + human = human.getValidCards(Tgts,card.getController(),card); int humanvalue = CardListUtil.sumCMC(human); humanvalue += human.getType("Land").size(); humanvalue += CardListUtil.sumAttack(human.getTokens()); // X = total converted mana cost + number of lands c (Human) @@ -3620,7 +3620,7 @@ public class CardFactory implements NewConstants { if(Destination.equals("Hand")) humanvalue += CardListUtil.sumDefense(human.getTokens()); // if the Destination is Hand tokens are more important if (AllZone.ComputerPlayer.getLife() < 7) { humanvalue += CardListUtil.sumAttack(human); } // in Low Life Emergency X = X + total power of human creatures - computer = computer.getValidCards(Tgts); + computer = computer.getValidCards(Tgts,card.getController(),card); int computervalue = CardListUtil.sumCMC(computer); computervalue += computer.getType("Land").size(); computervalue += CardListUtil.sumAttack(computer.getTokens()); // Y = total converted mana cost + number of lands + total power of tokens (Computer) @@ -3637,7 +3637,7 @@ public class CardFactory implements NewConstants { CardList all = new CardList(); all.addAll(AllZone.Human_Play.getCards()); all.addAll(AllZone.Computer_Play.getCards()); - all = all.getValidCards(Tgts); + all = all.getValidCards(Tgts,card.getController(),card); for(int i = 0; i < all.size(); i++) { Card c = all.get(i); @@ -3868,7 +3868,7 @@ public class CardFactory implements NewConstants { Player player = card.getController(); PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player); CardList list = new CardList(grave.getCards()); - list = list.getValidCards(Tgts); + list = list.getValidCards(Tgts,card.getController(),card); // AI will not use a Boggart Birth Rite to return a Boggart Birth Rite. // In testing the AI targeted a Sage's Knowledge with a Deja Vu. @@ -4032,7 +4032,7 @@ public class CardFactory implements NewConstants { PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player); CardList results = new CardList(); CardList choices = new CardList(grave.getCards()); - choices = choices.getValidCards(Tgts); + choices = choices.getValidCards(Tgts,card.getController(),card); // AI will not use an Eternal Witness to return an Eternal Witness. @@ -6091,7 +6091,7 @@ public class CardFactory implements NewConstants { CardList getTargets() { CardList tmpList = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer); - tmpList = tmpList.getValidCards(Tgts); + tmpList = tmpList.getValidCards(Tgts,card.getController(),card); tmpList = tmpList.getTargetableCards(card); tmpList = tmpList.filter(AllZoneUtil.untapped); return tmpList; @@ -6183,7 +6183,7 @@ public class CardFactory implements NewConstants { private CardList getTargets() { CardList tmpList = AllZoneUtil.getCardsInPlay(); - tmpList = tmpList.getValidCards(Tgts); + tmpList = tmpList.getValidCards(Tgts,card.getController(),card); tmpList = tmpList.getTargetableCards(card); tmpList = tmpList.filter(AllZoneUtil.untapped); return tmpList; @@ -6274,7 +6274,7 @@ public class CardFactory implements NewConstants { private CardList getTargets() { CardList tmpList = AllZoneUtil.getCardsInPlay(); - tmpList = tmpList.getValidCards(Tgts, card.getController()); + tmpList = tmpList.getValidCards(Tgts,card.getController(),card); //I don't think this is targeted //tmpList = tmpList.getTargetableCards(card); //tmpList = tmpList.filter(AllZoneUtil.untapped); @@ -6397,7 +6397,7 @@ public class CardFactory implements NewConstants { CardList getTargets() { CardList tmpList = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer); - tmpList = tmpList.getValidCards(Tgts, card.getController()); + tmpList = tmpList.getValidCards(Tgts,card.getController(),card); tmpList = tmpList.getTargetableCards(card); tmpList = tmpList.filter(AllZoneUtil.tapped); return tmpList; @@ -6487,7 +6487,7 @@ public class CardFactory implements NewConstants { CardList getTargets() { CardList tmpList = AllZoneUtil.getCardsInPlay(); - tmpList = tmpList.getValidCards(Tgts, card.getController()); + tmpList = tmpList.getValidCards(Tgts,card.getController(),card); //I don't think this is targeted //tmpList = tmpList.getTargetableCards(card); //tmpList = tmpList.filter(AllZoneUtil.tapped); @@ -9096,7 +9096,7 @@ public class CardFactory implements NewConstants { public void resolve() { Card crd = getTargetCard(); // if it's not a valid target on resolution, spell fizzles - if (crd == null || !AllZone.GameAction.isCardInPlay(crd) || !crd.isValidCard(Tgts)) + if (crd == null || !AllZone.GameAction.isCardInPlay(crd) || !crd.isValidCard(Tgts,card.getController(),card)) return; crd.addCounter(Counters.P1P1, 1); diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 8e3d5ca40dd..d24ca7da28b 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -2443,7 +2443,7 @@ public class CardFactoryUtil { allCards.addAll(AllZone.Human_Play.getCards()); allCards.addAll(AllZone.Computer_Play.getCards()); - CardList choices = allCards.getValidCards(Tgts); + CardList choices = allCards.getValidCards(Tgts,sa.getActivatingPlayer(),sa.getSourceCard()); boolean free = false; if(this.isFree()) free = true; stopSetNext(CardFactoryUtil.input_targetSpecific(sa, choices, message, true, free)); @@ -3099,7 +3099,7 @@ public class CardFactoryUtil { CardList list = new CardList(); PlayerZone zone = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); list.addAll(zone.getCards()); - list = list.getValidCards(Tgts); + list = list.getValidCards(Tgts,card.getController(),card); return list; } };// Input @@ -3542,7 +3542,7 @@ public class CardFactoryUtil { if(kw.startsWith("Protection:")) { //uses isValidCard String characteristic = kw.split(":")[1]; String characteristics[] = characteristic.split(","); - if(card.isValidCard(characteristics)) return true; + if(card.isValidCard(characteristics,card.getController(),card)) return true; } } @@ -4114,7 +4114,7 @@ public class CardFactoryUtil { if (d[0].contains("Type")) { String dd[] = d[0].split("\\."); - ut = ut.getValidCards(dd); + ut = ut.getValidCards(dd,cardController,Src); } for (int i=0; i { }); } + /* public CardList getValidCards(final String Restrictions[], final Card source) { return this.filter(new CardListFilter() { public boolean addCard(Card c) { @@ -338,7 +339,7 @@ public class CardList implements Iterable { } }); }//getValidCards - + */ public CardList getEquipMagnets() { return this.filter(new CardListFilter() { diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index d367327895c..25a08e87dcb 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -440,7 +440,7 @@ public class CombatUtil { String parse = defender.getKeyword().get(KeywordPosition).toString(); String k[] = parse.split(":"); final String restrictions[] = k[1].split(","); - if(attacker.isValidCard(restrictions)) return true; + if(attacker.isValidCard(restrictions, defender.getController(), defender)) return true; } if(attacker.getName().equals("Sylvan Basilisk") && !defender.getKeyword().contains("Indestructible")) return false; @@ -564,7 +564,7 @@ public class CombatUtil { String parse = attacker.getKeyword().get(KeywordPosition).toString(); String k[] = parse.split(":"); final String restrictions[] = k[1].split(","); - if(defender.isValidCard(restrictions)) return true; + if(defender.isValidCard(restrictions,attacker.getController(),attacker)) return true; } if(defender.hasStartOfKeyword("Prevent all combat damage that would be dealt to") || @@ -2161,7 +2161,7 @@ public class CombatUtil { String parse = b.getKeyword().get(KeywordPosition).toString(); String k[] = parse.split(":"); final String restrictions[] = k[1].split(","); - if(a.isValidCard(restrictions)) { + if(a.isValidCard(restrictions,b.getController(),b)) { final Card attacker = a; final Ability ability = new Ability(b, "0") { @Override @@ -2197,7 +2197,7 @@ public class CombatUtil { String parse = a.getKeyword().get(KeywordPosition).toString(); String k[] = parse.split(":"); final String restrictions[] = k[1].split(","); - if(b.isValidCard(restrictions)) { + if(b.isValidCard(restrictions,a.getController(),a)) { final Card blocker = b; final Ability ability = new Ability(a, "0") { @Override diff --git a/src/forge/ComputerAI_General.java b/src/forge/ComputerAI_General.java index 696f29c436a..70cb966871b 100644 --- a/src/forge/ComputerAI_General.java +++ b/src/forge/ComputerAI_General.java @@ -53,7 +53,7 @@ public class ComputerAI_General implements Computer { if (buffedcard.getSVar("BuffedBy").length() > 0) { String buffedby = buffedcard.getSVar("BuffedBy"); String bffdby[] = buffedby.split(","); - if (c.isValidCard(bffdby)) return true; + if (c.isValidCard(bffdby,c.getController(),c)) return true; } }//BuffedBy @@ -63,7 +63,7 @@ public class ComputerAI_General implements Computer { if (buffedcard.getSVar("AntiBuffedBy").length() > 0) { String buffedby = buffedcard.getSVar("AntiBuffedBy"); String bffdby[] = buffedby.split(","); - if (c.isValidCard(bffdby)) return true; + if (c.isValidCard(bffdby,c.getController(),c)) return true; } }//AntiBuffedBy diff --git a/src/forge/ComputerUtil.java b/src/forge/ComputerUtil.java index 700fd3e4935..1ff4be36c51 100644 --- a/src/forge/ComputerUtil.java +++ b/src/forge/ComputerUtil.java @@ -245,7 +245,7 @@ public class ComputerUtil { PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getTapXType().split(",")); + typeList = typeList.getValidCards(cost.getTapXType().split(","),sa.getActivatingPlayer() ,sa.getSourceCard()); if (cost.getTap()) typeList.remove(sa.getSourceCard()); @@ -291,7 +291,7 @@ public class ComputerUtil else{ if (!discType.equals("Any") && !discType.equals("Random")){ String validType[] = discType.split(","); - handList = handList.getValidCards(validType); + handList = handList.getValidCards(validType,sa.getActivatingPlayer() ,sa.getSourceCard()); } if (discAmount > handList.size()){ // not enough cards in hand to pay @@ -305,7 +305,7 @@ public class ComputerUtil if (!cost.getSacThis()){ PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getSacType().split(",")); + typeList = typeList.getValidCards(cost.getSacType().split(","),sa.getActivatingPlayer() ,sa.getSourceCard()); Card target = sa.getTargetCard(); if (target != null && target.getController().equals(AllZone.ComputerPlayer)) // don't sacrifice the card we're pumping typeList.remove(target); @@ -322,7 +322,7 @@ public class ComputerUtil if (!cost.getExileThis()){ PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getExileType().split(",")); + typeList = typeList.getValidCards(cost.getExileType().split(","),sa.getActivatingPlayer() ,sa.getSourceCard()); Card target = sa.getTargetCard(); if (target != null && target.getController().equals(AllZone.ComputerPlayer)) // don't exile the card we're pumping typeList.remove(target); @@ -339,7 +339,7 @@ public class ComputerUtil if (!cost.getReturnThis()){ PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getReturnType().split(",")); + typeList = typeList.getValidCards(cost.getReturnType().split(","),sa.getActivatingPlayer() ,sa.getSourceCard()); Card target = sa.getTargetCard(); if (target != null && target.getController().equals(AllZone.ComputerPlayer)) // don't bounce the card we're pumping typeList.remove(target); @@ -621,7 +621,7 @@ public class ComputerUtil static public Card getCardPreference(Card activate, String pref, CardList typeList){ String[] prefValid = activate.getSVar("AIPreference").split("\\$"); if (prefValid[0].equals(pref)){ - CardList prefList = typeList.getValidCards(prefValid[1].split(",")); + CardList prefList = typeList.getValidCards(prefValid[1].split(","),activate.getController() ,activate); if (prefList.size() != 0){ prefList.shuffle(); return prefList.get(0); @@ -647,7 +647,7 @@ public class ComputerUtil static public Card chooseSacrificeType(String type, Card activate, Card target){ PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(type.split(",")); + typeList = typeList.getValidCards(type.split(","),activate.getController() ,activate); if (target != null && target.getController().equals(AllZone.ComputerPlayer) && typeList.contains(target)) // don't sacrifice the card we're pumping typeList.remove(target); @@ -670,7 +670,7 @@ public class ComputerUtil static public Card chooseTapType(String type, Card activate, boolean tap, int index){ PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(type.split(",")); + typeList = typeList.getValidCards(type.split(","),activate.getController() ,activate); //is this needed? typeList = typeList.filter(new CardListFilter() @@ -694,7 +694,7 @@ public class ComputerUtil static public Card chooseReturnType(String type, Card activate, Card target){ PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(type.split(",")); + typeList = typeList.getValidCards(type.split(","),activate.getController() ,activate); if (target != null && target.getController().equals(AllZone.ComputerPlayer) && typeList.contains(target)) // don't bounce the card we're pumping typeList.remove(target); diff --git a/src/forge/Cost_Payment.java b/src/forge/Cost_Payment.java index 4fcc37d5287..fc54812ec49 100644 --- a/src/forge/Cost_Payment.java +++ b/src/forge/Cost_Payment.java @@ -81,7 +81,7 @@ public class Cost_Payment { PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getTapXType().split(",")); + typeList = typeList.getValidCards(cost.getTapXType().split(","),ability.getActivatingPlayer() ,ability.getSourceCard()); if (cost.getTap()) { typeList = typeList.filter(new CardListFilter() @@ -130,7 +130,7 @@ public class Cost_Payment { else{ if (!discType.equals("Any") && !discType.equals("Random")){ String validType[] = discType.split(","); - handList = handList.getValidCards(validType); + handList = handList.getValidCards(validType,ability.getActivatingPlayer() ,ability.getSourceCard()); } if (discAmount > handList.size()){ // not enough cards in hand to pay @@ -144,7 +144,7 @@ public class Cost_Payment { PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getSacType().split(",")); + typeList = typeList.getValidCards(cost.getSacType().split(","),ability.getActivatingPlayer() ,ability.getSourceCard()); if (typeList.size() < cost.getSacAmount()) return false; } @@ -156,7 +156,7 @@ public class Cost_Payment { if (!cost.getExileThis()){ CardList typeList = AllZoneUtil.getPlayerCardsInPlay(card.getController()); - typeList = typeList.getValidCards(cost.getExileType().split(",")); + typeList = typeList.getValidCards(cost.getExileType().split(","),ability.getActivatingPlayer() ,ability.getSourceCard()); if (typeList.size() < cost.getExileAmount()) return false; } @@ -169,7 +169,7 @@ public class Cost_Payment { PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getReturnType().split(",")); + typeList = typeList.getValidCards(cost.getReturnType().split(","),ability.getActivatingPlayer() ,ability.getSourceCard()); if (typeList.size() < cost.getReturnAmount()) return false; } @@ -218,7 +218,7 @@ public class Cost_Payment { if (!payTapXType && cost.getTapXTypeCost()){ PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); CardList typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(cost.getTapXType().split(",")); + typeList = typeList.getValidCards(cost.getTapXType().split(","),ability.getActivatingPlayer() ,ability.getSourceCard()); changeInput.stopSetNext(input_tapXCost(cost.getTapXTypeAmount(),cost.getTapXType(), typeList, ability, this)); return false; @@ -289,7 +289,7 @@ public class Cost_Payment { else{ if (!discType.equals("Any")){ String validType[] = discType.split(","); - handList = handList.getValidCards(validType); + handList = handList.getValidCards(validType,ability.getActivatingPlayer() ,ability.getSourceCard()); } changeInput.stopSetNext(input_discardCost(discAmount, discType, handList, ability, this)); return false; @@ -692,7 +692,7 @@ public class Cost_Payment { PlayerZone play = AllZone.getZone(Constant.Zone.Play, spell.getSourceCard().getController()); typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(type.split(",")); + typeList = typeList.getValidCards(type.split(","),spell.getActivatingPlayer() ,spell.getSourceCard()); AllZone.Display.showMessage(msg.toString()); ButtonUtil.enableOnlyCancel(); } @@ -786,7 +786,7 @@ public class Cost_Payment { PlayerZone play = AllZone.getZone(Constant.Zone.Play, spell.getSourceCard().getController()); typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(type.split(",")); + typeList = typeList.getValidCards(type.split(","),spell.getActivatingPlayer() ,spell.getSourceCard()); AllZone.Display.showMessage(msg.toString()); ButtonUtil.enableOnlyCancel(); } @@ -932,7 +932,7 @@ public class Cost_Payment { PlayerZone play = AllZone.getZone(Constant.Zone.Play, spell.getSourceCard().getController()); typeList = new CardList(play.getCards()); - typeList = typeList.getValidCards(type.split(",")); + typeList = typeList.getValidCards(type.split(","),spell.getActivatingPlayer() ,spell.getSourceCard()); AllZone.Display.showMessage(msg.toString()); ButtonUtil.enableOnlyCancel(); } diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index 9f5eee55c75..bb569e51574 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -198,7 +198,7 @@ public class GameAction { public boolean AI_discardNumType(int numDiscard, String[] uTypes, SpellAbility sa) { CardList hand = new CardList(); hand.addAll(AllZone.getZone(Constant.Zone.Hand, AllZone.ComputerPlayer).getCards()); - CardList tHand = hand.getValidCards(uTypes); + CardList tHand = hand.getValidCards(uTypes,sa.getActivatingPlayer(),sa.getSourceCard()); if(tHand.size() >= numDiscard) { CardListUtil.sortCMC(tHand); diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 8a77205af36..6a23a4b6a07 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -3791,7 +3791,7 @@ public class GameActionUtil { private static CardList Defiler_of_Souls_getTargets(final Player player, Card card) { CardList creats = AllZoneUtil.getCreaturesInPlay(player); String mono[] = {"Creature.MonoColor"}; - creats = creats.getValidCards(mono); + creats = creats.getValidCards(mono,player,card); return creats; } @@ -7287,7 +7287,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7359,7 +7359,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7447,7 +7447,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7536,7 +7536,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7620,7 +7620,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7688,12 +7688,12 @@ public class GameActionUtil { String[] smallCreatures = { "Creature.toughnessLE2" }; CardList humanCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer); - humanCreatures = humanCreatures.getValidCards(smallCreatures); + humanCreatures = humanCreatures.getValidCards(smallCreatures,k.getController(),k); humanCreatures = humanCreatures.canBeDamagedBy(k); humanCreatures = humanCreatures.getNotKeyword("Indestructible"); CardList computerCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer); - computerCreatures = computerCreatures.getValidCards(smallCreatures); + computerCreatures = computerCreatures.getValidCards(smallCreatures,k.getController(),k); computerCreatures = computerCreatures.canBeDamagedBy(k); computerCreatures = computerCreatures.getNotKeyword("Indestructible"); @@ -7701,7 +7701,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7781,7 +7781,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7859,7 +7859,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -7931,7 +7931,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -8001,7 +8001,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -8092,7 +8092,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -8162,7 +8162,7 @@ public class GameActionUtil { // We do not want to slow down the pace of the game by asking too many questions. // Dialogs outside of the Ability appear at the previous end of turn phase !!! - if (peek[0].isValidCard(shareTypes)) { + if (peek[0].isValidCard(shareTypes,k.getController(),k)) { if (player.isHuman()) { StringBuilder question = new StringBuilder(); question.append("Your top card is ").append(peek[0].getName()); @@ -9496,7 +9496,7 @@ public class GameActionUtil { public void resolve() { CardList handList = AllZoneUtil.getCardsInZone(Constant.Zone.Hand, player); CardList playList = AllZoneUtil.getCardsInZone(Constant.Zone.Play, player); - playList = playList.getValidCards("Permanents".split(",")); + playList = playList.getValidCards("Permanents".split(","),source.getController(),source); playList.remove(source); if (playList.size() == 0 && handList.size() == 0) diff --git a/src/forge/Generate2ColorDeck.java b/src/forge/Generate2ColorDeck.java index 91af7864373..7b8e7276e52 100644 --- a/src/forge/Generate2ColorDeck.java +++ b/src/forge/Generate2ColorDeck.java @@ -137,8 +137,8 @@ public class Generate2ColorDeck CardList Cr2 = CL2.getType("Creature"); String ISE[] = {"Instant", "Sorcery", "Enchantment", "Planeswalker"}; - CardList Sp1 = CL1.getValidCards(ISE); - CardList Sp2 = CL2.getValidCards(ISE); + CardList Sp1 = CL1.getValidCards(ISE,null,null); + CardList Sp2 = CL2.getValidCards(ISE,null,null); // final card pools CardList Cr12 = new CardList(); diff --git a/src/forge/Generate3ColorDeck.java b/src/forge/Generate3ColorDeck.java index e186ae6cce0..0ad01f2e27a 100644 --- a/src/forge/Generate3ColorDeck.java +++ b/src/forge/Generate3ColorDeck.java @@ -150,9 +150,9 @@ public class Generate3ColorDeck CardList Cr3 = CL3.getType("Creature"); String ISE[] = {"Instant", "Sorcery", "Enchantment", "Planeswalker"}; - CardList Sp1 = CL1.getValidCards(ISE); - CardList Sp2 = CL2.getValidCards(ISE); - CardList Sp3 = CL3.getValidCards(ISE); + CardList Sp1 = CL1.getValidCards(ISE,null,null); + CardList Sp2 = CL2.getValidCards(ISE,null,null); + CardList Sp3 = CL3.getValidCards(ISE,null,null); // final card pools CardList Cr123 = new CardList(); diff --git a/src/forge/PhaseUtil.java b/src/forge/PhaseUtil.java index 420fdee9e3f..77173e54014 100644 --- a/src/forge/PhaseUtil.java +++ b/src/forge/PhaseUtil.java @@ -65,10 +65,11 @@ public class PhaseUtil { String parse = ca.getKeyword().get(KeywordPosition).toString(); String k[] = parse.split(":"); final String restrictions[] = k[1].split(","); + final Card card = ca; list = list.filter(new CardListFilter() { public boolean addCard(Card c) { - return !c.isValidCard(restrictions); + return !c.isValidCard(restrictions,card.getController(),card); } // filter out cards that should not untap }); }