diff --git a/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java b/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java index 5af1fa349a..f845cc6612 100644 --- a/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java @@ -36,6 +36,7 @@ import mage.constants.Outcome; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.game.stack.Spell; import mage.game.stack.StackObject; /** @@ -76,9 +77,9 @@ public class CantCounterSourceEffect extends ContinuousRuleModifiyingEffectImpl @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.COUNTER) { - StackObject stackObject = game.getStack().getStackObject(event.getTargetId()); - if (stackObject != null) { - if (stackObject.getSourceId().equals(source.getSourceId())) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell != null) { + if (spell.getSourceId().equals(source.getSourceId())) { return true; } } diff --git a/Mage/src/mage/game/stack/SpellStack.java b/Mage/src/mage/game/stack/SpellStack.java index 305c062535..6ddc6aea69 100644 --- a/Mage/src/mage/game/stack/SpellStack.java +++ b/Mage/src/mage/game/stack/SpellStack.java @@ -82,16 +82,28 @@ public class SpellStack extends ArrayDeque { StackObject stackObject = getStackObject(objectId); MageObject sourceObject = game.getObject(sourceId); if (stackObject != null && sourceObject != null) { + MageObject targetSourceObject = game.getObject(stackObject.getSourceId()); + String counteredObjectName, targetSourceName; + if (targetSourceObject == null) { + targetSourceName = "[Object not found]"; + } else { + targetSourceName = game.getObject(stackObject.getSourceId()).getName(); + } + if (stackObject instanceof Spell) { + counteredObjectName = targetSourceName; + } else { + counteredObjectName = "Ability (" + stackObject.getStackAbility().getRule(targetSourceName) + ") of " + targetSourceName; + } if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) { if ( stackObject instanceof Spell ) { game.rememberLKI(objectId, Zone.STACK, (Spell)stackObject); } this.remove(stackObject); stackObject.counter(sourceId, game); // tries to move to graveyard - game.informPlayers(new StringBuilder(stackObject.getName()).append(" is countered by ").append(sourceObject.getLogName()).toString()); + game.informPlayers(counteredObjectName + " is countered by " + sourceObject.getLogName()); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId())); } else { - game.informPlayers(new StringBuilder(stackObject.getName()).append(" could not be countered by ").append(sourceObject.getLogName()).toString()); + game.informPlayers(counteredObjectName + " could not be countered by " + sourceObject.getLogName()); } return true; }