diff --git a/Mage/src/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java b/Mage/src/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java index 9396fe95a4..465cac1abf 100644 --- a/Mage/src/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java +++ b/Mage/src/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java @@ -68,7 +68,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect { return false; } Permanent plainswalker = game.getPermanent(defenderId); - return plainswalker == null || !plainswalker.getControllerId().equals(source.getSourceId()); + return plainswalker == null || !plainswalker.getControllerId().equals(source.getControllerId()); } diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 22166a4015..40450cf685 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -35,6 +35,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; @@ -872,23 +873,44 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { if (hasSummoningSickness()) { return false; } + //20101001 - 508.1c + if (defenderId == null) { + boolean oneCanBeAttacked = false; + for (UUID defenderToCheckId: game.getCombat().getDefenders()) { + if (canAttackCheckRestrictionEffects(defenderToCheckId, game)) { + oneCanBeAttacked = true; + break; + } + } + if (!oneCanBeAttacked) { + return false; + } + } else { + if (!canAttackCheckRestrictionEffects(defenderId, game)) { + return false; + } + } + + return !abilities.containsKey(DefenderAbility.getInstance().getId()) + || game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK, this.getControllerId(), game); + } + + + private boolean canAttackCheckRestrictionEffects(UUID defenderId, Game game) { //20101001 - 508.1c for (Map.Entry> effectEntry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { if (!effectEntry.getKey().canAttack(game)) { return false; } - if (defenderId != null) { - for (Ability ability :effectEntry.getValue()) { - if (!effectEntry.getKey().canAttack(defenderId, ability, game)) { - return false; - } + for (Ability ability :effectEntry.getValue()) { + if (!effectEntry.getKey().canAttack(defenderId, ability, game)) { + return false; } } } - return !abilities.containsKey(DefenderAbility.getInstance().getId()) - || game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK, this.getControllerId(), game); + return true; } - + @Override public boolean canBlock(UUID attackerId, Game game) { if (tapped && !game.getState().getContinuousEffects().asThough(this.getId(), AsThoughEffectType.BLOCK_TAPPED, this.getControllerId(), game)) {