use of mage.components.CardInfoPane in project mage by magefree.
the class UpdateDeckTask method moveSelectorCardToDeck.
private void moveSelectorCardToDeck(Event event) {
SimpleCardView cardView = (SimpleCardView) event.getSource();
Card card = null;
boolean gameMode = mode != DeckEditorMode.FREE_BUILDING;
if (gameMode) {
// game: use existing real cards
for (Card sideCard : deck.getSideboard()) {
if (sideCard.getId().equals(cardView.getId())) {
card = sideCard;
break;
}
}
} else {
// editor: create mock card
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
card = cardInfo != null ? cardInfo.getMockCard() : null;
}
if (card != null) {
deck.getCards().add(card);
if (gameMode) {
// game: move card from another board
deck.getSideboard().remove(card);
cardSelector.removeCard(card.getId());
cardSelector.setCardCount(deck.getSideboard().size());
cardSelector.refresh();
}
// card hint update
if (cardInfoPane instanceof CardInfoPane) {
((CardInfoPane) cardInfoPane).setCard(new CardView(card), null);
}
hidePopup();
}
}
use of mage.components.CardInfoPane in project mage by magefree.
the class UpdateDeckTask method moveSelectorCardToSideboard.
private void moveSelectorCardToSideboard(Event event) {
boolean gameMode = mode != DeckEditorMode.FREE_BUILDING;
if (gameMode) {
throw new IllegalArgumentException("ERROR, you can move card to sideboard from selector in game mode.");
}
SimpleCardView cardView = (SimpleCardView) event.getSource();
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
if (card != null) {
deck.getSideboard().add(card);
}
// card hint update
if (cardInfoPane instanceof CardInfoPane) {
((CardInfoPane) cardInfoPane).setCard(new CardView(card), null);
}
hidePopup();
}
Aggregations