use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class StormHeraldAttachableToPredicate method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
Permanent aura = ((ZoneChangeEvent) event).getTarget();
MageObject sourceObject = source.getSourceObject(game);
if (aura != null && sourceObject != null) {
game.informPlayers(aura.getLogName() + "goes to exile instead (" + sourceObject.getLogName() + ")");
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class TheOzolithMoveCountersEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!super.checkTrigger(event, game)) {
return false;
}
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
Counters counters = permanent.getCounters(game);
if (counters.values().stream().mapToInt(Counter::getCount).noneMatch(x -> x > 0)) {
return false;
}
this.getEffects().clear();
this.addEffect(new TheOzolithLeaveEffect(counters));
return true;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class CommanderReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
String originToZone = zEvent.getToZone().toString().toLowerCase(Locale.ENGLISH);
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
Permanent permanent = zEvent.getTarget();
if (permanent != null) {
Player player = game.getPlayer(permanent.getOwnerId());
if (player != null && (forceToMove || player.chooseUse(Outcome.Benefit, "Move " + commanderTypeName + " to command zone instead " + originToZone + "?", source, game))) {
zEvent.setToZone(Zone.COMMAND);
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " has moved their " + commanderTypeName + " to the command zone instead " + originToZone);
}
}
}
} else {
Card card = null;
if (zEvent.getFromZone() == Zone.STACK) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null) {
card = game.getCard(spell.getSourceId());
}
}
if (card == null) {
card = game.getCard(event.getTargetId());
}
if (card != null) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null && (forceToMove || player.chooseUse(Outcome.Benefit, "Move " + commanderTypeName + " to command zone instead " + originToZone + "?", source, game))) {
((ZoneChangeEvent) event).setToZone(Zone.COMMAND);
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " has moved their " + commanderTypeName + " to the command zone instead " + originToZone);
}
}
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class DauthiVoidwalkerPlayEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
Card card = ((ZoneChangeEvent) event).getTarget();
if (card == null) {
card = game.getCard(event.getTargetId());
}
if (controller == null || card == null) {
return false;
}
CardUtil.moveCardWithCounter(game, source, controller, card, Zone.EXILED, CounterType.VOID.createInstance());
return true;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class AthreosShroudVeiledEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent == null || !permanent.isCreature(game) || !permanent.getCounters(game).containsKey(CounterType.COIN)) {
return false;
}
this.getEffects().clear();
this.addEffect(new AthreosShroudVeiledEffect(new MageObjectReference(zEvent.getTarget(), game)));
return true;
}
Aggregations