Search in sources :

Example 56 with ContinuousEffect

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

the class EwokAmbushCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new EwokToken(), 2);
        effect.apply(game, source);
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent token = game.getPermanent(tokenId);
            if (token != null) {
                ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                continuousEffect.setTargetPointer(new FixedTarget(tokenId));
                game.addEffect(continuousEffect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : EwokToken(mage.game.permanent.token.EwokToken) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 57 with ContinuousEffect

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

the class FinaleOfDevastationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    if (xValue >= 10) {
        ContinuousEffect effect1 = new BoostControlledEffect(xValue, xValue, Duration.EndOfTurn);
        game.addEffect(effect1, source);
        ContinuousEffect effect2 = new GainAbilityControlledEffect(HasteAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent());
        game.addEffect(effect2, source);
    }
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostControlledEffect(mage.abilities.effects.common.continuous.BoostControlledEffect)

Example 58 with ContinuousEffect

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

the class FumbleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget());
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || permanent == null) {
        return false;
    }
    List<Permanent> attachments = new ArrayList<>();
    for (UUID permId : permanent.getAttachments()) {
        Permanent attachment = game.getPermanent(permId);
        if (attachment != null) {
            if (attachment.hasSubtype(SubType.AURA, game) || attachment.hasSubtype(SubType.EQUIPMENT, game)) {
                attachments.add(attachment);
            }
        }
    }
    new ReturnToHandTargetEffect().apply(game, source);
    if (!attachments.isEmpty()) {
        Target target = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true);
        Permanent newCreature = null;
        if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
            newCreature = game.getPermanent(target.getFirstTarget());
        }
        for (Permanent attachment : attachments) {
            if (!attachment.hasSubtype(SubType.AURA, game) && !attachment.hasSubtype(SubType.EQUIPMENT, game)) {
                continue;
            }
            ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, player.getId());
            effect.setTargetPointer(new FixedTarget(attachment, game));
            game.addEffect(effect, source);
            if (newCreature != null) {
                attachment.attachTo(newCreature.getId(), source, game);
            }
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ArrayList(java.util.ArrayList) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 59 with ContinuousEffect

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

the class FruitcakeElementalControlSourceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player != null && permanent != null) {
        ContinuousEffect effect = new FruitcakeElementalControlSourceEffect();
        game.addEffect(effect, source);
        game.informPlayers(permanent.getName() + " is now controlled by " + player.getLogName());
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) Permanent(mage.game.permanent.Permanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 60 with ContinuousEffect

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

the class GoblinDarkDwellersReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
        if (card != null) {
            if (controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getLogName() + '?', source, game)) {
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
                if (cardWasCast) {
                    ContinuousEffect effect = new GoblinDarkDwellersReplacementEffect(card.getId());
                    effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
                    game.addEffect(effect, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) Card(mage.cards.Card)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)322 FixedTarget (mage.target.targetpointer.FixedTarget)245 Player (mage.players.Player)225 Permanent (mage.game.permanent.Permanent)202 Card (mage.cards.Card)97 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)76 UUID (java.util.UUID)65 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)55 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)50 MageObject (mage.MageObject)47 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)43 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)37 FilterCard (mage.filter.FilterCard)34 TargetPermanent (mage.target.TargetPermanent)33 Effect (mage.abilities.effects.Effect)32 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)31 OneShotEffect (mage.abilities.effects.OneShotEffect)30 Target (mage.target.Target)30 FilterPermanent (mage.filter.FilterPermanent)24 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)23