Search in sources :

Example 1 with CardInfoPane

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();
    }
}
Also used : SimpleCardView(mage.view.SimpleCardView) SimpleCardView(mage.view.SimpleCardView) CardView(mage.view.CardView) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card) BigCard(mage.client.cards.BigCard) CardInfoPane(mage.components.CardInfoPane)

Example 2 with CardInfoPane

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();
}
Also used : SimpleCardView(mage.view.SimpleCardView) SimpleCardView(mage.view.SimpleCardView) CardView(mage.view.CardView) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card) BigCard(mage.client.cards.BigCard) CardInfoPane(mage.components.CardInfoPane)

Aggregations

Card (mage.cards.Card)2 CardInfo (mage.cards.repository.CardInfo)2 BigCard (mage.client.cards.BigCard)2 CardInfoPane (mage.components.CardInfoPane)2 CardView (mage.view.CardView)2 SimpleCardView (mage.view.SimpleCardView)2