use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class LuminousBroodmothEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getTarget() == null || zEvent.getTarget().getId().equals(this.getSourceId())) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(zEvent.getTarget().getId());
if (permanent != null && zEvent.isDiesEvent() && permanent.isCreature(game) && !permanent.getAbilities().containsKey(FlyingAbility.getInstance().getId()) && permanent.isControlledBy(this.controllerId)) {
this.getEffects().setTargetPointer(new FixedTarget(zEvent.getTargetId()));
return true;
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class ShrivelingRotEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent()) {
if (zEvent.getTarget().isCreature(game)) {
Effect effect = this.getEffects().get(0);
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
return true;
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class WookieeMysticWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.MANA_PAID) {
MageObject target = game.getObject(event.getTargetId());
if (event.getSourceId() != null && event.getSourceId().equals(this.getSourceId()) && target != null && target.isCreature(game) && event.getFlag()) {
if (target instanceof Spell) {
this.creatures.add(((Spell) target).getCard().getId());
}
}
}
if (event.getType() == GameEvent.EventType.COUNTERED) {
if (creatures.contains(event.getTargetId())) {
creatures.remove(event.getSourceId());
}
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
if (creatures.contains(event.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
// spell was e.g. exiled and goes again to stack, so previous cast has not resolved.
if (zEvent.getToZone() == Zone.STACK) {
creatures.remove(event.getSourceId());
}
}
}
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
if (creatures.contains(event.getSourceId())) {
Permanent creature = game.getPermanent(event.getSourceId());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
creatures.remove(event.getSourceId());
}
}
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class LeavesBattlefieldAllTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer != SetTargetPointer.NONE) {
for (Effect effect : this.getEffects()) {
switch(setTargetPointer) {
case PERMANENT:
effect.setTargetPointer(new FixedTarget(permanent, game));
break;
case PLAYER:
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
break;
}
}
}
return true;
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class DiesSourceTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent() || !event.getTargetId().equals(getSourceId())) {
return false;
}
getEffects().setValue("permanentLeftBattlefield", zEvent.getTarget());
return true;
}
Aggregations