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