Package mage.cards

Examples of mage.cards.Cards


    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard());
            if (player.searchLibrary(target, game)) {
                Cards cards = new CardsImpl();
                Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
                if (card != null) {
                    cards.add(card);
                    if (MorbidCondition.getInstance().apply(game, source)
                            && player.chooseUse(Outcome.PutLandInPlay, "Do you wish to put the card onto the battlefield instead?", game)) {
                        card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId());
                    } else {
                        card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
View Full Code Here


        if (perm != null) {
            Player player = game.getPlayer(perm.getOwnerId());
            if (player != null) {
                perm.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
                player.shuffleLibrary(game);
                Cards cards = new CardsImpl();
                while (true) {
                    Card card = player.getLibrary().removeFromTop(game);
                    if (card == null)
                        break;
                    if (card.getName().equals("Mirror-Mad Phantasm")) {
                        card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), player.getId());
                        break;
                    }
                    cards.add(card);
                }
                player.revealCards("Mirror-Mad Phantasm", cards, game);
                for (Card card: cards.getCards(game)) {
                    card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
                }
                return true;
            }
        }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller == null) {
            return false;
        }
        Cards cards = new CardsImpl();

        Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY);
        int count = 0;
        if (obj != null && obj instanceof SpellAbility) {
            count = ((SpellAbility) obj).getManaCostsToPay().getX();
            // using other var because of tooltip
            int size = Math.min(controller.getLibrary().size(), count);
            for (int i = 0; i < size; i++) {
                Card card = controller.getLibrary().removeFromTop(game);
                cards.add(card);
            }
        }

        if (cards.size() > 0) {
            controller.revealCards("Genesis Hydra", cards, game);
        }

        FilterCard filter = new FilterPermanentCard("a nonland permanent card with converted mana cost " + count + " or less to put onto the battlefield");
        filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
        filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, count + 1));
        TargetCard target1 = new TargetCard(Zone.LIBRARY, filter);
        target1.setRequired(false);
        if (cards.count(filter, controller.getId(), source.getSourceId(), game) > 0) {
            if (controller.choose(Outcome.PutCardInPlay, cards, target1, game)) {
                Card card = cards.get(target1.getFirstTarget(), game);
                if (card != null) {
                    cards.remove(card);
                    controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
                }
                target1.clearChosen();
            } else {
                game.informPlayers(controller.getName() + " didn't choose anything");
            }
        } else {
            game.informPlayers("No nonland permanent card with converted mana cost " + count + " or less to choose.");
        }
        while (cards.size() > 0) {
            Card card = cards.get(cards.iterator().next(), game);
            cards.remove(card);
            card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
        }
        controller.shuffleLibrary(game);
        return true;
    }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());

        if (player != null) {
            Cards cards = new CardsImpl(Zone.PICK);
            int cardsCount = Math.min(7, player.getLibrary().size());
            for (int i = 0; i < cardsCount; i++) {
                Card card = player.getLibrary().removeFromTop(game);
                if (card != null) {
                    cards.add(card);
                    game.setZone(card.getId(), Zone.PICK);
                }
            }

            if (cards.size() > 0) {
                player.lookAtCards("Ancestral Memories", cards, game);

                TargetCard target = new TargetCard(Math.min(2, cards.size()), Zone.PICK, new FilterCard("two cards to put in your hand"));
                if (player.choose(Outcome.Benefit, cards, target, game)) {
                    for (UUID targetId : (List<UUID>)target.getTargets()) {
                        Card card = cards.get(targetId, game);
                        if (card != null) {
                            card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
                            cards.remove(card);
                        }  
                    }
                }

                for (Card card : cards.getCards(game)) {
                    card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
                }
            }
            return true;
        }
