diff --git a/Mage.Sets/src/mage/cards/u/UnshakableTail.java b/Mage.Sets/src/mage/cards/u/UnshakableTail.java new file mode 100644 index 000000000000..122fb51a88ce --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UnshakableTail.java @@ -0,0 +1,143 @@ +package mage.cards.u; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; +import mage.abilities.effects.keyword.InvestigateEffect; +import mage.abilities.effects.keyword.SurveilEffect; +import mage.cards.Card; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeGroupEvent; + +/** + * + * @author kleese + */ +public final class UnshakableTail extends CardImpl { + + public UnshakableTail(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}"); + + this.subtype.add(SubType.ZOMBIE); + this.subtype.add(SubType.DETECTIVE); + this.power = new MageInt(3); + this.toughness = new MageInt(2); + + // When Unshakable Tail enters the battlefield and at the beginning of your upkeep, surveil 1. + this.addAbility(new UnshakableTailSurveilTriggeredAbility()); + + // Whenever one or more creature cards are put into your graveyard from your library, investigate. + this.addAbility(new UnshakableTailInvestigateTriggeredAbility()); + + // {2}, Sacrifice a Clue: Return Unshakable Tail from your graveyard to your hand. + Ability ability = new SimpleActivatedAbility( + Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new ManaCostsImpl<>("{2}") + ); + ability.addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_CLUE)); + this.addAbility(ability); + } + + private UnshakableTail(final UnshakableTail card) { + super(card); + } + + @Override + public UnshakableTail copy() { + return new UnshakableTail(this); + } +} + +class UnshakableTailSurveilTriggeredAbility extends TriggeredAbilityImpl { + + UnshakableTailSurveilTriggeredAbility() { + super(Zone.BATTLEFIELD, new SurveilEffect(1)); + } + + private UnshakableTailSurveilTriggeredAbility(final UnshakableTailSurveilTriggeredAbility ability) { + super(ability); + } + + @Override + public UnshakableTailSurveilTriggeredAbility copy() { + return new UnshakableTailSurveilTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + || event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { + return event.getTargetId().equals(getSourceId()); + } + return game.isActivePlayer(getControllerId()); + } + + @Override + public String getRule() { + return "When {this} enters the battlefield and at the beginning of your upkeep, surveil 1."; + } +} + +class UnshakableTailInvestigateTriggeredAbility extends TriggeredAbilityImpl { + + public UnshakableTailInvestigateTriggeredAbility() { + super(Zone.BATTLEFIELD, new InvestigateEffect(), false); + } + + private UnshakableTailInvestigateTriggeredAbility(final UnshakableTailInvestigateTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; + if (zEvent != null + && Zone.LIBRARY == zEvent.getFromZone() + && Zone.GRAVEYARD == zEvent.getToZone() + && zEvent.getCards() != null) { + for (Card card : zEvent.getCards()) { + if (card != null) { + UUID cardOwnerId = card.getOwnerId(); + if (cardOwnerId != null + && card.isOwnedBy(getControllerId()) + && card.isCreature(game)) { + return true; + } + } + + } + } + return false; + } + + @Override + public UnshakableTailInvestigateTriggeredAbility copy() { + return new UnshakableTailInvestigateTriggeredAbility(this); + } + + @Override + public String getRule() { + return "Whenever one or more creature cards are put into your graveyard from your library, investigate."; + } +} diff --git a/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java b/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java index 1b9927585e89..b5817254d910 100644 --- a/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java +++ b/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java @@ -278,6 +278,7 @@ private MurdersAtKarlovManorCommander() { cards.add(new SetCardInfo("Twilight Prophet", 143, Rarity.MYTHIC, mage.cards.t.TwilightProphet.class)); cards.add(new SetCardInfo("Ugin's Mastery", 53, Rarity.RARE, mage.cards.u.UginsMastery.class)); cards.add(new SetCardInfo("Ulvenwald Mysteries", 193, Rarity.UNCOMMON, mage.cards.u.UlvenwaldMysteries.class)); + cards.add(new SetCardInfo("Unshakable Tail", 29, Rarity.RARE, mage.cards.u.UnshakableTail.class)); cards.add(new SetCardInfo("Vengeful Ancestor", 163, Rarity.RARE, mage.cards.v.VengefulAncestor.class)); cards.add(new SetCardInfo("Vizier of Many Faces", 123, Rarity.RARE, mage.cards.v.VizierOfManyFaces.class)); cards.add(new SetCardInfo("Vow of Duty", 89, Rarity.UNCOMMON, mage.cards.v.VowOfDuty.class));