diff --git a/Mage.Sets/src/mage/cards/m/Mistfolk.java b/Mage.Sets/src/mage/cards/m/Mistfolk.java new file mode 100644 index 0000000000..497feb0ec5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/Mistfolk.java @@ -0,0 +1,83 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.CounterTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.filter.FilterSpell; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.target.Target; +import mage.target.TargetSpell; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class Mistfolk extends CardImpl { + + private static final FilterSpell filter = new FilterSpell("spell that this creature"); + + static { + filter.add(MistfolkPredicate.instance); + } + + public Mistfolk(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{U}"); + + this.subtype.add(SubType.ILLUSION); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // {U}: Counter target spell that targets Mistfolk. + Ability ability = new SimpleActivatedAbility( + new CounterTargetEffect() + .setText("counter target spell that targets {this}"), + new ManaCostsImpl("{U}") + ); + ability.addTarget(new TargetSpell(filter)); + this.addAbility(ability); + } + + public Mistfolk(final Mistfolk card) { + super(card); + } + + @Override + public Mistfolk copy() { + return new Mistfolk(this); + } +} + +enum MistfolkPredicate implements ObjectSourcePlayerPredicate> { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + Permanent sourceObject = game.getPermanent(input.getSourceId()); + if (sourceObject == null || input.getObject() == null) { + return false; + } + for (SpellAbility spellAbility : input.getObject().getSpellAbilities()) { + for (Mode mode : spellAbility.getModes().values()) { + for (Target target : spellAbility.getTargets()) { + if (target.getTargets().contains(input.getSourceId())) { + return true; + } + } + } + } + return false; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/IceAge.java b/Mage.Sets/src/mage/sets/IceAge.java index fc2e781f9c..2112294e3b 100644 --- a/Mage.Sets/src/mage/sets/IceAge.java +++ b/Mage.Sets/src/mage/sets/IceAge.java @@ -215,6 +215,7 @@ public final class IceAge extends ExpansionSet { cards.add(new SetCardInfo("Mind Warp", 148, Rarity.UNCOMMON, mage.cards.m.MindWarp.class)); cards.add(new SetCardInfo("Minion of Leshrac", 150, Rarity.RARE, mage.cards.m.MinionOfLeshrac.class)); cards.add(new SetCardInfo("Minion of Tevesh Szat", 151, Rarity.RARE, mage.cards.m.MinionOfTeveshSzat.class)); + cards.add(new SetCardInfo("Mistfolk", 84, Rarity.COMMON, mage.cards.m.Mistfolk.class)); cards.add(new SetCardInfo("Mole Worms", 152, Rarity.UNCOMMON, mage.cards.m.MoleWorms.class)); cards.add(new SetCardInfo("Monsoon", 298, Rarity.RARE, mage.cards.m.Monsoon.class)); cards.add(new SetCardInfo("Moor Fiend", 153, Rarity.COMMON, mage.cards.m.MoorFiend.class)); diff --git a/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java b/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java index bd579657da..85f700357f 100644 --- a/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/MentorAbility.java @@ -13,7 +13,6 @@ import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; /** - * * @author TheElk801 */ public class MentorAbility extends AttacksTriggeredAbility { @@ -22,7 +21,7 @@ public class MentorAbility extends AttacksTriggeredAbility { static { filter.add(new AttackingPredicate()); - filter.add(new MentorAbilityPredicate()); + filter.add(MentorAbilityPredicate.instance); } public MentorAbility() { @@ -46,7 +45,8 @@ public class MentorAbility extends AttacksTriggeredAbility { } -class MentorAbilityPredicate implements ObjectSourcePlayerPredicate> { +enum MentorAbilityPredicate implements ObjectSourcePlayerPredicate> { + instance; @Override public boolean apply(ObjectSourcePlayer input, Game game) {