Package mage.cards.repository

Examples of mage.cards.repository.CardInfo


        return deck;
    }

    private static Card createCard(DeckCardInfo deckCardInfo, boolean mockCards) {
        CardInfo cardInfo = CardRepository.instance.findCard(deckCardInfo.getSetCode(), deckCardInfo.getCardNum());
        if (cardInfo == null) {
            return null;
        }

        if (mockCards) {
            return cardInfo.getMockCard();
        } else {
            return cardInfo.getCard();
        }
    }
View Full Code Here


            int count = Integer.parseInt(m.group(2));
            String setCode = m.group(3);
            int cardNum = Integer.parseInt(m.group(4));

            DeckCardInfo deckCardInfo  = null;
            CardInfo cardInfo = CardRepository.instance.findCard(setCode, cardNum);
            if (cardInfo != null) {
                deckCardInfo = new DeckCardInfo(cardInfo.getName(), cardInfo.getCardNumber(), cardInfo.getSetCode());
            }
            if (deckCardInfo != null) {
                for (int i = 0; i < count; i++) {
                    if (!sideboard) {
                        deckList.getCards().add(deckCardInfo);
View Full Code Here

            if (cards.isEmpty()) {
                sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
            } else {
                // search the card released last with this name
                Date lastReleaseDate = new GregorianCalendar(1900, 1, 1).getTime();
                CardInfo lastReleasedCard = null;
                for (CardInfo cardinfo: cards) {
                    ExpansionInfo set = ExpansionRepository.instance.getSetByCode(cardinfo.getSetCode());
                    if (set != null) {
                        if (lastReleaseDate == null || set.getReleaseDate().after(lastReleaseDate)) {
                            lastReleasedCard = cardinfo;
                            lastReleaseDate = set.getReleaseDate();
                        }
                    }
                }
                if (lastReleasedCard == null) {
                    lastReleasedCard = cards.get(0);
                }
                for (int i = 0; i < num; i++) {
                    if (!sideboard) {
                        deckList.getCards().add(new DeckCardInfo(lastReleasedCard.getName(),lastReleasedCard.getCardNumber(), lastReleasedCard.getSetCode()));
                    } else {
                        deckList.getSideboard().add(new DeckCardInfo(lastReleasedCard.getName(),lastReleasedCard.getCardNumber(), lastReleasedCard.getSetCode()));
                    }
                }
            }
        } catch (NumberFormatException nfe) {
            sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append("\n");
View Full Code Here

            if (cards.isEmpty()) {
                sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
            } else {
                Random random = new Random();
                for (int i = 0; i < num; i++) {
                    CardInfo cardInfo = cards.get(random.nextInt(cards.size()));
                    if (!sideboard) {
                        deckList.getCards().add(new DeckCardInfo(cardInfo.getName(),cardInfo.getCardNumber(), cardInfo.getSetCode()));
                    } else {
                        deckList.getSideboard().add(new DeckCardInfo(cardInfo.getName(),cardInfo.getCardNumber(), cardInfo.getSetCode()));
                    }
                }
            }
        } catch (NumberFormatException nfe) {
            sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append("\n");
View Full Code Here

            if (cards.isEmpty()) {
                sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
            } else {
                Random random = new Random();
                for (int i = 0; i < num; i++) {
                    CardInfo cardInfo = cards.get(random.nextInt(cards.size()));
                    if (!sideboard) {
                        deckList.getCards().add(new DeckCardInfo(cardInfo.getName(),cardInfo.getCardNumber(), cardInfo.getSetCode()));
                    } else {
                        deckList.getSideboard().add(new DeckCardInfo(cardInfo.getName(),cardInfo.getCardNumber(), cardInfo.getSetCode()));
                    }
                }
            }
        } catch (NumberFormatException nfe) {
            sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append("\n");
View Full Code Here

        int count = 0;
        int tries = 0;
        List<Card> cardPool = new ArrayList<>();
        while (count < cardsCount) {
            CardInfo cardInfo = cards.get(rnd.nextInt(cards.size()));
            Card card = cardInfo != null ? cardInfo.getCard() : null;
            if (card != null) {
                cardPool.add(card);
                count++;
            }
            tries++;
View Full Code Here

     */
    private DeckCardLists createDeck() {
        DeckCardLists deckList = new DeckCardLists();
        Deck deck = generateRandomDeck();
        for (Card card : deck.getCards()) {
            CardInfo cardInfo = CardRepository.instance.findCard(card.getExpansionSetCode(), card.getCardNumber());
            if (cardInfo != null) {
                deckList.getCards().add(new DeckCardInfo(cardInfo.getName(), cardInfo.getCardNumber(), cardInfo.getSetCode()));
            }
        }
        return deckList;
    }
View Full Code Here

        }
    }

    private void addToBooster(List<Card> booster, List<CardInfo> cards) {
        if (!cards.isEmpty()) {
            CardInfo cardInfo = cards.remove(rnd.nextInt(cards.size()));
            if (cardInfo != null) {
                Card card = cardInfo.getCard();
                if (card != null) {
                    booster.add(card);
                }
            }
        }
View Full Code Here

        for (String ruleText : card.getRules()) {
            this.addAbility(textAbilityFromString(ruleText));
        }

        CardInfo leftHalf = CardRepository.instance.findCard(getLeftHalfName(card));
        if(leftHalf != null) {
            this.leftHalfCard = new MockCard(leftHalf);
        }

        CardInfo rightHalf = CardRepository.instance.findCard(getRightHalfName(card));
        if(rightHalf != null) {
            this.rightHalfCard = new MockCard(rightHalf);
        }
    }
View Full Code Here

            while (!done) {
                int index = rnd.nextInt(leftCubeCards.size());
                CardIdentity cardId = leftCubeCards.get(index);
                leftCubeCards.remove(index);
                if (!cardId.getName().isEmpty()) {
                    CardInfo cardInfo = null;
                    if (!cardId.getExtension().isEmpty()) {
                        CardCriteria criteria = new CardCriteria().name(cardId.getName()).setCodes(cardId.extension);
                        List<CardInfo> cardList = CardRepository.instance.findCards(criteria);
                        if (cardList != null && cardList.size() > 0) {
                            cardInfo = cardList.get(0);
                        }
                    } else {
                        cardInfo = CardRepository.instance.findCard(cardId.getName());
                    }
                   
                    if (cardInfo != null) {
                        booster.add(cardInfo.getCard());
                        done = true;
                    } else {
                        logger.warn(new StringBuilder(this.getName()).append(" - Card not found: ").append(cardId.getName()).append(":").append(cardId.extension));
                        notValid++;
                    }
View Full Code Here

TOP

Related Classes of mage.cards.repository.CardInfo

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.