From 193033ad6f79dc68273651a88607a06c80603643 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 12 Apr 2020 20:01:22 -0400 Subject: [PATCH] Implemented Swallow Whole --- Mage.Sets/src/mage/cards/s/SwallowWhole.java | 92 +++++++++++++++++++ .../src/mage/sets/IkoriaLairOfBehemoths.java | 1 + 2 files changed, 93 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SwallowWhole.java diff --git a/Mage.Sets/src/mage/cards/s/SwallowWhole.java b/Mage.Sets/src/mage/cards/s/SwallowWhole.java new file mode 100644 index 00000000000..cf9ebcb1a1f --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SwallowWhole.java @@ -0,0 +1,92 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.Target; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SwallowWhole extends CardImpl { + + private static final FilterControlledPermanent filter + = new FilterControlledCreaturePermanent("an untapped creature you control"); + private static final FilterPermanent filter2 + = new FilterCreaturePermanent("tapped creature"); + + static { + filter.add(Predicates.not(TappedPredicate.instance)); + filter2.add(TappedPredicate.instance); + } + + public SwallowWhole(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}"); + + // As an additional cost to cast this spell, tap an untapped creature you control. + this.getSpellAbility().addCost(new TapTargetCost(new TargetControlledPermanent(filter))); + + // Exile target tapped creature. Put a +1/+1 counter on the creature tapped to cast this spell. + this.getSpellAbility().addEffect(new ExileTargetEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter2)); + this.getSpellAbility().addEffect(new SwallowWholeEffect()); + } + + private SwallowWhole(final SwallowWhole card) { + super(card); + } + + @Override + public SwallowWhole copy() { + return new SwallowWhole(this); + } +} + +class SwallowWholeEffect extends OneShotEffect { + + SwallowWholeEffect() { + super(Outcome.Benefit); + staticText = "Put a +1/+1 counter on the creature tapped to cast this spell."; + } + + private SwallowWholeEffect(final SwallowWholeEffect effect) { + super(effect); + } + + @Override + public SwallowWholeEffect copy() { + return new SwallowWholeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = source.getCosts() + .stream() + .filter(TapTargetCost.class::isInstance) + .map(TapTargetCost.class::cast) + .map(TapTargetCost::getTarget) + .map(Target::getFirstTarget) + .map(game::getPermanent) + .findFirst() + .orElse(null); + return permanent != null && permanent.addCounters(CounterType.P1P1.createInstance(), source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index 1f8dbbd8504..1264382dd3d 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -278,6 +278,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet { cards.add(new SetCardInfo("Sudden Spinnerets", 171, Rarity.COMMON, mage.cards.s.SuddenSpinnerets.class)); cards.add(new SetCardInfo("Suffocating Fumes", 100, Rarity.COMMON, mage.cards.s.SuffocatingFumes.class)); cards.add(new SetCardInfo("Survivors' Bond", 172, Rarity.COMMON, mage.cards.s.SurvivorsBond.class)); + cards.add(new SetCardInfo("Swallow Whole", 35, Rarity.UNCOMMON, mage.cards.s.SwallowWhole.class)); cards.add(new SetCardInfo("Swamp", 266, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Swamp", 267, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Swamp", 268, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));