use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class DiesCreatureTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent() || !filter.match(zEvent.getTarget(), sourceId, controllerId, game)) {
return false;
}
getEffects().setValue("creatureDied", zEvent.getTarget());
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
}
return true;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class BellBorcaSpectralSergeantWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ZONE_CHANGE || ((ZoneChangeEvent) event).getToZone() != Zone.EXILED) {
return;
}
Card card = game.getCard(event.getTargetId());
if (card == null || card.isFaceDown(game)) {
return;
}
int cmc = card.getManaValue();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
if (permanent == null || cmcMap.get(permanent.getId()) != null && cmcMap.get(permanent.getId()) >= cmc) {
continue;
}
cmcMap.put(permanent.getId(), cmc);
}
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class BurnAwayDelayedTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTargetId().equals(getTargets().getFirstTarget())) {
// else spell fizzles because target creature died
this.getTargets().clear();
Target target = new TargetPlayer();
target.add(zEvent.getTarget().getControllerId(), game);
this.addTarget(target);
return true;
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class DraugrNecromancerSpendAnyManaEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || permanent == null || !controller.hasOpponent(permanent.getControllerId(), game)) {
return false;
}
return CardUtil.moveCardWithCounter(game, source, controller, permanent, Zone.EXILED, CounterType.ICE.createInstance());
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class GutterGrimeEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
UUID targetId = event.getTargetId();
MageObject card = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
if (card instanceof Permanent && !(card instanceof PermanentToken)) {
Permanent permanent = (Permanent) card;
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent() && permanent.isControlledBy(this.controllerId) && (targetId.equals(this.getSourceId()) || (permanent.isCreature(game) && !(permanent instanceof PermanentToken)))) {
return true;
}
}
return false;
}
Aggregations