Search in sources :

Example 31 with ZoneChangeEvent

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

the class UginTheIneffableLookAtFaceDownEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = ((ZoneChangeEvent) event);
    if (zEvent.getToZone() == Zone.BATTLEFIELD || tokenRefs.stream().noneMatch(tokenRef -> tokenRef.refersTo(zEvent.getTarget(), game))) {
        return false;
    }
    this.getEffects().clear();
    Effect effect = new ReturnToHandTargetEffect();
    effect.setTargetPointer(new FixedTarget(cardRef));
    this.addEffect(effect);
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) UginTheIneffableToken(mage.game.permanent.token.UginTheIneffableToken) MageObjectReference(mage.MageObjectReference) Predicates(mage.filter.predicate.Predicates) FilterPermanent(mage.filter.FilterPermanent) Player(mage.players.Player) FixedTarget(mage.target.targetpointer.FixedTarget) HashSet(java.util.HashSet) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) MageObject(mage.MageObject) Card(mage.cards.Card) mage.constants(mage.constants) FilterCard(mage.filter.FilterCard) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) Set(java.util.Set) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) UUID(java.util.UUID) LoyaltyAbility(mage.abilities.LoyaltyAbility) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) AsThoughEffectImpl(mage.abilities.effects.AsThoughEffectImpl) Effect(mage.abilities.effects.Effect) GameEvent(mage.game.events.GameEvent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) InfoEffect(mage.abilities.effects.common.InfoEffect) CardImpl(mage.cards.CardImpl) SpellsCostReductionControllerEffect(mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ColorlessPredicate(mage.filter.predicate.mageobject.ColorlessPredicate) Benefit(mage.constants.Outcome.Benefit) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) Ability(mage.abilities.Ability) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) InfoEffect(mage.abilities.effects.common.InfoEffect) SpellsCostReductionControllerEffect(mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

Example 32 with ZoneChangeEvent

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

the class CalixDestinysHandReturnEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getFromZone() != Zone.BATTLEFIELD || !this.myMor.refersTo(zEvent.getTarget(), game)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false).setTargetPointer(new FixedTarget(this.theirMor)));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)

Example 33 with ZoneChangeEvent

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

the class GrolnokTheOmnivorePlayEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    Card card = game.getCard(zEvent.getTargetId());
    if (card != null && zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getFromZone() == Zone.LIBRARY && card.isOwnedBy(controllerId) && card.isPermanent(game)) {
        getEffects().setTargetPointer(new FixedTarget(card, game));
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Card(mage.cards.Card)

Example 34 with ZoneChangeEvent

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

the class MagusOfTheBridgeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.isDiesEvent()) {
        Permanent permanent = zEvent.getTarget();
        Player controller = game.getPlayer(getControllerId());
        return permanent != null && controller != null && permanent.isCreature(game) && controller.hasOpponent(permanent.getOwnerId(), game);
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

Example 35 with ZoneChangeEvent

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

the class PlanarVoidTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getToZone() != Zone.GRAVEYARD || event.getTargetId().equals(getSourceId())) {
        return false;
    }
    this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent)

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