diff --git a/Mage.Sets/src/mage/cards/u/UnluckyCabbageMerchant.java b/Mage.Sets/src/mage/cards/u/UnluckyCabbageMerchant.java new file mode 100644 index 00000000000..37d0e1f4564 --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UnluckyCabbageMerchant.java @@ -0,0 +1,92 @@ +package mage.cards.u; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SacrificePermanentTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +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.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.token.FoodToken; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class UnluckyCabbageMerchant extends CardImpl { + + public UnluckyCabbageMerchant(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.CITIZEN); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // When this creature enters, create a Food token. + this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new FoodToken()))); + + // Whenever you sacrifice a Food, you may search your library for a basic land card and put it onto the battlefield tapped. If you search your library this way, put this creature on the bottom of its owner's library, then shuffle. + this.addAbility(new SacrificePermanentTriggeredAbility( + new UnluckyCabbageMerchantEffect(), StaticFilters.FILTER_CONTROLLED_FOOD + )); + } + + private UnluckyCabbageMerchant(final UnluckyCabbageMerchant card) { + super(card); + } + + @Override + public UnluckyCabbageMerchant copy() { + return new UnluckyCabbageMerchant(this); + } +} + +class UnluckyCabbageMerchantEffect extends OneShotEffect { + + UnluckyCabbageMerchantEffect() { + super(Outcome.Benefit); + staticText = "you may search your library for a basic land card and put it onto the battlefield tapped. " + + "If you search your library this way, put this creature on the bottom of its owner's library, then shuffle"; + } + + private UnluckyCabbageMerchantEffect(final UnluckyCabbageMerchantEffect effect) { + super(effect); + } + + @Override + public UnluckyCabbageMerchantEffect copy() { + return new UnluckyCabbageMerchantEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || !player.chooseUse( + Outcome.PutLandInPlay, "Search your library for a basic land?", source, game + )) { + return false; + } + TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND); + if (!player.searchLibrary(target, source, game)) { + return false; + } + player.moveCards( + player.getLibrary().getCard(target.getFirstTarget(), game), Zone.BATTLEFIELD, + source, game, true, false, false, null + ); + player.putCardsOnBottomOfLibrary(source.getSourcePermanentIfItStillExists(game), game, source); + player.shuffleLibrary(source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java b/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java index 1f72503cbb1..db52004040b 100644 --- a/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java +++ b/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java @@ -382,6 +382,7 @@ public final class AvatarTheLastAirbender extends ExpansionSet { cards.add(new SetCardInfo("Uncle Iroh", 248, Rarity.UNCOMMON, mage.cards.u.UncleIroh.class)); cards.add(new SetCardInfo("United Front", 331, Rarity.MYTHIC, mage.cards.u.UnitedFront.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("United Front", 39, Rarity.MYTHIC, mage.cards.u.UnitedFront.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Unlucky Cabbage Merchant", 201, Rarity.UNCOMMON, mage.cards.u.UnluckyCabbageMerchant.class)); cards.add(new SetCardInfo("Vengeful Villagers", 40, Rarity.UNCOMMON, mage.cards.v.VengefulVillagers.class)); cards.add(new SetCardInfo("Vindictive Warden", 249, Rarity.COMMON, mage.cards.v.VindictiveWarden.class)); cards.add(new SetCardInfo("Walltop Sentries", 202, Rarity.COMMON, mage.cards.w.WalltopSentries.class));