mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Fixed that CantCounterSourceEffect only prevents the SpellAbility from beeing countered and not e.g. triggered abilities from that source (fixes #625).
This commit is contained in:
parent
1cdf2ab4b0
commit
109e18fdd5
2 changed files with 18 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,16 +82,28 @@ public class SpellStack extends ArrayDeque<StackObject> {
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue