From 2733d736d51a3e0ca9df04b3b7d8e386e9f6bb4f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 5 Oct 2017 13:35:42 -0400 Subject: [PATCH] fixed Curtain of Light targeting, updated how being unblocked is checked --- Mage.Sets/src/mage/cards/c/CurtainOfLight.java | 6 +++--- .../src/mage/cards/w/WeatheredBodyguards.java | 14 ++------------ .../predicate/permanent/BlockedPredicate.java | 8 +------- .../main/java/mage/game/permanent/Permanent.java | 2 ++ .../java/mage/game/permanent/PermanentImpl.java | 11 +++++++++++ 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/CurtainOfLight.java b/Mage.Sets/src/mage/cards/c/CurtainOfLight.java index 6f7211f921..f7a762d49e 100644 --- a/Mage.Sets/src/mage/cards/c/CurtainOfLight.java +++ b/Mage.Sets/src/mage/cards/c/CurtainOfLight.java @@ -41,7 +41,7 @@ import mage.constants.TurnPhase; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.permanent.AttackingPredicate; -import mage.filter.predicate.permanent.BlockingPredicate; +import mage.filter.predicate.permanent.BlockedPredicate; import mage.game.Game; import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; @@ -58,11 +58,11 @@ public class CurtainOfLight extends CardImpl { static { filter.add(new AttackingPredicate()); - filter.add(Predicates.not(new BlockingPredicate())); + filter.add(Predicates.not(new BlockedPredicate())); } public CurtainOfLight(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}"); // Cast Curtain of Light only during combat after blockers are declared. this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, AfterBlockersAreDeclaredCondition.instance)); diff --git a/Mage.Sets/src/mage/cards/w/WeatheredBodyguards.java b/Mage.Sets/src/mage/cards/w/WeatheredBodyguards.java index f6dc7d6a98..e346bf6de8 100644 --- a/Mage.Sets/src/mage/cards/w/WeatheredBodyguards.java +++ b/Mage.Sets/src/mage/cards/w/WeatheredBodyguards.java @@ -42,7 +42,6 @@ import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; -import mage.game.combat.CombatGroup; import mage.game.events.DamagePlayerEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -95,17 +94,8 @@ class WeatheredBodyguardsEffect extends ReplacementEffectImpl { DamagePlayerEvent damageEvent = (DamagePlayerEvent) event; Permanent damager = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId()); Permanent p = game.getPermanent(source.getSourceId()); - boolean applyIt = false; - if (p != null && !p.isTapped() && damageEvent.isCombatDamage() && damager != null && damager.isAttacking()) { - for (CombatGroup cg : game.getCombat().getGroups()) { - if (cg.getAttackers().contains(damager.getId()) && !cg.getBlocked()) { - applyIt = true; - break; - } - } - if (applyIt) { - p.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable()); - } + if (p != null && !p.isTapped() && damageEvent.isCombatDamage() && damager != null && damager.isAttacking() && !damager.isBlocked(game)) { + p.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable()); return true; } return true; diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/BlockedPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/BlockedPredicate.java index 603d3ae6d7..198bf268c0 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/BlockedPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/BlockedPredicate.java @@ -29,7 +29,6 @@ package mage.filter.predicate.permanent; import mage.filter.predicate.Predicate; import mage.game.Game; -import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; /** @@ -40,12 +39,7 @@ public class BlockedPredicate implements Predicate { @Override public boolean apply(Permanent input, Game game) { - for (CombatGroup combatGroup : game.getCombat().getGroups()) { - if (!combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(input.getId())) { - return true; - } - } - return false; + return input.isBlocked(game); } @Override diff --git a/Mage/src/main/java/mage/game/permanent/Permanent.java b/Mage/src/main/java/mage/game/permanent/Permanent.java index 68efe807b6..fedf9aad48 100644 --- a/Mage/src/main/java/mage/game/permanent/Permanent.java +++ b/Mage/src/main/java/mage/game/permanent/Permanent.java @@ -193,6 +193,8 @@ public interface Permanent extends Card, Controllable { boolean isAttacking(); + boolean isBlocked(Game game); + int getBlocking(); void setAttacking(boolean attacking); diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 18babecc50..f4bd39bb1a 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -48,6 +48,7 @@ import mage.game.Game; import mage.game.GameState; import mage.game.ZoneChangeInfo; import mage.game.ZonesHandler; +import mage.game.combat.CombatGroup; import mage.game.command.CommandObject; import mage.game.events.*; import mage.game.events.GameEvent.EventType; @@ -509,6 +510,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { return attacking; } + @Override + public boolean isBlocked(Game game) { + for (CombatGroup combatGroup : game.getCombat().getGroups()) { + if (combatGroup.getBlocked() && combatGroup.getAttackers().contains(this.getId())) { + return true; + } + } + return false; + } + @Override public int getBlocking() { return blocking;