mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Fixed NPE errors in canBlock restrict checks;
This commit is contained in:
parent
454d76e30b
commit
60a0ec03c0
18 changed files with 86 additions and 69 deletions
|
|
@ -53,6 +53,13 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param attacker can be empty for general checks
|
||||
* @param blocker
|
||||
* @param source
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -32,6 +30,9 @@ public class CanBlockOnlyFlyingAttachedEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return attacker.getAbilities().contains(FlyingAbility.getInstance());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -10,7 +8,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
|
@ -33,6 +30,9 @@ public class CanBlockOnlyFlyingEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return attacker.getAbilities().contains(FlyingAbility.getInstance());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.Duration;
|
||||
import static mage.constants.Duration.EndOfTurn;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import static mage.constants.Duration.EndOfTurn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public class CantBlockAttachedEffect extends RestrictionEffect {
|
||||
|
|
@ -70,6 +69,9 @@ public class CantBlockAttachedEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return !filter.match(attacker, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ public class CantBlockCreaturesSourceEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return !filter.match(attacker, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.EvasionAbility;
|
||||
import mage.abilities.MageSingleton;
|
||||
|
|
@ -10,6 +9,8 @@ import mage.constants.Duration;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
* "Shadow" keyword
|
||||
*
|
||||
|
|
@ -60,6 +61,9 @@ class ShadowEffect extends RestrictionEffect implements MageSingleton {
|
|||
|
||||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return attacker.getAbilities().containsKey(ShadowAbility.getInstance().getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.EvasionAbility;
|
||||
import mage.abilities.MageSingleton;
|
||||
|
|
@ -10,8 +8,9 @@ import mage.constants.Duration;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class SpaceflightAbility extends EvasionAbility implements MageSingleton {
|
||||
|
|
@ -59,6 +58,9 @@ class SpaceFlightEffect extends RestrictionEffect implements MageSingleton {
|
|||
|
||||
@Override
|
||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return attacker.getAbilities().containsKey(SpaceflightAbility.getInstance().getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue