Search in sources :

Example 6 with PlayFromNotOwnHandZoneTargetEffect

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

the class NicolBolasGodPharaohPlusTwoEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (opponent == null) {
        return false;
    }
    Library library = opponent.getLibrary();
    Card card;
    do {
        card = library.getFromTop(game);
        if (card == null) {
            continue;
        }
        opponent.moveCards(card, Zone.EXILED, source, game);
        if (card.isLand(game)) {
            continue;
        }
        ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.EndOfTurn, true);
        effect.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(effect, source);
        break;
    } while (library.hasCards() && card != null);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) Library(mage.players.Library) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard)

Example 7 with PlayFromNotOwnHandZoneTargetEffect

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

the class ExileTopXMayPlayUntilEndOfTurnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
    if (cards.isEmpty()) {
        return true;
    }
    controller.moveCardsToExile(cards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    // remove cards that could not be moved to exile
    cards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
    if (!cards.isEmpty()) {
        game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, duration).setTargetPointer(new FixedTargets(cards, game)), source);
    }
    return true;
}
Also used : Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) Card(mage.cards.Card)

Example 8 with PlayFromNotOwnHandZoneTargetEffect

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

the class ApexOfPowerManaEffect 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;
    }
    Set<Card> cards = controller.getLibrary().getTopCards(game, 7);
    if (cards.isEmpty()) {
        return false;
    }
    controller.moveCards(cards, Zone.EXILED, source, game);
    for (Card card : cards) {
        if (card.isLand(game)) {
            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) Card(mage.cards.Card)

Example 9 with PlayFromNotOwnHandZoneTargetEffect

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

the class ChandraHeartOfFireUltimateEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Set<Card> exiledCards = new HashSet<>();
        // from graveyard
        Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter, true).withChooseHint("from graveyard");
        if (target.canChoose(source.getSourceId(), controller.getId(), game) && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), game)) {
            Set<Card> cards = new CardsImpl(target.getTargets()).getCards(game);
            exiledCards.addAll(cards);
        }
        // from library
        target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter).withChooseHint("from library");
        if (target.canChoose(source.getSourceId(), controller.getId(), game) && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), game)) {
            Set<Card> cards = new CardsImpl(target.getTargets()).getCards(game);
            exiledCards.addAll(cards);
        }
        // exile cards all at once and set the exile name to the source card
        controller.moveCardsToExile(exiledCards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
        controller.shuffleLibrary(source, game);
        exiledCards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
        if (!exiledCards.isEmpty()) {
            ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTargets(exiledCards, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetAnyTarget(mage.target.common.TargetAnyTarget) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CardsImpl(mage.cards.CardsImpl) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) HashSet(java.util.HashSet)

Example 10 with PlayFromNotOwnHandZoneTargetEffect

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

the class SinsOfThePastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
    if (card != null) {
        ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.GRAVEYARD, TargetController.YOU, Duration.EndOfTurn, true);
        effect.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(effect, source);
        effect = new ExileCardEnteringGraveyardReplacementEffect(card.getId());
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) ExileCardEnteringGraveyardReplacementEffect(mage.abilities.effects.common.ExileCardEnteringGraveyardReplacementEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) 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