use of mage.game.events.ZoneChangeGroupEvent in project mage by magefree.
the class SefrisOfTheHiddenWaysTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Boolean applies = false;
/*
Sefris of the Hidden Ways must be on the battlefield for its first ability to trigger.
It does not trigger when Sefris goes to the graveyard from the battlefield, even if other
creature cards also went to the graveyard at the same time.
*/
Permanent sourceCard = game.getPermanent(sourceId);
if (((ZoneChangeGroupEvent) event).getToZone() != Zone.GRAVEYARD || sourceCard == null) {
return false;
}
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
Set<Card> cards = zEvent.getCards();
for (Card card : cards) {
if (card.isCreature(game) && // 603.6c, 603.10a, and 603.10.
(Card) sourceCard != card && !card.isCopy() && card.isOwnedBy(controllerId)) {
applies = true;
}
}
return applies;
}
use of mage.game.events.ZoneChangeGroupEvent in project mage by magefree.
the class LaeliaTheBladeReforgedAddCountersTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
final int numberExiled = zEvent.getCards().size();
if (zEvent.getToZone() != Zone.EXILED || numberExiled == 0) {
return false;
}
switch(zEvent.getFromZone()) {
case LIBRARY:
if (zEvent.getCards().stream().filter(Objects::nonNull).map(Card::getOwnerId).anyMatch(this::isControlledBy) && numberExiled > 0) {
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance()));
return true;
}
case GRAVEYARD:
if (zEvent.getCards().stream().filter(Objects::nonNull).map(Card::getOwnerId).anyMatch(this::isControlledBy) && numberExiled > 0) {
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance()));
return true;
}
}
return false;
}
use of mage.game.events.ZoneChangeGroupEvent in project mage by magefree.
the class RakshasaVizierTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
if (zEvent != null && Zone.GRAVEYARD == zEvent.getFromZone() && Zone.EXILED == zEvent.getToZone() && zEvent.getCards() != null) {
int cardCount = 0;
for (Card card : zEvent.getCards()) {
if (card != null && card.isOwnedBy(getControllerId())) {
cardCount++;
}
}
if (cardCount == 0) {
return false;
}
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(cardCount)));
return true;
}
return false;
}
use of mage.game.events.ZoneChangeGroupEvent in project mage by magefree.
the class RanarTheEverWatchfulTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
final int numberExiled = zEvent.getCards().size() + zEvent.getTokens().size();
if (zEvent.getToZone() != Zone.EXILED || numberExiled == 0) {
return false;
}
switch(zEvent.getFromZone()) {
case BATTLEFIELD:
return // source ability/spell that exiled the permanent
zEvent.getSource() != null && controllerId.equals(zEvent.getSource().getControllerId()) && // must include both card permanents and tokens on the battlefield
numberExiled > 0;
case HAND:
return zEvent.getCards().stream().filter(Objects::nonNull).map(Card::getOwnerId).anyMatch(this::isControlledBy);
}
return false;
}
use of mage.game.events.ZoneChangeGroupEvent in project mage by magefree.
the class MysticReflectionGainAbilityEffect method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ZONE_CHANGE_GROUP) {
return;
}
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
if (zEvent.getToZone() != Zone.BATTLEFIELD) {
return;
}
Set<Card> cards = new HashSet<>();
cards.addAll(zEvent.getCards());
cards.addAll(zEvent.getTokens());
if (cards.stream().filter(Objects::nonNull).map(MageItem::getId).map(game::getPermanent).filter(Objects::nonNull).anyMatch(p -> p.isPlaneswalker(game) || p.isCreature(game))) {
enteredThisTurn++;
}
}
Aggregations