use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class CacheProviderTests method createCards.
@Before
public void createCards() {
mc = new MagicCard();
mc.setName("Black Lotus");
mc.setLayout("normal");
mc.setCost("{0}");
mc.setCmc(0);
mc.getTypes().add("Artifact");
mc.setReserved(true);
mc.setText("{T}, Sacrifice Black Lotus: Add three mana of any one color to your mana pool.");
mc.setRarity("Rare");
mc.setArtist("Christopher Rush");
mc.setId("c944c7dc960c4832604973844edee2a1fdc82d98");
mc.setMciNumber("232");
MagicEdition ed = new MagicEdition();
ed.setId("lea");
ed.setSet("Limited Edition Alpha");
ed.setBorder("Black");
ed.setRarity("Rare");
ed.setArtist("Christopher Rush");
ed.setMultiverse_id("3");
ed.setNumber("232");
mc.getEditions().add(ed);
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class MagicCardsTreeCellRenderer method getTreeCellRendererComponent.
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean isLeaf, int row, boolean focused) {
Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused);
try {
if (((DefaultMutableTreeNode) value).getUserObject() instanceof MagicEdition) {
MagicEdition ed = (MagicEdition) ((DefaultMutableTreeNode) value).getUserObject();
setIcon(IconSetProvider.getInstance().get16(ed.getId()));
} else if (((DefaultMutableTreeNode) value).getUserObject() instanceof MagicCard) {
MagicCard mc = (MagicCard) ((DefaultMutableTreeNode) value).getUserObject();
setOpaque(false);
setIcon(uncolor);
if (mc.getFullType().toLowerCase().contains("artifact")) {
setIcon(map.get("{X}"));
}
if (mc.getColors().size() == 1) {
setIcon(map.get(ColorParser.parse(mc.getColors().get(0))));
}
if (mc.getColors().size() > 1) {
setIcon(gold);
}
if (mc.getFullType().toLowerCase().contains("land")) {
setIcon(uncolor);
}
} else {
setIcon(back);
}
return c;
} catch (Exception e) {
return c;
}
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class DAOProviderTests method createCards.
@Before
public void createCards() {
mc = new MagicCard();
mc.setName("Black Lotus");
mc.setLayout("normal");
mc.setCost("{0}");
mc.setCmc(0);
mc.getTypes().add("Artifact");
mc.setReserved(true);
mc.setText("{T}, Sacrifice Black Lotus: Add three mana of any one color to your mana pool.");
mc.setRarity("Rare");
mc.setArtist("Christopher Rush");
mc.setId("c944c7dc960c4832604973844edee2a1fdc82d98");
mc.setMciNumber("232");
MagicEdition ed = new MagicEdition();
ed.setId("lea");
ed.setSet("Limited Edition Alpha");
ed.setBorder("Black");
ed.setRarity("Rare");
ed.setArtist("Christopher Rush");
ed.setMultiverse_id("3");
ed.setNumber("232");
mc.getEditions().add(ed);
col = new MagicCollection("TEST");
MTGLogger.changeLevel(Level.ERROR);
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class DeckModel method setValueAt.
@Override
public void setValueAt(Object aValue, int row, int column) {
MagicCard mc = (this.t == TYPE.DECK) ? deck.getValueAt(row) : deck.getSideValueAt(row);
if (column == 3) {
MagicEdition ed = (MagicEdition) aValue;
mc.getEditions().remove(ed);
mc.getEditions().add(0, (MagicEdition) aValue);
}
if (column == 4)
if (Integer.valueOf(aValue.toString()) == 0) {
if (t == TYPE.DECK) {
deck.getMap().remove(deck.getValueAt(row));
} else {
deck.getMapSideBoard().remove(deck.getValueAt(row));
}
} else {
if (t == TYPE.DECK) {
deck.getMap().put(deck.getValueAt(row), Integer.valueOf(aValue.toString()));
} else {
deck.getMapSideBoard().put(deck.getSideValueAt(row), Integer.valueOf(aValue.toString()));
}
}
fireTableDataChanged();
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class MongoDbDAO method listCardsFromCollection.
@Override
public List<MagicCard> listCardsFromCollection(MagicCollection collection, MagicEdition me) throws SQLException {
logger.debug("getCardsFromCollection " + collection + " " + me);
BasicDBObject query = new BasicDBObject();
List<MagicCard> ret = new ArrayList<>();
List<BasicDBObject> obj = new ArrayList<>();
obj.add(new BasicDBObject(dbColIDField, collection.getName()));
if (me != null) {
obj.add(new BasicDBObject(dbEditionField, me.getId().toUpperCase()));
query.put("$and", obj);
}
db.getCollection(colCards, BasicDBObject.class).find(query).forEach((Consumer<BasicDBObject>) result -> ret.add(deserialize(result.get("card").toString(), MagicCard.class)));
return ret;
}
Aggregations