diff --git a/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java b/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java index c6765dacbc..5dd5979935 100644 --- a/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java +++ b/Mage.Sets/src/mage/sets/magic2010/ProteanHydra.java @@ -98,7 +98,7 @@ public class ProteanHydra extends CardImpl { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { + if (permanent != null && source.getManaCostsToPay().getVariableCosts().size() > 0) { int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount(); permanent.addCounters(new PlusOneCounter(amount)); } diff --git a/Mage.Sets/src/mage/sets/magic2011/GargoyleSentinel.java b/Mage.Sets/src/mage/sets/magic2011/GargoyleSentinel.java index 321a75b15d..5ac450c2bb 100644 --- a/Mage.Sets/src/mage/sets/magic2011/GargoyleSentinel.java +++ b/Mage.Sets/src/mage/sets/magic2011/GargoyleSentinel.java @@ -28,6 +28,7 @@ package mage.sets.magic2011; +import java.util.Iterator; import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; @@ -102,9 +103,10 @@ class GargoyleSentinelEffect extends ContinuousEffectImpl i = permanent.getAbilities().iterator(); i.hasNext();) { + Ability entry = i.next(); + if (entry.getId().equals(DefenderAbility.getInstance().getId())) + i.remove(); } permanent.getAbilities().add(FlyingAbility.getInstance()); } diff --git a/Mage/src/mage/abilities/effects/RedirectionEffect.java b/Mage/src/mage/abilities/effects/RedirectionEffect.java index 856ceabbd4..a3ace22334 100644 --- a/Mage/src/mage/abilities/effects/RedirectionEffect.java +++ b/Mage/src/mage/abilities/effects/RedirectionEffect.java @@ -71,7 +71,7 @@ public abstract class RedirectionEffect> extends DamageEvent damageEvent = (DamageEvent)event; Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget()); Ability damageSource = getSource(damageEvent.getSourceId(), game); - if (permanent != null) { + if (permanent != null && damageSource != null) { permanent.damage(damageEvent.getAmount(), damageSource.getId(), game, damageEvent.isPreventable(), damageEvent.isCombatDamage()); return true; } diff --git a/Mage/src/mage/abilities/effects/common/DestroyTargetEffect.java b/Mage/src/mage/abilities/effects/common/DestroyTargetEffect.java index 1e60a0d79b..f6b4fb8fca 100644 --- a/Mage/src/mage/abilities/effects/common/DestroyTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/DestroyTargetEffect.java @@ -67,13 +67,15 @@ public class DestroyTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int affectedTargets = 0; - for (UUID permanentId : source.getTargets().get(0).getTargets()) { - Permanent permanent = game.getPermanent(permanentId); - if (permanent != null) { - permanent.destroy(source.getId(), game, noRegen); - affectedTargets++; - } - } + if (source.getTargets().size() > 0) { + for (UUID permanentId : source.getTargets().get(0).getTargets()) { + Permanent permanent = game.getPermanent(permanentId); + if (permanent != null) { + permanent.destroy(source.getId(), game, noRegen); + affectedTargets++; + } + } + } return affectedTargets > 0; } diff --git a/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java b/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java index 88326bcf15..ff73283bdc 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java @@ -58,19 +58,21 @@ public class ReturnToHandTargetEffect extends OneShotEffect 0) { + switch (source.getTargets().get(0).getZone()) { + case BATTLEFIELD: + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent != null) { + return permanent.moveToZone(Zone.HAND, source.getId(), game, false); + } + break; + case GRAVEYARD: + Card card = game.getCard(source.getFirstTarget()); + if (card != null) { + return card.moveToZone(Zone.HAND, source.getId(), game, true); + } + break; + } } return false; } diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostPowerXSourceEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostPowerXSourceEffect.java index dd6e98d3b5..68945df9c7 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostPowerXSourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostPowerXSourceEffect.java @@ -63,14 +63,16 @@ public class BoostPowerXSourceEffect extends ContinuousEffectImpl 0) { + int amountX = source.getManaCostsToPay().getVariableCosts().get(0).getAmount(); + if (amountX == 0) { + return false; + } + Permanent target = (Permanent) game.getPermanent(source.getSourceId()); + if (target != null) { + target.addPower(amountX); + return true; + } } return false; } diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 92604cb294..816575244c 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -318,7 +318,7 @@ public class GameState implements Serializable, Copyable { //TODO: this is awkward - improve if (event.getType() == EventType.ZONE_CHANGE) { ZoneChangeEvent zEvent = (ZoneChangeEvent)event; - if (zEvent.getFromZone() == Zone.BATTLEFIELD) { + if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getTarget() != null) { if (zEvent.getTarget() instanceof PermanentCard) { ((PermanentCard)zEvent.getTarget()).checkPermanentOnlyTriggers(zEvent, game); }