diff --git a/Mage.Sets/src/mage/cards/c/ChampionOfLambholt.java b/Mage.Sets/src/mage/cards/c/ChampionOfLambholt.java index 79b077a5d3..00e0561590 100644 --- a/Mage.Sets/src/mage/cards/c/ChampionOfLambholt.java +++ b/Mage.Sets/src/mage/cards/c/ChampionOfLambholt.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; @@ -10,11 +8,7 @@ import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.TargetController; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.AnotherPredicate; @@ -22,6 +16,8 @@ import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * @author noxx */ @@ -79,7 +75,7 @@ class ChampionOfLambholtEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - if (sourcePermanent != null && attacker.isControlledBy(sourcePermanent.getControllerId())) { + if (sourcePermanent != null && attacker != null && attacker.isControlledBy(sourcePermanent.getControllerId())) { return blocker.getPower().getValue() >= sourcePermanent.getPower().getValue(); } return true; diff --git a/Mage.Sets/src/mage/cards/c/Chaosphere.java b/Mage.Sets/src/mage/cards/c/Chaosphere.java index c7b2180bf4..dae8b6f7b7 100644 --- a/Mage.Sets/src/mage/cards/c/Chaosphere.java +++ b/Mage.Sets/src/mage/cards/c/Chaosphere.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.RestrictionEffect; @@ -20,8 +18,9 @@ import mage.filter.predicate.mageobject.AbilityPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class Chaosphere extends CardImpl { @@ -80,6 +79,9 @@ class ChaosphereEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } return attacker.hasAbility(FlyingAbility.getInstance().getId(), game); } diff --git a/Mage.Sets/src/mage/cards/d/DenseCanopy.java b/Mage.Sets/src/mage/cards/d/DenseCanopy.java index df435bc7cb..308cbe8ae1 100644 --- a/Mage.Sets/src/mage/cards/d/DenseCanopy.java +++ b/Mage.Sets/src/mage/cards/d/DenseCanopy.java @@ -1,7 +1,5 @@ - package mage.cards.d; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.RestrictionEffect; @@ -16,14 +14,15 @@ import mage.filter.predicate.mageobject.AbilityPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class DenseCanopy extends CardImpl { public DenseCanopy(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); // Creatures with flying can block only creatures with flying. @@ -64,6 +63,9 @@ class DenseCanopyCantBlockEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } return attacker.hasAbility(FlyingAbility.getInstance().getId(), game); } diff --git a/Mage.Sets/src/mage/cards/e/Exogorth.java b/Mage.Sets/src/mage/cards/e/Exogorth.java index 5fcb04443f..1475b478f5 100644 --- a/Mage.Sets/src/mage/cards/e/Exogorth.java +++ b/Mage.Sets/src/mage/cards/e/Exogorth.java @@ -1,7 +1,5 @@ - package mage.cards.e; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -12,14 +10,15 @@ import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Duration; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author Styxo */ public final class Exogorth extends CardImpl { @@ -84,6 +83,9 @@ class CanBlockOnlySpaceflightEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } return attacker.getAbilities().contains(SpaceflightAbility.getInstance()); } diff --git a/Mage.Sets/src/mage/cards/g/GoblinGoon.java b/Mage.Sets/src/mage/cards/g/GoblinGoon.java index b448b4f703..823e5f8a92 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinGoon.java +++ b/Mage.Sets/src/mage/cards/g/GoblinGoon.java @@ -111,6 +111,9 @@ class GoblinGoonCantBlockEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } UUID attackingPlayerId = attacker.getControllerId(); if (attackingPlayerId != null) { return game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), source.getControllerId(), game) > game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), attackingPlayerId, game); diff --git a/Mage.Sets/src/mage/cards/i/IronclawCurse.java b/Mage.Sets/src/mage/cards/i/IronclawCurse.java index 93d16b6851..84e5ce57a7 100644 --- a/Mage.Sets/src/mage/cards/i/IronclawCurse.java +++ b/Mage.Sets/src/mage/cards/i/IronclawCurse.java @@ -1,7 +1,5 @@ - package mage.cards.i; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.AttachEffect; @@ -10,19 +8,15 @@ import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.AttachmentType; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author L_J */ public final class IronclawCurse extends CardImpl { @@ -73,6 +67,9 @@ class IronclawCurseEffect extends CantBlockAttachedEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (enchantment == null) { return false; diff --git a/Mage.Sets/src/mage/cards/m/MirriWeatherlightDuelist.java b/Mage.Sets/src/mage/cards/m/MirriWeatherlightDuelist.java index 7f195643e6..9d359363d6 100644 --- a/Mage.Sets/src/mage/cards/m/MirriWeatherlightDuelist.java +++ b/Mage.Sets/src/mage/cards/m/MirriWeatherlightDuelist.java @@ -1,7 +1,5 @@ - package mage.cards.m; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; @@ -14,20 +12,14 @@ import mage.abilities.effects.common.AddContinuousEffectToGame; import mage.abilities.keyword.FirstStrikeAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.constants.SuperType; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class MirriWeatherlightDuelist extends CardImpl { @@ -87,6 +79,9 @@ class MirriWeatherlightDuelistBlockRestrictionEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } for (UUID creature : game.getCombat().getBlockers()) { if (game.getPlayer(game.getPermanent(creature).getOwnerId()).hasOpponent(attacker.getControllerId(), game)) { return false; diff --git a/Mage.Sets/src/mage/cards/m/MoggToady.java b/Mage.Sets/src/mage/cards/m/MoggToady.java index 7ce51ffe81..9afd5a3116 100644 --- a/Mage.Sets/src/mage/cards/m/MoggToady.java +++ b/Mage.Sets/src/mage/cards/m/MoggToady.java @@ -110,6 +110,9 @@ class MoggToadyCantBlockEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } UUID attackingPlayerId = attacker.getControllerId(); if (attackingPlayerId != null) { return game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), source.getControllerId(), game) > game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), attackingPlayerId, game); diff --git a/Mage.Sets/src/mage/cards/m/MonstrousHound.java b/Mage.Sets/src/mage/cards/m/MonstrousHound.java index 4cc6b545f6..c89875a1ac 100644 --- a/Mage.Sets/src/mage/cards/m/MonstrousHound.java +++ b/Mage.Sets/src/mage/cards/m/MonstrousHound.java @@ -119,6 +119,9 @@ class CantBlockUnlessControllerControlsMoreLandsEffect extends RestrictionEffect @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } UUID attackingPlayerId = attacker.getControllerId(); if (attackingPlayerId != null) { return game.getBattlefield().countAll(new FilterControlledLandPermanent(), diff --git a/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java b/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java index 7e767a16c2..63853758b8 100644 --- a/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java +++ b/Mage.Sets/src/mage/cards/s/SidarKondoOfJamuraa.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -13,19 +11,15 @@ import mage.abilities.keyword.PartnerAbility; import mage.abilities.keyword.ReachAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.ComparisonType; -import mage.constants.Duration; -import mage.constants.SuperType; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.PowerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class SidarKondoOfJamuraa extends CardImpl { @@ -92,9 +86,12 @@ class SidarKondoOfJamuraaCantBlockCreaturesSourceEffect extends RestrictionEffec } return game.getOpponents(source.getControllerId()).contains(permanent.getControllerId()); } - + @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); } diff --git a/Mage.Sets/src/mage/cards/s/SpitfireHandler.java b/Mage.Sets/src/mage/cards/s/SpitfireHandler.java index 6d4872d74f..b4190b637f 100644 --- a/Mage.Sets/src/mage/cards/s/SpitfireHandler.java +++ b/Mage.Sets/src/mage/cards/s/SpitfireHandler.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -9,18 +7,15 @@ import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ColoredManaCost; import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect; -import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.ColoredManaSymbol; -import mage.constants.Duration; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class SpitfireHandler extends CardImpl { @@ -67,6 +62,9 @@ class SpitfireHandlerCantBlockEffect extends RestrictionEffect { @Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + if (attacker == null) { + return true; + } return (blocker.getPower().getValue() >= attacker.getPower().getValue()); } diff --git a/Mage/src/main/java/mage/abilities/effects/RestrictionEffect.java b/Mage/src/main/java/mage/abilities/effects/RestrictionEffect.java index 8ee2f8037c..aa8d55f841 100644 --- a/Mage/src/main/java/mage/abilities/effects/RestrictionEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/RestrictionEffect.java @@ -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; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java index 2e01519ec2..885ac1063c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java @@ -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()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingEffect.java index b703fc64c5..d843a3f6b7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingEffect.java @@ -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()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java index d4e7176eeb..63ef028cfe 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java @@ -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); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java index 9667983168..10a9518451 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockCreaturesSourceEffect.java @@ -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); } diff --git a/Mage/src/main/java/mage/abilities/keyword/ShadowAbility.java b/Mage/src/main/java/mage/abilities/keyword/ShadowAbility.java index 6188b91b59..2f55a16b72 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ShadowAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ShadowAbility.java @@ -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()); } diff --git a/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java b/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java index 9a15056e04..d125487fd1 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SpaceflightAbility.java @@ -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()); }