Search in sources :

Example 36 with ZoneChangeEvent

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

the class RavenousSlimeEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getToZone() != Zone.GRAVEYARD) {
        return false;
    }
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    if (permanent == null || !game.getOpponents(source.getControllerId()).contains(permanent.getControllerId())) {
        return false;
    }
    if (zEvent.getTarget() != null) {
        // if it comes from permanent, check if it was a creature on the battlefield
        return zEvent.getTarget().isCreature(game);
    } else
        return permanent.isCreature(game);
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent)

Example 37 with ZoneChangeEvent

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

the class RavenousSlimeEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourceCreature = game.getPermanent(source.getSourceId());
    if (controller == null || sourceCreature == null) {
        return false;
    }
    if (((ZoneChangeEvent) event).getFromZone() != Zone.BATTLEFIELD) {
        return false;
    }
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    if (permanent == null) {
        return false;
    }
    int power = permanent.getPower().getValue();
    controller.moveCards(permanent, Zone.EXILED, source, game);
    return new AddCountersSourceEffect(CounterType.P1P1.createInstance(power)).apply(game, source);
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 38 with ZoneChangeEvent

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

the class TheUpsideDownLeavesAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    Set<MageObjectReference> morSet = (Set<MageObjectReference>) game.getState().getValue(TheUpsideDown.makeKey(this, game));
    return morSet != null && !morSet.isEmpty() && morSet.stream().anyMatch(mor -> mor.refersTo(zEvent.getTarget(), game));
}
Also used : BlackManaAbility(mage.abilities.mana.BlackManaAbility) StaticFilters(mage.filter.StaticFilters) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Zone(mage.constants.Zone) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Outcome(mage.constants.Outcome) Set(java.util.Set) MageObjectReference(mage.MageObjectReference) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) HashSet(java.util.HashSet) TriggeredAbilityImpl(mage.abilities.TriggeredAbilityImpl) Game(mage.game.Game) GameEvent(mage.game.events.GameEvent) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) Card(mage.cards.Card) SuperType(mage.constants.SuperType) Ability(mage.abilities.Ability) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Set(java.util.Set) HashSet(java.util.HashSet) MageObjectReference(mage.MageObjectReference)

Example 39 with ZoneChangeEvent

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

the class ViridianRevelTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((ZoneChangeEvent) event).isDiesEvent()) {
        Card card = game.getPermanentOrLKIBattlefield(event.getTargetId());
        Player controller = game.getPlayer(getControllerId());
        if (controller != null && card != null && card.isArtifact(game) && controller.hasOpponent(card.getOwnerId(), game)) {
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Card(mage.cards.Card)

Example 40 with ZoneChangeEvent

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

the class CosmicInterventionReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    ZoneChangeEvent zoneChangeEvent = (ZoneChangeEvent) event;
    if (zoneChangeEvent.isDiesEvent()) {
        Player controller = game.getPlayer(source.getControllerId());
        Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
        if (permanent == null || controller == null || permanent.getControllerId() == controller.getId()) {
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

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