Fixed evasion abilities. Splitted canBlock to canBeBlocked and canBlock methods (previous version caused bugs). Refactored some cards.

This commit is contained in:
magenoxx 2011-07-05 17:00:05 +04:00
parent 8bcc228aa4
commit a3a38823d6
9 changed files with 18 additions and 10 deletions

View file

@ -115,7 +115,7 @@ class SignalPestEffect extends RestrictionEffect<SignalPestEffect> {
} }
@Override @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())) { if (blocker.getAbilities().contains(FlyingAbility.getInstance()) || blocker.getAbilities().contains(ReachAbility.getInstance())) {
return true; return true;
} }

View file

@ -101,7 +101,7 @@ class JuggernautEffect extends CantBlockSourceEffect {
} }
@Override @Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
return !blocker.getSubtype().contains("Wall"); return !blocker.getSubtype().contains("Wall");
} }

View file

@ -64,5 +64,9 @@ public abstract class RestrictionEffect<T extends RestrictionEffect<T>> extends
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
return true; return true;
} }
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
return true;
}
} }

View file

@ -29,6 +29,8 @@
package mage.abilities.keyword; package mage.abilities.keyword;
import java.io.ObjectStreamException; import java.io.ObjectStreamException;
import mage.Constants;
import mage.Constants.Duration; import mage.Constants.Duration;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.EvasionAbility; import mage.abilities.EvasionAbility;
@ -87,8 +89,8 @@ class FearEffect extends RestrictionEffect<FearEffect> {
} }
@Override @Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
if (blocker.getAbilities().containsKey(FearAbility.getInstance().getId()) || blocker.getColor().isBlack()) { if (blocker.getCardType().contains(Constants.CardType.ARTIFACT) || blocker.getColor().isBlack()) {
return true; return true;
} }
return false; return false;

View file

@ -87,7 +87,7 @@ class FlyingEffect extends RestrictionEffect<FlyingEffect> {
} }
@Override @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())) if (blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId()) || blocker.getAbilities().containsKey(ReachAbility.getInstance().getId()))
return true; return true;
return false; return false;

View file

@ -47,7 +47,7 @@ class IntimidateEffect extends RestrictionEffect<IntimidateEffect> {
} }
@Override @Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
boolean result = false; boolean result = false;
if (blocker.getCardType().contains(Constants.CardType.ARTIFACT) && (blocker.getCardType().contains(Constants.CardType.CREATURE))) if (blocker.getCardType().contains(Constants.CardType.ARTIFACT) && (blocker.getCardType().contains(Constants.CardType.CREATURE)))
result = true; result = true;

View file

@ -72,7 +72,7 @@ class LandwalkEffect extends RestrictionEffect<LandwalkEffect> {
} }
@Override @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); return !game.getBattlefield().contains(filter, blocker.getControllerId(), 1);
} }

View file

@ -87,7 +87,7 @@ class UnblockableEffect extends RestrictionEffect<UnblockableEffect> {
} }
@Override @Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
return false; return false;
} }

View file

@ -610,8 +610,10 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
} }
// check also attacker's restriction effects // check also attacker's restriction effects
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game)) { for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game)) {
if (!effect.canBlock(attacker, this, game)) /*if (!effect.canBlock(attacker, this, game))
return false; return false;*/
if (!effect.canBeBlocked(attacker, this, game))
return false;
} }
if (attacker.hasProtectionFrom(this)) if (attacker.hasProtectionFrom(this))
return false; return false;