Search in sources :

Example 21 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class HourOfDevastationCollator method generateBoosterMap.

@Override
protected void generateBoosterMap() {
    super.generateBoosterMap();
    CardRepository.instance.findCards(new CardCriteria().setCodes("MP2").minCardNumber(31)).stream().forEach(cardInfo -> inBoosterMap.put("MP2_" + cardInfo.getCardNumber(), cardInfo));
}
Also used : CardCriteria(mage.cards.repository.CardCriteria)

Example 22 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class SelectionBox method blingDeck.

public void blingDeck() {
    if (this.mode != Constants.DeckEditorMode.FREE_BUILDING) {
        return;
    }
    if (JOptionPane.showConfirmDialog(null, "Are you sure you want to bling your deck?  This process will add cards!", "WARNING", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
        return;
    }
    // TODO: Why are these a HashMap? It can be a HashSet<String> instead, as the value is never used in the code.
    Map<String, Integer> pimpedSets = new HashMap<>();
    Map<CardView, Integer> pimpedCards = new HashMap<>();
    pimpedSets.put("PCMP", 1);
    pimpedSets.put("MPS", 1);
    pimpedSets.put("MP2", 1);
    pimpedSets.put("EXP", 1);
    pimpedSets.put("CP1", 1);
    pimpedSets.put("CP2", 1);
    pimpedSets.put("CP3", 1);
    // Judge Reward Gifts
    pimpedSets.put("JGP", 1);
    pimpedSets.put("G99", 1);
    pimpedSets.put("G00", 1);
    pimpedSets.put("G01", 1);
    pimpedSets.put("G02", 1);
    pimpedSets.put("G03", 1);
    pimpedSets.put("G04", 1);
    pimpedSets.put("G05", 1);
    pimpedSets.put("G06", 1);
    pimpedSets.put("G07", 1);
    pimpedSets.put("G08", 1);
    pimpedSets.put("G09", 1);
    pimpedSets.put("G10", 1);
    pimpedSets.put("G11", 1);
    pimpedSets.put("J12", 1);
    pimpedSets.put("J13", 1);
    pimpedSets.put("J14", 1);
    pimpedSets.put("J15", 1);
    pimpedSets.put("J16", 1);
    pimpedSets.put("J17", 1);
    pimpedSets.put("J18", 1);
    pimpedSets.put("J19", 1);
    pimpedSets.put("J20", 1);
    // Arena League
    pimpedSets.put("PARL", 1);
    pimpedSets.put("PAL99", 1);
    pimpedSets.put("PAL00", 1);
    pimpedSets.put("PAL01", 1);
    pimpedSets.put("PAL02", 1);
    pimpedSets.put("PAL03", 1);
    pimpedSets.put("PAL04", 1);
    pimpedSets.put("PAL05", 1);
    pimpedSets.put("PAL06", 1);
    pimpedSets.put("UGIN", 1);
    pimpedSets.put("PALP", 1);
    pimpedSets.put("PELP", 1);
    // Friday Night Magic
    pimpedSets.put("FNM", 1);
    pimpedSets.put("F01", 1);
    pimpedSets.put("F02", 1);
    pimpedSets.put("F03", 1);
    pimpedSets.put("F04", 1);
    pimpedSets.put("F05", 1);
    pimpedSets.put("F06", 1);
    pimpedSets.put("F07", 1);
    pimpedSets.put("F08", 1);
    pimpedSets.put("F09", 1);
    pimpedSets.put("F10", 1);
    pimpedSets.put("F11", 1);
    pimpedSets.put("F12", 1);
    pimpedSets.put("F13", 1);
    pimpedSets.put("F14", 1);
    pimpedSets.put("F15", 1);
    pimpedSets.put("F16", 1);
    pimpedSets.put("F17", 1);
    pimpedSets.put("F18", 1);
    // Magic Player Rewards 2001-2011, except for 2002 (P02), which only contains tokens
    pimpedSets.put("MPR", 1);
    pimpedSets.put("P03", 1);
    pimpedSets.put("P04", 1);
    pimpedSets.put("P05", 1);
    pimpedSets.put("P06", 1);
    pimpedSets.put("P07", 1);
    pimpedSets.put("P08", 1);
    pimpedSets.put("P09", 1);
    pimpedSets.put("P10", 1);
    pimpedSets.put("P11", 1);
    // Vintage Championship
    pimpedSets.put("OVNT", 1);
    // Junior Series Europe
    pimpedSets.put("PJSE", 1);
    // Two-Headed Giant Tournament
    pimpedSets.put("P2HG", 1);
    // Gateway 2006
    pimpedSets.put("PGTW", 1);
    // Junior APAC Series
    pimpedSets.put("PJAS", 1);
    pimpedSets.put("EXP", 1);
    pimpedSets.put("PGPX", 1);
    pimpedSets.put("PMEI", 1);
    pimpedSets.put("PLS", 1);
    String[] sets = pimpedSets.keySet().toArray(new String[pimpedSets.keySet().size()]);
    Boolean didModify = false;
    for (List<List<CardView>> gridRow : cardGrid) {
        for (List<CardView> stack : gridRow) {
            for (CardView card : stack) {
                if (card.getSuperTypes().contains(SuperType.BASIC)) {
                    continue;
                }
                if (!pimpedSets.containsKey(card.getExpansionSetCode())) {
                    final CardCriteria cardCriteria = new CardCriteria();
                    cardCriteria.setCodes(sets);
                    cardCriteria.name(card.getName());
                    java.util.List<CardInfo> cardPool = CardRepository.instance.findCards(cardCriteria);
                    if (!cardPool.isEmpty()) {
                        Card acard = cardPool.get(RandomUtil.nextInt(cardPool.size())).getMockCard();
                        if (acard.getName().equals(card.getName())) {
                            CardView pimpedCard = new CardView(acard);
                            addCardView(pimpedCard, false);
                            eventSource.fireEvent(pimpedCard, ClientEventType.DECK_ADD_SPECIFIC_CARD);
                            pimpedCards.put(pimpedCard, 1);
                            didModify = true;
                        }
                    }
                }
            }
        }
        if (didModify) {
            for (CardView c : pimpedCards.keySet()) {
                sortIntoGrid(c);
            }
            trimGrid();
            layoutGrid();
            repaintGrid();
            JOptionPane.showMessageDialog(null, "Added " + pimpedCards.size() + " cards.  You can select them and the originals by choosing 'Multiples'");
        }
    }
}
Also used : CardCriteria(mage.cards.repository.CardCriteria) CardView(mage.view.CardView) DeckCardInfo(mage.cards.decks.DeckCardInfo) CardInfo(mage.cards.repository.CardInfo) MageCard(mage.cards.MageCard) Card(mage.cards.Card) java.util(java.util) List(java.util.List)

Example 23 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class MageBook method getCards.

private List<CardInfo> getCards(int page, String set) {
    CardCriteria criteria = new CardCriteria();
    criteria.setCodes(set);
    List<CardInfo> cards = CardRepository.instance.findCards(criteria);
    cards.sort(new NaturalOrderCardNumberComparator());
    int start = page * conf.CARDS_PER_PAGE;
    int end = page * conf.CARDS_PER_PAGE + conf.CARDS_PER_PAGE;
    if (end > cards.size()) {
        end = cards.size();
    }
    if (cards.size() > end) {
        pageRight.setVisible(true);
    }
    return cards.subList(start, end);
}
Also used : NaturalOrderCardNumberComparator(mage.client.util.NaturalOrderCardNumberComparator) CardCriteria(mage.cards.repository.CardCriteria) CardInfo(mage.cards.repository.CardInfo)

Example 24 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class MageBook method loadCards.

private List<Object> loadCards() {
    CardCriteria criteria = new CardCriteria();
    criteria.setCodes(currentSet);
    List<CardInfo> cards = CardRepository.instance.findCards(criteria);
    cards.sort(new NaturalOrderCardNumberComparator());
    List<Object> res = new ArrayList<>();
    cards.forEach(card -> res.add(new CardView(card.getMockCard())));
    return res;
}
Also used : NaturalOrderCardNumberComparator(mage.client.util.NaturalOrderCardNumberComparator) CardCriteria(mage.cards.repository.CardCriteria) ArrayList(java.util.ArrayList) CardInfo(mage.cards.repository.CardInfo)

Example 25 with CardCriteria

use of mage.cards.repository.CardCriteria in project mage by magefree.

the class LoadMissingCardDataNew method findMissingCards.

public void findMissingCards() {
    updateGlobalMessage("Loading...");
    this.cardsAll.clear();
    this.cardsMissing.clear();
    this.cardsDownloadQueue.clear();
    updateGlobalMessage("Loading cards list...");
    this.cardsAll = Collections.synchronizedList(CardRepository.instance.findCards(new CardCriteria()));
    updateGlobalMessage("Finding missing images...");
    this.cardsMissing = prepareMissingCards(this.cardsAll, uiDialog.getRedownloadCheckbox().isSelected());
    updateGlobalMessage("Finding available sets from selected source...");
    this.uiDialog.getSetsCombo().setModel(new DefaultComboBoxModel<>(getSetsForCurrentImageSource()));
    reloadCardsToDownload(this.uiDialog.getSetsCombo().getSelectedItem().toString());
    this.uiDialog.showDownloadControls(true);
    updateGlobalMessage("");
    showDownloadControls(true);
}
Also used : CardCriteria(mage.cards.repository.CardCriteria)

Aggregations

CardCriteria (mage.cards.repository.CardCriteria)25 CardInfo (mage.cards.repository.CardInfo)14 Card (mage.cards.Card)6 DeckCardInfo (mage.cards.decks.DeckCardInfo)3 Player (mage.players.Player)3 java.util (java.util)2 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2 Choice (mage.choices.Choice)2 ChoiceImpl (mage.choices.ChoiceImpl)2 NaturalOrderCardNumberComparator (mage.client.util.NaturalOrderCardNumberComparator)2 ColoredManaSymbol (mage.constants.ColoredManaSymbol)2 Token (mage.game.permanent.token.Token)2 File (java.io.File)1 Constructor (java.lang.reflect.Constructor)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1