From cd37b8c3bac270aa8cf80e4e94dd6a776d1f2f65 Mon Sep 17 00:00:00 2001 From: North Date: Sun, 15 Jul 2012 16:32:19 +0300 Subject: [PATCH 1/5] [filters] Added support for Predicates with sourceId and PlayerId --- Mage/src/mage/filter/FilterImpl.java | 12 ++--- Mage/src/mage/filter/FilterPermanent.java | 18 +++++-- Mage/src/mage/filter/FilterStackObject.java | 17 ++++-- .../mage/filter/predicate/ObjectPlayer.java | 53 +++++++++++++++++++ .../predicate/ObjectPlayerPredicate.java | 35 ++++++++++++ .../filter/predicate/ObjectSourcePlayer.java | 48 +++++++++++++++++ .../ObjectSourcePlayerPredicate.java | 35 ++++++++++++ 7 files changed, 201 insertions(+), 17 deletions(-) create mode 100644 Mage/src/mage/filter/predicate/ObjectPlayer.java create mode 100644 Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java create mode 100644 Mage/src/mage/filter/predicate/ObjectSourcePlayer.java create mode 100644 Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java diff --git a/Mage/src/mage/filter/FilterImpl.java b/Mage/src/mage/filter/FilterImpl.java index e243e0bb0fa..55741ac7028 100644 --- a/Mage/src/mage/filter/FilterImpl.java +++ b/Mage/src/mage/filter/FilterImpl.java @@ -31,6 +31,7 @@ package mage.filter; import java.util.ArrayList; import java.util.List; import mage.filter.predicate.Predicate; +import mage.filter.predicate.Predicates; import mage.game.Game; /** @@ -40,7 +41,7 @@ import mage.game.Game; */ public abstract class FilterImpl implements Filter { - protected List predicates = new ArrayList(); + protected List> predicates = new ArrayList>(); protected String message; protected boolean notFilter = false; @@ -54,17 +55,12 @@ public abstract class FilterImpl implements Filter { public FilterImpl(FilterImpl filter) { this.message = filter.message; this.notFilter = filter.notFilter; - this.predicates = new ArrayList(filter.predicates); + this.predicates = new ArrayList>(filter.predicates); } @Override public boolean match(E e, Game game) { - for (int i = 0; i < predicates.size(); i++) { - if (!predicates.get(i).apply(e, game)) { - return false; - } - } - return true; + return Predicates.and(predicates).apply(e, game); } @Override diff --git a/Mage/src/mage/filter/FilterPermanent.java b/Mage/src/mage/filter/FilterPermanent.java index f878d050833..343e246d8fe 100644 --- a/Mage/src/mage/filter/FilterPermanent.java +++ b/Mage/src/mage/filter/FilterPermanent.java @@ -28,19 +28,22 @@ package mage.filter; -import mage.Constants.TargetController; -import mage.game.Game; -import mage.game.permanent.Permanent; - import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mage.Constants.TargetController; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.permanent.Permanent; /** * * @author BetaSteward_at_googlemail.com */ public class FilterPermanent extends FilterObject { + protected List>> extraPredicates = new ArrayList>>(); protected List controllerId = new ArrayList(); protected boolean notController; protected TargetController controller = TargetController.ANY; @@ -58,6 +61,7 @@ public class FilterPermanent extends FilterObject { this.controller = filter.controller; this.owner = filter.owner; this.another = filter.another; + this.extraPredicates = new ArrayList>>(extraPredicates); } public FilterPermanent(String name) { @@ -120,7 +124,11 @@ public class FilterPermanent extends FilterObject { } } - return !notFilter; + return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(permanent, sourceId, playerId), game); + } + + public void add(ObjectSourcePlayerPredicate predicate) { + extraPredicates.add(predicate); } public List getControllerId() { diff --git a/Mage/src/mage/filter/FilterStackObject.java b/Mage/src/mage/filter/FilterStackObject.java index d96ac3e6e8b..1a9b80b18f2 100644 --- a/Mage/src/mage/filter/FilterStackObject.java +++ b/Mage/src/mage/filter/FilterStackObject.java @@ -28,20 +28,24 @@ package mage.filter; -import mage.Constants.TargetController; -import mage.game.Game; -import mage.game.stack.StackObject; - import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mage.Constants.TargetController; +import mage.filter.predicate.ObjectPlayer; +import mage.filter.predicate.ObjectPlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; /** * * @author BetaSteward_at_googlemail.com + * @author North */ public class FilterStackObject extends FilterObject { + protected List>> extraPredicates = new ArrayList>>(); protected List controllerId = new ArrayList(); protected boolean notController = false; protected TargetController controller = TargetController.ANY; @@ -59,6 +63,7 @@ public class FilterStackObject extends FilterObject { this.controllerId.addAll(filter.controllerId); this.notController = filter.notController; this.controller = filter.controller; + this.extraPredicates = new ArrayList>>(extraPredicates); } @Override @@ -97,6 +102,10 @@ public class FilterStackObject extends FilterObject { return !notFilter; } + public void add(ObjectPlayerPredicate predicate) { + extraPredicates.add(predicate); + } + public List getControllerId() { return controllerId; } diff --git a/Mage/src/mage/filter/predicate/ObjectPlayer.java b/Mage/src/mage/filter/predicate/ObjectPlayer.java new file mode 100644 index 00000000000..7cb609a331c --- /dev/null +++ b/Mage/src/mage/filter/predicate/ObjectPlayer.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.filter.predicate; + +import java.util.UUID; + +/** + * + * @author North + */ +public class ObjectPlayer { + + protected T object; + protected UUID playerId; + + public ObjectPlayer(T object, UUID playerId) { + this.object = object; + this.playerId = playerId; + } + + public T getObject() { + return object; + } + + public UUID getPlayerId() { + return playerId; + } +} diff --git a/Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java b/Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java new file mode 100644 index 00000000000..5fddeed0138 --- /dev/null +++ b/Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.filter.predicate; + +/** + * + * @author North + */ +public interface ObjectPlayerPredicate extends Predicate { +} diff --git a/Mage/src/mage/filter/predicate/ObjectSourcePlayer.java b/Mage/src/mage/filter/predicate/ObjectSourcePlayer.java new file mode 100644 index 00000000000..2a7493da431 --- /dev/null +++ b/Mage/src/mage/filter/predicate/ObjectSourcePlayer.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.filter.predicate; + +import java.util.UUID; + +/** + * + * @author North + */ +public class ObjectSourcePlayer extends ObjectPlayer { + + protected UUID sourceId; + + public ObjectSourcePlayer(T object, UUID sourceId, UUID playerId) { + super(object, playerId); + this.sourceId = sourceId; + } + + public UUID getSourceId() { + return sourceId; + } +} diff --git a/Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java b/Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java new file mode 100644 index 00000000000..32e7a771547 --- /dev/null +++ b/Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.filter.predicate; + +/** + * + * @author North + */ +public interface ObjectSourcePlayerPredicate extends Predicate { +} From d66c1729528c24e303206ea0405fffd057d09362 Mon Sep 17 00:00:00 2001 From: North Date: Sun, 15 Jul 2012 16:58:01 +0300 Subject: [PATCH 2/5] [filters] Refactored FilterAbility to use Predicates FilterAbility isn't used anywhere. I only noticed after I finished rewriting it. I'll keep the class in the repository just in case someone would need it. --- .../src/mage/player/ai/ComputerPlayer7.java | 16 --- .../src/mage/player/ai/ComputerPlayer3.java | 16 --- Mage/src/mage/filter/FilterAbility.java | 117 +++++++----------- 3 files changed, 44 insertions(+), 105 deletions(-) diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java index ecb4f9571e0..7b6c02436f4 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java @@ -29,11 +29,8 @@ package mage.player.ai; import mage.Constants; -import mage.Constants.AbilityType; import mage.Constants.RangeOfInfluence; -import mage.Constants.Zone; import mage.abilities.Ability; -import mage.filter.FilterAbility; import mage.game.Game; import mage.game.combat.Combat; import mage.game.combat.CombatGroup; @@ -54,21 +51,8 @@ public class ComputerPlayer7 extends ComputerPlayer6 implements Player { private static final transient Logger logger = Logger.getLogger(ComputerPlayer7.class); - private static FilterAbility filterLand = new FilterAbility(); - private static FilterAbility filterNotLand = new FilterAbility(); - private boolean allowBadMoves; - static { - filterLand.getTypes().add(AbilityType.PLAY_LAND); - filterLand.setZone(Zone.HAND); - - filterNotLand.getTypes().add(AbilityType.PLAY_LAND); - filterNotLand.setZone(Zone.HAND); - filterNotLand.setNotFilter(true); - - } - public ComputerPlayer7(String name, RangeOfInfluence range, int skill) { super(name, range, skill); } diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java index 2f36d168791..c151a8d4f9e 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java @@ -28,12 +28,9 @@ package mage.player.ai; -import mage.Constants.AbilityType; import mage.Constants.PhaseStep; import mage.Constants.RangeOfInfluence; -import mage.Constants.Zone; import mage.abilities.Ability; -import mage.filter.FilterAbility; import mage.game.Game; import mage.game.combat.Combat; import mage.game.combat.CombatGroup; @@ -54,19 +51,6 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player { private static final transient Logger logger = Logger.getLogger(ComputerPlayer3.class); - private static FilterAbility filterLand = new FilterAbility(); - private static FilterAbility filterNotLand = new FilterAbility(); - - static { - filterLand.getTypes().add(AbilityType.PLAY_LAND); - filterLand.setZone(Zone.HAND); - - filterNotLand.getTypes().add(AbilityType.PLAY_LAND); - filterNotLand.setZone(Zone.HAND); - filterNotLand.setNotFilter(true); - - } - public ComputerPlayer3(String name, RangeOfInfluence range, int skill) { super(name, range, skill); } diff --git a/Mage/src/mage/filter/FilterAbility.java b/Mage/src/mage/filter/FilterAbility.java index f54f0013cd2..13c763a013c 100644 --- a/Mage/src/mage/filter/FilterAbility.java +++ b/Mage/src/mage/filter/FilterAbility.java @@ -25,105 +25,76 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.filter; import mage.Constants.AbilityType; -import mage.Constants.Outcome; import mage.Constants.Zone; import mage.abilities.Ability; +import mage.filter.predicate.Predicate; import mage.game.Game; -import java.util.ArrayList; -import java.util.List; - /** * - * @author BetaSteward_at_googlemail.com + * @author North */ -public class FilterAbility extends FilterImpl { - - protected static ListComparer compOutcome = new ListComparer(); - - protected List outcomes = new ArrayList(); - protected ComparisonScope scopeOutcome = ComparisonScope.All; - protected boolean notOutcome; - protected List types = new ArrayList(); - protected boolean notType; - protected Zone zone; - protected boolean notZone; +public class FilterAbility extends FilterImpl { public FilterAbility() { super(""); } - public FilterAbility(FilterAbility filter) { + public FilterAbility(FilterAbility filter) { super(filter); - for (Outcome outcome: filter.outcomes) { - this.outcomes.add(outcome); - } - this.scopeOutcome = filter.scopeOutcome; - this.notOutcome = filter.notOutcome; - for (AbilityType aType: filter.types) { - this.types.add(aType); - } - this.notType = filter.notType; - this.zone = filter.zone; - this.notZone = filter.notZone; } @Override - public boolean match(T object, Game game) { + public FilterAbility copy() { + return new FilterAbility(this); + } - if (zone != null) { - if (object.getZone().match(zone) == notZone) - return notFilter; + public static Predicate zone(Zone zone) { + return new AbilityZonePredicate(zone); + } + + public static Predicate type(AbilityType type) { + return new AbilityTypePredicate(type); + } + + private static final class AbilityZonePredicate implements Predicate { + + private Zone zone; + + public AbilityZonePredicate(Zone zone) { + this.zone = zone; } - if (outcomes.size() > 0) { - if (!compOutcome.compare(outcomes, object.getEffects().getOutcomes(), scopeOutcome, notOutcome)) - return notFilter; + @Override + public boolean apply(Ability input, Game game) { + return input.getZone().match(zone); } - if (types.size() > 0) { - if (types.contains(object.getAbilityType()) == notType) - return notFilter; + @Override + public String toString() { + return "Zone(" + zone.toString() + ")"; + } + } + + private static final class AbilityTypePredicate implements Predicate { + + private AbilityType type; + + public AbilityTypePredicate(AbilityType type) { + this.type = type; } - return !notFilter; - } + @Override + public boolean apply(Ability input, Game game) { + return input.getAbilityType().equals(type); + } - public List getOutcomes() { - return this.outcomes; + @Override + public String toString() { + return "AbilityType(" + type + ')'; + } } - - public void setScopeOutcome(ComparisonScope scopeOutcome) { - this.scopeOutcome = scopeOutcome; - } - - public void setNotOutcome(boolean notOutcome) { - this.notOutcome = notOutcome; - } - - public List getTypes() { - return types; - } - - public void setNotType(boolean notType) { - this.notType = notType; - } - - public void setZone(Zone zone) { - this.zone = zone; - } - - public void setNotZone(boolean notZone) { - this.notZone = notZone; - } - - @Override - public FilterAbility copy() { - return new FilterAbility(this); - } - } From 021e2b59df009a25dd79151920debb6391e9686c Mon Sep 17 00:00:00 2001 From: North Date: Sun, 15 Jul 2012 17:18:33 +0300 Subject: [PATCH 3/5] [filters] Replaced Another condition with Predicate --- .../avacynrestored/DemonicTaskmaster.java | 3 +- .../avacynrestored/DemonlordOfAshmouth.java | 5 +- .../mage/sets/avacynrestored/Fettergeist.java | 5 +- .../avacynrestored/GoldnightRedeemer.java | 5 +- .../sets/avacynrestored/HavengulSkaab.java | 3 +- .../championsofkamigawa/HisokasGuard.java | 3 +- .../MyojinOfCleansingFire.java | 3 +- .../src/mage/sets/innistrad/FiendHunter.java | 14 +++--- .../sets/innistrad/GrimgrinCorpseBorn.java | 3 +- .../sets/innistrad/MikaeusTheLunarch.java | 3 +- .../mage/sets/innistrad/OliviaVoldaren.java | 3 +- Mage.Sets/src/mage/sets/lorwyn/MadAuntie.java | 3 +- .../src/mage/sets/magic2010/XathridDemon.java | 3 +- .../src/mage/sets/magic2012/AegisAngel.java | 3 +- .../sets/mirrodinbesieged/Cryptoplasm.java | 3 +- .../mirrodinbesieged/ThopterAssembly.java | 3 +- .../mage/sets/shardsofalara/OblivionRing.java | 5 +- .../sets/worldwake/TideforceElemental.java | 4 +- .../mage/sets/zendikar/JourneyToNowhere.java | 3 +- Mage/src/mage/filter/FilterPermanent.java | 17 ------- .../predicate/permanent/AnotherPredicate.java | 50 +++++++++++++++++++ .../mage/watchers/common/SoulbondWatcher.java | 5 +- 22 files changed, 100 insertions(+), 49 deletions(-) create mode 100644 Mage/src/mage/filter/predicate/permanent/AnotherPredicate.java diff --git a/Mage.Sets/src/mage/sets/avacynrestored/DemonicTaskmaster.java b/Mage.Sets/src/mage/sets/avacynrestored/DemonicTaskmaster.java index 6e78af860e9..24b34cd05bc 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/DemonicTaskmaster.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/DemonicTaskmaster.java @@ -37,6 +37,7 @@ import mage.abilities.effects.common.SacrificeEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import java.util.UUID; @@ -49,7 +50,7 @@ public class DemonicTaskmaster extends CardImpl { private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("a creature other than Demonic Taskmaster"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public DemonicTaskmaster(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/DemonlordOfAshmouth.java b/Mage.Sets/src/mage/sets/avacynrestored/DemonlordOfAshmouth.java index 5125765bd4b..2bb7a1bcd4a 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/DemonlordOfAshmouth.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/DemonlordOfAshmouth.java @@ -37,6 +37,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.UndyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.common.TargetControlledPermanent; import java.util.UUID; @@ -46,10 +47,10 @@ import java.util.UUID; */ public class DemonlordOfAshmouth extends CardImpl { - private static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(" another creature"); + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(" another creature"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public DemonlordOfAshmouth(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/Fettergeist.java b/Mage.Sets/src/mage/sets/avacynrestored/Fettergeist.java index 7bf8a0c3d31..4b4d404e476 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/Fettergeist.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/Fettergeist.java @@ -39,6 +39,7 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -79,10 +80,10 @@ public class Fettergeist extends CardImpl { class FettergeistUnlessPaysEffect extends OneShotEffect { - private static FilterCreaturePermanent filter = new FilterCreaturePermanent(); + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public FettergeistUnlessPaysEffect() { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/GoldnightRedeemer.java b/Mage.Sets/src/mage/sets/avacynrestored/GoldnightRedeemer.java index cab90a84018..fbdd2b83924 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/GoldnightRedeemer.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/GoldnightRedeemer.java @@ -36,6 +36,7 @@ import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import java.util.UUID; @@ -46,10 +47,10 @@ import java.util.UUID; */ public class GoldnightRedeemer extends CardImpl { - private static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("other creature you control"); + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("other creature you control"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public GoldnightRedeemer(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/HavengulSkaab.java b/Mage.Sets/src/mage/sets/avacynrestored/HavengulSkaab.java index 93e2bfcbb26..a2a500657b8 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/HavengulSkaab.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/HavengulSkaab.java @@ -36,6 +36,7 @@ import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.target.common.TargetControlledCreaturePermanent; @@ -77,7 +78,7 @@ class HavengulSkaabAbility extends TriggeredAbilityImpl { private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature you control"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public HavengulSkaabAbility() { diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/HisokasGuard.java b/Mage.Sets/src/mage/sets/championsofkamigawa/HisokasGuard.java index af6f782426a..98207d81c50 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/HisokasGuard.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/HisokasGuard.java @@ -40,6 +40,7 @@ import mage.abilities.effects.RestrictionEffect; import mage.abilities.keyword.ShroudAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -68,7 +69,7 @@ public class HisokasGuard extends CardImpl { // {1}{U}, {T}: Target creature you control other than Hisoka's Guard has shroud for as long as Hisoka's Guard remains tapped. (It can't be the target of spells or abilities.) FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); - filter.setAnother(true); + filter.add(new AnotherPredicate()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HisokasGuardGainAbilityTargetEffect(), new ManaCostsImpl("{1}{U}")); ability.addCost(new TapSourceCost()); Target target = new TargetControlledCreaturePermanent(1, 1, filter, true, true); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java index cbf054a9462..7912ac1e050 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfCleansingFire.java @@ -48,6 +48,7 @@ import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.watchers.common.CastFromHandWatcher; /** @@ -57,7 +58,7 @@ public class MyojinOfCleansingFire extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("other creatures"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public MyojinOfCleansingFire(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/FiendHunter.java b/Mage.Sets/src/mage/sets/innistrad/FiendHunter.java index 229b74f8bec..957a883c90e 100644 --- a/Mage.Sets/src/mage/sets/innistrad/FiendHunter.java +++ b/Mage.Sets/src/mage/sets/innistrad/FiendHunter.java @@ -27,6 +27,7 @@ */ package mage.sets.innistrad; +import java.util.UUID; import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -34,14 +35,13 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility; -import mage.cards.CardImpl; -import mage.filter.common.FilterCreaturePermanent; -import mage.target.Target; -import mage.target.TargetPermanent; - -import java.util.UUID; import mage.abilities.effects.common.ExileTargetForSourceEffect; import mage.abilities.effects.common.ReturnFromExileForSourceEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.target.Target; +import mage.target.TargetPermanent; /** * @author nantuko @@ -50,7 +50,7 @@ public class FiendHunter extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public FiendHunter(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java b/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java index a566d3927fa..56b9f51ed09 100644 --- a/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java +++ b/Mage.Sets/src/mage/sets/innistrad/GrimgrinCorpseBorn.java @@ -45,6 +45,7 @@ import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.target.common.TargetControlledCreaturePermanent; @@ -59,7 +60,7 @@ public class GrimgrinCorpseBorn extends CardImpl { private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public GrimgrinCorpseBorn(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/MikaeusTheLunarch.java b/Mage.Sets/src/mage/sets/innistrad/MikaeusTheLunarch.java index a091b6fb9e6..d00718597ad 100644 --- a/Mage.Sets/src/mage/sets/innistrad/MikaeusTheLunarch.java +++ b/Mage.Sets/src/mage/sets/innistrad/MikaeusTheLunarch.java @@ -45,6 +45,7 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; @@ -58,7 +59,7 @@ public class MikaeusTheLunarch extends CardImpl { private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public MikaeusTheLunarch(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/OliviaVoldaren.java b/Mage.Sets/src/mage/sets/innistrad/OliviaVoldaren.java index 318df6de485..d23b3180c69 100644 --- a/Mage.Sets/src/mage/sets/innistrad/OliviaVoldaren.java +++ b/Mage.Sets/src/mage/sets/innistrad/OliviaVoldaren.java @@ -45,6 +45,7 @@ import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -57,7 +58,7 @@ public class OliviaVoldaren extends CardImpl { private static final FilterCreaturePermanent vampireFilter = new FilterCreaturePermanent("Vampire"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); vampireFilter.add(new SubtypePredicate("Vampire")); } diff --git a/Mage.Sets/src/mage/sets/lorwyn/MadAuntie.java b/Mage.Sets/src/mage/sets/lorwyn/MadAuntie.java index 0ddf4d51b00..b44946bb1ac 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/MadAuntie.java +++ b/Mage.Sets/src/mage/sets/lorwyn/MadAuntie.java @@ -41,6 +41,7 @@ import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.common.TargetControlledCreaturePermanent; import java.util.UUID; @@ -56,7 +57,7 @@ public class MadAuntie extends CardImpl { static { filter1.add(new SubtypePredicate("Goblin")); - filter1.setAnother(true); + filter1.add(new AnotherPredicate()); filter2.add(new SubtypePredicate("Goblin")); } diff --git a/Mage.Sets/src/mage/sets/magic2010/XathridDemon.java b/Mage.Sets/src/mage/sets/magic2010/XathridDemon.java index cce2fcaf319..edcfd4d1435 100644 --- a/Mage.Sets/src/mage/sets/magic2010/XathridDemon.java +++ b/Mage.Sets/src/mage/sets/magic2010/XathridDemon.java @@ -42,6 +42,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -107,7 +108,7 @@ class XathridDemonEffect extends OneShotEffect { } FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature other than " + sourcePermanent.getName()); - filter.setAnother(true); + filter.add(new AnotherPredicate()); Target target = new TargetControlledCreaturePermanent(1, 1, filter, true, true); if (target.canChoose(source.getSourceId(), player.getId(), game)) { diff --git a/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java b/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java index fa544dec7b0..a9f410a4ebc 100644 --- a/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java +++ b/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java @@ -41,6 +41,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.Target; import mage.target.TargetPermanent; @@ -58,7 +59,7 @@ public class AegisAngel extends CardImpl { this.toughness = new MageInt(5); this.addAbility(FlyingAbility.getInstance()); FilterPermanent filter = new FilterPermanent("another target permanent"); - filter.setAnother(true); + filter.add(new AnotherPredicate()); Ability ability = new EntersBattlefieldTriggeredAbility(new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Constants.Duration.WhileOnBattlefield), false); Target target = new TargetPermanent(filter); target.setRequired(true); diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java index 9d5f80466fc..25341f6793e 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/Cryptoplasm.java @@ -40,6 +40,7 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.cards.Card; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; @@ -52,7 +53,7 @@ public class Cryptoplasm extends CardImpl { final static FilterCreaturePermanent filter = new FilterCreaturePermanent(); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public Cryptoplasm(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java index 432a90a8439..26d4e72ba67 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/ThopterAssembly.java @@ -43,6 +43,7 @@ import mage.game.events.GameEvent; import mage.game.permanent.token.Token; import java.util.UUID; +import mage.filter.predicate.permanent.AnotherPredicate; /** * @@ -92,7 +93,7 @@ class ThopterAssemblyTriggeredAbility extends TriggeredAbilityImpl { - private static FilterNonlandPermanent anotherNonlandPermanent = new FilterNonlandPermanent("another nonland permanent"); + private static final FilterNonlandPermanent anotherNonlandPermanent = new FilterNonlandPermanent("another nonland permanent"); static { - anotherNonlandPermanent.setAnother(true); + anotherNonlandPermanent.add(new AnotherPredicate()); } public OblivionRing(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/worldwake/TideforceElemental.java b/Mage.Sets/src/mage/sets/worldwake/TideforceElemental.java index 872d38c3473..0fd409c6716 100644 --- a/Mage.Sets/src/mage/sets/worldwake/TideforceElemental.java +++ b/Mage.Sets/src/mage/sets/worldwake/TideforceElemental.java @@ -42,6 +42,7 @@ import mage.abilities.effects.common.MayTapOrUntapTargetEffect; import mage.abilities.effects.common.UntapSourceEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -50,11 +51,10 @@ import mage.target.common.TargetCreaturePermanent; */ public class TideforceElemental extends CardImpl { - // private final static String text = "You may tap or untap another target creature"; private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public TideforceElemental(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/JourneyToNowhere.java b/Mage.Sets/src/mage/sets/zendikar/JourneyToNowhere.java index 9db17447d78..e70c7f13612 100644 --- a/Mage.Sets/src/mage/sets/zendikar/JourneyToNowhere.java +++ b/Mage.Sets/src/mage/sets/zendikar/JourneyToNowhere.java @@ -39,6 +39,7 @@ import mage.abilities.effects.common.ExileTargetForSourceEffect; import mage.abilities.effects.common.ReturnFromExileForSourceEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.Target; import mage.target.TargetPermanent; @@ -53,7 +54,7 @@ public class JourneyToNowhere extends CardImpl { this.expansionSetCode = "ZEN"; this.color.setWhite(true); FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.setAnother(true); + filter.add(new AnotherPredicate()); Ability ability1 = new EntersBattlefieldTriggeredAbility(new ExileTargetForSourceEffect("Journey to Nowhere exile"), false); Target target = new TargetPermanent(filter); target.setRequired(true); diff --git a/Mage/src/mage/filter/FilterPermanent.java b/Mage/src/mage/filter/FilterPermanent.java index 343e246d8fe..f2db3f8fc30 100644 --- a/Mage/src/mage/filter/FilterPermanent.java +++ b/Mage/src/mage/filter/FilterPermanent.java @@ -48,7 +48,6 @@ public class FilterPermanent extends FilterObject { protected boolean notController; protected TargetController controller = TargetController.ANY; protected TargetController owner = TargetController.ANY; - protected boolean another; public FilterPermanent() { super("permanent"); @@ -60,7 +59,6 @@ public class FilterPermanent extends FilterObject { this.notController = filter.notController; this.controller = filter.controller; this.owner = filter.owner; - this.another = filter.another; this.extraPredicates = new ArrayList>>(extraPredicates); } @@ -117,13 +115,6 @@ public class FilterPermanent extends FilterObject { } } - if (another) { - // filter out itself - if (permanent.getId().equals(sourceId)) { - return notFilter; - } - } - return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(permanent, sourceId, playerId), game); } @@ -147,14 +138,6 @@ public class FilterPermanent extends FilterObject { this.owner = owner; } - public boolean isAnother() { - return another; - } - - public void setAnother(boolean another) { - this.another = another; - } - public boolean matchController(UUID testControllerId) { if (controllerId.size() > 0 && controllerId.contains(testControllerId) == notController) return false; diff --git a/Mage/src/mage/filter/predicate/permanent/AnotherPredicate.java b/Mage/src/mage/filter/predicate/permanent/AnotherPredicate.java new file mode 100644 index 00000000000..a27eb3fc747 --- /dev/null +++ b/Mage/src/mage/filter/predicate/permanent/AnotherPredicate.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.filter.predicate.permanent; + +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author North + */ +public class AnotherPredicate implements ObjectSourcePlayerPredicate> { + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + return !input.getObject().getId().equals(input.getSourceId()); + } + + @Override + public String toString() { + return "Another"; + } +} diff --git a/Mage/src/mage/watchers/common/SoulbondWatcher.java b/Mage/src/mage/watchers/common/SoulbondWatcher.java index 16297b7b2ea..71128aca828 100644 --- a/Mage/src/mage/watchers/common/SoulbondWatcher.java +++ b/Mage/src/mage/watchers/common/SoulbondWatcher.java @@ -34,6 +34,7 @@ import mage.abilities.keyword.SoulbondAbility; import mage.cards.Cards; import mage.cards.CardsImpl; import mage.filter.common.FilterNotPairedControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; @@ -49,10 +50,10 @@ import mage.watchers.WatcherImpl; */ public class SoulbondWatcher extends WatcherImpl { - private static FilterNotPairedControlledCreaturePermanent filter = new FilterNotPairedControlledCreaturePermanent("another not paired creature you control"); + private static final FilterNotPairedControlledCreaturePermanent filter = new FilterNotPairedControlledCreaturePermanent("another not paired creature you control"); static { - filter.setAnother(true); + filter.add(new AnotherPredicate()); } public SoulbondWatcher() { From 4563e518a6323e292160b2dd71f2fd911da11718 Mon Sep 17 00:00:00 2001 From: North Date: Mon, 16 Jul 2012 20:55:58 +0300 Subject: [PATCH 4/5] [filters] Replaced TargetController condition with Predicate --- .../src/mage/player/human/HumanPlayer.java | 3 +- .../mage/sets/avacynrestored/Dreadwaters.java | 3 +- .../sets/avacynrestored/PeelFromReality.java | 3 +- .../MyojinOfSeeingWinds.java | 3 +- .../mage/sets/darkascension/AlphaBrawl.java | 3 +- .../sets/darkascension/ArchdemonOfGreed.java | 3 +- .../sets/darkascension/DungeonGeists.java | 3 +- .../mage/sets/darkascension/FeedThePack.java | 3 +- .../src/mage/sets/darkascension/Helvault.java | 3 +- .../mage/sets/darksteel/EmissaryOfHope.java | 4 +- .../mage/sets/innistrad/DivineReckoning.java | 3 +- .../sets/innistrad/GarrukTheVeilCursed.java | 3 +- .../sets/innistrad/HystericalBlindness.java | 3 +- .../mage/sets/innistrad/OneEyedScarecrow.java | 3 +- .../src/mage/sets/innistrad/PreyUpon.java | 3 +- .../sets/innistrad/ScourgeOfGeierReach.java | 3 +- .../mage/sets/innistrad/TributeToHunger.java | 3 +- .../src/mage/sets/innistrad/VampiricFury.java | 3 +- .../src/mage/sets/lorwyn/ScionOfOona.java | 3 +- .../mage/sets/magic2010/AlluringSiren.java | 3 +- .../mage/sets/magic2010/ArmoredAscension.java | 3 +- .../mage/sets/magic2010/CapriciousEfreet.java | 5 +- .../src/mage/sets/magic2010/SafePassage.java | 3 +- .../mage/sets/magic2010/YawningFissure.java | 3 +- .../src/mage/sets/magic2011/Corrupt.java | 3 +- .../src/mage/sets/magic2011/EarthServant.java | 3 +- .../mage/sets/magic2011/MystifyingMaze.java | 3 +- .../mage/sets/magic2011/NecroticPlague.java | 3 +- .../src/mage/sets/magic2011/QuagSickness.java | 3 +- .../mage/sets/magic2011/SteelOverseer.java | 3 +- .../src/mage/sets/magic2012/Smallpox.java | 5 +- .../src/mage/sets/magic2013/CowerInFear.java | 3 +- .../mage/sets/magic2013/FungalSprouting.java | 3 +- .../magic2013/LilianaOfTheDarkRealms.java | 3 +- .../src/mage/sets/magic2013/Mutilate.java | 3 +- .../sets/magic2013/ThundermawHellkite.java | 3 +- .../mage/sets/magic2013/TimberpackWolf.java | 3 +- .../src/mage/sets/mirrodin/NightmareLash.java | 3 +- .../newphyrexia/ChancellorOfTheForge.java | 3 +- .../mage/sets/newphyrexia/DeceiverExarch.java | 3 +- .../src/mage/sets/newphyrexia/Lashwrithe.java | 3 +- .../mage/sets/newphyrexia/VitalSplicer.java | 3 +- .../mage/sets/planechase/FiresOfYavimaya.java | 3 +- .../riseoftheeldrazi/ConsumingVapors.java | 3 +- .../scarsofmirrodin/DarksteelJuggernaut.java | 3 +- .../sets/scarsofmirrodin/KothOfTheHammer.java | 5 +- .../sets/scarsofmirrodin/OgreGeargrabber.java | 5 +- .../mage/sets/shadowmoor/ToilToRenown.java | 3 +- .../sets/shardsofalara/MasterOfEtherium.java | 3 +- .../sets/worldwake/AkoumBattlesinger.java | 3 +- .../mage/sets/worldwake/ButcherOfMalakir.java | 3 +- .../mage/sets/worldwake/ClawsOfValakut.java | 3 +- .../mage/sets/worldwake/HalimarExcavator.java | 3 +- .../mage/sets/zendikar/HagraDiabolist.java | 3 +- .../mage/sets/zendikar/HighlandBerserker.java | 3 +- .../src/mage/sets/zendikar/JoragaBard.java | 3 +- .../src/mage/sets/zendikar/KazuulWarlord.java | 3 +- .../src/mage/sets/zendikar/KorHookmaster.java | 3 +- .../mage/sets/zendikar/LandbindRitual.java | 3 +- .../src/mage/sets/zendikar/MindSludge.java | 3 +- .../mage/sets/zendikar/MurasaPyromancer.java | 3 +- .../src/mage/sets/zendikar/OnduCleric.java | 3 +- .../src/mage/sets/zendikar/PrimalBellow.java | 3 +- .../mage/sets/zendikar/SeascapeAerialist.java | 3 +- .../src/mage/sets/zendikar/SpireBarrage.java | 3 +- .../src/mage/sets/zendikar/TajuruArcher.java | 3 +- .../mage/sets/zendikar/TimbermawLarva.java | 3 +- .../common/CantTargetControlledEffect.java | 3 +- .../effects/common/SacrificeEffect.java | 3 +- .../abilities/keyword/AnnihilatorAbility.java | 3 +- .../abilities/keyword/FortifyAbility.java | 3 +- Mage/src/mage/filter/FilterPermanent.java | 64 ++------------- Mage/src/mage/filter/ListComparer.java | 55 ------------- .../common/FilterControlledPermanent.java | 3 +- .../ObjectSourcePlayerPredicate.java | 2 +- .../permanent/ControllerPredicate.java | 80 +++++++++++++++++++ 76 files changed, 235 insertions(+), 191 deletions(-) delete mode 100644 Mage/src/mage/filter/ListComparer.java create mode 100644 Mage/src/mage/filter/predicate/permanent/ControllerPredicate.java diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 29cd9d2b242..9787e20d492 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -46,6 +46,7 @@ import mage.choices.ChoiceImpl; import mage.filter.common.FilterAttackingCreature; import mage.filter.common.FilterBlockingCreature; import mage.filter.common.FilterCreatureForCombat; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.draft.Draft; import mage.game.match.Match; @@ -80,7 +81,7 @@ public class HumanPlayer extends PlayerImpl { private static Map staticOptions = new HashMap(); static { - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); replacementEffectChoice.setMessage("Choose replacement effect"); staticOptions.put("UI.right.btn.text", "Done"); } diff --git a/Mage.Sets/src/mage/sets/avacynrestored/Dreadwaters.java b/Mage.Sets/src/mage/sets/avacynrestored/Dreadwaters.java index 5aa2b5b8495..14b617fda9f 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/Dreadwaters.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/Dreadwaters.java @@ -34,6 +34,7 @@ import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPlayer; import java.util.UUID; @@ -48,7 +49,7 @@ public class Dreadwaters extends CardImpl { private static final FilterLandPermanent filter = new FilterLandPermanent("lands you control"); static { - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public Dreadwaters(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/PeelFromReality.java b/Mage.Sets/src/mage/sets/avacynrestored/PeelFromReality.java index 7f7fc15e5f7..24ae4c1fb04 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/PeelFromReality.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/PeelFromReality.java @@ -37,6 +37,7 @@ import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetControlledCreaturePermanent; @@ -51,7 +52,7 @@ public class PeelFromReality extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you don't control"); static { - filter.setTargetController(TargetController.NOT_YOU); + filter.add(new ControllerPredicate(TargetController.NOT_YOU)); } public PeelFromReality(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfSeeingWinds.java b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfSeeingWinds.java index 823ced55d55..806d0d4a1ed 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfSeeingWinds.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfSeeingWinds.java @@ -51,6 +51,7 @@ import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.watchers.common.CastFromHandWatcher; /** @@ -60,7 +61,7 @@ public class MyojinOfSeeingWinds extends CardImpl { private static final FilterPermanent filter = new FilterPermanent("permanent you control"); static { - filter.setTargetOwner(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public MyojinOfSeeingWinds(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java b/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java index f94a357be22..086c3f5e013 100644 --- a/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java +++ b/Mage.Sets/src/mage/sets/darkascension/AlphaBrawl.java @@ -34,6 +34,7 @@ import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -50,7 +51,7 @@ public class AlphaBrawl extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); static { - filter.setTargetController(Constants.TargetController.OPPONENT); + filter.add(new ControllerPredicate(Constants.TargetController.OPPONENT)); } public AlphaBrawl(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/darkascension/ArchdemonOfGreed.java b/Mage.Sets/src/mage/sets/darkascension/ArchdemonOfGreed.java index 14ee45f8a97..bb1e873618d 100644 --- a/Mage.Sets/src/mage/sets/darkascension/ArchdemonOfGreed.java +++ b/Mage.Sets/src/mage/sets/darkascension/ArchdemonOfGreed.java @@ -40,6 +40,7 @@ import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -56,7 +57,7 @@ public class ArchdemonOfGreed extends CardImpl { static { filter.add(new SubtypePredicate("Human")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public ArchdemonOfGreed(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java b/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java index 42036e1a805..5709d62fa57 100644 --- a/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java +++ b/Mage.Sets/src/mage/sets/darkascension/DungeonGeists.java @@ -40,6 +40,7 @@ import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; @@ -58,7 +59,7 @@ public class DungeonGeists extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); static { - filter.setTargetController(Constants.TargetController.OPPONENT); + filter.add(new ControllerPredicate(Constants.TargetController.OPPONENT)); } public DungeonGeists(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/darkascension/FeedThePack.java b/Mage.Sets/src/mage/sets/darkascension/FeedThePack.java index e30427bb46d..96a0935ebee 100644 --- a/Mage.Sets/src/mage/sets/darkascension/FeedThePack.java +++ b/Mage.Sets/src/mage/sets/darkascension/FeedThePack.java @@ -38,6 +38,7 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterNonTokenPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.WolfToken; @@ -77,7 +78,7 @@ class FeedThePackEffect extends OneShotEffect { static { filter.add(new CardTypePredicate(CardType.CREATURE)); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public FeedThePackEffect() { diff --git a/Mage.Sets/src/mage/sets/darkascension/Helvault.java b/Mage.Sets/src/mage/sets/darkascension/Helvault.java index 62768cf5c89..cab0aeb1b18 100644 --- a/Mage.Sets/src/mage/sets/darkascension/Helvault.java +++ b/Mage.Sets/src/mage/sets/darkascension/Helvault.java @@ -40,6 +40,7 @@ import mage.abilities.effects.common.ExileTargetForSourceEffect; import mage.abilities.effects.common.ReturnFromExileForSourceEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; @@ -52,7 +53,7 @@ public class Helvault extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you don't control"); static { - filter.setTargetController(TargetController.NOT_YOU); + filter.add(new ControllerPredicate(TargetController.NOT_YOU)); } public Helvault(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/darksteel/EmissaryOfHope.java b/Mage.Sets/src/mage/sets/darksteel/EmissaryOfHope.java index 80a88adb325..f3ca21d6a40 100644 --- a/Mage.Sets/src/mage/sets/darksteel/EmissaryOfHope.java +++ b/Mage.Sets/src/mage/sets/darksteel/EmissaryOfHope.java @@ -38,9 +38,9 @@ import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; -import mage.filter.Filter; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.players.Player; @@ -79,7 +79,7 @@ class EmissaryOfHopeEffect extends OneShotEffect { static { filter.add(new CardTypePredicate(CardType.ARTIFACT)); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } EmissaryOfHopeEffect() { diff --git a/Mage.Sets/src/mage/sets/innistrad/DivineReckoning.java b/Mage.Sets/src/mage/sets/innistrad/DivineReckoning.java index f396ac3d951..7932fe0e423 100644 --- a/Mage.Sets/src/mage/sets/innistrad/DivineReckoning.java +++ b/Mage.Sets/src/mage/sets/innistrad/DivineReckoning.java @@ -37,6 +37,7 @@ import mage.abilities.keyword.FlashbackAbility; import mage.cards.Card; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -80,7 +81,7 @@ class DivineReckoningEffect extends OneShotEffect { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); static { - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public DivineReckoningEffect() { diff --git a/Mage.Sets/src/mage/sets/innistrad/GarrukTheVeilCursed.java b/Mage.Sets/src/mage/sets/innistrad/GarrukTheVeilCursed.java index 979f2b11e99..8ba6114b4a4 100644 --- a/Mage.Sets/src/mage/sets/innistrad/GarrukTheVeilCursed.java +++ b/Mage.Sets/src/mage/sets/innistrad/GarrukTheVeilCursed.java @@ -47,6 +47,7 @@ import mage.filter.FilterPermanent; import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.WolfTokenWithDeathtouch; @@ -136,7 +137,7 @@ class GarrukTheVeilCursedEffect extends OneShotEffect static { filterCreature.add(new CardTypePredicate(CardType.CREATURE)); - filterCreature.setTargetController(Constants.TargetController.YOU); + filterCreature.add(new ControllerPredicate(Constants.TargetController.YOU)); } public GarrukTheVeilCursedEffect() { diff --git a/Mage.Sets/src/mage/sets/innistrad/HystericalBlindness.java b/Mage.Sets/src/mage/sets/innistrad/HystericalBlindness.java index 57409bc2ab4..6bb27629af9 100644 --- a/Mage.Sets/src/mage/sets/innistrad/HystericalBlindness.java +++ b/Mage.Sets/src/mage/sets/innistrad/HystericalBlindness.java @@ -35,6 +35,7 @@ import mage.Constants.TargetController; import mage.abilities.effects.common.continious.BoostAllEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -45,7 +46,7 @@ public class HystericalBlindness extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures your opponents control"); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public HystericalBlindness(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/OneEyedScarecrow.java b/Mage.Sets/src/mage/sets/innistrad/OneEyedScarecrow.java index 463118414d7..c6a7fcc4d7e 100644 --- a/Mage.Sets/src/mage/sets/innistrad/OneEyedScarecrow.java +++ b/Mage.Sets/src/mage/sets/innistrad/OneEyedScarecrow.java @@ -41,6 +41,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AbilityPredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -52,7 +53,7 @@ public class OneEyedScarecrow extends CardImpl { static { filter.add(new AbilityPredicate(FlyingAbility.class)); - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public OneEyedScarecrow(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/PreyUpon.java b/Mage.Sets/src/mage/sets/innistrad/PreyUpon.java index 0b1a5b42c3b..77efa2d733d 100644 --- a/Mage.Sets/src/mage/sets/innistrad/PreyUpon.java +++ b/Mage.Sets/src/mage/sets/innistrad/PreyUpon.java @@ -34,6 +34,7 @@ import mage.Constants.TargetController; import mage.abilities.effects.common.FightTargetsEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; @@ -46,7 +47,7 @@ public class PreyUpon extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you don't control"); static { - filter.setTargetController(TargetController.NOT_YOU); + filter.add(new ControllerPredicate(TargetController.NOT_YOU)); } public PreyUpon(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/ScourgeOfGeierReach.java b/Mage.Sets/src/mage/sets/innistrad/ScourgeOfGeierReach.java index d6fcc4446e8..b20f326be2d 100644 --- a/Mage.Sets/src/mage/sets/innistrad/ScourgeOfGeierReach.java +++ b/Mage.Sets/src/mage/sets/innistrad/ScourgeOfGeierReach.java @@ -39,6 +39,7 @@ import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.effects.common.continious.BoostSourceEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -49,7 +50,7 @@ public class ScourgeOfGeierReach extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(""); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public ScourgeOfGeierReach(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/innistrad/TributeToHunger.java b/Mage.Sets/src/mage/sets/innistrad/TributeToHunger.java index b1f23dff2a4..cabb1e46a50 100644 --- a/Mage.Sets/src/mage/sets/innistrad/TributeToHunger.java +++ b/Mage.Sets/src/mage/sets/innistrad/TributeToHunger.java @@ -37,6 +37,7 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -93,7 +94,7 @@ class TributeToHungerEffect extends OneShotEffect { FilterControlledPermanent filter = new FilterControlledPermanent("creature"); filter.add(new CardTypePredicate(CardType.CREATURE)); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false); if (target.canChoose(player.getId(), game)) { diff --git a/Mage.Sets/src/mage/sets/innistrad/VampiricFury.java b/Mage.Sets/src/mage/sets/innistrad/VampiricFury.java index 8017b76bb53..aca4be3a979 100644 --- a/Mage.Sets/src/mage/sets/innistrad/VampiricFury.java +++ b/Mage.Sets/src/mage/sets/innistrad/VampiricFury.java @@ -37,6 +37,7 @@ import mage.abilities.keyword.FirstStrikeAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import java.util.UUID; @@ -49,7 +50,7 @@ public class VampiricFury extends CardImpl { static { vampires.add(new SubtypePredicate("Vampire")); - vampires.setTargetController(Constants.TargetController.YOU); + vampires.add(new ControllerPredicate(Constants.TargetController.YOU)); } public VampiricFury(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/lorwyn/ScionOfOona.java b/Mage.Sets/src/mage/sets/lorwyn/ScionOfOona.java index 2cb23a4672d..5874880f9de 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/ScionOfOona.java +++ b/Mage.Sets/src/mage/sets/lorwyn/ScionOfOona.java @@ -43,6 +43,7 @@ import mage.abilities.keyword.ShroudAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -54,7 +55,7 @@ public class ScionOfOona extends CardImpl { static { filter.add(new SubtypePredicate("Faerie")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public ScionOfOona(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2010/AlluringSiren.java b/Mage.Sets/src/mage/sets/magic2010/AlluringSiren.java index 9a521959c93..6cb24cdbb8d 100644 --- a/Mage.Sets/src/mage/sets/magic2010/AlluringSiren.java +++ b/Mage.Sets/src/mage/sets/magic2010/AlluringSiren.java @@ -41,6 +41,7 @@ import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.common.AttacksIfAbleTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -52,7 +53,7 @@ public class AlluringSiren extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public AlluringSiren(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2010/ArmoredAscension.java b/Mage.Sets/src/mage/sets/magic2010/ArmoredAscension.java index e3e21882d73..7bf6c08f037 100644 --- a/Mage.Sets/src/mage/sets/magic2010/ArmoredAscension.java +++ b/Mage.Sets/src/mage/sets/magic2010/ArmoredAscension.java @@ -45,6 +45,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; @@ -58,7 +59,7 @@ public class ArmoredAscension extends CardImpl { static { filter.add(new SubtypePredicate("Plains")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public ArmoredAscension(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2010/CapriciousEfreet.java b/Mage.Sets/src/mage/sets/magic2010/CapriciousEfreet.java index 7b5489a7b66..24e4214d2e7 100644 --- a/Mage.Sets/src/mage/sets/magic2010/CapriciousEfreet.java +++ b/Mage.Sets/src/mage/sets/magic2010/CapriciousEfreet.java @@ -40,6 +40,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterNonlandPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; @@ -54,8 +55,8 @@ public class CapriciousEfreet extends CardImpl { private static final FilterNonlandPermanent filterNotControlled = new FilterNonlandPermanent("nonland permanent you don't control"); static { - filterControlled.setTargetController(TargetController.YOU); - filterNotControlled.setTargetController(TargetController.NOT_YOU); + filterControlled.add(new ControllerPredicate(TargetController.YOU)); + filterNotControlled.add(new ControllerPredicate(TargetController.NOT_YOU)); } public CapriciousEfreet(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2010/SafePassage.java b/Mage.Sets/src/mage/sets/magic2010/SafePassage.java index 100dec4d413..cd792dccc9b 100644 --- a/Mage.Sets/src/mage/sets/magic2010/SafePassage.java +++ b/Mage.Sets/src/mage/sets/magic2010/SafePassage.java @@ -36,6 +36,7 @@ import mage.Constants.TargetController; import mage.abilities.effects.common.PreventAllDamageToEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreatureOrPlayer; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -46,7 +47,7 @@ public class SafePassage extends CardImpl { private static final FilterCreatureOrPlayer filter = new FilterCreatureOrPlayer("you and creatures you control"); static { - filter.getCreatureFilter().setTargetController(TargetController.YOU); + filter.getCreatureFilter().add(new ControllerPredicate(TargetController.YOU)); filter.getPlayerFilter().setPlayerTarget(TargetController.YOU); } diff --git a/Mage.Sets/src/mage/sets/magic2010/YawningFissure.java b/Mage.Sets/src/mage/sets/magic2010/YawningFissure.java index f0cbdbd3410..56178dd2e31 100644 --- a/Mage.Sets/src/mage/sets/magic2010/YawningFissure.java +++ b/Mage.Sets/src/mage/sets/magic2010/YawningFissure.java @@ -38,6 +38,7 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -90,7 +91,7 @@ class YawningFissureEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { FilterControlledPermanent filter = new FilterControlledPermanent("land you control"); filter.add(new CardTypePredicate(CardType.LAND)); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); Set opponents = game.getOpponents(source.getControllerId()); for (UUID opponentId : opponents) { diff --git a/Mage.Sets/src/mage/sets/magic2011/Corrupt.java b/Mage.Sets/src/mage/sets/magic2011/Corrupt.java index 1595d2fd7f0..ff953fd1039 100644 --- a/Mage.Sets/src/mage/sets/magic2011/Corrupt.java +++ b/Mage.Sets/src/mage/sets/magic2011/Corrupt.java @@ -38,6 +38,7 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -74,7 +75,7 @@ class CorruptEffect extends OneShotEffect { static { filter.add(new SubtypePredicate("Swamp")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public CorruptEffect() { diff --git a/Mage.Sets/src/mage/sets/magic2011/EarthServant.java b/Mage.Sets/src/mage/sets/magic2011/EarthServant.java index 1870c478657..7693b422ddd 100644 --- a/Mage.Sets/src/mage/sets/magic2011/EarthServant.java +++ b/Mage.Sets/src/mage/sets/magic2011/EarthServant.java @@ -41,6 +41,7 @@ import mage.abilities.effects.common.continious.BoostSourceEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -52,7 +53,7 @@ public class EarthServant extends CardImpl { static { filter.add(new SubtypePredicate("Mountain")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public EarthServant(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java b/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java index cc97b4de361..f9706646c78 100644 --- a/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java +++ b/Mage.Sets/src/mage/sets/magic2011/MystifyingMaze.java @@ -44,6 +44,7 @@ import mage.abilities.effects.common.ReturnFromExileEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; import mage.filter.common.FilterAttackingCreature; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; @@ -57,7 +58,7 @@ public class MystifyingMaze extends CardImpl { private static final FilterAttackingCreature filter = new FilterAttackingCreature("attacking creature an opponent controls"); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public MystifyingMaze(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java b/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java index a7503222292..df68fb38ea2 100644 --- a/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java +++ b/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java @@ -50,6 +50,7 @@ import mage.abilities.keyword.EnchantAbility; import mage.cards.Card; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; @@ -175,7 +176,7 @@ class NecroticPlagueEffect2 extends OneShotEffect { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public NecroticPlagueEffect2(UUID cardId) { diff --git a/Mage.Sets/src/mage/sets/magic2011/QuagSickness.java b/Mage.Sets/src/mage/sets/magic2011/QuagSickness.java index f5bbfd10d87..cf9bf7cfecd 100644 --- a/Mage.Sets/src/mage/sets/magic2011/QuagSickness.java +++ b/Mage.Sets/src/mage/sets/magic2011/QuagSickness.java @@ -43,6 +43,7 @@ import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; @@ -56,7 +57,7 @@ public class QuagSickness extends CardImpl { static { filter.add(new SubtypePredicate("Swamp")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public QuagSickness(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2011/SteelOverseer.java b/Mage.Sets/src/mage/sets/magic2011/SteelOverseer.java index e26fe71df79..3adbb432c98 100644 --- a/Mage.Sets/src/mage/sets/magic2011/SteelOverseer.java +++ b/Mage.Sets/src/mage/sets/magic2011/SteelOverseer.java @@ -41,6 +41,7 @@ import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -53,7 +54,7 @@ public class SteelOverseer extends CardImpl { static { filter.add(new CardTypePredicate(CardType.ARTIFACT)); filter.add(new CardTypePredicate(CardType.CREATURE)); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public SteelOverseer(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2012/Smallpox.java b/Mage.Sets/src/mage/sets/magic2012/Smallpox.java index 686c8a0f4e7..731039ed39a 100644 --- a/Mage.Sets/src/mage/sets/magic2012/Smallpox.java +++ b/Mage.Sets/src/mage/sets/magic2012/Smallpox.java @@ -37,6 +37,7 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -76,9 +77,9 @@ class SmallpoxEffect extends OneShotEffect { static { filterCreature.add(new CardTypePredicate(CardType.CREATURE)); - filterCreature.setTargetController(Constants.TargetController.YOU); + filterCreature.add(new ControllerPredicate(Constants.TargetController.YOU)); filterLand.add(new CardTypePredicate(CardType.LAND)); - filterLand.setTargetController(Constants.TargetController.YOU); + filterLand.add(new ControllerPredicate(Constants.TargetController.YOU)); } SmallpoxEffect() { diff --git a/Mage.Sets/src/mage/sets/magic2013/CowerInFear.java b/Mage.Sets/src/mage/sets/magic2013/CowerInFear.java index 8b731a8e6cc..906e9115eab 100644 --- a/Mage.Sets/src/mage/sets/magic2013/CowerInFear.java +++ b/Mage.Sets/src/mage/sets/magic2013/CowerInFear.java @@ -35,6 +35,7 @@ import mage.Constants.Rarity; import mage.abilities.effects.common.continious.BoostAllEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -45,7 +46,7 @@ public class CowerInFear extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures your opponents control"); static { - filter.setTargetController(Constants.TargetController.OPPONENT); + filter.add(new ControllerPredicate(Constants.TargetController.OPPONENT)); } public CowerInFear(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2013/FungalSprouting.java b/Mage.Sets/src/mage/sets/magic2013/FungalSprouting.java index 4e274610432..58f3a4428b7 100644 --- a/Mage.Sets/src/mage/sets/magic2013/FungalSprouting.java +++ b/Mage.Sets/src/mage/sets/magic2013/FungalSprouting.java @@ -37,6 +37,7 @@ import mage.cards.CardImpl; import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.SaprolingToken; @@ -74,7 +75,7 @@ class FungalSproutingEffect extends OneShotEffect { static { filter.add(new CardTypePredicate(CardType.CREATURE)); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public FungalSproutingEffect() { diff --git a/Mage.Sets/src/mage/sets/magic2013/LilianaOfTheDarkRealms.java b/Mage.Sets/src/mage/sets/magic2013/LilianaOfTheDarkRealms.java index ef0cc399759..2c79fffddaa 100644 --- a/Mage.Sets/src/mage/sets/magic2013/LilianaOfTheDarkRealms.java +++ b/Mage.Sets/src/mage/sets/magic2013/LilianaOfTheDarkRealms.java @@ -53,6 +53,7 @@ import mage.counters.CounterType; import mage.filter.common.FilterLandCard; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.command.Emblem; import mage.game.permanent.Permanent; @@ -127,7 +128,7 @@ class LilianaOfTheDarkRealmsEffect extends ContinuousEffectImpl { static { filter.add(new SubtypePredicate("Swamp")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public Mutilate(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2013/ThundermawHellkite.java b/Mage.Sets/src/mage/sets/magic2013/ThundermawHellkite.java index 0077b9be78a..7e3f02236df 100644 --- a/Mage.Sets/src/mage/sets/magic2013/ThundermawHellkite.java +++ b/Mage.Sets/src/mage/sets/magic2013/ThundermawHellkite.java @@ -41,6 +41,7 @@ import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AbilityPredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; @@ -54,7 +55,7 @@ public class ThundermawHellkite extends CardImpl { static { filter.add(new AbilityPredicate(FlyingAbility.class)); - filter.setTargetController(Constants.TargetController.OPPONENT); + filter.add(new ControllerPredicate(Constants.TargetController.OPPONENT)); } public ThundermawHellkite(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/magic2013/TimberpackWolf.java b/Mage.Sets/src/mage/sets/magic2013/TimberpackWolf.java index c73ec1f9f40..9c806fd0db9 100644 --- a/Mage.Sets/src/mage/sets/magic2013/TimberpackWolf.java +++ b/Mage.Sets/src/mage/sets/magic2013/TimberpackWolf.java @@ -38,6 +38,7 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.NamePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; @@ -51,7 +52,7 @@ public class TimberpackWolf extends CardImpl { static { filter.add(new NamePredicate("Timberpack Wolf")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public TimberpackWolf(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/mirrodin/NightmareLash.java b/Mage.Sets/src/mage/sets/mirrodin/NightmareLash.java index 40071ecac85..a950019ce17 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/NightmareLash.java +++ b/Mage.Sets/src/mage/sets/mirrodin/NightmareLash.java @@ -40,6 +40,7 @@ import mage.abilities.keyword.EquipAbility; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -50,7 +51,7 @@ public class NightmareLash extends CardImpl { static { filter.add(new SubtypePredicate("Swamp")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public NightmareLash(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/newphyrexia/ChancellorOfTheForge.java b/Mage.Sets/src/mage/sets/newphyrexia/ChancellorOfTheForge.java index 0d721ef7010..48150f78b0f 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/ChancellorOfTheForge.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/ChancellorOfTheForge.java @@ -41,6 +41,7 @@ import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.token.Token; @@ -55,7 +56,7 @@ public class ChancellorOfTheForge extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control"); static { - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public ChancellorOfTheForge(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/newphyrexia/DeceiverExarch.java b/Mage.Sets/src/mage/sets/newphyrexia/DeceiverExarch.java index a69792897f1..d4d7eaa8760 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/DeceiverExarch.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/DeceiverExarch.java @@ -40,6 +40,7 @@ import mage.abilities.effects.common.UntapTargetEffect; import mage.abilities.keyword.FlashAbility; import mage.cards.CardImpl; import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPermanent; import mage.target.common.TargetControlledPermanent; @@ -52,7 +53,7 @@ public class DeceiverExarch extends CardImpl { private static final FilterPermanent filter = new FilterPermanent("permanent an opponent controls"); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public DeceiverExarch(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/newphyrexia/Lashwrithe.java b/Mage.Sets/src/mage/sets/newphyrexia/Lashwrithe.java index 1349b224a2e..69d00942ad1 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/Lashwrithe.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/Lashwrithe.java @@ -42,6 +42,7 @@ import mage.abilities.keyword.LivingWeaponAbility; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -53,7 +54,7 @@ public class Lashwrithe extends CardImpl { static { filter.add(new SubtypePredicate("Swamp")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public Lashwrithe(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/newphyrexia/VitalSplicer.java b/Mage.Sets/src/mage/sets/newphyrexia/VitalSplicer.java index 81eeb94c797..fc9f98c0cc7 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/VitalSplicer.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/VitalSplicer.java @@ -43,6 +43,7 @@ import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.permanent.token.GolemToken; import mage.target.common.TargetCreaturePermanent; @@ -57,7 +58,7 @@ public class VitalSplicer extends CardImpl { static { filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new SubtypePredicate("Golem")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public VitalSplicer(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/planechase/FiresOfYavimaya.java b/Mage.Sets/src/mage/sets/planechase/FiresOfYavimaya.java index a87da3cce7c..eb78859c560 100644 --- a/Mage.Sets/src/mage/sets/planechase/FiresOfYavimaya.java +++ b/Mage.Sets/src/mage/sets/planechase/FiresOfYavimaya.java @@ -41,6 +41,7 @@ import mage.abilities.effects.common.continious.GainAbilityAllEffect; import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -52,7 +53,7 @@ public class FiresOfYavimaya extends CardImpl { private final static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Creatures you control"); static { - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public FiresOfYavimaya(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/ConsumingVapors.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/ConsumingVapors.java index b55fb49e5fa..e1562aad80b 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/ConsumingVapors.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/ConsumingVapors.java @@ -38,6 +38,7 @@ import mage.abilities.keyword.ReboundAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -90,7 +91,7 @@ class ConsumingVaporsEffect extends OneShotEffect { FilterControlledPermanent filter = new FilterControlledPermanent("creature"); filter.add(new CardTypePredicate(CardType.CREATURE)); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false); //A spell or ability could have removed the only legal target this player diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/DarksteelJuggernaut.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/DarksteelJuggernaut.java index 6ea29579612..c7b36d91762 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/DarksteelJuggernaut.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/DarksteelJuggernaut.java @@ -41,6 +41,7 @@ import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.filter.common.FilterArtifactPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -50,7 +51,7 @@ public class DarksteelJuggernaut extends CardImpl { private static final FilterArtifactPermanent filter = new FilterArtifactPermanent("artifacts you control"); static { - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public DarksteelJuggernaut (UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/KothOfTheHammer.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/KothOfTheHammer.java index 7481e0364f0..6054efdde41 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/KothOfTheHammer.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/KothOfTheHammer.java @@ -53,6 +53,7 @@ import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; @@ -69,9 +70,9 @@ public class KothOfTheHammer extends CardImpl { static { filter.add(new SubtypePredicate("Mountain")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); filterCount.add(new SubtypePredicate("Mountain")); - filterCount.setTargetController(Constants.TargetController.YOU); + filterCount.add(new ControllerPredicate(Constants.TargetController.YOU)); } public KothOfTheHammer (UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/OgreGeargrabber.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/OgreGeargrabber.java index 9b6dda95387..88b3e8b5110 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/OgreGeargrabber.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/OgreGeargrabber.java @@ -41,6 +41,7 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continious.GainControlTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterEquipment; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -52,10 +53,10 @@ import mage.target.TargetPermanent; */ public class OgreGeargrabber extends CardImpl { - private static FilterEquipment filter = new FilterEquipment("Equipment an opponent controls"); + private static final FilterEquipment filter = new FilterEquipment("Equipment an opponent controls"); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public OgreGeargrabber(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/shadowmoor/ToilToRenown.java b/Mage.Sets/src/mage/sets/shadowmoor/ToilToRenown.java index c484e10b683..bbb58db0605 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/ToilToRenown.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/ToilToRenown.java @@ -37,6 +37,7 @@ import mage.cards.CardImpl; import mage.filter.FilterPermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.TappedPredicate; /** @@ -53,7 +54,7 @@ public class ToilToRenown extends CardImpl { new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE), new CardTypePredicate(CardType.LAND))); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public ToilToRenown(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/shardsofalara/MasterOfEtherium.java b/Mage.Sets/src/mage/sets/shardsofalara/MasterOfEtherium.java index 10995dfa634..ef0a8503f3c 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/MasterOfEtherium.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/MasterOfEtherium.java @@ -41,6 +41,7 @@ import mage.cards.CardImpl; import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -54,7 +55,7 @@ public class MasterOfEtherium extends CardImpl { static { filterCounted.add(new CardTypePredicate(CardType.ARTIFACT)); filterBoosted.add(new CardTypePredicate(CardType.ARTIFACT)); - filterBoosted.setTargetController(Constants.TargetController.YOU); + filterBoosted.add(new ControllerPredicate(Constants.TargetController.YOU)); } public MasterOfEtherium(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/worldwake/AkoumBattlesinger.java b/Mage.Sets/src/mage/sets/worldwake/AkoumBattlesinger.java index 6d0003eb74a..d17ddba7007 100644 --- a/Mage.Sets/src/mage/sets/worldwake/AkoumBattlesinger.java +++ b/Mage.Sets/src/mage/sets/worldwake/AkoumBattlesinger.java @@ -38,6 +38,7 @@ import mage.abilities.effects.common.continious.BoostControlledEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -49,7 +50,7 @@ public class AkoumBattlesinger extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public AkoumBattlesinger(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/worldwake/ButcherOfMalakir.java b/Mage.Sets/src/mage/sets/worldwake/ButcherOfMalakir.java index 815b4a34bb4..20b117ae210 100644 --- a/Mage.Sets/src/mage/sets/worldwake/ButcherOfMalakir.java +++ b/Mage.Sets/src/mage/sets/worldwake/ButcherOfMalakir.java @@ -40,6 +40,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -99,7 +100,7 @@ class ButcherOfMalakirEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { FilterControlledPermanent filter = new FilterControlledPermanent("creature you control"); filter.add(new CardTypePredicate(CardType.CREATURE)); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); Set opponents = game.getOpponents(source.getControllerId()); for (UUID opponentId : opponents) { diff --git a/Mage.Sets/src/mage/sets/worldwake/ClawsOfValakut.java b/Mage.Sets/src/mage/sets/worldwake/ClawsOfValakut.java index b22a223fc0b..862fa8b13d6 100644 --- a/Mage.Sets/src/mage/sets/worldwake/ClawsOfValakut.java +++ b/Mage.Sets/src/mage/sets/worldwake/ClawsOfValakut.java @@ -45,6 +45,7 @@ import mage.abilities.keyword.FirstStrikeAbility; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; @@ -58,7 +59,7 @@ public class ClawsOfValakut extends CardImpl { static { filter.add(new SubtypePredicate("Mountain")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public ClawsOfValakut (UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/worldwake/HalimarExcavator.java b/Mage.Sets/src/mage/sets/worldwake/HalimarExcavator.java index 54e486e8304..f9f694c0d1f 100644 --- a/Mage.Sets/src/mage/sets/worldwake/HalimarExcavator.java +++ b/Mage.Sets/src/mage/sets/worldwake/HalimarExcavator.java @@ -40,6 +40,7 @@ import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPlayer; /** @@ -52,7 +53,7 @@ public class HalimarExcavator extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public HalimarExcavator(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/HagraDiabolist.java b/Mage.Sets/src/mage/sets/zendikar/HagraDiabolist.java index 9834cb3c34d..ad400996fa2 100644 --- a/Mage.Sets/src/mage/sets/zendikar/HagraDiabolist.java +++ b/Mage.Sets/src/mage/sets/zendikar/HagraDiabolist.java @@ -40,6 +40,7 @@ import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPlayer; /** @@ -52,7 +53,7 @@ public class HagraDiabolist extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public HagraDiabolist(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/HighlandBerserker.java b/Mage.Sets/src/mage/sets/zendikar/HighlandBerserker.java index 7e7032695e1..4faed11438c 100644 --- a/Mage.Sets/src/mage/sets/zendikar/HighlandBerserker.java +++ b/Mage.Sets/src/mage/sets/zendikar/HighlandBerserker.java @@ -40,6 +40,7 @@ import mage.abilities.keyword.FirstStrikeAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -51,7 +52,7 @@ public class HighlandBerserker extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public HighlandBerserker(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/JoragaBard.java b/Mage.Sets/src/mage/sets/zendikar/JoragaBard.java index b6618ef7fb0..8227a1fc184 100644 --- a/Mage.Sets/src/mage/sets/zendikar/JoragaBard.java +++ b/Mage.Sets/src/mage/sets/zendikar/JoragaBard.java @@ -40,6 +40,7 @@ import mage.abilities.keyword.VigilanceAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -51,7 +52,7 @@ public class JoragaBard extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public JoragaBard(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/KazuulWarlord.java b/Mage.Sets/src/mage/sets/zendikar/KazuulWarlord.java index 8a1f897f84a..d11fc5f65d0 100644 --- a/Mage.Sets/src/mage/sets/zendikar/KazuulWarlord.java +++ b/Mage.Sets/src/mage/sets/zendikar/KazuulWarlord.java @@ -39,6 +39,7 @@ import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -50,7 +51,7 @@ public class KazuulWarlord extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public KazuulWarlord(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/KorHookmaster.java b/Mage.Sets/src/mage/sets/zendikar/KorHookmaster.java index 879c306d829..c7af0967b22 100644 --- a/Mage.Sets/src/mage/sets/zendikar/KorHookmaster.java +++ b/Mage.Sets/src/mage/sets/zendikar/KorHookmaster.java @@ -37,6 +37,7 @@ import mage.abilities.effects.common.SkipNextUntapTargetEffect; import mage.abilities.effects.common.TapTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -48,7 +49,7 @@ public class KorHookmaster extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls"); static { - filter.setTargetController(TargetController.OPPONENT); + filter.add(new ControllerPredicate(TargetController.OPPONENT)); } public KorHookmaster(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/LandbindRitual.java b/Mage.Sets/src/mage/sets/zendikar/LandbindRitual.java index 849b7650ed4..970e54c7147 100644 --- a/Mage.Sets/src/mage/sets/zendikar/LandbindRitual.java +++ b/Mage.Sets/src/mage/sets/zendikar/LandbindRitual.java @@ -36,6 +36,7 @@ import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -47,7 +48,7 @@ public class LandbindRitual extends CardImpl { static { filter.add(new SubtypePredicate("Plains")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public LandbindRitual(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/MindSludge.java b/Mage.Sets/src/mage/sets/zendikar/MindSludge.java index 3d4ecdab114..c9937a0f937 100644 --- a/Mage.Sets/src/mage/sets/zendikar/MindSludge.java +++ b/Mage.Sets/src/mage/sets/zendikar/MindSludge.java @@ -36,6 +36,7 @@ import mage.abilities.effects.common.DiscardTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.TargetPlayer; /** @@ -48,7 +49,7 @@ public class MindSludge extends CardImpl { static { filter.add(new SubtypePredicate("Swamp")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public MindSludge(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/MurasaPyromancer.java b/Mage.Sets/src/mage/sets/zendikar/MurasaPyromancer.java index 10fd44006c9..a6b10842ab3 100644 --- a/Mage.Sets/src/mage/sets/zendikar/MurasaPyromancer.java +++ b/Mage.Sets/src/mage/sets/zendikar/MurasaPyromancer.java @@ -40,6 +40,7 @@ import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -52,7 +53,7 @@ public class MurasaPyromancer extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public MurasaPyromancer(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/OnduCleric.java b/Mage.Sets/src/mage/sets/zendikar/OnduCleric.java index 74c1400d40b..c3e68895d02 100644 --- a/Mage.Sets/src/mage/sets/zendikar/OnduCleric.java +++ b/Mage.Sets/src/mage/sets/zendikar/OnduCleric.java @@ -39,6 +39,7 @@ import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -50,7 +51,7 @@ public class OnduCleric extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public OnduCleric(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/PrimalBellow.java b/Mage.Sets/src/mage/sets/zendikar/PrimalBellow.java index 60682f8d85d..62065dc65f7 100644 --- a/Mage.Sets/src/mage/sets/zendikar/PrimalBellow.java +++ b/Mage.Sets/src/mage/sets/zendikar/PrimalBellow.java @@ -37,6 +37,7 @@ import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -49,7 +50,7 @@ public class PrimalBellow extends CardImpl { static { filter.add(new SubtypePredicate("Forest")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } diff --git a/Mage.Sets/src/mage/sets/zendikar/SeascapeAerialist.java b/Mage.Sets/src/mage/sets/zendikar/SeascapeAerialist.java index 2a665e439a0..0b85d6125a6 100644 --- a/Mage.Sets/src/mage/sets/zendikar/SeascapeAerialist.java +++ b/Mage.Sets/src/mage/sets/zendikar/SeascapeAerialist.java @@ -40,6 +40,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -51,7 +52,7 @@ public class SeascapeAerialist extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); } public SeascapeAerialist(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/SpireBarrage.java b/Mage.Sets/src/mage/sets/zendikar/SpireBarrage.java index df2a5b9047d..122060143fb 100644 --- a/Mage.Sets/src/mage/sets/zendikar/SpireBarrage.java +++ b/Mage.Sets/src/mage/sets/zendikar/SpireBarrage.java @@ -35,6 +35,7 @@ import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreatureOrPlayer; import java.util.UUID; @@ -49,7 +50,7 @@ public class SpireBarrage extends CardImpl { static { filter.add(new SubtypePredicate("Mountain")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public SpireBarrage(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/zendikar/TajuruArcher.java b/Mage.Sets/src/mage/sets/zendikar/TajuruArcher.java index c49b55379fc..4ac94e8ffd3 100644 --- a/Mage.Sets/src/mage/sets/zendikar/TajuruArcher.java +++ b/Mage.Sets/src/mage/sets/zendikar/TajuruArcher.java @@ -42,6 +42,7 @@ import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -55,7 +56,7 @@ public class TajuruArcher extends CardImpl { static { filter.add(new SubtypePredicate("Ally")); - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); filterTarget.add(new AbilityPredicate(FlyingAbility.class)); } diff --git a/Mage.Sets/src/mage/sets/zendikar/TimbermawLarva.java b/Mage.Sets/src/mage/sets/zendikar/TimbermawLarva.java index 6d06aa061b6..d23138b6d40 100644 --- a/Mage.Sets/src/mage/sets/zendikar/TimbermawLarva.java +++ b/Mage.Sets/src/mage/sets/zendikar/TimbermawLarva.java @@ -39,6 +39,7 @@ import mage.abilities.effects.common.continious.BoostSourceEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -50,7 +51,7 @@ public class TimbermawLarva extends CardImpl { static { filter.add(new SubtypePredicate("Forest")); - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } diff --git a/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java b/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java index a1bd610b84a..9a4c2151241 100644 --- a/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java @@ -35,6 +35,7 @@ import mage.abilities.Ability; import mage.abilities.effects.ReplacementEffectImpl; import mage.filter.FilterPermanent; import mage.filter.FilterStackObject; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; @@ -87,7 +88,7 @@ public class CantTargetControlledEffect extends ReplacementEffectImpl{ return false; } - filter.setTargetController(Constants.TargetController.YOU); + filter.add(new ControllerPredicate(Constants.TargetController.YOU)); int amount = count.calculate(game, source); int realCount = game.getBattlefield().countAll(filter, player.getId(), game); diff --git a/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java b/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java index 0fab1ccbebc..7cfb26a9e9a 100644 --- a/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java +++ b/Mage/src/mage/abilities/keyword/AnnihilatorAbility.java @@ -35,6 +35,7 @@ import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.OneShotEffect; import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; @@ -114,7 +115,7 @@ class AnnihilatorEffect extends OneShotEffect { player = game.getPlayer(permanent.getControllerId()); } - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); int amount = Math.min(count, game.getBattlefield().countAll(filter, player.getId(), game)); Target target = new TargetControlledPermanent(amount, amount, filter, false); diff --git a/Mage/src/mage/abilities/keyword/FortifyAbility.java b/Mage/src/mage/abilities/keyword/FortifyAbility.java index c7b5cbc03cd..56108ba1802 100644 --- a/Mage/src/mage/abilities/keyword/FortifyAbility.java +++ b/Mage/src/mage/abilities/keyword/FortifyAbility.java @@ -35,6 +35,7 @@ import mage.abilities.ActivatedAbilityImpl; import mage.abilities.costs.Cost; import mage.abilities.effects.common.AttachEffect; import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetLandPermanent; /** @@ -48,7 +49,7 @@ public class FortifyAbility extends ActivatedAbilityImpl { private static final FilterLandPermanent filter = new FilterLandPermanent("land you control"); static { - filter.setTargetController(TargetController.YOU); + filter.add(new ControllerPredicate(TargetController.YOU)); } public FortifyAbility(Zone zone, AttachEffect effect, Cost cost) { diff --git a/Mage/src/mage/filter/FilterPermanent.java b/Mage/src/mage/filter/FilterPermanent.java index f2db3f8fc30..5e20eb3a5f8 100644 --- a/Mage/src/mage/filter/FilterPermanent.java +++ b/Mage/src/mage/filter/FilterPermanent.java @@ -31,9 +31,9 @@ package mage.filter; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.Constants.TargetController; +import mage.filter.predicate.ObjectPlayer; +import mage.filter.predicate.ObjectPlayerPredicate; import mage.filter.predicate.ObjectSourcePlayer; -import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.filter.predicate.Predicates; import mage.game.Game; import mage.game.permanent.Permanent; @@ -43,11 +43,9 @@ import mage.game.permanent.Permanent; * @author BetaSteward_at_googlemail.com */ public class FilterPermanent extends FilterObject { - protected List>> extraPredicates = new ArrayList>>(); + protected List>> extraPredicates = new ArrayList>>(); protected List controllerId = new ArrayList(); protected boolean notController; - protected TargetController controller = TargetController.ANY; - protected TargetController owner = TargetController.ANY; public FilterPermanent() { super("permanent"); @@ -57,9 +55,7 @@ public class FilterPermanent extends FilterObject { super(filter); this.controllerId = new ArrayList(filter.controllerId); this.notController = filter.notController; - this.controller = filter.controller; - this.owner = filter.owner; - this.extraPredicates = new ArrayList>>(extraPredicates); + this.extraPredicates = new ArrayList>>(extraPredicates); } public FilterPermanent(String name) { @@ -79,46 +75,12 @@ public class FilterPermanent extends FilterObject { public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { if (!this.match(permanent, game)) - return notFilter; - - if (controller != TargetController.ANY && playerId != null) { - switch(controller) { - case YOU: - if (!permanent.getControllerId().equals(playerId)) - return notFilter; - break; - case OPPONENT: - if (!game.getOpponents(playerId).contains(permanent.getControllerId())) - return notFilter; - break; - case NOT_YOU: - if (permanent.getControllerId().equals(playerId)) - return notFilter; - break; - } - } - - if (owner != TargetController.ANY && playerId != null) { - switch(owner) { - case YOU: - if (!permanent.getOwnerId().equals(playerId)) - return notFilter; - break; - case OPPONENT: - if (!game.getOpponents(playerId).contains(permanent.getOwnerId())) - return notFilter; - break; - case NOT_YOU: - if (permanent.getOwnerId().equals(playerId)) - return notFilter; - break; - } - } + return false; return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(permanent, sourceId, playerId), game); } - public void add(ObjectSourcePlayerPredicate predicate) { + public void add(ObjectPlayerPredicate predicate) { extraPredicates.add(predicate); } @@ -130,20 +92,6 @@ public class FilterPermanent extends FilterObject { this.notController = notController; } - public void setTargetController(TargetController controller) { - this.controller = controller; - } - - public void setTargetOwner(TargetController owner) { - this.owner = owner; - } - - public boolean matchController(UUID testControllerId) { - if (controllerId.size() > 0 && controllerId.contains(testControllerId) == notController) - return false; - return true; - } - @Override public FilterPermanent copy() { return new FilterPermanent(this); diff --git a/Mage/src/mage/filter/ListComparer.java b/Mage/src/mage/filter/ListComparer.java deleted file mode 100644 index 75f870d49a3..00000000000 --- a/Mage/src/mage/filter/ListComparer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are -* permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, this list -* of conditions and the following disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The views and conclusions contained in the software and documentation are those of the -* authors and should not be interpreted as representing official policies, either expressed -* or implied, of BetaSteward_at_googlemail.com. -*/ - -package mage.filter; - -import java.util.ArrayList; -import java.util.List; -import mage.filter.Filter.ComparisonScope; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class ListComparer { - - public boolean compare(List list1, List list2, ComparisonScope scope, boolean negate) { - if (scope == ComparisonScope.All) { - if (list2.containsAll(list1) == negate) { - return false; - } - } - else { - List check = new ArrayList(list1); - if (check.removeAll(list2) == negate) { - return false; - } - } - return true; - } -} diff --git a/Mage/src/mage/filter/common/FilterControlledPermanent.java b/Mage/src/mage/filter/common/FilterControlledPermanent.java index 8ffaae4fcab..05c4ef6eb35 100644 --- a/Mage/src/mage/filter/common/FilterControlledPermanent.java +++ b/Mage/src/mage/filter/common/FilterControlledPermanent.java @@ -30,6 +30,7 @@ package mage.filter.common; import mage.Constants.TargetController; import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -43,7 +44,7 @@ public class FilterControlledPermanent extends FilterPermanent { public FilterControlledPermanent(String name) { super(name); - this.controller = TargetController.YOU; + this.add(new ControllerPredicate(TargetController.YOU)); } public FilterControlledPermanent(final FilterControlledPermanent filter) { diff --git a/Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java b/Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java index 32e7a771547..6099abc8322 100644 --- a/Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java +++ b/Mage/src/mage/filter/predicate/ObjectSourcePlayerPredicate.java @@ -31,5 +31,5 @@ package mage.filter.predicate; * * @author North */ -public interface ObjectSourcePlayerPredicate extends Predicate { +public interface ObjectSourcePlayerPredicate extends ObjectPlayerPredicate { } diff --git a/Mage/src/mage/filter/predicate/permanent/ControllerPredicate.java b/Mage/src/mage/filter/predicate/permanent/ControllerPredicate.java new file mode 100644 index 00000000000..78e06142283 --- /dev/null +++ b/Mage/src/mage/filter/predicate/permanent/ControllerPredicate.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.filter.predicate.permanent; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.TargetController; +import mage.filter.predicate.ObjectPlayer; +import mage.filter.predicate.ObjectPlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author North + */ +public class ControllerPredicate implements ObjectPlayerPredicate> { + + private Constants.TargetController controller; + + public ControllerPredicate(TargetController controller) { + this.controller = controller; + } + + @Override + public boolean apply(ObjectPlayer input, Game game) { + Permanent permanent = input.getObject(); + UUID playerId = input.getPlayerId(); + + switch (controller) { + case YOU: + if (permanent.getControllerId().equals(playerId)) { + return true; + } + break; + case OPPONENT: + if (game.getOpponents(playerId).contains(permanent.getControllerId())) { + return true; + } + break; + case NOT_YOU: + if (!permanent.getControllerId().equals(playerId)) { + return true; + } + break; + } + + return true; + } + + @Override + public String toString() { + return "TargetController(" + controller.toString() + ')'; + } +} From 30cbdd643d0e94e4ef192a6c69f27ec8042cc899 Mon Sep 17 00:00:00 2001 From: North Date: Mon, 16 Jul 2012 21:41:00 +0300 Subject: [PATCH 5/5] [filters] Replaced ControllerId condition in FilterPermanent with Predicate --- .../mage/sets/avacynrestored/Aggravate.java | 3 +- .../championsofkamigawa/FeastOfWorms.java | 5 +- .../YoseiTheMorningStar.java | 9 ++- .../mage/sets/darkascension/SoulSeizer.java | 4 +- .../sets/eventide/AshlingTheExtinguisher.java | 6 +- .../sets/innistrad/GrimgrinCorpseBorn.java | 5 +- .../sets/magic2010/LightwielderPaladin.java | 23 +++++--- .../mage/sets/magic2011/AncientHellkite.java | 10 ++-- .../mage/sets/magic2011/CyclopsGladiator.java | 3 +- .../mage/sets/newphyrexia/ArmWithAEther.java | 7 ++- .../mage/sets/newphyrexia/BlindZealot.java | 8 ++- .../src/mage/sets/worldwake/HammerOfRuin.java | 18 ++++-- Mage/src/mage/filter/FilterPermanent.java | 25 +-------- .../common/FilterPlaneswalkerOrPlayer.java | 15 +++-- .../permanent/ControllerIdPredicate.java | 56 +++++++++++++++++++ 15 files changed, 131 insertions(+), 66 deletions(-) create mode 100644 Mage/src/mage/filter/predicate/permanent/ControllerIdPredicate.java diff --git a/Mage.Sets/src/mage/sets/avacynrestored/Aggravate.java b/Mage.Sets/src/mage/sets/avacynrestored/Aggravate.java index b96ffa59351..1afc888b675 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/Aggravate.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/Aggravate.java @@ -38,6 +38,7 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.RequirementEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -95,7 +96,7 @@ class AggraveteEffect extends OneShotEffect { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.getControllerId().add(player.getId()); + filter.add(new ControllerIdPredicate(player.getId())); List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getId(), game); for (Permanent creature : creatures) { creature.damage(1, source.getSourceId(), game, true, false); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/FeastOfWorms.java b/Mage.Sets/src/mage/sets/championsofkamigawa/FeastOfWorms.java index 48c635ace37..76714689b32 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/FeastOfWorms.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/FeastOfWorms.java @@ -39,6 +39,7 @@ import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -98,15 +99,13 @@ class FeastOfWormsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - //Player player = game.getPlayer(source.getControllerId()); Permanent permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD); Player targetPlayer = game.getPlayer(permanent.getControllerId()); if (targetPlayer != null && permanent != null && (permanent.getSupertype().get(0).toString().equals("Legendary"))) { FilterControlledPermanent filter = new FilterControlledPermanent("land to sacrifice"); filter.add(new CardTypePredicate(CardType.LAND)); - filter.getControllerId().add(targetPlayer.getId()); - filter.setNotController(false); + filter.add(new ControllerIdPredicate(targetPlayer.getId())); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false); if (target.canChoose(targetPlayer.getId(), game)) { diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/YoseiTheMorningStar.java b/Mage.Sets/src/mage/sets/championsofkamigawa/YoseiTheMorningStar.java index 296e2891a8f..d7cd342831c 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/YoseiTheMorningStar.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/YoseiTheMorningStar.java @@ -40,6 +40,7 @@ import mage.abilities.effects.common.SkipNextPlayerUntapStepEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -85,8 +86,10 @@ public class YoseiTheMorningStar extends CardImpl { class YoseiTheMorningStarTarget extends TargetPermanent { + private static final FilterPermanent filterTemplate = new FilterPermanent("up to five target permanents that player controls that will be tapped"); + public YoseiTheMorningStarTarget() { - super(0, 5, new FilterPermanent("up to five target permanents that player controls that will be tapped"), false); + super(0, 5, filterTemplate, false); } public YoseiTheMorningStarTarget(final YoseiTheMorningStarTarget target) { @@ -97,8 +100,8 @@ public class YoseiTheMorningStar extends CardImpl { public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { - filter.getControllerId().clear(); - filter.getControllerId().add(player.getId()); + this.filter = filterTemplate.copy(); + this.filter.add(new ControllerIdPredicate(player.getId())); return super.canTarget(controllerId, id, source, game); } return false; diff --git a/Mage.Sets/src/mage/sets/darkascension/SoulSeizer.java b/Mage.Sets/src/mage/sets/darkascension/SoulSeizer.java index bdec3448f42..f4ea379c3a5 100644 --- a/Mage.Sets/src/mage/sets/darkascension/SoulSeizer.java +++ b/Mage.Sets/src/mage/sets/darkascension/SoulSeizer.java @@ -40,6 +40,7 @@ import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.TransformAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; @@ -105,7 +106,8 @@ class SoulSeizerTriggeredAbility extends TriggeredAbilityImpl { class AncientHellkiteAbility extends ActivatedAbilityImpl { - private FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); - public AncientHellkiteAbility() { super(Zone.BATTLEFIELD, new DamageTargetEffect(1)); addCost(new AncientHellkiteCost()); - addTarget(new TargetCreaturePermanent(filter)); addManaCost(new ColoredManaCost(ColoredManaSymbol.R)); } public AncientHellkiteAbility(final AncientHellkiteAbility ability) { super(ability); - this.filter = ability.filter; } @Override @@ -100,9 +97,10 @@ class AncientHellkiteAbility extends ActivatedAbilityImpl { UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId()); if (defenderId != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); - filter.getControllerId().add(defenderId); + filter.add(new ControllerIdPredicate(defenderId)); TargetCreaturePermanent target = new TargetCreaturePermanent(filter); Player player = game.getPlayer(source.getControllerId()); if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/sets/newphyrexia/ArmWithAEther.java b/Mage.Sets/src/mage/sets/newphyrexia/ArmWithAEther.java index ae9d079c458..2d80cff5f81 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/ArmWithAEther.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/ArmWithAEther.java @@ -38,6 +38,7 @@ import mage.abilities.effects.common.continious.GainAbilityControlledEffect; import mage.cards.CardImpl; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.players.Player; @@ -57,6 +58,7 @@ public class ArmWithAEther extends CardImpl { this.color.setBlue(true); + // Until end of turn, creatures you control gain "Whenever this creature deals damage to an opponent, you may return target creature that player controls to its owner's hand." this.getSpellAbility().addEffect(new GainAbilityControlledEffect(new ArmWithAEtherTriggeredAbility(), Duration.EndOfTurn, filter)); } @@ -89,9 +91,10 @@ class ArmWithAEtherTriggeredAbility extends TriggeredAbilityImpl { this.toughness = new MageInt(2); this.addAbility(IntimidateAbility.getInstance()); + // Whenever Blind Zealot deals combat damage to a player, you may sacrifice it. If you do, destroy target creature that player controls. this.addAbility(new BlindZealotTriggeredAbility()); } @@ -106,11 +108,11 @@ class BlindZealotTriggeredAbility extends TriggeredAbilityImpl { super(ownerId, 124, "Hammer of Ruin", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); this.expansionSetCode = "WWK"; this.subtype.add("Equipment"); + + // Equipped creature gets +2/+0. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(2, 0))); + // Whenever equipped creature deals combat damage to a player, you may destroy target Equipment that player controls. this.addAbility(new HammerOfRuinTriggeredAbility()); + // Equip {2} this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2))); } @@ -79,9 +84,6 @@ class HammerOfRuinTriggeredAbility extends TriggeredAbilityImpl { protected List>> extraPredicates = new ArrayList>>(); - protected List controllerId = new ArrayList(); - protected boolean notController; public FilterPermanent() { super("permanent"); @@ -53,8 +51,6 @@ public class FilterPermanent extends FilterObject { public FilterPermanent(final FilterPermanent filter) { super(filter); - this.controllerId = new ArrayList(filter.controllerId); - this.notController = filter.notController; this.extraPredicates = new ArrayList>>(extraPredicates); } @@ -62,17 +58,6 @@ public class FilterPermanent extends FilterObject { super(name); } - @Override - public boolean match(Permanent permanent, Game game) { - if (!super.match(permanent, game)) - return notFilter; - - if (controllerId.size() > 0 && controllerId.contains(permanent.getControllerId()) == notController) - return notFilter; - - return !notFilter; - } - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { if (!this.match(permanent, game)) return false; @@ -84,14 +69,6 @@ public class FilterPermanent extends FilterObject { extraPredicates.add(predicate); } - public List getControllerId() { - return controllerId; - } - - public void setNotController(boolean notController) { - this.notController = notController; - } - @Override public FilterPermanent copy() { return new FilterPermanent(this); diff --git a/Mage/src/mage/filter/common/FilterPlaneswalkerOrPlayer.java b/Mage/src/mage/filter/common/FilterPlaneswalkerOrPlayer.java index 0e46ee97468..1bb5f97dc17 100644 --- a/Mage/src/mage/filter/common/FilterPlaneswalkerOrPlayer.java +++ b/Mage/src/mage/filter/common/FilterPlaneswalkerOrPlayer.java @@ -28,15 +28,18 @@ package mage.filter.common; +import java.util.ArrayList; +import java.util.Set; +import java.util.UUID; import mage.filter.FilterImpl; import mage.filter.FilterPlayer; +import mage.filter.predicate.Predicate; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import java.util.Set; -import java.util.UUID; - /** * * @author BetaSteward_at_googlemail.com @@ -48,8 +51,12 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl { public FilterPlaneswalkerOrPlayer(Set defenders) { super("planeswalker or player"); + ArrayList> permanentPredicates = new ArrayList>(); + for (UUID defenderId : defenders) { + permanentPredicates.add(new ControllerIdPredicate(defenderId)); + } planeswalkerFilter = new FilterPlaneswalkerPermanent(); - planeswalkerFilter.getControllerId().addAll(defenders); + planeswalkerFilter.add(Predicates.or(permanentPredicates)); playerFilter = new FilterPlayer(); playerFilter.getPlayerId().addAll(defenders); } diff --git a/Mage/src/mage/filter/predicate/permanent/ControllerIdPredicate.java b/Mage/src/mage/filter/predicate/permanent/ControllerIdPredicate.java new file mode 100644 index 00000000000..23396673644 --- /dev/null +++ b/Mage/src/mage/filter/predicate/permanent/ControllerIdPredicate.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.filter.predicate.permanent; + +import java.util.UUID; +import mage.filter.predicate.Predicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author North + */ +public class ControllerIdPredicate implements Predicate { + + private final UUID controllerId; + + public ControllerIdPredicate(UUID controllerId) { + this.controllerId = controllerId; + } + + @Override + public boolean apply(Permanent input, Game game) { + return controllerId.equals(input.getControllerId()); + } + + @Override + public String toString() { + return "ControllerId(" + controllerId + ')'; + } +}