Package mage.cards.decks

Examples of mage.cards.decks.Deck


            }
        }
        if (table.getState() != TableState.SIDEBOARDING && table.getState() != TableState.CONSTRUCTING) {
            return false;
        }
        Deck deck = Deck.load(deckList, false, false);
        if (!Main.isTestMode() && !table.getValidator().validate(deck)) {
            throw new InvalidDeckException("Invalid deck for this format", table.getValidator().getInvalid());
        }
        submitDeck(userId, playerId, deck);
        return true;
View Full Code Here


    public void updateDeck(UUID userId, DeckCardLists deckList) throws MageException {
        UUID playerId = userPlayerMap.get(userId);
        if (table.getState() != TableState.SIDEBOARDING && table.getState() != TableState.CONSTRUCTING) {
            return;
        }
        Deck deck = Deck.load(deckList, false, false);
        updateDeck(userId, playerId, deck);
    }
View Full Code Here

                deck.getSideboard().add(card);
            }
            deck.getCards().clear();
            cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), this.bigCard);
        } else {
            deck = new Deck();
        }
        refreshDeck();
    }//GEN-LAST:event_btnNewActionPerformed
View Full Code Here

                            }
                        case "sideboard":
                            {
                                TableClientMessage message = (TableClientMessage) callback.getData();
                                DeckView deckView = message.getDeck();
                                Deck deck = DeckUtil.construct(deckView);
                                if (message.getFlag()) {
                                    construct(deck, message.getTableId(), message.getTime());
                                } else {
                                    sideboard(deck, message.getTableId(), message.getTime());
                                }       break;
                            }
                        case "construct":
                            {
                                TableClientMessage message = (TableClientMessage) callback.getData();
                                DeckView deckView = message.getDeck();
                                Deck deck = DeckUtil.construct(deckView);
                                construct(deck, message.getTableId(), message.getTime());
                                break;
                            }
                        case "draftOver":
                            MageFrame.removeDraft(callback.getObjectId());
View Full Code Here

    private DeckUtil() {
    }

    public static Deck construct(DeckView view) {
        Deck deck = new Deck();
        for (SimpleCardView cardView : view.getCards().values()) {
            CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
            Card card = cardInfo != null ? cardInfo.getMockCard() : null;
            if (card != null) {
                deck.getCards().add(card);
            } else {
                log.fatal("(Deck constructing) Couldn't find card: set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
            }
        }
        for (SimpleCardView cardView : view.getSideboard().values()) {
            CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
            Card card = cardInfo != null ? cardInfo.getMockCard() : null;
            if (card != null) {
                deck.getSideboard().add(card);
            } else {
                log.fatal("(Deck constructing) Couldn't find card: set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
            }
        }
        return deck;
View Full Code Here

            deck.getCards().add(land);
        }
    }

    public static Deck buildDeck(List<Card> cardPool, final List<ColoredManaSymbol> colors) {
        Deck deck = new Deck();
        List<Card> sortedCards = new ArrayList<>(cardPool);
        Collections.sort(sortedCards, new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                Integer score1 = RateCard.rateCard(o1, colors);
                Integer score2 = RateCard.rateCard(o2, colors);
                return score2.compareTo(score1);
            }
        });
        int cardNum = 0;
        while (deck.getCards().size() < 23 && sortedCards.size() > cardNum) {
            Card card = sortedCards.get(cardNum);
            if (!card.getSupertype().contains("Basic")) {
                deck.getCards().add(card);
                deck.getSideboard().remove(card);
            }
            cardNum++;
        }
        // add basic lands
        // TODO:  compensate for non basic lands
        Mana mana = new Mana();
        for (Card card: deck.getCards()) {
            mana.add(card.getManaCost().getMana());
        }
        double total = mana.getBlack() + mana.getBlue() + mana.getGreen() + mana.getRed() + mana.getWhite();
        int mostLand = 0;
        String mostLandName = "Forest";
        if (mana.getGreen() > 0) {
            int number = (int) Math.round(mana.getGreen() / total * 17);
            addBasicLands(deck, "Forest", number);
            mostLand = number;
        }
        if (mana.getBlack() > 0) {
            int number = (int) Math.round(mana.getBlack() / total * 17);
            addBasicLands(deck, "Swamp", number);
            if (number > mostLand) {
                mostLand = number;
                mostLandName = "Swamp";
            }
        }
        if (mana.getBlue() > 0) {
            int number = (int) Math.round(mana.getBlue() / total * 17);
            addBasicLands(deck, "Island", number);
            if (number > mostLand) {
                mostLand = number;
                mostLandName = "Island";
            }
        }
        if (mana.getWhite() > 0) {
            int number = (int) Math.round(mana.getWhite() / total * 17);
            addBasicLands(deck, "Plains", number);
            if (number > mostLand) {
                mostLand = number;
                mostLandName = "Plains";
            }
        }
        if (mana.getRed() > 0) {
            int number = (int) Math.round(mana.getRed() / total * 17);
            addBasicLands(deck, "Mountain", number);
            if (number > mostLand) {
                mostLandName = "Plains";
            }
        }

        addBasicLands(deck, mostLandName, 40 - deck.getCards().size());

        return deck;
    }
