use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class HauntEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
switch(event.getType()) {
case ENTERS_THE_BATTLEFIELD:
return game.getState().getZone(getSourceId()) == Zone.BATTLEFIELD && event.getTargetId().equals(getSourceId());
case ZONE_CHANGE:
if (usedFromExile || game.getState().getZone(getSourceId()) != Zone.EXILED) {
return false;
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
Card card = game.getCard(getSourceId());
if (card == null || game.getCard(event.getTargetId()) == null) {
return false;
}
String key = new StringBuilder("Haunting_").append(getSourceId().toString()).append(card.getZoneChangeCounter(game) + (game.getPermanentOrLKIBattlefield(event.getTargetId())).getZoneChangeCounter(game)).toString();
Object object = game.getState().getValue(key);
if (!(object instanceof FixedTarget)) {
return false;
}
FixedTarget target = (FixedTarget) object;
if (target.getTarget() != null && target.getTarget().equals(event.getTargetId())) {
usedFromExile = true;
return true;
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class ColfenorTheLastYewTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!super.checkTrigger(event, game)) {
return false;
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent == null) {
return false;
}
FilterCard filterCard = new FilterCreatureCard("creature card with toughness less than " + permanent.getToughness().getValue());
filterCard.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, permanent.getToughness().getValue()));
filterCard.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(permanent, game))));
this.getTargets().clear();
this.addTarget(new TargetCardInYourGraveyard(0, 1, filterCard));
return true;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class DarigaazReincarnatedReturnEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (permanent == null || controller == null) {
return false;
}
return CardUtil.moveCardWithCounter(game, source, controller, permanent, Zone.EXILED, CounterType.EGG.createInstance(3));
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class ErebossTitanTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone() == Zone.GRAVEYARD) {
Card card = game.getCard(zEvent.getTargetId());
Player controller = game.getPlayer(getControllerId());
return card != null && card.isCreature(game) && controller != null && controller.hasOpponent(card.getOwnerId(), game);
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class GisaGloriousResurrectorReturnEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getTarget() instanceof PermanentToken) {
return player.moveCards(zEvent.getTarget(), Zone.EXILED, source, game);
}
game.getState().setValue("GisaGloriousResurrectorExile" + source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()), source);
return player.moveCardsToExile(zEvent.getTarget(), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
}
Aggregations