Search in sources :

Example 86 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class ExtraplanarLensTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    // need only info about permanent
    Permanent landTappedForMana = ((TappedForManaEvent) event).getPermanent();
    Permanent extraplanarLens = game.getPermanent(getSourceId());
    if (extraplanarLens != null && landTappedForMana != null && !extraplanarLens.getImprinted().isEmpty()) {
        Card imprinted = game.getCard(extraplanarLens.getImprinted().get(0));
        if (imprinted != null && game.getState().getZone(imprinted.getId()) == Zone.EXILED) {
            if (landTappedForMana.getName().equals(imprinted.getName()) && landTappedForMana.isLand(game)) {
                ManaEvent mEvent = (ManaEvent) event;
                for (Effect effect : getEffects()) {
                    effect.setValue("mana", mEvent.getMana());
                    effect.setValue("tappedPermanent", landTappedForMana);
                }
                getEffects().get(0).setTargetPointer(new FixedTarget(landTappedForMana.getId()));
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AddManaOfAnyTypeProducedEffect(mage.abilities.effects.mana.AddManaOfAnyTypeProducedEffect) ManaEvent(mage.game.events.ManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent) Card(mage.cards.Card)

Example 87 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class HarshJusticeEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player controller = game.getPlayer(this.getControllerId());
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent damagePermanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
    if (controller != null && damagePermanent != null) {
        if (damageEvent.isCombatDamage() && controller.getId().equals(damageEvent.getTargetId()) && filter.match(damagePermanent, game)) {
            for (Effect effect : this.getEffects()) {
                effect.setValue("damage", damageEvent.getAmount());
                effect.setValue("sourceId", damageEvent.getSourceId());
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 88 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class KillerInstinctEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Library library = player.getLibrary();
    if (library == null || !library.hasCards()) {
        return false;
    }
    Card card = library.getFromTop(game);
    if (card == null) {
        return false;
    }
    player.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
    if (card.isCreature(game) && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        Permanent permanent = game.getPermanent(card.getId());
        if (permanent != null) {
            FixedTarget ft = new FixedTarget(permanent, game);
            ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
            effect.setTargetPointer(ft);
            game.addEffect(effect, source);
            Effect sacrificeEffect = new SacrificeTargetEffect("Sacrifice it at the beginning of the next end step", source.getControllerId());
            sacrificeEffect.setTargetPointer(ft);
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) Library(mage.players.Library) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 89 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class MarkOfSakikoTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedEvent) event).isCombatDamage()) {
        if (event.getSourceId().equals(getSourceId())) {
            this.getEffects().clear();
            Effect effect = new AddManaToManaPoolTargetControllerEffect(Mana.GreenMana(event.getAmount()), "that player", true);
            effect.setTargetPointer(new FixedTarget(getControllerId()));
            effect.setText("add that much {G}. Until end of turn, you don't lose this mana as steps and phases end");
            this.addEffect(effect);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) DamagedEvent(mage.game.events.DamagedEvent) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) GainAbilityAttachedEffect(mage.abilities.effects.common.continuous.GainAbilityAttachedEffect)

Example 90 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class MindWhipEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controllerOfEnchantedCreature = game.getPlayer(targetPointer.getFirst(game, source));
    Permanent mindWhip = game.getPermanent(source.getSourceId());
    if (controllerOfEnchantedCreature != null && mindWhip != null) {
        Permanent enchantedCreature = game.getPermanent(mindWhip.getAttachedTo());
        if (enchantedCreature != null) {
            Effect effect = new DamageTargetEffect(2);
            effect.setTargetPointer(new FixedTarget(controllerOfEnchantedCreature.getId()));
            effect.apply(game, source);
            enchantedCreature.tap(source, game);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) DoUnlessTargetPlayerOrTargetsControllerPaysEffect(mage.abilities.effects.common.DoUnlessTargetPlayerOrTargetsControllerPaysEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Aggregations

Effect (mage.abilities.effects.Effect)328 OneShotEffect (mage.abilities.effects.OneShotEffect)254 FixedTarget (mage.target.targetpointer.FixedTarget)224 Permanent (mage.game.permanent.Permanent)180 Player (mage.players.Player)167 UUID (java.util.UUID)75 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)60 Card (mage.cards.Card)57 MageObject (mage.MageObject)41 ContinuousEffect (mage.abilities.effects.ContinuousEffect)40 TargetPermanent (mage.target.TargetPermanent)39 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)38 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)38 FilterPermanent (mage.filter.FilterPermanent)29 ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)28 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)27 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)25 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)24 AttachEffect (mage.abilities.effects.common.AttachEffect)23 Target (mage.target.Target)22