From bd5962a93530bec8935e80303c6eb616868dfe03 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 1 Oct 2022 21:36:58 -0400 Subject: [PATCH] [DMC] Implemented Activated Sleeper --- .../src/mage/cards/a/ActivatedSleeper.java | 112 ++++++++++++++++++ .../mage/sets/DominariaUnitedCommander.java | 1 + 2 files changed, 113 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/ActivatedSleeper.java diff --git a/Mage.Sets/src/mage/cards/a/ActivatedSleeper.java b/Mage.Sets/src/mage/cards/a/ActivatedSleeper.java new file mode 100644 index 0000000000..eae000c43e --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/ActivatedSleeper.java @@ -0,0 +1,112 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CopyEffect; +import mage.abilities.keyword.FlashAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterCard; +import mage.filter.common.FilterCreatureCard; +import mage.filter.predicate.card.PutIntoGraveFromBattlefieldThisTurnPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetCardInGraveyard; +import mage.util.functions.CopyApplier; +import mage.watchers.common.CardsPutIntoGraveyardWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ActivatedSleeper extends CardImpl { + + public ActivatedSleeper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}"); + + this.subtype.add(SubType.PHYREXIAN); + this.subtype.add(SubType.SHAPESHIFTER); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // You may have Activated Sleeper enter the battlefield as a copy of any creature card in a graveyard that was put there from the battelfield this turn, except it's a Phyrexian in addition to its other types. + this.addAbility(new EntersBattlefieldAbility( + new ActivatedSleeperEffect(), true + ), new CardsPutIntoGraveyardWatcher()); + } + + private ActivatedSleeper(final ActivatedSleeper card) { + super(card); + } + + @Override + public ActivatedSleeper copy() { + return new ActivatedSleeper(this); + } +} + +class ActivatedSleeperEffect extends OneShotEffect { + + private static final FilterCard filter = new FilterCreatureCard( + "creature card in a graveyard that was put there from the battelfield this turn" + ); + + static { + filter.add(PutIntoGraveFromBattlefieldThisTurnPredicate.instance); + } + + ActivatedSleeperEffect() { + super(Outcome.Benefit); + staticText = "as a copy of any creature card in a graveyard that was put there from " + + "the battlefield this turn, except it's a Phyrexian in addition to its other types"; + } + + private ActivatedSleeperEffect(final ActivatedSleeperEffect effect) { + super(effect); + } + + @Override + public ActivatedSleeperEffect copy() { + return new ActivatedSleeperEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Target target = new TargetCardInGraveyard(filter); + target.setNotTarget(true); + if (!target.canChoose(source.getControllerId(), source, game)) { + return true; + } + player.choose(outcome, target, source, game); + Card copyFromCard = game.getCard(target.getFirstTarget()); + if (copyFromCard != null) { + CopyEffect copyEffect = new CopyEffect(Duration.Custom, copyFromCard, source.getSourceId()); + copyEffect.setApplier(new CopyApplier() { + @Override + public boolean apply(Game game, MageObject blueprint, Ability source, UUID targetObjectId) { + blueprint.addSubType(SubType.PHYREXIAN); + return true; + } + }); + game.addEffect(copyEffect, source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java index c1ebe9969b..26599c61e4 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java +++ b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java @@ -21,6 +21,7 @@ public final class DominariaUnitedCommander extends ExpansionSet { cards.add(new SetCardInfo("Abundant Growth", 128, Rarity.COMMON, mage.cards.a.AbundantGrowth.class)); cards.add(new SetCardInfo("Abzan Charm", 138, Rarity.UNCOMMON, mage.cards.a.AbzanCharm.class)); + cards.add(new SetCardInfo("Activated Sleeper", 24, Rarity.RARE, mage.cards.a.ActivatedSleeper.class)); cards.add(new SetCardInfo("Adriana, Captain of the Guard", 139, Rarity.RARE, mage.cards.a.AdrianaCaptainOfTheGuard.class)); cards.add(new SetCardInfo("Alesha, Who Smiles at Death", 118, Rarity.RARE, mage.cards.a.AleshaWhoSmilesAtDeath.class)); cards.add(new SetCardInfo("Ambition's Cost", 110, Rarity.UNCOMMON, mage.cards.a.AmbitionsCost.class));