Search in sources :

Example 51 with MagicCard

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);
}
Also used : MagicCard(org.magic.api.beans.MagicCard) MagicEdition(org.magic.api.beans.MagicEdition) Before(org.junit.Before)

Example 52 with MagicCard

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;
    }
}
Also used : MagicCard(org.magic.api.beans.MagicCard) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MagicEdition(org.magic.api.beans.MagicEdition) Component(java.awt.Component)

Example 53 with MagicCard

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);
}
Also used : MagicCard(org.magic.api.beans.MagicCard) MagicEdition(org.magic.api.beans.MagicEdition) MagicCollection(org.magic.api.beans.MagicCollection) Before(org.junit.Before)

Example 54 with MagicCard

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();
}
Also used : MagicCard(org.magic.api.beans.MagicCard) MagicEdition(org.magic.api.beans.MagicEdition)

Example 55 with MagicCard

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;
        }
    }
}
Also used : MagicCard(org.magic.api.beans.MagicCard) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

MagicCard (org.magic.api.beans.MagicCard)106 MagicEdition (org.magic.api.beans.MagicEdition)40 ArrayList (java.util.ArrayList)31 IOException (java.io.IOException)28 MagicDeck (org.magic.api.beans.MagicDeck)21 MagicCollection (org.magic.api.beans.MagicCollection)14 SQLException (java.sql.SQLException)12 Date (java.util.Date)11 MagicCardStock (org.magic.api.beans.MagicCardStock)10 DisplayableCard (org.magic.game.gui.components.DisplayableCard)10 JsonArray (com.google.gson.JsonArray)8 List (java.util.List)8 FileReader (java.io.FileReader)7 Before (org.junit.Before)7 BufferedReader (java.io.BufferedReader)6 File (java.io.File)6 FileWriter (java.io.FileWriter)6 MalformedURLException (java.net.MalformedURLException)6 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6