From 28efe6233934c9ca42465e67d4f79ad1ed3cf2e2 Mon Sep 17 00:00:00 2001 From: Quercitron Date: Wed, 22 Jan 2014 03:31:12 +0400 Subject: [PATCH] Add SourceHasSubtypeCondition --- .../src/mage/sets/theros/ErebossEmissary.java | 22 ++------------- .../common/SourceHasSubtypeCondition.java | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 Mage/src/mage/abilities/condition/common/SourceHasSubtypeCondition.java diff --git a/Mage.Sets/src/mage/sets/theros/ErebossEmissary.java b/Mage.Sets/src/mage/sets/theros/ErebossEmissary.java index ff90ff2aab..24994c4bd2 100644 --- a/Mage.Sets/src/mage/sets/theros/ErebossEmissary.java +++ b/Mage.Sets/src/mage/sets/theros/ErebossEmissary.java @@ -29,11 +29,9 @@ package mage.sets.theros; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.condition.Condition; -import mage.abilities.costs.common.DiscardCardCost; +import mage.abilities.condition.common.SourceHasSubtypeCondition; import mage.abilities.costs.common.DiscardTargetCost; import mage.abilities.decorator.ConditionalContinousEffect; import mage.abilities.effects.common.continious.BoostEnchantedEffect; @@ -45,8 +43,6 @@ import mage.constants.Duration; import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetCardInHand; /** @@ -68,9 +64,9 @@ public class ErebossEmissary extends CardImpl { this.addAbility(new BestowAbility(this, "{5}{B}")); // Discard a creature card: Erebos's Emissary gets +2/+2 until end of turn. If Erebos's Emissary is an Aura, enchanted creature gets +2/+2 until end of turn instead. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new ConditionalContinousEffect( - new BoostSourceEffect(2,2, Duration.EndOfTurn), new BoostEnchantedEffect(2,2, Duration.EndOfTurn), - new NoAuraCondition(), + new BoostSourceEffect(2,2, Duration.EndOfTurn), + new SourceHasSubtypeCondition("Aura"), "{this} gets +2/+2 until end of turn. If Erebos's Emissary is an Aura, enchanted creature gets +2/+2 until end of turn instead"), new DiscardTargetCost(new TargetCardInHand(new FilterCreatureCard())))); // Enchanted creature gets +3/+3 @@ -86,15 +82,3 @@ public class ErebossEmissary extends CardImpl { return new ErebossEmissary(this); } } - -class NoAuraCondition implements Condition { - - @Override - public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - return !permanent.hasSubtype("Aura"); - } - return false; - } -} \ No newline at end of file diff --git a/Mage/src/mage/abilities/condition/common/SourceHasSubtypeCondition.java b/Mage/src/mage/abilities/condition/common/SourceHasSubtypeCondition.java new file mode 100644 index 0000000000..21852e227e --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/SourceHasSubtypeCondition.java @@ -0,0 +1,28 @@ +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author Quercitron + */ +public class SourceHasSubtypeCondition implements Condition { + + private final String subtype; + + public SourceHasSubtypeCondition(String subtype) { + this.subtype = subtype; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + return permanent.hasSubtype(subtype); + } + return false; + } +}