From 3c653d8b19c023312509d9fa042b9c7b9375fee7 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Mon, 22 Jun 2020 09:40:39 -0500 Subject: [PATCH] - First part of fix #6660 --- Mage.Sets/src/mage/cards/c/ChokingVines.java | 12 +++++- .../BecomesBlockedSourceTriggeredAbility.java | 43 +++++++++++++++++++ ...hantedCreatureBlockedTriggeredAbility.java | 3 +- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/common/BecomesBlockedSourceTriggeredAbility.java diff --git a/Mage.Sets/src/mage/cards/c/ChokingVines.java b/Mage.Sets/src/mage/cards/c/ChokingVines.java index 91ab935276..24b284da90 100644 --- a/Mage.Sets/src/mage/cards/c/ChokingVines.java +++ b/Mage.Sets/src/mage/cards/c/ChokingVines.java @@ -20,6 +20,8 @@ import mage.target.common.TargetCreaturePermanent; import mage.target.targetadjustment.TargetAdjuster; import static mage.filter.StaticFilters.FILTER_ATTACKING_CREATURES; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; /** * @author arcox @@ -30,7 +32,8 @@ public final class ChokingVines extends CardImpl { 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")); + 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()); @@ -85,7 +88,12 @@ class ChokingVinesEffect extends OneShotEffect { for (UUID id : target.getTargets()) { CombatGroup combatGroup = game.getCombat().findGroup(id); if (combatGroup != null) { - combatGroup.setBlocked(true, game); + combatGroup.setBlocked(true); // non-banded creatures + combatGroup.setBlocked(true, game); // this only works for banded creatures and needs to be checked out + Permanent attacker = game.getPermanent(id); + if (attacker != null) { + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CREATURE_BLOCKED, attacker.getId(), null)); + } } } } diff --git a/Mage/src/main/java/mage/abilities/common/BecomesBlockedSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BecomesBlockedSourceTriggeredAbility.java new file mode 100644 index 0000000000..8fc710f1f5 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/common/BecomesBlockedSourceTriggeredAbility.java @@ -0,0 +1,43 @@ + +package mage.abilities.common; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author North + */ +public class BecomesBlockedSourceTriggeredAbility extends TriggeredAbilityImpl { + + public BecomesBlockedSourceTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + public BecomesBlockedSourceTriggeredAbility(final BecomesBlockedSourceTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CREATURE_BLOCKED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return event.getTargetId().equals(this.getSourceId()); + } + + @Override + public String getRule() { + return "Whenever {this} becomes blocked, " + super.getRule(); + } + + @Override + public BecomesBlockedSourceTriggeredAbility copy() { + return new BecomesBlockedSourceTriggeredAbility(this); + } +} diff --git a/Mage/src/main/java/mage/abilities/common/EnchantedCreatureBlockedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/EnchantedCreatureBlockedTriggeredAbility.java index 5f907b63a3..a55686155c 100644 --- a/Mage/src/main/java/mage/abilities/common/EnchantedCreatureBlockedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/EnchantedCreatureBlockedTriggeredAbility.java @@ -1,4 +1,3 @@ - package mage.abilities.common; import mage.abilities.TriggeredAbilityImpl; @@ -43,7 +42,7 @@ public class EnchantedCreatureBlockedTriggeredAbility extends TriggeredAbilityIm @Override public String getRule() { - return "Whenever enchanted creature becomes blocked by a creature, " + super.getRule(); + return "Whenever enchanted creature becomes blocked, " + super.getRule(); } @Override