* Fixed a bug that occured if a copied spell was countered and should be moved to another zone as graveyard.

This commit is contained in:
LevelX2 2014-02-16 10:24:58 +01:00
parent 198a7df4fb
commit f2736807f3
2 changed files with 15 additions and 5 deletions

View file

@ -83,15 +83,19 @@ public class CounterTargetWithReplacementEffect extends OneShotEffect<CounterTar
StackObject stackObject = game.getStack().getStackObject(objectId);
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) {
boolean spell =false;
if (stackObject instanceof Spell) {
game.rememberLKI(objectId, Zone.STACK, (Spell) stackObject);
spell = true;
}
game.getStack().remove(stackObject);
MageObject card = game.getObject(stackObject.getSourceId());
if (card instanceof Card) {
((Card) card).moveToZone(targetZone, sourceId, game, flag);
} else {
game.informPlayers("Server: Couldn't move card to zone = " + targetZone + " as it has other than Card type.");
if (spell && !((Spell) stackObject).isCopiedSpell()) {
MageObject card = game.getObject(stackObject.getSourceId());
if (card instanceof Card) {
((Card) card).moveToZone(targetZone, sourceId, game, flag);
} else {
game.informPlayers("Server: Couldn't move card to zone = " + targetZone + " as it has other than Card type.");
}
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
return true;

View file

@ -652,6 +652,12 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
@Override
public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) {
// 706.10a If a copy of a spell is in a zone other than the stack, it ceases to exist.
// If a copy of a card is in any zone other than the stack or the battlefield, it ceases to exist.
// These are state-based actions. See rule 704.
if (this.isCopiedSpell() && !zone.equals(Zone.STACK)) {
return true;
}
throw new UnsupportedOperationException("Unsupported operation");
}