From 8bae8a911bc205229e1a3c9104b2ed95dec57c22 Mon Sep 17 00:00:00 2001 From: arcox <10953229+arcox@users.noreply.github.com> Date: Wed, 17 Jun 2020 14:15:16 +0000 Subject: [PATCH] Implement Choking Vines from Weatherlight set (#6655) --- Mage.Sets/src/mage/cards/c/ChokingVines.java | 93 ++++++++++++++++++++ Mage.Sets/src/mage/cards/f/FogPatch.java | 2 +- Mage.Sets/src/mage/sets/Weatherlight.java | 1 + 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/c/ChokingVines.java diff --git a/Mage.Sets/src/mage/cards/c/ChokingVines.java b/Mage.Sets/src/mage/cards/c/ChokingVines.java new file mode 100644 index 00000000000..285e78f3b1f --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ChokingVines.java @@ -0,0 +1,93 @@ +package mage.cards.c; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.PhaseStep; +import mage.game.Game; +import mage.game.combat.CombatGroup; +import mage.players.Player; +import mage.target.Target; +import mage.target.Targets; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetadjustment.TargetAdjuster; + +import static mage.filter.StaticFilters.FILTER_ATTACKING_CREATURES; + +/** + * @author arcox + */ +public final class ChokingVines extends CardImpl { + + public ChokingVines(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{G}"); + + // Cast only during the declare blockers step. + this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(null, PhaseStep.DECLARE_BLOCKERS, null, "Cast this spell only during the declare blockers step")); + + // X target attacking creatures become blocked. Choking Vines deals 1 damage to each of those creatures. + this.getSpellAbility().addEffect(new ChokingVinesEffect()); + this.getSpellAbility().addEffect(new DamageTargetEffect(1)); + this.getSpellAbility().setTargetAdjuster(ChokingVinesAdjuster.instance); + } + + public ChokingVines(final ChokingVines card) { + super(card); + } + + @Override + public ChokingVines copy() { + return new ChokingVines(this); + } +} + +enum ChokingVinesAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + ability.getTargets().clear(); + int x = ability.getManaCostsToPay().getX(); + ability.addTarget(new TargetCreaturePermanent(x, x, FILTER_ATTACKING_CREATURES, false)); + } +} + +class ChokingVinesEffect extends OneShotEffect { + + public ChokingVinesEffect() { + super(Outcome.Benefit); + this.staticText = "X target attacking creatures become blocked"; + } + + public ChokingVinesEffect(final ChokingVinesEffect effect) { + super(effect); + } + + @Override + public ChokingVinesEffect copy() { + return new ChokingVinesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Targets targets = source.getTargets(); + if (controller != null && !targets.isEmpty()) { + for (Target target : targets) { + CombatGroup combatGroup = game.getCombat().findGroup(target.getFirstTarget()); + if (combatGroup != null) { + combatGroup.setBlocked(true, game); + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/cards/f/FogPatch.java b/Mage.Sets/src/mage/cards/f/FogPatch.java index 7c62a881193..7e054f6c074 100644 --- a/Mage.Sets/src/mage/cards/f/FogPatch.java +++ b/Mage.Sets/src/mage/cards/f/FogPatch.java @@ -66,7 +66,7 @@ class FogPatchEffect extends OneShotEffect { if (attacker != null) { CombatGroup combatGroup = game.getCombat().findGroup(attacker.getId()); if (combatGroup != null) { - combatGroup.setBlocked(true); + combatGroup.setBlocked(true, game); } } } diff --git a/Mage.Sets/src/mage/sets/Weatherlight.java b/Mage.Sets/src/mage/sets/Weatherlight.java index b69ac023139..1bcc0907210 100644 --- a/Mage.Sets/src/mage/sets/Weatherlight.java +++ b/Mage.Sets/src/mage/sets/Weatherlight.java @@ -62,6 +62,7 @@ public final class Weatherlight extends ExpansionSet { cards.add(new SetCardInfo("Buried Alive", 63, Rarity.UNCOMMON, mage.cards.b.BuriedAlive.class)); cards.add(new SetCardInfo("Call of the Wild", 122, Rarity.RARE, mage.cards.c.CallOfTheWild.class)); cards.add(new SetCardInfo("Chimeric Sphere", 148, Rarity.UNCOMMON, mage.cards.c.ChimericSphere.class)); + cards.add(new SetCardInfo("Choking Vines", 123, Rarity.COMMON, mage.cards.c.ChokingVines.class)); cards.add(new SetCardInfo("Cinder Giant", 93, Rarity.UNCOMMON, mage.cards.c.CinderGiant.class)); cards.add(new SetCardInfo("Cinder Wall", 94, Rarity.COMMON, mage.cards.c.CinderWall.class)); cards.add(new SetCardInfo("Cloud Djinn", 36, Rarity.UNCOMMON, mage.cards.c.CloudDjinn.class));