use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class BreathlessKnightTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event instanceof EntersTheBattlefieldEvent) {
EntersTheBattlefieldEvent entersEvent = (EntersTheBattlefieldEvent) event;
Permanent permanent = entersEvent.getTarget();
if (permanent != null && permanent.isCreature(game) && permanent.isControlledBy(this.getControllerId())) {
if (entersEvent.getFromZone() == Zone.GRAVEYARD) {
return true;
}
CastFromGraveyardWatcher watcher = game.getState().getWatcher(CastFromGraveyardWatcher.class);
int zcc = game.getState().getZoneChangeCounter(entersEvent.getSourceId());
return watcher != null && watcher.spellWasCastFromGraveyard(entersEvent.getSourceId(), zcc - 1);
}
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class AncientGreenwardenEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!(event instanceof NumberOfTriggersEvent)) {
return false;
}
NumberOfTriggersEvent numberOfTriggersEvent = (NumberOfTriggersEvent) event;
if (!source.isControlledBy(event.getPlayerId())) {
return false;
}
GameEvent sourceEvent = numberOfTriggersEvent.getSourceEvent();
if (sourceEvent == null || sourceEvent.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD || !(sourceEvent instanceof EntersTheBattlefieldEvent) || !((EntersTheBattlefieldEvent) sourceEvent).getTarget().isLand(game)) {
return false;
}
return game.getPermanent(numberOfTriggersEvent.getSourceId()) != null;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class BloodsporeThrinaxEntersBattlefieldEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourceCreature = game.getPermanent(source.getSourceId());
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourceCreature != null && creature != null) {
int amount = sourceCreature.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
creature.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
}
}
return false;
}
Aggregations