From c7f57d8c68221730d940d0fa17f63e30c1c239ec Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 27 May 2018 10:40:57 -0400 Subject: [PATCH] Fixed implementation of team-controlled effects --- .../src/mage/cards/a/AuroraChampion.java | 8 +--- .../src/mage/cards/b/BullRushBruiser.java | 8 +--- .../src/mage/cards/d/DecoratedChampion.java | 8 +--- .../src/mage/cards/d/DwarvenLightsmith.java | 11 +---- .../src/mage/cards/k/KhorvathBrightflame.java | 11 +---- .../src/mage/cards/n/NimbusChampion.java | 11 +---- .../src/mage/cards/r/RushbladeCommander.java | 15 +------ Mage.Sets/src/mage/cards/s/SickleDancer.java | 8 +--- .../src/mage/cards/s/SylviaBrightspear.java | 11 +---- Mage.Sets/src/mage/cards/t/ThrasherBrute.java | 8 +--- .../mage/abilities/ActivatedAbilityImpl.java | 7 +++- .../java/mage/constants/TargetController.java | 2 +- .../common/FilterTeamCreaturePermanent.java | 41 ++++++++++++++++++ .../filter/common/FilterTeamPermanent.java | 42 +++++++++++++++++++ .../permanent/ControllerPredicate.java | 9 +++- 15 files changed, 116 insertions(+), 84 deletions(-) create mode 100644 Mage/src/main/java/mage/filter/common/FilterTeamCreaturePermanent.java create mode 100644 Mage/src/main/java/mage/filter/common/FilterTeamPermanent.java diff --git a/Mage.Sets/src/mage/cards/a/AuroraChampion.java b/Mage.Sets/src/mage/cards/a/AuroraChampion.java index cef9b795ba7..4ff38a4637a 100644 --- a/Mage.Sets/src/mage/cards/a/AuroraChampion.java +++ b/Mage.Sets/src/mage/cards/a/AuroraChampion.java @@ -38,11 +38,8 @@ import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.TargetController; -import mage.filter.FilterPermanent; -import mage.filter.predicate.Predicates; +import mage.filter.common.FilterTeamPermanent; import mage.filter.predicate.permanent.AnotherPredicate; -import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -51,11 +48,10 @@ import mage.target.common.TargetCreaturePermanent; */ public class AuroraChampion extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent(SubType.WARRIOR, "another Warrior"); + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "another Warrior"); static { filter.add(new AnotherPredicate()); - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); } public AuroraChampion(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/b/BullRushBruiser.java b/Mage.Sets/src/mage/cards/b/BullRushBruiser.java index 0c0a3cb19e2..7645a1a1d23 100644 --- a/Mage.Sets/src/mage/cards/b/BullRushBruiser.java +++ b/Mage.Sets/src/mage/cards/b/BullRushBruiser.java @@ -38,11 +38,8 @@ import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.TargetController; -import mage.filter.FilterPermanent; -import mage.filter.predicate.Predicates; +import mage.filter.common.FilterTeamPermanent; import mage.filter.predicate.permanent.AnotherPredicate; -import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -50,11 +47,10 @@ import mage.filter.predicate.permanent.ControllerPredicate; */ public class BullRushBruiser extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent(SubType.WARRIOR, "another Warrior"); + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "another Warrior"); static { filter.add(new AnotherPredicate()); - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); } public BullRushBruiser(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/d/DecoratedChampion.java b/Mage.Sets/src/mage/cards/d/DecoratedChampion.java index 13e38c2af8b..603ec8f710f 100644 --- a/Mage.Sets/src/mage/cards/d/DecoratedChampion.java +++ b/Mage.Sets/src/mage/cards/d/DecoratedChampion.java @@ -35,12 +35,9 @@ import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.TargetController; import mage.counters.CounterType; -import mage.filter.FilterPermanent; -import mage.filter.predicate.Predicates; +import mage.filter.common.FilterTeamPermanent; import mage.filter.predicate.permanent.AnotherPredicate; -import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -48,11 +45,10 @@ import mage.filter.predicate.permanent.ControllerPredicate; */ public class DecoratedChampion extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent(SubType.WARRIOR, "another Warrior"); + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "another Warrior"); static { filter.add(new AnotherPredicate()); - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); } public DecoratedChampion(UUID ownerId, CardSetInfo setInfo) { diff --git a/Mage.Sets/src/mage/cards/d/DwarvenLightsmith.java b/Mage.Sets/src/mage/cards/d/DwarvenLightsmith.java index 49b5f81b0d6..9738176fa48 100644 --- a/Mage.Sets/src/mage/cards/d/DwarvenLightsmith.java +++ b/Mage.Sets/src/mage/cards/d/DwarvenLightsmith.java @@ -37,10 +37,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.TargetController; -import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.ControllerPredicate; +import mage.filter.common.FilterTeamCreaturePermanent; /** * @@ -48,11 +45,7 @@ import mage.filter.predicate.permanent.ControllerPredicate; */ public class DwarvenLightsmith extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures your team controls"); - - static { - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); - } + private static final FilterTeamCreaturePermanent filter = new FilterTeamCreaturePermanent("creatures your team controls"); public DwarvenLightsmith(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}"); diff --git a/Mage.Sets/src/mage/cards/k/KhorvathBrightflame.java b/Mage.Sets/src/mage/cards/k/KhorvathBrightflame.java index 62fba0471d2..e5c88257523 100644 --- a/Mage.Sets/src/mage/cards/k/KhorvathBrightflame.java +++ b/Mage.Sets/src/mage/cards/k/KhorvathBrightflame.java @@ -41,11 +41,8 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.TargetController; import mage.constants.Zone; -import mage.filter.FilterPermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.ControllerPredicate; +import mage.filter.common.FilterTeamPermanent; /** * @@ -53,11 +50,7 @@ import mage.filter.predicate.permanent.ControllerPredicate; */ public class KhorvathBrightflame extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent(SubType.KNIGHT, "Knights your team controls"); - - static { - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); - } + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.KNIGHT, "Knights your team controls"); public KhorvathBrightflame(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}"); diff --git a/Mage.Sets/src/mage/cards/n/NimbusChampion.java b/Mage.Sets/src/mage/cards/n/NimbusChampion.java index 0e7f04dd2b5..7271074f26d 100644 --- a/Mage.Sets/src/mage/cards/n/NimbusChampion.java +++ b/Mage.Sets/src/mage/cards/n/NimbusChampion.java @@ -40,10 +40,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.filter.FilterPermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.ControllerPredicate; +import mage.filter.common.FilterTeamPermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; @@ -83,11 +80,7 @@ public class NimbusChampion extends CardImpl { class NimbusChampionEffect extends OneShotEffect { - private static final FilterPermanent filter = new FilterPermanent(SubType.WARRIOR, "Warriors your team controls"); - - static { - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); - } + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "Warriors your team controls"); NimbusChampionEffect() { super(Outcome.Benefit); diff --git a/Mage.Sets/src/mage/cards/r/RushbladeCommander.java b/Mage.Sets/src/mage/cards/r/RushbladeCommander.java index 1e9388bc9d7..ecb45b5b26e 100644 --- a/Mage.Sets/src/mage/cards/r/RushbladeCommander.java +++ b/Mage.Sets/src/mage/cards/r/RushbladeCommander.java @@ -37,12 +37,8 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.TargetController; import mage.constants.Zone; -import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.filter.predicate.permanent.ControllerPredicate; +import mage.filter.common.FilterTeamPermanent; /** * @@ -50,14 +46,7 @@ import mage.filter.predicate.permanent.ControllerPredicate; */ public class RushbladeCommander extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Warrior creatures your team controls"); - - static { - filter.add(Predicates.not( - new ControllerPredicate(TargetController.OPPONENT) - )); - filter.add(new SubtypePredicate(SubType.WARRIOR)); - } + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "Warriors your team controls"); public RushbladeCommander(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{R}"); diff --git a/Mage.Sets/src/mage/cards/s/SickleDancer.java b/Mage.Sets/src/mage/cards/s/SickleDancer.java index 86690e99b67..062c963613b 100644 --- a/Mage.Sets/src/mage/cards/s/SickleDancer.java +++ b/Mage.Sets/src/mage/cards/s/SickleDancer.java @@ -38,11 +38,8 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.TargetController; -import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicates; +import mage.filter.common.FilterTeamPermanent; import mage.filter.predicate.permanent.AnotherPredicate; -import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -50,10 +47,9 @@ import mage.filter.predicate.permanent.ControllerPredicate; */ public class SickleDancer extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(SubType.WARRIOR, "Warrior creature"); + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.WARRIOR, "Warrior creature"); static { - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); filter.add(new AnotherPredicate()); } diff --git a/Mage.Sets/src/mage/cards/s/SylviaBrightspear.java b/Mage.Sets/src/mage/cards/s/SylviaBrightspear.java index 6a456de6b68..d62688412a6 100644 --- a/Mage.Sets/src/mage/cards/s/SylviaBrightspear.java +++ b/Mage.Sets/src/mage/cards/s/SylviaBrightspear.java @@ -39,11 +39,8 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.TargetController; import mage.constants.Zone; -import mage.filter.FilterPermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.ControllerPredicate; +import mage.filter.common.FilterTeamPermanent; /** * @@ -51,11 +48,7 @@ import mage.filter.predicate.permanent.ControllerPredicate; */ public class SylviaBrightspear extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent(SubType.DRAGON, "Dragons your team controls"); - - static { - filter.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); - } + private static final FilterTeamPermanent filter = new FilterTeamPermanent(SubType.DRAGON, "Dragons your team controls"); public SylviaBrightspear(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}"); diff --git a/Mage.Sets/src/mage/cards/t/ThrasherBrute.java b/Mage.Sets/src/mage/cards/t/ThrasherBrute.java index 12383777bc7..07c628b6a79 100644 --- a/Mage.Sets/src/mage/cards/t/ThrasherBrute.java +++ b/Mage.Sets/src/mage/cards/t/ThrasherBrute.java @@ -37,11 +37,8 @@ import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.TargetController; import mage.constants.Zone; -import mage.filter.FilterPermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.permanent.ControllerPredicate; +import mage.filter.common.FilterTeamPermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetOpponent; @@ -86,11 +83,10 @@ public class ThrasherBrute extends CardImpl { } } -class ThrasherBruteFilter extends FilterPermanent { +class ThrasherBruteFilter extends FilterTeamPermanent { ThrasherBruteFilter() { super(); - this.add(Predicates.not(new ControllerPredicate(TargetController.OPPONENT))); } ThrasherBruteFilter(final ThrasherBruteFilter effect) { diff --git a/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java b/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java index 073a4596885..f199003774e 100644 --- a/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java @@ -185,13 +185,16 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa switch (mayActivate) { case ANY: break; - case NOT_YOU: if (controlsAbility(playerId, game)) { return false; } break; - + case TEAM: + if (game.getPlayer(controllerId).hasOpponent(playerId, game)) { + return false; + } + break; case OPPONENT: if (!game.getPlayer(controllerId).hasOpponent(playerId, game)) { return false; diff --git a/Mage/src/main/java/mage/constants/TargetController.java b/Mage/src/main/java/mage/constants/TargetController.java index 82766cdbad7..2236ebe4649 100644 --- a/Mage/src/main/java/mage/constants/TargetController.java +++ b/Mage/src/main/java/mage/constants/TargetController.java @@ -6,5 +6,5 @@ package mage.constants; */ public enum TargetController { - ACTIVE, ANY, YOU, NOT_YOU, OPPONENT, OWNER, CONTROLLER_ATTACHED_TO, NEXT + ACTIVE, ANY, YOU, NOT_YOU, OPPONENT, TEAM, OWNER, CONTROLLER_ATTACHED_TO, NEXT } diff --git a/Mage/src/main/java/mage/filter/common/FilterTeamCreaturePermanent.java b/Mage/src/main/java/mage/filter/common/FilterTeamCreaturePermanent.java new file mode 100644 index 00000000000..7d6bb67c72b --- /dev/null +++ b/Mage/src/main/java/mage/filter/common/FilterTeamCreaturePermanent.java @@ -0,0 +1,41 @@ +package mage.filter.common; + +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.filter.predicate.permanent.ControllerPredicate; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author TheElk801 + */ +public class FilterTeamCreaturePermanent extends FilterCreaturePermanent { + + public FilterTeamCreaturePermanent() { + this("creature your team controls"); + } + + public FilterTeamCreaturePermanent(String name) { + super(name); + this.add(new ControllerPredicate(TargetController.TEAM)); + + } + + public FilterTeamCreaturePermanent(SubType subtype, String name) { + super(subtype, name); + this.add(new ControllerPredicate(TargetController.TEAM)); + } + + public FilterTeamCreaturePermanent(final FilterTeamCreaturePermanent filter) { + super(filter); + } + + @Override + public FilterTeamCreaturePermanent copy() { + return new FilterTeamCreaturePermanent(this); + } +} diff --git a/Mage/src/main/java/mage/filter/common/FilterTeamPermanent.java b/Mage/src/main/java/mage/filter/common/FilterTeamPermanent.java new file mode 100644 index 00000000000..445088e6607 --- /dev/null +++ b/Mage/src/main/java/mage/filter/common/FilterTeamPermanent.java @@ -0,0 +1,42 @@ +package mage.filter.common; + +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author TheElk801 + */ +public class FilterTeamPermanent extends FilterPermanent { + + public FilterTeamPermanent() { + this("permanent your team controls"); + } + + public FilterTeamPermanent(String name) { + super(name); + this.add(new ControllerPredicate(TargetController.TEAM)); + + } + + public FilterTeamPermanent(SubType subtype, String name) { + super(subtype, name); + this.add(new ControllerPredicate(TargetController.TEAM)); + } + + public FilterTeamPermanent(final FilterTeamPermanent filter) { + super(filter); + } + + @Override + public FilterTeamPermanent copy() { + return new FilterTeamPermanent(this); + } +} diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/ControllerPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/ControllerPredicate.java index 21234780d9d..3cbe8a72587 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/ControllerPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/ControllerPredicate.java @@ -58,9 +58,14 @@ public class ControllerPredicate implements ObjectPlayerPredicate