mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 06:22:01 -08:00
* Commander - Fixed that the commander replacement effect did not work if the commander spell on the stack was exiled.
This commit is contained in:
parent
898f111533
commit
100decf7ce
3 changed files with 55 additions and 23 deletions
|
|
@ -38,6 +38,7 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
|
@ -88,13 +89,21 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
Card card = null;
|
||||
if (((ZoneChangeEvent)event).getFromZone().equals(Zone.STACK)) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null) {
|
||||
card = game.getCard(spell.getSourceId());
|
||||
}
|
||||
} else {
|
||||
card = game.getCard(event.getTargetId());
|
||||
}
|
||||
|
||||
if (card != null) {
|
||||
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", game)){
|
||||
boolean result = card.moveToZone(Zone.COMMAND, source.getSourceId(), game, false);
|
||||
return result;
|
||||
game.informPlayers(player.getName() + " moved his commander to the command zone instead");
|
||||
return card.moveToZone(Zone.COMMAND, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -104,8 +113,18 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD || ((ZoneChangeEvent)event).getToZone() == Zone.EXILED)) {
|
||||
if(commanderId != null && commanderId.equals(event.getTargetId())){
|
||||
return true;
|
||||
if (commanderId != null) {
|
||||
if (((ZoneChangeEvent)event).getFromZone().equals(Zone.STACK)) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null) {
|
||||
if (commanderId.equals(spell.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(commanderId.equals(event.getTargetId())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.watchers.Watcher;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -325,6 +326,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
game.getState().getCommand().remove((Commander)game.getObject(objectId));
|
||||
break;
|
||||
case STACK:
|
||||
StackObject stackObject = game.getStack().getStackObject(getId());
|
||||
if (stackObject != null) {
|
||||
game.getStack().remove(stackObject);
|
||||
}
|
||||
break;
|
||||
case PICK:
|
||||
case BATTLEFIELD: // for sacrificing permanents
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue