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));
}
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'");
}
}
}
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);
}
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;
}
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);
}
Aggregations