diff --git a/Mage.Sets/src/mage/cards/u/UnholyIndenture.java b/Mage.Sets/src/mage/cards/u/UnholyIndenture.java new file mode 100644 index 0000000000..21e10ddd1b --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UnholyIndenture.java @@ -0,0 +1,93 @@ +package mage.cards.u; + +import mage.abilities.Ability; +import mage.abilities.common.DiesAttachedTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.counters.Counters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentToken; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author JayDi85 + */ +public final class UnholyIndenture extends CardImpl { + + public UnholyIndenture(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}"); + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // When enchanted creature dies, return that card to the battlefield under your control with a +1/+1 counter on it. + this.addAbility(new DiesAttachedTriggeredAbility(new UnholyIndentureReturnEffect(), "enchanted creature")); + } + + public UnholyIndenture(final UnholyIndenture card) { + super(card); + } + + @Override + public UnholyIndenture copy() { + return new UnholyIndenture(this); + } +} + +class UnholyIndentureReturnEffect extends OneShotEffect { + + public UnholyIndentureReturnEffect() { + super(Outcome.Benefit); + staticText = "return that card to the battlefield under your control with a +1/+1 counter on it"; + } + + public UnholyIndentureReturnEffect(final UnholyIndentureReturnEffect effect) { + super(effect); + } + + @Override + public UnholyIndentureReturnEffect copy() { + return new UnholyIndentureReturnEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + // copy from ReturnToBattlefieldUnderYourControlAttachedEffect + Object object = getValue("attachedTo"); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null && object instanceof Permanent + && !(object instanceof PermanentToken)) { // not token + Card card = game.getCard(((Permanent) object).getId()); + // Move the card only, if it is still in the next zone after the battlefield + if (card != null && card.getZoneChangeCounter(game) == ((Permanent) object).getZoneChangeCounter(game) + 1) { + Counters countersToAdd = new Counters(); + countersToAdd.addCounter(CounterType.P1P1.createInstance()); + game.setEnterWithCounters(card.getId(), countersToAdd); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null); + return true; + } + } + + return false; + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 39d500e61d..07ff3b6a13 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -315,6 +315,7 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Uncaged Fury", 163, Rarity.UNCOMMON, mage.cards.u.UncagedFury.class)); cards.add(new SetCardInfo("Unchained Berserker", 164, Rarity.UNCOMMON, mage.cards.u.UnchainedBerserker.class)); cards.add(new SetCardInfo("Undead Servant", 118, Rarity.COMMON, mage.cards.u.UndeadServant.class)); + cards.add(new SetCardInfo("Unholy Indenture", 119, Rarity.COMMON, mage.cards.u.UnholyIndenture.class)); cards.add(new SetCardInfo("Unsummon", 78, Rarity.COMMON, mage.cards.u.Unsummon.class)); cards.add(new SetCardInfo("Vampire of the Dire Moon", 120, Rarity.UNCOMMON, mage.cards.v.VampireOfTheDireMoon.class)); cards.add(new SetCardInfo("Veil of Summer", 198, Rarity.UNCOMMON, mage.cards.v.VeilOfSummer.class));