diff --git a/Mage.Sets/src/mage/cards/t/TroveWarden.java b/Mage.Sets/src/mage/cards/t/TroveWarden.java new file mode 100644 index 0000000000..0472466244 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TroveWarden.java @@ -0,0 +1,99 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DiesTriggeredAbility; +import mage.abilities.common.LandfallAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTargetForSourceEffect; +import mage.abilities.keyword.VigilanceAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.common.FilterPermanentCard; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.ExileZone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TroveWarden extends CardImpl { + + private static final FilterCard filter + = new FilterPermanentCard("permanent card with converted mana cost 3 or less from your graveyard"); + + static { + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 4)); + } + + public TroveWarden(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); + + this.subtype.add(SubType.CAT); + this.subtype.add(SubType.BEAST); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // Vigilance + this.addAbility(VigilanceAbility.getInstance()); + + // Landfall — Whenever a land enters the battlefield under your control, exile target permanent card with converted mana cost 3 or less from your graveyard. + Ability ability = new LandfallAbility(new ExileTargetForSourceEffect()); + ability.addTarget(new TargetCardInYourGraveyard(filter)); + this.addAbility(ability); + + // When Trove Warden dies, put each permanent card exiled with it onto the battlefield under the control of that card's owner. + this.addAbility(new DiesTriggeredAbility(new TroveWardenEffect())); + } + + private TroveWarden(final TroveWarden card) { + super(card); + } + + @Override + public TroveWarden copy() { + return new TroveWarden(this); + } +} + +class TroveWardenEffect extends OneShotEffect { + + TroveWardenEffect() { + super(Outcome.Benefit); + staticText = "put each permanent card exiled with it onto the battlefield under the control of that card's owner"; + } + + private TroveWardenEffect(final TroveWardenEffect effect) { + super(effect); + } + + @Override + public TroveWardenEffect copy() { + return new TroveWardenEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId( + game, source.getSourceId(), source.getSourceObjectZoneChangeCounter() + )); + if (exileZone == null) { + return true; + } + return controller.moveCards( + exileZone.getCards(game), Zone.BATTLEFIELD, source, game, + false, false, true, null + ); + } +} diff --git a/Mage.Sets/src/mage/sets/ZendikarRisingCommander.java b/Mage.Sets/src/mage/sets/ZendikarRisingCommander.java index 25114a0dda..958a077d67 100644 --- a/Mage.Sets/src/mage/sets/ZendikarRisingCommander.java +++ b/Mage.Sets/src/mage/sets/ZendikarRisingCommander.java @@ -23,5 +23,6 @@ public final class ZendikarRisingCommander extends ExpansionSet { cards.add(new SetCardInfo("Enigma Thief", 4, Rarity.RARE, mage.cards.e.EnigmaThief.class)); cards.add(new SetCardInfo("Geode Rager", 6, Rarity.RARE, mage.cards.g.GeodeRager.class)); cards.add(new SetCardInfo("Obuun, Mul Daya Ancestor", 2, Rarity.MYTHIC, mage.cards.o.ObuunMulDayaAncestor.class)); + cards.add(new SetCardInfo("Trove Warden", 3, Rarity.MYTHIC, mage.cards.t.TroveWarden.class)); } }