From db1521d30c6d7e32b5592732d145fb62fc3d137c Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 8 Oct 2013 17:12:04 +0200 Subject: [PATCH] * Fixed some problems with blocking requirements (fixes #355). --- .../src/mage/sets/avacynrestored/RevengeOfTheHunted.java | 2 +- Mage.Sets/src/mage/sets/worldwake/FeralContest.java | 7 +++---- Mage.Sets/src/mage/sets/zendikar/GrapplingHook.java | 5 ++++- .../common/combat/MustBeBlockedByAllAttachedEffect.java | 4 ++++ .../common/combat/MustBeBlockedByAllSourceEffect.java | 2 +- .../common/combat/MustBeBlockedByTargetSourceEffect.java | 8 +++++--- Mage/src/mage/game/combat/Combat.java | 4 ++-- Mage/src/mage/game/permanent/PermanentImpl.java | 4 ++++ 8 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/sets/avacynrestored/RevengeOfTheHunted.java b/Mage.Sets/src/mage/sets/avacynrestored/RevengeOfTheHunted.java index d3a25e4b53..be22708f6c 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/RevengeOfTheHunted.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/RevengeOfTheHunted.java @@ -91,7 +91,7 @@ class RevengeOfTheHuntedEffect extends RequirementEffect { } @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (creature != null) { - return true; + public boolean applies(Permanent permanent, Ability source, Game game) { + if (permanent.getId().equals(source.getTargets().get(1).getFirstTarget())) { + return permanent.canBlock(source.getFirstTarget(), game); } return false; } diff --git a/Mage.Sets/src/mage/sets/zendikar/GrapplingHook.java b/Mage.Sets/src/mage/sets/zendikar/GrapplingHook.java index 90aa89417e..c5d66f03b1 100644 --- a/Mage.Sets/src/mage/sets/zendikar/GrapplingHook.java +++ b/Mage.Sets/src/mage/sets/zendikar/GrapplingHook.java @@ -96,7 +96,10 @@ class GrapplingHookEffect extends RequirementEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getFirstTarget())) { - return true; + Permanent equipment = game.getPermanent(source.getSourceId()); + if (equipment != null && equipment.getAttachedTo() != null) { + return permanent.canBlock(equipment.getAttachedTo(), game); + } } return false; } diff --git a/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java b/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java index c1ba763d6d..db9c5afc6f 100644 --- a/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java +++ b/Mage/src/mage/abilities/effects/common/combat/MustBeBlockedByAllAttachedEffect.java @@ -60,6 +60,10 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect { * and the requirement, so that's the only option. */ for (Permanent creature : game.getBattlefield().getActivePermanents(filterBlockers, player.getId(), game)) { - if (game.getOpponents(attackerId).contains(creature.getControllerId())) { + if (game.getOpponents(attackerId).contains(creature.getControllerId())) { for (Map.Entry entry : game.getContinuousEffects().getApplicableRequirementEffects(creature, game).entrySet()) { RequirementEffect effect = (RequirementEffect)entry.getKey(); if (effect.mustBlock(game)) { @@ -400,7 +400,7 @@ public class Combat implements Serializable, Copyable { } public boolean checkBlockRequirementsAfter(Player player, Player controller, Game game) { - // Get one time a list of all opponents in range + // Get once a list of all opponents in range Set opponents = game.getOpponents(attackerId); //20101001 - 509.1c // map with attackers (UUID) that must be blocked by at least one blocker and a set of all creatures that can block it and don't block yet diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 2b6d375752..fccd958b58 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -869,6 +869,10 @@ public abstract class PermanentImpl> extends CardImpl return false; } Permanent attacker = game.getPermanent(attackerId); + // controller of attacking permanent must be an opponent + if (!game.getOpponents(this.getControllerId()).contains(attacker.getControllerId())) { + return false; + } //20101001 - 509.1b for (Map.Entry entry: game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { RestrictionEffect effect = (RestrictionEffect)entry.getKey();