Search in sources :

Example 1 with ReturnToHandTargetEffect

use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.

the class InameLifeAspectEffect 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 (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit cards?", source, game)) {
            Effect effect = new ReturnToHandTargetEffect();
            effect.setTargetPointer(getTargetPointer());
            effect.getTargetPointer().init(game, source);
            new ExileSourceEffect().apply(game, source);
            return effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) Player(mage.players.Player) MageObject(mage.MageObject) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

Example 2 with ReturnToHandTargetEffect

use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.

the class GreasefangOkibaBossEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (controller == null || card == null || game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
        return false;
    }
    controller.moveCards(card, Zone.BATTLEFIELD, source, game);
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent != null) {
        ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
        hasteEffect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(hasteEffect, source);
        Effect bounceEffect = new ReturnToHandTargetEffect().setText("return it to your hand");
        bounceEffect.setTargetPointer(new FixedTarget(permanent, game));
        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(bounceEffect), source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 3 with ReturnToHandTargetEffect

use of mage.abilities.effects.common.ReturnToHandTargetEffect 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 4 with ReturnToHandTargetEffect

use of mage.abilities.effects.common.ReturnToHandTargetEffect 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 5 with ReturnToHandTargetEffect

use of mage.abilities.effects.common.ReturnToHandTargetEffect 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)

Aggregations

ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)26 FixedTarget (mage.target.targetpointer.FixedTarget)21 Effect (mage.abilities.effects.Effect)19 OneShotEffect (mage.abilities.effects.OneShotEffect)18 Player (mage.players.Player)15 Permanent (mage.game.permanent.Permanent)14 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)13 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)9 Card (mage.cards.Card)9 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)6 FilterCard (mage.filter.FilterCard)5 TargetPermanent (mage.target.TargetPermanent)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)4 TargetCardInHand (mage.target.common.TargetCardInHand)4 UUID (java.util.UUID)3 Cost (mage.abilities.costs.Cost)3 ArrayList (java.util.ArrayList)2 MageObject (mage.MageObject)2 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)2