fixed Curtain of Light targeting, updated how being unblocked is checked

This commit is contained in:
Evan Kranzler 2017-10-05 13:35:42 -04:00
parent 3b0b923b7c
commit 2733d736d5
5 changed files with 19 additions and 22 deletions

View file

@ -41,7 +41,7 @@ import mage.constants.TurnPhase;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.AttackingPredicate; 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.Game;
import mage.game.combat.CombatGroup; import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -58,11 +58,11 @@ public class CurtainOfLight extends CardImpl {
static { static {
filter.add(new AttackingPredicate()); filter.add(new AttackingPredicate());
filter.add(Predicates.not(new BlockingPredicate())); filter.add(Predicates.not(new BlockedPredicate()));
} }
public CurtainOfLight(UUID ownerId, CardSetInfo setInfo) { 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. // Cast Curtain of Light only during combat after blockers are declared.
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, AfterBlockersAreDeclaredCondition.instance)); this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, AfterBlockersAreDeclaredCondition.instance));

View file

@ -42,7 +42,6 @@ import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.DamagePlayerEvent; import mage.game.events.DamagePlayerEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -95,17 +94,8 @@ class WeatheredBodyguardsEffect extends ReplacementEffectImpl {
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event; DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
Permanent damager = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId()); Permanent damager = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
Permanent p = game.getPermanent(source.getSourceId()); Permanent p = game.getPermanent(source.getSourceId());
boolean applyIt = false; if (p != null && !p.isTapped() && damageEvent.isCombatDamage() && damager != null && damager.isAttacking() && !damager.isBlocked(game)) {
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()); p.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable());
}
return true; return true;
} }
return true; return true;

View file

@ -29,7 +29,6 @@ package mage.filter.predicate.permanent;
import mage.filter.predicate.Predicate; import mage.filter.predicate.Predicate;
import mage.game.Game; import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
@ -40,12 +39,7 @@ public class BlockedPredicate implements Predicate<Permanent> {
@Override @Override
public boolean apply(Permanent input, Game game) { public boolean apply(Permanent input, Game game) {
for (CombatGroup combatGroup : game.getCombat().getGroups()) { return input.isBlocked(game);
if (!combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(input.getId())) {
return true;
}
}
return false;
} }
@Override @Override

View file

@ -193,6 +193,8 @@ public interface Permanent extends Card, Controllable {
boolean isAttacking(); boolean isAttacking();
boolean isBlocked(Game game);
int getBlocking(); int getBlocking();
void setAttacking(boolean attacking); void setAttacking(boolean attacking);

View file

@ -48,6 +48,7 @@ import mage.game.Game;
import mage.game.GameState; import mage.game.GameState;
import mage.game.ZoneChangeInfo; import mage.game.ZoneChangeInfo;
import mage.game.ZonesHandler; import mage.game.ZonesHandler;
import mage.game.combat.CombatGroup;
import mage.game.command.CommandObject; import mage.game.command.CommandObject;
import mage.game.events.*; import mage.game.events.*;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
@ -509,6 +510,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return attacking; 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 @Override
public int getBlocking() { public int getBlocking() {
return blocking; return blocking;