use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class RavenousSlimeEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() != Zone.GRAVEYARD) {
return false;
}
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent == null || !game.getOpponents(source.getControllerId()).contains(permanent.getControllerId())) {
return false;
}
if (zEvent.getTarget() != null) {
// if it comes from permanent, check if it was a creature on the battlefield
return zEvent.getTarget().isCreature(game);
} else
return permanent.isCreature(game);
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class RavenousSlimeEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (controller == null || sourceCreature == null) {
return false;
}
if (((ZoneChangeEvent) event).getFromZone() != Zone.BATTLEFIELD) {
return false;
}
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent == null) {
return false;
}
int power = permanent.getPower().getValue();
controller.moveCards(permanent, Zone.EXILED, source, game);
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(power)).apply(game, source);
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class TheUpsideDownLeavesAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Set<MageObjectReference> morSet = (Set<MageObjectReference>) game.getState().getValue(TheUpsideDown.makeKey(this, game));
return morSet != null && !morSet.isEmpty() && morSet.stream().anyMatch(mor -> mor.refersTo(zEvent.getTarget(), game));
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class ViridianRevelTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((ZoneChangeEvent) event).isDiesEvent()) {
Card card = game.getPermanentOrLKIBattlefield(event.getTargetId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && card != null && card.isArtifact(game) && controller.hasOpponent(card.getOwnerId(), game)) {
return true;
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class CosmicInterventionReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
ZoneChangeEvent zoneChangeEvent = (ZoneChangeEvent) event;
if (zoneChangeEvent.isDiesEvent()) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null || controller == null || permanent.getControllerId() == controller.getId()) {
return true;
}
}
return false;
}
Aggregations