Search in sources :

Example 6 with DisplayableCard

use of org.magic.game.gui.components.DisplayableCard in project MtgDesktopCompanion by nicho92.

the class SealedPanel method addLands.

private void addLands() {
    int qte = Integer.parseInt(txtNumberLand.getText());
    String land = cboLands.getSelectedItem().toString();
    MagicEdition ed = new MagicEdition();
    ed.setId(MTGControler.getInstance().get("default-land-deck"));
    try {
        MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", land, ed, true).get(0);
        for (int i = 0; i < qte; i++) {
            deck.add(mc);
            DisplayableCard c = createCard(mc);
            panelDeck.addComponent(c);
            panelDeck.postTreatment(c);
        }
        refreshStats();
    } catch (IOException e) {
        MTGLogger.printStackTrace(e);
    }
}
Also used : MagicCard(org.magic.api.beans.MagicCard) DisplayableCard(org.magic.game.gui.components.DisplayableCard) MagicEdition(org.magic.api.beans.MagicEdition) IOException(java.io.IOException)

Example 7 with DisplayableCard

use of org.magic.game.gui.components.DisplayableCard in project MtgDesktopCompanion by nicho92.

the class EmblemActions method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    try {
        MagicCard tok = GamePanelGUI.getInstance().getTokenGenerator().generateEmblemFor(card.getMagicCard());
        DisplayableCard dc = new DisplayableCard(tok, MTGControler.getInstance().getCardsDimension(), true);
        dc.setMagicCard(tok);
        GamePanelGUI.getInstance().getPanelBattleField().addComponent(dc);
        GamePanelGUI.getInstance().getPanelBattleField().revalidate();
        GamePanelGUI.getInstance().getPanelBattleField().repaint();
        GamePanelGUI.getInstance().getPlayer().logAction("generate " + tok + " emblem");
    } catch (Exception ex) {
        logger.error(ex);
    }
}
Also used : MagicCard(org.magic.api.beans.MagicCard) DisplayableCard(org.magic.game.gui.components.DisplayableCard)

Example 8 with DisplayableCard

use of org.magic.game.gui.components.DisplayableCard in project MtgDesktopCompanion by nicho92.

the class MoveGraveyardActions method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String res = JOptionPane.showInputDialog("How many card to discard ?");
    if (res != null) {
        int c = Integer.parseInt(res);
        List<MagicCard> disc = GamePanelGUI.getInstance().getPlayer().discardCardFromLibrary(c);
        for (MagicCard mc : disc) {
            GamePanelGUI.getInstance().getPanelGrave().addComponent(new DisplayableCard(mc, MTGControler.getInstance().getCardsDimension(), true));
        }
        GamePanelGUI.getInstance().getPanelGrave().postTreatment(null);
    }
}
Also used : MagicCard(org.magic.api.beans.MagicCard) DisplayableCard(org.magic.game.gui.components.DisplayableCard)

Example 9 with DisplayableCard

use of org.magic.game.gui.components.DisplayableCard in project MtgDesktopCompanion by nicho92.

the class CardTransfertHandler method importData.

@Override
public boolean importData(TransferSupport support) {
    if (!canImport(support))
        return false;
    try {
        Draggable target = (Draggable) support.getComponent();
        DisplayableCard src = (DisplayableCard) support.getTransferable().getTransferData(localObjectFlavor);
        if ((((Draggable) src.getParent()).getOrigine() != target.getOrigine())) {
            src.getParent().revalidate();
            target.updatePanel();
            src.getParent().repaint();
            GameManager.getInstance().getStack().put(new CardSpell(src.getName(), src.getText(), src));
            logger.debug("move " + src.getMagicCard().getName() + " from " + ((Draggable) src.getParent()).getOrigine() + " to " + target.getOrigine());
            ((Draggable) src.getParent()).moveCard(src, target.getOrigine());
            target.addComponent(src);
        } else {
            target.postTreatment(src);
        }
        return true;
    } catch (Exception ufe) {
        logger.error("Error transfert", ufe);
    }
    return false;
}
Also used : Draggable(org.magic.game.gui.components.Draggable) CardSpell(org.magic.game.model.CardSpell) DisplayableCard(org.magic.game.gui.components.DisplayableCard) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException)

Example 10 with DisplayableCard

use of org.magic.game.gui.components.DisplayableCard in project MtgDesktopCompanion by nicho92.

the class MeldActions method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    DisplayableCard card2;
    try {
        card2 = GamePanelGUI.getInstance().getPanelBattleField().lookupCardBy("name", meldWith).get(0);
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "Could not meld the card, " + meldWith + " is not on the battlefield");
        return;
    }
    GamePanelGUI.getInstance().getPlayer().logAction("Meld " + card.getMagicCard() + " and " + meldWith + " to " + card.getMagicCard().getRotatedCardName());
    card.removeAllCounters();
    GamePanelGUI.getInstance().getPlayer().exileCardFromBattleField(card.getMagicCard());
    GamePanelGUI.getInstance().getPanelBattleField().remove(card);
    card2.removeAllCounters();
    GamePanelGUI.getInstance().getPlayer().exileCardFromBattleField(card2.getMagicCard());
    GamePanelGUI.getInstance().getPanelBattleField().remove(card2);
    MagicCard mc;
    try {
        mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", card.getMagicCard().getRotatedCardName(), card.getMagicCard().getEditions().get(0), true).get(0);
        Dimension d = new Dimension((int) (MTGControler.getInstance().getCardsDimension().getWidth() * 1.5), (int) (MTGControler.getInstance().getCardsDimension().getHeight() * 1.5));
        DisplayableCard c = new DisplayableCard(mc, d, true);
        c.initActions();
        GamePanelGUI.getInstance().getPanelBattleField().addComponent(c);
    } catch (Exception e1) {
        logger.error(e1);
    }
    GamePanelGUI.getInstance().getPanelBattleField().revalidate();
    GamePanelGUI.getInstance().getPanelBattleField().repaint();
}
Also used : MagicCard(org.magic.api.beans.MagicCard) DisplayableCard(org.magic.game.gui.components.DisplayableCard) Dimension(java.awt.Dimension)

Aggregations

DisplayableCard (org.magic.game.gui.components.DisplayableCard)20 MagicCard (org.magic.api.beans.MagicCard)10 Dimension (java.awt.Dimension)4 IOException (java.io.IOException)4 MagicEdition (org.magic.api.beans.MagicEdition)4 JScrollPane (javax.swing.JScrollPane)3 BorderLayout (java.awt.BorderLayout)2 FlowLayout (java.awt.FlowLayout)2 GridLayout (java.awt.GridLayout)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JButton (javax.swing.JButton)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JSplitPane (javax.swing.JSplitPane)2 JTextField (javax.swing.JTextField)2 PositionEnum (org.magic.game.model.PositionEnum)2 Component (java.awt.Component)1 GridBagConstraints (java.awt.GridBagConstraints)1