Implement Choking Vines from Weatherlight set (#6655)

This commit is contained in:
arcox 2020-06-17 14:15:16 +00:00 committed by GitHub
parent 5e54832426
commit 8bae8a911b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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);
}
}
}

View file

@ -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));