Search in sources :

Example 1 with ZoneChangeEvent

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) UUID(java.util.UUID)

Example 2 with ZoneChangeEvent

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);
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 3 with ZoneChangeEvent

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;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) Zone(mage.constants.Zone) MageObject(mage.MageObject)

Example 4 with ZoneChangeEvent

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;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 5 with ZoneChangeEvent

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken)

Aggregations

ZoneChangeEvent (mage.game.events.ZoneChangeEvent)94 Permanent (mage.game.permanent.Permanent)56 Player (mage.players.Player)27 FixedTarget (mage.target.targetpointer.FixedTarget)23 Card (mage.cards.Card)20 UUID (java.util.UUID)14 MageObject (mage.MageObject)11 MageObjectReference (mage.MageObjectReference)10 Effect (mage.abilities.effects.Effect)9 FilterCard (mage.filter.FilterCard)8 PermanentToken (mage.game.permanent.PermanentToken)8 FilterPermanent (mage.filter.FilterPermanent)7 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)7 Ability (mage.abilities.Ability)6 OneShotEffect (mage.abilities.effects.OneShotEffect)6 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)6 Spell (mage.game.stack.Spell)6 Zone (mage.constants.Zone)5 TargetPermanent (mage.target.TargetPermanent)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5