Search in sources :

Example 41 with ZoneChangeEvent

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

the class DeathsOasisEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!super.checkTrigger(event, game)) {
        return false;
    }
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getTarget() == null) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new MillCardsControllerEffect(2));
    this.addEffect(new DeathsOasisEffect(zEvent.getTarget().getManaValue()));
    return true;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) MillCardsControllerEffect(mage.abilities.effects.common.MillCardsControllerEffect)

Example 42 with ZoneChangeEvent

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

the class DiabolicServitudeSourceLeftBattlefieldEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((ZoneChangeEvent) event).isDiesEvent()) {
        ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
        Object object = game.getState().getValue(getSourceId().toString() + "returnedCreature");
        if ((object instanceof MageObjectReference) && ((MageObjectReference) object).refersTo(zEvent.getTarget(), game)) {
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) MageObjectReference(mage.MageObjectReference)

Example 43 with ZoneChangeEvent

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

the class CardPutIntoOpponentGraveThisTurn method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    UUID cardId = event.getTargetId();
    Card card = game.getCard(cardId);
    if (card != null && zEvent.getToZone() == Zone.GRAVEYARD && !card.isCopy() && game.getOpponents(controllerId).contains(card.getOwnerId())) {
        for (Effect effect : this.getEffects()) {
            effect.setTargetPointer(new FixedTarget(card.getOwnerId()));
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) LoseLifeTargetEffect(mage.abilities.effects.common.LoseLifeTargetEffect) PutLibraryIntoGraveTargetEffect(mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect) Effect(mage.abilities.effects.Effect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) UUID(java.util.UUID) Card(mage.cards.Card)

Example 44 with ZoneChangeEvent

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

the class GraveBetrayalReplacementEffect 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)) {
            Card card = (Card) game.getObject(permanent.getId());
            if (card != null) {
                Effect effect = new GraveBetrayalEffect();
                effect.setTargetPointer(new FixedTarget(card, game));
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
                game.addDelayedTriggeredAbility(delayedAbility, this);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) Effect(mage.abilities.effects.Effect) Card(mage.cards.Card)

Example 45 with ZoneChangeEvent

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

the class OrahSkyclaveHierophantTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (!zEvent.isDiesEvent() || !zEvent.getTarget().isControlledBy(getControllerId()) || (!zEvent.getTarget().hasSubtype(SubType.CLERIC, game) && !zEvent.getTarget().getId().equals(getSourceId()))) {
        return false;
    }
    FilterCard filterCard = new FilterCard("Cleric card with mana value less than " + (zEvent.getTarget().getManaValue()));
    filterCard.add(SubType.CLERIC.getPredicate());
    filterCard.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, zEvent.getTarget().getManaValue()));
    this.getTargets().clear();
    this.addTarget(new TargetCardInYourGraveyard(filterCard));
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

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