From 021e2b59df009a25dd79151920debb6391e9686c Mon Sep 17 00:00:00 2001 From: North Date: Sun, 15 Jul 2012 17:18:33 +0300 Subject: [PATCH] [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() {