diff --git a/Mage.Sets/src/mage/cards/b/BarbedFoliage.java b/Mage.Sets/src/mage/cards/b/BarbedFoliage.java new file mode 100644 index 00000000000..e3d7f423d27 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BarbedFoliage.java @@ -0,0 +1,84 @@ +/* + * 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.cards.b; + +import java.util.UUID; +import mage.abilities.common.AttackedByCreatureTriggeredAbility; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.continuous.LoseAbilityTargetEffect; +import mage.abilities.keyword.FlankingAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SetTargetPointer; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.AbilityPredicate; + +/** + * + * @author TheElk801 + */ +public final class BarbedFoliage extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature without flying"); + + static { + filter.add(Predicates.not(new AbilityPredicate(FlyingAbility.class))); + } + + public BarbedFoliage(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{G}"); + + // Whenever a creature attacks you, it loses flanking until end of turn. + this.addAbility(new AttackedByCreatureTriggeredAbility( + new LoseAbilityTargetEffect(new FlankingAbility()) + .setText("it loses flanking until end of turn"), + false, SetTargetPointer.PERMANENT + )); + + // Whenever a creature without flying attacks you, Barbed Foliage deals 1 damage to it. + this.addAbility(new AttackedByCreatureTriggeredAbility( + Zone.BATTLEFIELD, + new DamageTargetEffect(1) + .setText("{this} deals 1 damage to it"), + false, SetTargetPointer.PERMANENT, filter + )); + } + + public BarbedFoliage(final BarbedFoliage card) { + super(card); + } + + @Override + public BarbedFoliage copy() { + return new BarbedFoliage(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Mirage.java b/Mage.Sets/src/mage/sets/Mirage.java index a14e58b342d..9af280aa081 100644 --- a/Mage.Sets/src/mage/sets/Mirage.java +++ b/Mage.Sets/src/mage/sets/Mirage.java @@ -68,6 +68,7 @@ public final class Mirage extends ExpansionSet { cards.add(new SetCardInfo("Auspicious Ancestor", 3, Rarity.RARE, mage.cards.a.AuspiciousAncestor.class)); cards.add(new SetCardInfo("Azimaet Drake", 53, Rarity.COMMON, mage.cards.a.AzimaetDrake.class)); cards.add(new SetCardInfo("Bad River", 324, Rarity.UNCOMMON, mage.cards.b.BadRiver.class)); + cards.add(new SetCardInfo("Barbed Foliage", 105, Rarity.UNCOMMON, mage.cards.b.BarbedFoliage.class)); cards.add(new SetCardInfo("Barbed-Back Wurm", 105, Rarity.UNCOMMON, mage.cards.b.BarbedBackWurm.class)); cards.add(new SetCardInfo("Bay Falcon", 54, Rarity.COMMON, mage.cards.b.BayFalcon.class)); cards.add(new SetCardInfo("Benthic Djinn", 257, Rarity.RARE, mage.cards.b.BenthicDjinn.class)); diff --git a/Mage/src/main/java/mage/abilities/common/AttackedByCreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttackedByCreatureTriggeredAbility.java index 5469b289b16..cb04178b1db 100644 --- a/Mage/src/main/java/mage/abilities/common/AttackedByCreatureTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttackedByCreatureTriggeredAbility.java @@ -32,6 +32,8 @@ import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.constants.SetTargetPointer; import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -44,6 +46,7 @@ import mage.target.targetpointer.FixedTarget; public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl { protected SetTargetPointer setTargetPointer; + protected FilterCreaturePermanent filter; public AttackedByCreatureTriggeredAbility(Effect effect) { this(effect, false); @@ -58,13 +61,19 @@ public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl { } public AttackedByCreatureTriggeredAbility(Zone zone, Effect effect, boolean optional, SetTargetPointer setTargetPointer) { + this(zone, effect, optional, setTargetPointer, StaticFilters.FILTER_PERMANENT_A_CREATURE); + } + + public AttackedByCreatureTriggeredAbility(Zone zone, Effect effect, boolean optional, SetTargetPointer setTargetPointer, FilterCreaturePermanent filter) { super(zone, effect, optional); this.setTargetPointer = setTargetPointer; + this.filter = filter; } public AttackedByCreatureTriggeredAbility(final AttackedByCreatureTriggeredAbility ability) { super(ability); this.setTargetPointer = ability.setTargetPointer; + this.filter = ability.filter; } @Override @@ -76,7 +85,9 @@ public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { UUID defendingPlayer = game.getCombat().getDefendingPlayerId(event.getSourceId(), game); Permanent attackingCreature = game.getPermanent(event.getSourceId()); - if (getControllerId().equals(defendingPlayer) && attackingCreature != null) { + if (filter.match(attackingCreature, game) + && getControllerId().equals(defendingPlayer) + && attackingCreature != null) { switch (setTargetPointer) { case PERMANENT: this.getEffects().setTargetPointer(new FixedTarget(attackingCreature, game)); @@ -97,7 +108,7 @@ public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return "Whenever a creature attacks you, " + super.getRule(); + return "Whenever " + filter.getMessage() + " attacks you, " + super.getRule(); } }