From a3a38823d613f20f92d03f8b3aed501903c14aa4 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Tue, 5 Jul 2011 17:00:05 +0400 Subject: [PATCH] Fixed evasion abilities. Splitted canBlock to canBeBlocked and canBlock methods (previous version caused bugs). Refactored some cards. --- Mage.Sets/src/mage/sets/mirrodinbesieged/SignalPest.java | 2 +- Mage.Sets/src/mage/sets/tenth/Juggernaut.java | 2 +- Mage/src/mage/abilities/effects/RestrictionEffect.java | 4 ++++ Mage/src/mage/abilities/keyword/FearAbility.java | 6 ++++-- Mage/src/mage/abilities/keyword/FlyingAbility.java | 2 +- Mage/src/mage/abilities/keyword/IntimidateAbility.java | 2 +- Mage/src/mage/abilities/keyword/LandwalkAbility.java | 2 +- Mage/src/mage/abilities/keyword/UnblockableAbility.java | 2 +- Mage/src/mage/game/permanent/PermanentImpl.java | 6 ++++-- 9 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/SignalPest.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/SignalPest.java index bfc6478120..7e47bf591e 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/SignalPest.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/SignalPest.java @@ -115,7 +115,7 @@ class SignalPestEffect extends RestrictionEffect { } @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { if (blocker.getAbilities().contains(FlyingAbility.getInstance()) || blocker.getAbilities().contains(ReachAbility.getInstance())) { return true; } diff --git a/Mage.Sets/src/mage/sets/tenth/Juggernaut.java b/Mage.Sets/src/mage/sets/tenth/Juggernaut.java index 339d620d57..ac7d5db2ae 100644 --- a/Mage.Sets/src/mage/sets/tenth/Juggernaut.java +++ b/Mage.Sets/src/mage/sets/tenth/Juggernaut.java @@ -101,7 +101,7 @@ class JuggernautEffect extends CantBlockSourceEffect { } @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { return !blocker.getSubtype().contains("Wall"); } diff --git a/Mage/src/mage/abilities/effects/RestrictionEffect.java b/Mage/src/mage/abilities/effects/RestrictionEffect.java index 281db3e47f..44cf018ac7 100644 --- a/Mage/src/mage/abilities/effects/RestrictionEffect.java +++ b/Mage/src/mage/abilities/effects/RestrictionEffect.java @@ -64,5 +64,9 @@ public abstract class RestrictionEffect> extends public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { return true; } + + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { + return true; + } } diff --git a/Mage/src/mage/abilities/keyword/FearAbility.java b/Mage/src/mage/abilities/keyword/FearAbility.java index fce57cbacb..9e315a5e9c 100644 --- a/Mage/src/mage/abilities/keyword/FearAbility.java +++ b/Mage/src/mage/abilities/keyword/FearAbility.java @@ -29,6 +29,8 @@ package mage.abilities.keyword; import java.io.ObjectStreamException; + +import mage.Constants; import mage.Constants.Duration; import mage.abilities.Ability; import mage.abilities.EvasionAbility; @@ -87,8 +89,8 @@ class FearEffect extends RestrictionEffect { } @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { - if (blocker.getAbilities().containsKey(FearAbility.getInstance().getId()) || blocker.getColor().isBlack()) { + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { + if (blocker.getCardType().contains(Constants.CardType.ARTIFACT) || blocker.getColor().isBlack()) { return true; } return false; diff --git a/Mage/src/mage/abilities/keyword/FlyingAbility.java b/Mage/src/mage/abilities/keyword/FlyingAbility.java index 1790aea989..cd106029d1 100644 --- a/Mage/src/mage/abilities/keyword/FlyingAbility.java +++ b/Mage/src/mage/abilities/keyword/FlyingAbility.java @@ -87,7 +87,7 @@ class FlyingEffect extends RestrictionEffect { } @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { if (blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId()) || blocker.getAbilities().containsKey(ReachAbility.getInstance().getId())) return true; return false; diff --git a/Mage/src/mage/abilities/keyword/IntimidateAbility.java b/Mage/src/mage/abilities/keyword/IntimidateAbility.java index 5d0d38bcd9..b9e1f7ce45 100644 --- a/Mage/src/mage/abilities/keyword/IntimidateAbility.java +++ b/Mage/src/mage/abilities/keyword/IntimidateAbility.java @@ -47,7 +47,7 @@ class IntimidateEffect extends RestrictionEffect { } @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { boolean result = false; if (blocker.getCardType().contains(Constants.CardType.ARTIFACT) && (blocker.getCardType().contains(Constants.CardType.CREATURE))) result = true; diff --git a/Mage/src/mage/abilities/keyword/LandwalkAbility.java b/Mage/src/mage/abilities/keyword/LandwalkAbility.java index d49b27ce89..b7b9337a3d 100644 --- a/Mage/src/mage/abilities/keyword/LandwalkAbility.java +++ b/Mage/src/mage/abilities/keyword/LandwalkAbility.java @@ -72,7 +72,7 @@ class LandwalkEffect extends RestrictionEffect { } @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { return !game.getBattlefield().contains(filter, blocker.getControllerId(), 1); } diff --git a/Mage/src/mage/abilities/keyword/UnblockableAbility.java b/Mage/src/mage/abilities/keyword/UnblockableAbility.java index cd732e027c..0752c3031f 100644 --- a/Mage/src/mage/abilities/keyword/UnblockableAbility.java +++ b/Mage/src/mage/abilities/keyword/UnblockableAbility.java @@ -87,7 +87,7 @@ class UnblockableEffect extends RestrictionEffect { } @Override - public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) { return false; } diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 3a93512cf7..737dea4872 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -610,8 +610,10 @@ public abstract class PermanentImpl> extends CardImpl } // check also attacker's restriction effects for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game)) { - if (!effect.canBlock(attacker, this, game)) - return false; + /*if (!effect.canBlock(attacker, this, game)) + return false;*/ + if (!effect.canBeBlocked(attacker, this, game)) + return false; } if (attacker.hasProtectionFrom(this)) return false;