use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class UnscytheEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((ZoneChangeEvent) event).isDiesEvent()) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getTarget().isCreature(game)) {
// target token can't create Zombie
Permanent equipment = game.getPermanent(getSourceId());
// the currently equiped creature must have done damage to the dying creature
if (equipment != null && equipment.getAttachedTo() != null) {
boolean damageDealt = false;
for (MageObjectReference mor : zEvent.getTarget().getDealtDamageByThisTurn()) {
if (mor.refersTo(equipment.getAttachedTo(), game)) {
damageDealt = true;
break;
}
}
if (damageDealt) {
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 UnquenchableFuryTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
return permanent != null && zEvent.isDiesEvent() && permanent.getId().equals(this.getSourceId()) && permanent.isOwnedBy(permanent.getControllerId());
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class VoidMawCost method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent != null) {
UUID exileZoneId = CardUtil.getCardExileZoneId(game, source);
if (controller.moveCardsToExile(permanent, source, game, false, exileZoneId, sourceObject.getIdName())) {
return true;
}
}
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class HallOfTheBanditLordWatcher 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())) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
game.addEffect(effect, source);
creatures.remove(event.getSourceId());
}
}
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class MimicVatCreateTokenEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
// make sure card is on battlefield
UUID sourceCardId = getSourceId();
if (game.getPermanent(sourceCardId) == null) {
// or it is being removed
if (game.getLastKnownInformation(sourceCardId, Zone.BATTLEFIELD) == null) {
return false;
}
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent != null && zEvent.isDiesEvent() && !(permanent instanceof PermanentToken) && permanent.isCreature(game)) {
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId(), game));
return true;
}
return false;
}
Aggregations