Search in sources :

Example 56 with Effect

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

the class BerserkDelayedDestroyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        // create delayed triggered ability
        Effect effect = new BerserkDelayedDestroyEffect();
        effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source), game));
        AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect)

Example 57 with Effect

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

the class BroodOfCockroachesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedLifeLost = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1));
    game.addDelayedTriggeredAbility(delayedLifeLost, source);
    Effect effect = new ReturnToHandTargetEffect();
    effect.setText("return {this} to your hand.");
    effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect)

Example 58 with Effect

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

the class DermoplasmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent thisCreature = game.getPermanent(source.getId());
    FilterCreatureCard filter = new FilterCreatureCard("a creature card with a morph ability");
    filter.add(new AbilityPredicate(MorphAbility.class));
    Effect effect = new PutCardFromHandOntoBattlefieldEffect(filter);
    if (effect.apply(game, source)) {
        if (thisCreature != null) {
            effect = new ReturnToHandTargetEffect();
            effect.setTargetPointer(new FixedTarget(thisCreature.getId(), game));
            effect.apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreatureCard(mage.filter.common.FilterCreatureCard) MorphAbility(mage.abilities.keyword.MorphAbility) Permanent(mage.game.permanent.Permanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) AbilityPredicate(mage.filter.predicate.mageobject.AbilityPredicate)

Example 59 with Effect

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

the class ExplosionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    Effect effect = new DamageTargetEffect(StaticValue.get(xValue), true, "", true);
    effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
    effect.apply(game, source);
    Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
    if (player != null) {
        player.drawCards(xValue, source, game);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) CopyTargetSpellEffect(mage.abilities.effects.common.CopyTargetSpellEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 60 with Effect

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

the class GalepowderMageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        if (getTargetPointer().getFirst(game, source) != null) {
            Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
            if (permanent != null) {
                UUID exileId = UUID.randomUUID();
                if (controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
                    Card card = game.getCard(getTargetPointer().getFirst(game, source));
                    if (card != null) {
                        Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
                        effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
                        AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
                        game.addDelayedTriggeredAbility(delayedAbility, 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) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) Card(mage.cards.Card)

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