diff --git a/Mage.Sets/src/mage/cards/c/CoilingRebirth.java b/Mage.Sets/src/mage/cards/c/CoilingRebirth.java new file mode 100644 index 00000000000..5b7fec0fb6b --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CoilingRebirth.java @@ -0,0 +1,89 @@ +package mage.cards.c; + +import mage.abilities.Ability; +import mage.abilities.condition.common.GiftWasPromisedCondition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenCopyTargetEffect; +import mage.abilities.keyword.GiftAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.GiftType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author xenohedron + */ +public final class CoilingRebirth extends CardImpl { + + public CoilingRebirth(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}"); + + // Gift a card + this.addAbility(new GiftAbility(this, GiftType.CARD)); + + // Return target creature card from your graveyard to the battlefield. Then if the gift was promised and that creature isn't legendary, create a token that's a copy of that creature, except it's 1/1. + this.getSpellAbility().addEffect(new CoilingRebirthEffect()); + this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); + } + + private CoilingRebirth(final CoilingRebirth card) { + super(card); + } + + @Override + public CoilingRebirth copy() { + return new CoilingRebirth(this); + } +} + +class CoilingRebirthEffect extends OneShotEffect { + + CoilingRebirthEffect() { + super(Outcome.PutCreatureInPlay); + staticText = "Return target creature card from your graveyard to the battlefield. Then if the gift was promised " + + "and that creature isn't legendary, create a token that's a copy of that creature, except it's 1/1."; + } + + private CoilingRebirthEffect(final CoilingRebirthEffect effect) { + super(effect); + } + + @Override + public CoilingRebirthEffect copy() { + return new CoilingRebirthEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Card card = game.getCard(getTargetPointer().getFirst(game, source)); + if (controller == null || card == null || game.getState().getZone(card.getId()) != Zone.GRAVEYARD) { + return false; + } + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + if (GiftWasPromisedCondition.TRUE.apply(game, source)) { + game.processAction(); + Permanent permanent = game.getPermanent(card.getId()); + if (permanent != null && !permanent.isLegendary(game)) { + CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect( + null, null, false, 1, false, false, + null, 1, 1, false + ); + effect.setTargetPointer(new FixedTarget(permanent, game)); + effect.apply(game, source); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Bloomburrow.java b/Mage.Sets/src/mage/sets/Bloomburrow.java index 3732d5f572b..c3ebff10808 100644 --- a/Mage.Sets/src/mage/sets/Bloomburrow.java +++ b/Mage.Sets/src/mage/sets/Bloomburrow.java @@ -61,6 +61,7 @@ public final class Bloomburrow extends ExpansionSet { cards.add(new SetCardInfo("Charmed Sleep", 388, Rarity.COMMON, mage.cards.c.CharmedSleep.class)); cards.add(new SetCardInfo("Cindering Cutthroat", 208, Rarity.COMMON, mage.cards.c.CinderingCutthroat.class)); cards.add(new SetCardInfo("Clifftop Lookout", 168, Rarity.UNCOMMON, mage.cards.c.ClifftopLookout.class)); + cards.add(new SetCardInfo("Coiling Rebirth", 86, Rarity.RARE, mage.cards.c.CoilingRebirth.class)); cards.add(new SetCardInfo("Colossification", 392, Rarity.RARE, mage.cards.c.Colossification.class)); cards.add(new SetCardInfo("Conduct Electricity", 130, Rarity.COMMON, mage.cards.c.ConductElectricity.class)); cards.add(new SetCardInfo("Consumed by Greed", 87, Rarity.UNCOMMON, mage.cards.c.ConsumedByGreed.class));