mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Fixed card selector not removing card from sideboard.
This commit is contained in:
parent
dfbe144ad2
commit
baedfd54bf
2 changed files with 19 additions and 3 deletions
|
@ -305,6 +305,10 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
}
|
||||
}
|
||||
|
||||
public void setCardCount(int value) {
|
||||
this.cardCount.setText(String.valueOf(value));
|
||||
}
|
||||
|
||||
public ICardGrid getCardsList() {
|
||||
return this.currentView;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ import java.awt.event.ActionListener;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -171,14 +172,25 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
if (event.getEventName().equals("double-click")) {
|
||||
SimpleCardView cardView = (SimpleCardView) event.getSource();
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
|
||||
Card card = cardInfo != null ? cardInfo.getCard() : null;
|
||||
Card card = null;
|
||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
||||
Iterator sideboard = deck.getSideboard().iterator();
|
||||
while (sideboard.hasNext()) {
|
||||
card = (Card) sideboard.next();
|
||||
if (card.getId().equals(cardView.getId())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
card = cardInfo != null ? cardInfo.getCard() : null;
|
||||
}
|
||||
if (card != null) {
|
||||
deck.getCards().add(card);
|
||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
||||
deck.getSideboard().remove(card);
|
||||
cardSelector.removeCard(card.getId());
|
||||
cardSelector.setCardCount(deck.getSideboard().size());
|
||||
cardSelector.refresh();
|
||||
|
||||
}
|
||||
if (cardInfoPane instanceof CardInfoPane) {
|
||||
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
||||
|
|
Loading…
Reference in a new issue