use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class CardsPutIntoGraveyardWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ZONE_CHANGE || ((ZoneChangeEvent) event).getToZone() != Zone.GRAVEYARD) {
return;
}
UUID playerId = event.getPlayerId();
if (playerId == null || game.getCard(event.getTargetId()) == null) {
return;
}
amountOfCardsThisTurn.compute(playerId, (k, amount) -> amount == null ? 1 : Integer.sum(amount, 1));
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
cardsPutIntoGraveyardFromBattlefield.add(new MageObjectReference(((ZoneChangeEvent) event).getTarget(), game, 1));
} else {
cardsPutIntoGraveyardFromEverywhereElse.add(new MageObjectReference(((ZoneChangeEvent) event).getTarget(), game, 1));
}
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class CreaturesDiedWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTarget().isCreature(game)) {
int amount = getAmountOfCreaturesDiedThisTurnByController(zEvent.getTarget().getControllerId());
amountOfCreaturesThatDiedByController.put(zEvent.getTarget().getControllerId(), amount + 1);
amount = getAmountOfCreaturesDiedThisTurnByOwner(zEvent.getTarget().getOwnerId());
amountOfCreaturesThatDiedByOwner.put(zEvent.getTarget().getOwnerId(), amount + 1);
}
}
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class EnigmaSphinxEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent != null && zEvent.isDiesEvent() && permanent.getId().equals(this.getSourceId()) && // graveyard from the battlefield, so Enigma Sphinx's middle ability won't trigger.
permanent.isOwnedBy(permanent.getControllerId())) {
return true;
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class FalkenrathNobleTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (permanent == null) {
return false;
}
if (permanent.getId().equals(this.getSourceId())) {
return true;
}
return permanent.isCreature(game);
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class FlayingTendrilsReplacementEffect 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) {
return controller.moveCards(permanent, Zone.EXILED, source, game);
}
return false;
}
Aggregations