Search in sources :

Example 81 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class ThoughtpickerWitchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (controller != null && opponent != null) {
        Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, 2));
        if (!cards.isEmpty()) {
            TargetCard target = new TargetCardInLibrary(new FilterCard("card to exile"));
            if (controller.choose(Outcome.Exile, cards, target, game)) {
                Card card = cards.get(target.getFirstTarget(), game);
                if (card != null) {
                    cards.remove(card);
                    opponent.moveCards(card, Zone.EXILED, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 82 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class ThrillingEncoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
    if (controller == null || watcher == null) {
        return false;
    }
    Cards cards = new CardsImpl(watcher.getCardsPutIntoGraveyardFromBattlefield(game));
    cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
    return controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) CardsPutIntoGraveyardWatcher(mage.watchers.common.CardsPutIntoGraveyardWatcher) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 83 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class ThinkTankLookLibraryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.getLibrary().hasCards()) {
            Card card = controller.getLibrary().getFromTop(game);
            if (card != null) {
                CardsImpl cards = new CardsImpl();
                cards.add(card);
                controller.lookAtCards("Think Tank", cards, game);
                if (controller.chooseUse(Outcome.Neutral, "Put that card into your graveyard?", source, game)) {
                    return controller.moveCards(card, Zone.GRAVEYARD, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 84 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class ThoughtDistortionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    player.revealCards(source, player.getHand(), game);
    Cards cards = new CardsImpl(player.getHand().getCards(filter, game));
    cards.addAll(player.getGraveyard().getCards(filter, game));
    return player.moveCards(cards, Zone.EXILED, source, game);
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 85 with CardsImpl

use of mage.cards.CardsImpl in project mage by magefree.

the class ThrasiosTritonHeroEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    controller.scry(1, source, game);
    if (!controller.getLibrary().hasCards()) {
        return true;
    }
    CardsImpl cards = new CardsImpl();
    Card card = controller.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    cards.add(card);
    controller.revealCards(source, cards, game);
    if (card.isLand(game)) {
        return controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
    }
    controller.drawCards(1, source, game);
    return true;
}
Also used : Player(mage.players.Player) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Aggregations

CardsImpl (mage.cards.CardsImpl)507 Player (mage.players.Player)497 Cards (mage.cards.Cards)328 Card (mage.cards.Card)253 UUID (java.util.UUID)135 Permanent (mage.game.permanent.Permanent)114 FilterCard (mage.filter.FilterCard)108 MageObject (mage.MageObject)106 TargetCard (mage.target.TargetCard)99 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)53 TargetPlayer (mage.target.TargetPlayer)47 TargetCardInHand (mage.target.common.TargetCardInHand)41 OneShotEffect (mage.abilities.effects.OneShotEffect)37 Target (mage.target.Target)32 Ability (mage.abilities.Ability)27 FilterPermanent (mage.filter.FilterPermanent)27 CardSetInfo (mage.cards.CardSetInfo)25 Game (mage.game.Game)25 CardImpl (mage.cards.CardImpl)24 FilterCreatureCard (mage.filter.common.FilterCreatureCard)23