Search in sources :

Example 6 with ZoneChangeEvent

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

the class SaddledRimestagWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
        ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
        if (zEvent.getToZone() == Zone.BATTLEFIELD && zEvent.getTarget().isCreature(game)) {
            playerMap.putIfAbsent(zEvent.getTarget().getControllerId(), new HashSet<>());
            playerMap.get(zEvent.getTarget().getControllerId()).add(zEvent.getTargetId());
        }
    }
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent)

Example 7 with ZoneChangeEvent

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

the class SporogenesisRemoveCountersEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.isDiesEvent()) {
        Permanent permanent = game.getPermanentOrLKIBattlefield(zEvent.getTargetId());
        if (permanent != null && permanent.isCreature(game) && permanent.getCounters(game).containsKey(CounterType.FUNGUS)) {
            Effect effect = this.getEffects().get(0);
            effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 8 with ZoneChangeEvent

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

the class TheDeckOfManyThingsDelayedTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (!zEvent.isDiesEvent() || !mor.refersTo(zEvent.getTarget(), game)) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(zEvent.getTarget().getOwnerId(), game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent)

Example 9 with ZoneChangeEvent

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

the class TravelingPlagueEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
        Permanent enchantedCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
        Permanent travelingPlague = game.getPermanentOrLKIBattlefield(sourceId);
        if (enchantedCreature != null && enchantedCreature.getAttachments().contains(travelingPlague.getId())) {
            game.getState().setValue("travelingPlague" + sourceId, enchantedCreature);
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent)

Example 10 with ZoneChangeEvent

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

the class ValentinDeanOfTheVeinEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ((ZoneChangeEvent) event).setToZone(Zone.EXILED);
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new DoIfCostPaid(new CreateTokenEffect(new Pest11GainLifeToken()), new GenericManaCost(2)), false, "you may pay {2}. If you do, create a 1/1 black and green " + "Pest creature token with \"When this creature dies, you gain 1 life.\""), source);
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) Pest11GainLifeToken(mage.game.permanent.token.Pest11GainLifeToken) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

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