From f3de03342b138c737ece47069ef9a58ca1bc2baa Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 8 Sep 2019 09:15:28 -0400 Subject: [PATCH] Implemented Witch's Cottage --- Mage.Sets/src/mage/cards/w/WitchsCottage.java | 93 +++++++++++++++++++ Mage.Sets/src/mage/sets/ThroneOfEldraine.java | 1 + 2 files changed, 94 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WitchsCottage.java diff --git a/Mage.Sets/src/mage/cards/w/WitchsCottage.java b/Mage.Sets/src/mage/cards/w/WitchsCottage.java new file mode 100644 index 0000000000..9c78e1429c --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WitchsCottage.java @@ -0,0 +1,93 @@ +package mage.cards.w; + +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.PutOnLibraryTargetEffect; +import mage.abilities.effects.common.TapSourceEffect; +import mage.abilities.mana.BlackManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WitchsCottage extends CardImpl { + + private static final FilterPermanent filter + = new FilterControlledPermanent(SubType.SWAMP); + private static final Condition condition + = new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.FEWER_THAN, 3); + + public WitchsCottage(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); + + this.subtype.add(SubType.SWAMP); + + // ({T}: Add {B}.) + this.addAbility(new BlackManaAbility()); + + // Witch's Cottage enters the battlefield tapped unless you control three or more other Swamps. + this.addAbility(new EntersBattlefieldAbility( + new ConditionalOneShotEffect(new TapSourceEffect(), condition), + "tapped unless you control three or more other Swamps" + )); + + // When Witch's Cottage enters the battlefield untapped, you may put target creature card from your graveyard on top of your library. + this.addAbility(new WitchsCottageTriggeredAbility()); + } + + private WitchsCottage(final WitchsCottage card) { + super(card); + } + + @Override + public WitchsCottage copy() { + return new WitchsCottage(this); + } +} + +class WitchsCottageTriggeredAbility extends EntersBattlefieldTriggeredAbility { + + WitchsCottageTriggeredAbility() { + super(new PutOnLibraryTargetEffect(true), true); + this.addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); + } + + private WitchsCottageTriggeredAbility(final WitchsCottageTriggeredAbility ability) { + super(ability); + } + + @Override + public WitchsCottageTriggeredAbility copy() { + return new WitchsCottageTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!super.checkTrigger(event, game)) { + return false; + } + Permanent permanent = game.getPermanent(event.getTargetId()); + return permanent != null && permanent.isTapped(); + } + + @Override + public String getRule() { + return "When {this} enters the battlefield untapped, you may put target creature card from your graveyard on top of your library."; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index a75ced786b..ac1778d5aa 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -92,6 +92,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Wind-Scarred Crag", 308, Rarity.COMMON, mage.cards.w.WindScarredCrag.class)); cards.add(new SetCardInfo("Wintermoor Commander", 205, Rarity.UNCOMMON, mage.cards.w.WintermoorCommander.class)); cards.add(new SetCardInfo("Wishful Merfolk", 73, Rarity.COMMON, mage.cards.w.WishfulMerfolk.class)); + cards.add(new SetCardInfo("Witch's Cottage", 249, Rarity.COMMON, mage.cards.w.WitchsCottage.class)); cards.add(new SetCardInfo("Witching Well", 74, Rarity.COMMON, mage.cards.w.WitchingWell.class)); cards.add(new SetCardInfo("Workshop Elders", 318, Rarity.RARE, mage.cards.w.WorkshopElders.class));