Search in sources :

Example 1 with ReturnToHandSourceEffect

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

the class RecoverEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card sourceCard = game.getCard(source.getSourceId());
    if (controller != null && sourceCard != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
        if (controller.chooseUse(Outcome.Damage, "Pay " + cost.getText() + " to recover " + sourceCard.getLogName() + "? (Otherwise the card will be exiled)", source, game)) {
            cost.clearPaid();
            if (cost.pay(source, game, source, controller.getId(), false, null)) {
                return new ReturnToHandSourceEffect().apply(game, source);
            }
        }
        return new ExileSourceEffect().apply(game, source);
    }
    return false;
}
Also used : ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) Player(mage.players.Player) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Card(mage.cards.Card)

Example 2 with ReturnToHandSourceEffect

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

the class MetathranAerostatEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    FilterCreatureCard filter = new FilterCreatureCard("a creature with mana value " + xValue);
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
    if (new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source)) {
        return new ReturnToHandSourceEffect(true).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect)

Example 3 with ReturnToHandSourceEffect

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

the class ViashinoSandswimmerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        if (controller.flipCoin(source, game, true)) {
            new ReturnToHandSourceEffect().apply(game, source);
            return true;
        } else {
            new SacrificeSourceEffect().apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Permanent(mage.game.permanent.Permanent) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect)

Example 4 with ReturnToHandSourceEffect

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

the class SakashimaTheImpostorCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    blueprint.addSuperType(SuperType.LEGENDARY);
    blueprint.setName("Sakashima the Impostor");
    // {2}{U}{U}: Return Sakashima the Impostor to its owner's hand at the beginning of the next end step
    blueprint.getAbilities().add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToHandSourceEffect(true)), false), new ManaCostsImpl("{2}{U}{U}")));
    return true;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 5 with ReturnToHandSourceEffect

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

the class AethermagesTouchEffect 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) {
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
        if (!cards.isEmpty()) {
            FilterCreatureCard filter = new FilterCreatureCard("a creature card to put onto the battlefield");
            controller.revealCards(sourceObject.getIdName(), cards, game);
            TargetCard target = new TargetCard(Zone.LIBRARY, filter);
            if (cards.count(filter, game) > 0 && controller.choose(outcome, cards, target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    cards.remove(card);
                    if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                        // It gains \"At the beginning of your end step, return this creature to its owner's hand.\"
                        Permanent permanent = game.getPermanent(card.getId());
                        if (permanent != null) {
                            Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true), TargetController.YOU, null, false);
                            ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
                            effect.setTargetPointer(new FixedTarget(permanent, game));
                            game.addEffect(effect, source);
                        }
                    }
                }
            }
            controller.putCardsOnBottomOfLibrary(cards, game, source, true);
        }
        return true;
    }
    return false;
}
Also used : BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility) FilterCreatureCard(mage.filter.common.FilterCreatureCard) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

ReturnToHandSourceEffect (mage.abilities.effects.common.ReturnToHandSourceEffect)8 Player (mage.players.Player)6 Permanent (mage.game.permanent.Permanent)5 FilterCreatureCard (mage.filter.common.FilterCreatureCard)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 MageObject (mage.MageObject)1 Ability (mage.abilities.Ability)1 BeginningOfEndStepTriggeredAbility (mage.abilities.common.BeginningOfEndStepTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 AttachEffect (mage.abilities.effects.common.AttachEffect)1 CreateDelayedTriggeredAbilityEffect (mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect)1 ExileSourceEffect (mage.abilities.effects.common.ExileSourceEffect)1 PutCardFromHandOntoBattlefieldEffect (mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect)1 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)1