From 26676b9ab5ea4008d836c8bdab948f4765c8191f Mon Sep 17 00:00:00 2001 From: North Date: Sun, 8 Sep 2013 01:30:36 +0300 Subject: [PATCH] [refactor] removed constructor from FitlerControlledPermanent --- .../src/mage/sets/lorwyn/JaggedScarArchers.java | 12 ++++++++---- Mage.Sets/src/mage/sets/lorwyn/MerrowCommerce.java | 9 ++++++++- .../src/mage/sets/lorwyn/WanderwineProphets.java | 9 ++++++++- Mage.Sets/src/mage/sets/timeshifted/FireWhip.java | 1 - .../filter/common/FilterControlledPermanent.java | 8 -------- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Mage.Sets/src/mage/sets/lorwyn/JaggedScarArchers.java b/Mage.Sets/src/mage/sets/lorwyn/JaggedScarArchers.java index 5e6316dfd8..7512a4c467 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/JaggedScarArchers.java +++ b/Mage.Sets/src/mage/sets/lorwyn/JaggedScarArchers.java @@ -46,6 +46,7 @@ import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AbilityPredicate; +import mage.filter.predicate.mageobject.SubtypePredicate; import mage.target.common.TargetCreaturePermanent; /** @@ -54,10 +55,13 @@ import mage.target.common.TargetCreaturePermanent; */ public class JaggedScarArchers extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with flying"); + private static final FilterCreaturePermanent flyingCreatureFilter = new FilterCreaturePermanent("creature with flying"); + private static final FilterControlledPermanent controlledElvesFilter = new FilterControlledPermanent("Elves you control"); static { - filter.add(new AbilityPredicate(FlyingAbility.class)); + flyingCreatureFilter.add(new AbilityPredicate(FlyingAbility.class)); + controlledElvesFilter.add(new SubtypePredicate("Elf")); } + public JaggedScarArchers(UUID ownerId) { super(ownerId, 222, "Jagged-Scar Archers", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{G}{G}"); this.expansionSetCode = "LRW"; @@ -69,10 +73,10 @@ public class JaggedScarArchers extends CardImpl { this.toughness = new MageInt(0); // Jagged-Scar Archers's power and toughness are each equal to the number of Elves you control. - this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new PermanentsOnBattlefieldCount(new FilterControlledPermanent("Elf", "Elves you control")), Duration.EndOfGame))); + this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new PermanentsOnBattlefieldCount(controlledElvesFilter), Duration.EndOfGame))); // {tap}: Jagged-Scar Archers deals damage equal to its power to target creature with flying. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new SourcePermanentPowerCount()), new TapSourceCost()); - ability.addTarget(new TargetCreaturePermanent(filter)); + ability.addTarget(new TargetCreaturePermanent(flyingCreatureFilter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/lorwyn/MerrowCommerce.java b/Mage.Sets/src/mage/sets/lorwyn/MerrowCommerce.java index dd2bacc16c..e8dcd73969 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/MerrowCommerce.java +++ b/Mage.Sets/src/mage/sets/lorwyn/MerrowCommerce.java @@ -34,6 +34,7 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; /** * @@ -41,6 +42,12 @@ import mage.filter.common.FilterControlledPermanent; */ public class MerrowCommerce extends CardImpl { + private static final FilterControlledPermanent filter = new FilterControlledPermanent("Merfolk you control"); + + static { + filter.add(new SubtypePredicate("Merfolk")); + } + public MerrowCommerce(UUID ownerId) { super(ownerId, 72, "Merrow Commerce", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); this.expansionSetCode = "LRW"; @@ -50,7 +57,7 @@ public class MerrowCommerce extends CardImpl { this.color.setBlue(true); // At the beginning of your end step, untap all Merfolk you control. - this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new UntapAllControllerEffect(new FilterControlledPermanent("Merfolk", "Merfolk you control"), "untap all Merfolk you control"), false)); + this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new UntapAllControllerEffect(filter, "untap all Merfolk you control"), false)); } public MerrowCommerce(final MerrowCommerce card) { diff --git a/Mage.Sets/src/mage/sets/lorwyn/WanderwineProphets.java b/Mage.Sets/src/mage/sets/lorwyn/WanderwineProphets.java index 9c08e23e2a..8a40f877f4 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/WanderwineProphets.java +++ b/Mage.Sets/src/mage/sets/lorwyn/WanderwineProphets.java @@ -38,6 +38,7 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; import mage.target.common.TargetControlledPermanent; /** @@ -46,6 +47,12 @@ import mage.target.common.TargetControlledPermanent; */ public class WanderwineProphets extends CardImpl { + private static final FilterControlledPermanent filter = new FilterControlledPermanent("Merfolk"); + + static { + filter.add(new SubtypePredicate("Merfolk")); + } + public WanderwineProphets(UUID ownerId) { super(ownerId, 95, "Wanderwine Prophets", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{U}{U}"); this.expansionSetCode = "LRW"; @@ -60,7 +67,7 @@ public class WanderwineProphets extends CardImpl { this.addAbility(new ChampionAbility(this, "Merfolk")); // Whenever Wanderwine Prophets deals combat damage to a player, you may sacrifice a Merfolk. If you do, take an extra turn after this one. Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(new AddExtraTurnControllerEffect(), true); - ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, new FilterControlledPermanent("Merfolk", "Merfolk"), true))); + ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, true))); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/timeshifted/FireWhip.java b/Mage.Sets/src/mage/sets/timeshifted/FireWhip.java index 0c40271ece..98f5607461 100644 --- a/Mage.Sets/src/mage/sets/timeshifted/FireWhip.java +++ b/Mage.Sets/src/mage/sets/timeshifted/FireWhip.java @@ -47,7 +47,6 @@ import mage.constants.Zone; import mage.target.TargetPermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreatureOrPlayer; -import mage.target.common.TargetCreaturePermanent; /** * diff --git a/Mage/src/mage/filter/common/FilterControlledPermanent.java b/Mage/src/mage/filter/common/FilterControlledPermanent.java index 0c49c63228..a38e8d70ca 100644 --- a/Mage/src/mage/filter/common/FilterControlledPermanent.java +++ b/Mage/src/mage/filter/common/FilterControlledPermanent.java @@ -30,7 +30,6 @@ package mage.filter.common; import mage.constants.TargetController; import mage.filter.FilterPermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.ControllerPredicate; /** @@ -48,13 +47,6 @@ public class FilterControlledPermanent extends FilterPermanent { this.add(new ControllerPredicate(TargetController.YOU)); } - public FilterControlledPermanent(String subtype, String name) { - super(name); - this.add(new SubtypePredicate(subtype)); - this.add(new ControllerPredicate(TargetController.YOU)); - } - - public FilterControlledPermanent(final FilterControlledPermanent filter) { super(filter); }