View Full Code Here

        Player you = game.getPlayer(source.getControllerId());
        Player player = game.getPlayer(source.getFirstTarget());
        if (player == null || you == null) {
            return false;
        }
        Cards cards = new CardsImpl(Zone.PICK);
        int count = Math.min(player.getLibrary().size(), 3);
        for (int i = 0; i < count; i++) {
            Card card = player.getLibrary().removeFromTop(game);
            if (card != null) {
                cards.add(card);
                game.setZone(card.getId(), Zone.PICK);
            }
        }

        you.lookAtCards("Natural Selection", cards, game);

        TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the top of target player's library"));
        while (player.isInGame() && cards.size() > 1) {
            you.choose(Outcome.Neutral, cards, target, game);
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                cards.remove(card);
                card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
            }
            target.clearChosen();
        }
        if (cards.size() == 1) {
            Card card = cards.get(cards.iterator().next(), game);
            card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
        }
        if (you.chooseUse(Outcome.Neutral, "You may have that player shuffle his or her library", game)){
            player.shuffleLibrary(game);
        }
View Full Code Here

        if (player == null) {
            return false;
        }
        if (player.searchLibrary(target, game)) {
            if (target.getTargets().size() > 0) {
                Cards cards = new CardsImpl();
                for (UUID cardId: (List<UUID>)target.getTargets()) {
                    Card card = player.getLibrary().remove(cardId, game);
                    if (card != null){
                        card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
                        cards.add(card);
                    }
                }
                if (cards.size() > 0) {
                    player.revealCards("Quiet Speculation", cards, game);
                }
            }
            player.shuffleLibrary(game);
            return true;
View Full Code Here

        Player player = game.getPlayer(source.getControllerId());
        Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source));
        if (player != null && permanent != null) {
            int numLooked = Math.min(permanent.getPower().getValue(), player.getLibrary().size());
            if (numLooked > 0) {
                Cards cards = new CardsImpl();
                for (int i = 0; i < numLooked; i++) {
                    cards.add(player.getLibrary().removeFromTop(game));
                }
                TargetCard target = new TargetCardInHand(new FilterCard("card to put on top of your library"));
                player.choose(Outcome.Benefit, cards, target, game);
                Card card = cards.get(target.getFirstTarget(), game);
                cards.remove(card);
                player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, true, false);
                player.putCardsOnBottomOfLibrary(cards, game, source, true);
            }
            return true;
        }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            while (player.chooseUse(Outcome.Benefit, choiceText, game)) {
                Cards cards = player.getSideboard();
                if(cards.isEmpty()) {
                    game.informPlayer(player, "You have no cards outside the game.");
                    break;
                }

                Set<Card> filtered = cards.getCards(filter, game);
                if (filtered.isEmpty()) {
                    game.informPlayer(player, "You have no " + filter.getMessage() + " outside the game.");
                    break;
                }

                Cards filteredCards = new CardsImpl();
                for (Card card : filtered) {
                    filteredCards.add(card.getId());
                }

                TargetCard target = new TargetCard(Zone.PICK, filter);
                if (player.choose(Outcome.Benefit, filteredCards, target, game)) {
                    Card card = player.getSideboard().get(target.getFirstTarget(), game);
                    if (card != null) {

                        card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
                        Cards revealCard = new CardsImpl();
                        revealCard.add(card);
                        player.revealCards("Golden Wish", revealCard, game);
                        break;
                    }
                }
            }
View Full Code Here

        String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
        if (sourceObject == null || controller == null || cardName == null || cardName.isEmpty()) {
            return false;
        }
              
        Cards cards = new CardsImpl();
        while (controller.getLibrary().size() > 0) {
            Card card = controller.getLibrary().removeFromTop(game);
            if (card != null) {
                cards.add(card);
                if(card.getName().equals(cardName)){
                    controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
                    break;
                }
                else{
                    controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY);
                }
            }
            else{
                break;
            }
        }
       
        controller.revealCards(sourceObject.getLogName(), cards, game);
        controller.loseLife(cards.size(), game);
       
        return true;
    }
View Full Code Here

    private Permanent chooseOnePermanent(Game game, Player player, List<Permanent> permanents) {
        Permanent permanent = null;
        if (permanents.size() == 1) {
            permanent = permanents.iterator().next();
        } else if (permanents.size() > 1) {
            Cards cards = new CardsImpl();
            for (Permanent card : permanents) {
                cards.add(card);
            }

            TargetCard targetCard = new TargetCard(Zone.BATTLEFIELD, new FilterCard());
            if (player.choose(Outcome.Benefit, cards, targetCard, game)) {
                permanent = game.getPermanent(targetCard.getFirstTarget());
View Full Code Here

TOP

Related Classes of mage.cards.Cards

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.