Search in sources :

Example 11 with Cards

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

the class LordOfTheVoidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (player == null || controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
    controller.moveCards(cards, Zone.EXILED, source, game);
    if (!cards.getCards(StaticFilters.FILTER_CARD_CREATURE, game).isEmpty()) {
        TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
        if (controller.chooseTarget(outcome, cards, target, source, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 12 with Cards

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

the class MemoryLeakEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (controller == null || opponent == null) {
        return false;
    }
    opponent.revealCards(source, opponent.getHand(), game);
    TargetCard target;
    Cards cards;
    if (controller.chooseUse(outcome, "Exile a card from hand or graveyard?", null, "Hand", "Graveyard", source, game)) {
        FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s hand");
        target = new TargetCard(Zone.HAND, filter);
        target.setNotTarget(true);
        cards = opponent.getHand();
    } else {
        FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s graveyard");
        target = new TargetCard(Zone.GRAVEYARD, filter);
        target.setNotTarget(true);
        cards = opponent.getGraveyard();
    }
    if (controller.choose(outcome, cards, target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.EXILED, source, game);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 13 with Cards

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

the class MyojinOfGrimBetrayalEffect 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 14 with Cards

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

the class NoeticScalesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl();
    game.getBattlefield().getActivePermanents(filter, game.getActivePlayerId(), source.getSourceId(), game).stream().filter(Objects::nonNull).forEach(cards::add);
    return player.moveCards(cards, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 15 with Cards

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

the class PuresightMerrowEffect 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) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            Cards cards = new CardsImpl(card);
            controller.lookAtCards("Puresight Merrow", cards, game);
            if (controller.chooseUse(Outcome.Removal, "Exile the card from the top of your library?", source, game)) {
                controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.LIBRARY, true);
            } else {
                game.informPlayers(controller.getLogName() + " puts the card back on top of their library.");
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Aggregations

Cards (mage.cards.Cards)354 Player (mage.players.Player)342 CardsImpl (mage.cards.CardsImpl)328 Card (mage.cards.Card)157 UUID (java.util.UUID)104 FilterCard (mage.filter.FilterCard)86 TargetCard (mage.target.TargetCard)84 MageObject (mage.MageObject)73 Permanent (mage.game.permanent.Permanent)71 TargetPlayer (mage.target.TargetPlayer)35 OneShotEffect (mage.abilities.effects.OneShotEffect)27 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)27 Ability (mage.abilities.Ability)25 Target (mage.target.Target)24 TargetCardInHand (mage.target.common.TargetCardInHand)24 Game (mage.game.Game)23 CardSetInfo (mage.cards.CardSetInfo)22 CardImpl (mage.cards.CardImpl)21 CardType (mage.constants.CardType)21 FilterPermanent (mage.filter.FilterPermanent)19