Search in sources :

Example 16 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class DauthiVoidwalkerPlayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCardInExile target = new TargetCardInExile(0, 1, filter, null, true);
    player.choose(outcome, target, source.getSourceId(), game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.EndOfTurn, true, false).setTargetPointer(new FixedTarget(card, game)), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) TargetCardInExile(mage.target.common.TargetCardInExile) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 17 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class ChandraDressedToKillPlayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Card card = controller.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    MageObject sourceObject = source.getSourceObject(game);
    String exileName = sourceObject == null ? null : sourceObject.getIdName();
    controller.moveCardsToExile(card, source, game, true, exileId, exileName);
    if (game.getState().getZone(card.getId()) == Zone.EXILED && card.getColor(game).isRed()) {
        game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.EndOfTurn, false, true).setTargetPointer(new FixedTarget(card, game)), source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) MageObject(mage.MageObject) UUID(java.util.UUID) Card(mage.cards.Card)

Example 18 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class ChandraFireArtisanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || sourceObject == null) {
        return false;
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, (exileSeven ? 7 : 1)));
    controller.moveCards(cards, Zone.EXILED, source, game);
    for (Card card : cards.getCards(game)) {
        if (card == null) {
            continue;
        }
        ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 19 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class CunningAbductionSpendAnyManaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (opponent != null && sourceObject != null) {
        opponent.revealCards(sourceObject.getName(), opponent.getHand(), game);
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            int cardsHand = opponent.getHand().count(filter, game);
            Card card = null;
            if (cardsHand > 0) {
                TargetCard target = new TargetCard(Zone.HAND, filter);
                if (controller.choose(Outcome.Benefit, opponent.getHand(), target, game)) {
                    card = opponent.getHand().get(target.getFirstTarget(), game);
                }
            }
            if (card != null) {
                // move card to exile
                UUID exileId = CardUtil.getCardExileZoneId(game, source);
                controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getIdName());
                // allow to cast the card
                ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.Custom);
                effect.setTargetPointer(new FixedTarget(card, game));
                game.addEffect(effect, source);
                // and you may spend mana as though it were mana of any color to cast it
                effect = new CunningAbductionSpendAnyManaEffect();
                effect.setTargetPointer(new FixedTarget(card.getId(), game));
                game.addEffect(effect, source);
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 20 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class DeadMansChestSpendManaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    Permanent attachedTo = (Permanent) getValue("attachedTo");
    if (controller != null && sourceObject != null && attachedTo != null) {
        Player owner = game.getPlayer(attachedTo.getOwnerId());
        int amount = attachedTo.getPower().getValue();
        if (owner != null && amount > 0) {
            Set<Card> cards = owner.getLibrary().getTopCards(game, amount);
            if (!cards.isEmpty()) {
                controller.moveCardsToExile(cards, source, game, true, source.getSourceId(), sourceObject.getName());
                for (Card card : cards) {
                    if (!card.isLand(game)) {
                        ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.Custom);
                        effect.setTargetPointer(new FixedTarget(card, game));
                        game.addEffect(effect, source);
                        effect = new DeadMansChestSpendManaEffect();
                        effect.setTargetPointer(new FixedTarget(card, game));
                        game.addEffect(effect, source);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card)

Aggregations

PlayFromNotOwnHandZoneTargetEffect (mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect)21 Player (mage.players.Player)19 FixedTarget (mage.target.targetpointer.FixedTarget)17 Card (mage.cards.Card)16 ContinuousEffect (mage.abilities.effects.ContinuousEffect)12 MageObject (mage.MageObject)9 UUID (java.util.UUID)5 FilterCard (mage.filter.FilterCard)4 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)3 FixedTargets (mage.target.targetpointer.FixedTargets)3 Ability (mage.abilities.Ability)2 ConditionalAsThoughEffect (mage.abilities.decorator.ConditionalAsThoughEffect)2 CardsImpl (mage.cards.CardsImpl)2 FilterInstantOrSorceryCard (mage.filter.common.FilterInstantOrSorceryCard)2 FilterNonlandCard (mage.filter.common.FilterNonlandCard)2 Permanent (mage.game.permanent.Permanent)2 Spell (mage.game.stack.Spell)2 Target (mage.target.Target)2 TargetCard (mage.target.TargetCard)2 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)2