View Full Code Here

    private DeckBuilder() {
    }

    public synchronized static Deck buildDeck(List<Card> spellCardPool, List<ColoredManaSymbol> allowedColors, List<String> setsToUse, List<Card> landCardPool, int deckCardSize, RateCallback callback) {
        deckSize = deckCardSize;
        deck = new Deck();

        final Collection<MageScoredCard> remainingCards = new ArrayList<MageScoredCard>();
        Set<String> names = new HashSet<String>();
        for (final Card card : spellCardPool) {
            if (names.contains(card.getName())) {
                continue;
            }
            remainingCards.add(new MageScoredCard(card, allowedColors, callback));
            names.add(card.getName());
        }
// prints score and manaScore to log
//        for(MageScoredCard scoreCard :remainingCards) {
//            Logger.getLogger(DeckBuilder.class).info(
//                    new StringBuilder("Score: ")
//                    .append(scoreCard.getScore())
//                    .append(" ManaScore: ")
//                    .append(scoreCard.getManaCostScore(scoreCard.getCard(), allowedColors))
//                    .append(" ")
//                    .append(scoreCard.getCard().getName())
//                    .append(" ")
//                    .append(scoreCard.getCard().getManaCost().getText()).toString()
//                    );
//        }
        int min = 0;
        if (deckSize == 40) {
            deckCount = DECK_COUNT40;
            deckSpells = 23;
            deckLands = 17;
        } else {
            deckCount = DECK_COUNT60;
            deckSpells = 35;
            deckLands = 25;
        }

        for (int index = 0; index < deckCount.length; index++) {
            final int max = DECK_COST[index];
            addCardsToDeck(remainingCards, min, max, deckCount[index]);
            min = max + 1;
        }
        addCardsToDeck(remainingCards, 0, 4, deckSpells - deck.getCards().size());
        addCardsToDeck(remainingCards, 5, 10, deckSpells - deck.getCards().size());
        addLandsToDeck(allowedColors, setsToUse, landCardPool, callback);

        Deck returnedDeck = deck;
        deck = null;
        return returnedDeck;
    }
View Full Code Here

    private void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
        Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0, 20);

        Player computerA = createRandomPlayer("ComputerA");
        Deck deck = generateRandomDeck();

        if (deck.getCards().size() < 40) {
            throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
        }
        game.addPlayer(computerA, deck);
        game.loadCards(deck.getCards(), computerA.getId());

        Player computerB = createRandomPlayer("ComputerB");
        Deck deck2 = generateRandomDeck();
        if (deck2.getCards().size() < 40) {
            throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
        }
        game.addPlayer(computerB, deck2);
        game.loadCards(deck2.getCards(), computerB.getId());

        boolean testMode = true;

        long t1 = System.nanoTime();
        GameOptions options = new GameOptions();
View Full Code Here

        Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0, 20);

        Player computerA = createPlayer("ComputerA", "Computer - minimax hybrid");
//        Player playerA = createPlayer("ComputerA", "Computer - mad");
//        Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
        Deck deck = generateRandomDeck();

        if (deck.getCards().size() < 40) {
            throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
        }
        game.addPlayer(computerA, deck);
        game.loadCards(deck.getCards(), computerA.getId());

        Player computerB = createPlayer("ComputerB", "Computer - minimax hybrid");
//        Player playerB = createPlayer("ComputerB", "Computer - mad");
//        Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
        Deck deck2 = generateRandomDeck();
        if (deck2.getCards().size() < 40) {
            throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
        }
        game.addPlayer(computerB, deck2);
        game.loadCards(deck2.getCards(), computerB.getId());

//        parseScenario("scenario1.txt");
//        game.cheat(playerA.getId(), commandsA);
//        game.cheat(playerA.getId(), libraryCardsA, handCardsA, battlefieldCardsA, graveyardCardsA);
//        game.cheat(playerB.getId(), commandsB);
View Full Code Here

    protected TestPlayer createPlayer(Game game, TestPlayer player, String name) throws GameException {
        player = createNewPlayer(name);
        player.setTestMode(true);
        logger.debug("Loading deck...");
        Deck deck = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"), false, false);
        logger.debug("Done!");
        if (deck.getCards().size() < 40) {
            throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
        }
        game.addPlayer(player, deck);
        game.loadCards(deck.getCards(), player.getId());

        return player;
    }
View Full Code Here

TOP

Related Classes of mage.cards.decks.Deck

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.