use of org.magic.api.beans.MagicCard 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.MagicCard 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.MagicCard 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.MagicCard 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.MagicCard in project MtgDesktopCompanion by nicho92.
the class HsqlDAO method listCardsFromCollection.
public List<MagicCard> listCardsFromCollection(MagicCollection collection, MagicEdition me) throws SQLException {
logger.trace("cards for " + collection + " " + me);
String sql = "select mcard from cards where collection= ?";
if (me != null)
sql = "select mcard from cards where collection= ? and edition = ?";
if (collection == null)
throw new SQLException("collection must not be null");
try (PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, collection.getName());
if (me != null)
pst.setString(2, me.getId());
try (ResultSet rs = pst.executeQuery()) {
List<MagicCard> retour = new ArrayList<>();
while (rs.next()) {
try {
retour.add((MagicCard) rs.getObject(cardField));
} catch (Exception e) {
throw new SQLException("ERROR ", e);
}
}
return retour;
}
}
}
Aggregations