Search in sources :

Example 71 with ZoneChangeEvent

use of mage.game.events.ZoneChangeEvent in project mage by magefree.

the class DiesReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && permanent != null) {
        return controller.moveCards(permanent, Zone.EXILED, source, game);
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 72 with ZoneChangeEvent

use of mage.game.events.ZoneChangeEvent in project mage by magefree.

the class KothophedSoulHoarderTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getFromZone() == Zone.BATTLEFIELD) {
        Card card = game.getCard(zEvent.getTargetId());
        Player controller = game.getPlayer(getControllerId());
        return card != null && controller != null && controller.hasOpponent(card.getOwnerId(), game);
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Card(mage.cards.Card)

Example 73 with ZoneChangeEvent

use of mage.game.events.ZoneChangeEvent in project mage by magefree.

the class MillicentRestlessRevenantTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent permanent;
    switch(event.getType()) {
        case ZONE_CHANGE:
            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            if (!zEvent.isDiesEvent()) {
                return false;
            }
            permanent = zEvent.getTarget();
            break;
        case DAMAGED_PLAYER:
            if (!((DamagedEvent) event).isCombatDamage()) {
                return false;
            }
            permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
            break;
        default:
            return false;
    }
    if (permanent == null) {
        return false;
    }
    return permanent.getId().equals(this.getSourceId()) || (!(permanent instanceof PermanentToken) && permanent.hasSubtype(SubType.SPIRIT, game));
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken)

Example 74 with ZoneChangeEvent

use of mage.game.events.ZoneChangeEvent in project mage by magefree.

the class ProperBurialTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zoneChangeEvent = (ZoneChangeEvent) event;
    if (zoneChangeEvent.isDiesEvent()) {
        Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
        if (permanent != null && permanent.isControlledBy(this.getControllerId()) && permanent.isCreature(game)) {
            this.getEffects().clear();
            this.addEffect(new GainLifeEffect(permanent.getToughness().getValue()));
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 75 with ZoneChangeEvent

use of mage.game.events.ZoneChangeEvent in project mage by magefree.

the class SanctifierEnVecEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getToZone() == Zone.GRAVEYARD) {
        Permanent permanent = zEvent.getTarget();
        if (permanent != null) {
            return permanent.getColor(game).contains(ObjectColor.BLACK) || permanent.getColor(game).contains(ObjectColor.RED);
        }
        Card card = game.getCard(zEvent.getTargetId());
        if (card != null) {
            return card.getColor(game).contains(ObjectColor.BLACK) || card.getColor(game).contains(ObjectColor.RED);
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

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