diff --git a/Mage.Sets/src/mage/cards/c/ChampionsOfThePerfect.java b/Mage.Sets/src/mage/cards/c/ChampionsOfThePerfect.java new file mode 100644 index 00000000000..f23deb5c4db --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ChampionsOfThePerfect.java @@ -0,0 +1,52 @@ +package mage.cards.c; + +import mage.MageInt; +import mage.abilities.common.LeavesBattlefieldTriggeredAbility; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.costs.common.BeholdAndExileCost; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.ReturnExiledCardToHandEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.BeholdType; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.filter.StaticFilters; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ChampionsOfThePerfect extends CardImpl { + + public ChampionsOfThePerfect(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}"); + + this.subtype.add(SubType.ELF); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(6); + this.toughness = new MageInt(6); + + // As an additional cost to cast this spell, behold an Elf and exile it. + this.getSpellAbility().addCost(new BeholdAndExileCost(BeholdType.ELF)); + + // Whenever you cast a creature spell, draw a card. + this.addAbility(new SpellCastControllerTriggeredAbility( + new DrawCardSourceControllerEffect(1), + StaticFilters.FILTER_SPELL_A_CREATURE, false + )); + + // When this creature leaves the battlefield, return the exiled card to its owner's hand. + this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnExiledCardToHandEffect())); + } + + private ChampionsOfThePerfect(final ChampionsOfThePerfect card) { + super(card); + } + + @Override + public ChampionsOfThePerfect copy() { + return new ChampionsOfThePerfect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/LorwynEclipsed.java b/Mage.Sets/src/mage/sets/LorwynEclipsed.java index 3d380778c2e..d00de10ac4e 100644 --- a/Mage.Sets/src/mage/sets/LorwynEclipsed.java +++ b/Mage.Sets/src/mage/sets/LorwynEclipsed.java @@ -39,6 +39,8 @@ public final class LorwynEclipsed extends ExpansionSet { cards.add(new SetCardInfo("Bloom Tender", 400, Rarity.MYTHIC, mage.cards.b.BloomTender.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Blossoming Defense", 167, Rarity.UNCOMMON, mage.cards.b.BlossomingDefense.class)); cards.add(new SetCardInfo("Boggart Mischief", 92, Rarity.UNCOMMON, mage.cards.b.BoggartMischief.class)); + cards.add(new SetCardInfo("Champions of the Perfect", 171, Rarity.RARE, mage.cards.c.ChampionsOfThePerfect.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Champions of the Perfect", 365, Rarity.RARE, mage.cards.c.ChampionsOfThePerfect.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Chomping Changeling", 172, Rarity.UNCOMMON, mage.cards.c.ChompingChangeling.class)); cards.add(new SetCardInfo("Crossroads Watcher", 173, Rarity.COMMON, mage.cards.c.CrossroadsWatcher.class)); cards.add(new SetCardInfo("Deceit", 212, Rarity.MYTHIC, mage.cards.d.Deceit.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage/src/main/java/mage/abilities/costs/common/BeholdAndExileCost.java b/Mage/src/main/java/mage/abilities/costs/common/BeholdAndExileCost.java new file mode 100644 index 00000000000..09aa2d7a216 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/costs/common/BeholdAndExileCost.java @@ -0,0 +1,62 @@ +package mage.abilities.costs.common; + +import mage.abilities.Ability; +import mage.abilities.costs.Cost; +import mage.abilities.costs.CostImpl; +import mage.cards.Card; +import mage.constants.BeholdType; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class BeholdAndExileCost extends CostImpl { + + private final BeholdType beholdType; + + public BeholdAndExileCost(BeholdType beholdType) { + super(); + this.beholdType = beholdType; + this.text = "behold " + beholdType.getDescription() + " and exile it"; + } + + private BeholdAndExileCost(final BeholdAndExileCost cost) { + super(cost); + this.beholdType = cost.beholdType; + } + + @Override + public BeholdAndExileCost copy() { + return new BeholdAndExileCost(this); + } + + @Override + public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { + return beholdType.canBehold(controllerId, game, source); + } + + @Override + public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { + Player player = game.getPlayer(controllerId); + if (player == null) { + paid = false; + return paid; + } + Card card = beholdType.doBehold(player, game, source); + if (card == null) { + paid = false; + return paid; + } + player.moveCardsToExile( + card, source, game, true, + CardUtil.getExileZoneId(game, source, 1), + CardUtil.getSourceName(game, source) + ); + paid = true; + return paid; + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnExiledCardToHandEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnExiledCardToHandEffect.java new file mode 100644 index 00000000000..31ccd949e39 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnExiledCardToHandEffect.java @@ -0,0 +1,37 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.ExileZone; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * @author TheElk801 + */ +public class ReturnExiledCardToHandEffect extends OneShotEffect { + + public ReturnExiledCardToHandEffect() { + super(Outcome.Benefit); + staticText = "return the exiled card to its owner's hand"; + } + + private ReturnExiledCardToHandEffect(final ReturnExiledCardToHandEffect effect) { + super(effect); + } + + @Override + public ReturnExiledCardToHandEffect copy() { + return new ReturnExiledCardToHandEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source)); + return player != null && exileZone != null && player.moveCards(exileZone, Zone.HAND, source, game); + } +} diff --git a/Mage/src/main/java/mage/constants/BeholdType.java b/Mage/src/main/java/mage/constants/BeholdType.java index c5d110da309..24b97a09aad 100644 --- a/Mage/src/main/java/mage/constants/BeholdType.java +++ b/Mage/src/main/java/mage/constants/BeholdType.java @@ -21,6 +21,7 @@ import java.util.UUID; */ public enum BeholdType { DRAGON(SubType.DRAGON), + ELF(SubType.ELF), MERFOLK(SubType.MERFOLK); private final FilterPermanent filterPermanent;