diff --git a/Mage.Sets/src/mage/cards/c/CacheGrab.java b/Mage.Sets/src/mage/cards/c/CacheGrab.java new file mode 100644 index 00000000000..8e094b8bf92 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CacheGrab.java @@ -0,0 +1,83 @@ +package mage.cards.c; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.game.permanent.token.FoodToken; +import mage.players.Player; +import mage.target.TargetCard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CacheGrab extends CardImpl { + + public CacheGrab(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}"); + + // Mill four cards. You may put a permanent card from among the cards milled this way into your hand. If you control a Squirrel or returned a Squirrel card to your hand this way, create a Food token. + this.getSpellAbility().addEffect(new CacheGrabEffect()); + } + + private CacheGrab(final CacheGrab card) { + super(card); + } + + @Override + public CacheGrab copy() { + return new CacheGrab(this); + } +} + +class CacheGrabEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterControlledPermanent(SubType.SQUIRREL); + + CacheGrabEffect() { + super(Outcome.Benefit); + staticText = "mill four cards. You may put a permanent card from among the cards milled this way into your " + + "hand. If you control a Squirrel or returned a Squirrel card to your hand this way, create a Food token"; + } + + private CacheGrabEffect(final CacheGrabEffect effect) { + super(effect); + } + + @Override + public CacheGrabEffect copy() { + return new CacheGrabEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = player.millCards(4, source, game); + TargetCard target = new TargetCard( + 0, 1, Zone.ALL, StaticFilters.FILTER_CARD_PERMANENT + ); + player.choose(Outcome.DrawCard, cards, target, source, game); + Card card = game.getCard(target.getFirstTarget()); + player.moveCards(card, Zone.HAND, source, game); + if ((card != null && card.hasSubtype(SubType.SQUIRREL, game)) + || game.getBattlefield().contains(filter, source.getControllerId(), source, game, 1)) { + new FoodToken().putOntoBattlefield(1, game, source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Bloomburrow.java b/Mage.Sets/src/mage/sets/Bloomburrow.java index 10d93f32197..6b47f67d5c2 100644 --- a/Mage.Sets/src/mage/sets/Bloomburrow.java +++ b/Mage.Sets/src/mage/sets/Bloomburrow.java @@ -28,6 +28,7 @@ public final class Bloomburrow extends ExpansionSet { cards.add(new SetCardInfo("Brave-Kin Duo", 3, Rarity.COMMON, mage.cards.b.BraveKinDuo.class)); cards.add(new SetCardInfo("Bria, Riptide Rogue", 379, Rarity.MYTHIC, mage.cards.b.BriaRiptideRogue.class)); cards.add(new SetCardInfo("Byrke, Long Ear of the Law", 380, Rarity.MYTHIC, mage.cards.b.ByrkeLongEarOfTheLaw.class)); + cards.add(new SetCardInfo("Cache Grab", 167, Rarity.COMMON, mage.cards.c.CacheGrab.class)); cards.add(new SetCardInfo("Carrot Cake", 7, Rarity.COMMON, mage.cards.c.CarrotCake.class)); cards.add(new SetCardInfo("Early Winter", 93, Rarity.COMMON, mage.cards.e.EarlyWinter.class)); cards.add(new SetCardInfo("Fell", 95, Rarity.UNCOMMON, mage.cards.f.Fell.class));