use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class HatefulEidolonTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int auraCount = 0;
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (deadCreature.getAttachments().isEmpty()) {
return false;
}
for (UUID auraId : deadCreature.getAttachments()) {
Permanent attachment = game.getPermanentOrLKIBattlefield(auraId);
if (attachment.getControllerId().equals(controllerId) && attachment.isEnchantment(game)) {
// Shadowspear or any other equipment does not count
auraCount += 1;
}
}
if (auraCount == 0) {
// just equipment not aura's
return false;
}
Player controller = game.getPlayer(controllerId);
if (controller != null && controller.canRespond()) {
this.getEffects().clear();
DrawCardTargetEffect drawCard = new DrawCardTargetEffect(auraCount);
drawCard.setTargetPointer(new FixedTarget(controllerId));
this.addEffect(drawCard);
return true;
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class LorcanWarlockCollectorReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent == null) {
return false;
}
Player player = game.getPlayer(permanent.getControllerId());
return player != null && player.moveCards(permanent, Zone.EXILED, source, game);
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class MycoidShepherdTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
MageObject lastKnown = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (lastKnown == null) {
return false;
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent == null) {
return false;
}
if (super.getSourceId().equals(event.getTargetId()) || permanent.getPower().getValue() > 4 && permanent.isControlledBy(controllerId)) {
Zone after = game.getState().getZone(event.getTargetId());
return after != null && Zone.GRAVEYARD.match(after);
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class NissasChosenEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (permanent != null && controller != null) {
controller.moveCardToLibraryWithInfo(permanent, source, game, Zone.BATTLEFIELD, false, true);
return true;
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class PurgatoryReturnEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
if (sourcePermanent != null) {
Player controller = game.getPlayer(sourcePermanent.getControllerId());
if (controller != null) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent != null && zEvent.isDiesEvent() && !(permanent instanceof PermanentToken) && permanent.isCreature(game) && permanent.isOwnedBy(controller.getId())) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game));
return true;
}
}
}
return false;
}
Aggregations