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() {
|
public ICardGrid getCardsList() {
|
||||||
return this.currentView;
|
return this.currentView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ import java.awt.event.ActionListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -171,14 +172,25 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
if (event.getEventName().equals("double-click")) {
|
if (event.getEventName().equals("double-click")) {
|
||||||
SimpleCardView cardView = (SimpleCardView) event.getSource();
|
SimpleCardView cardView = (SimpleCardView) event.getSource();
|
||||||
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
|
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) {
|
if (card != null) {
|
||||||
deck.getCards().add(card);
|
deck.getCards().add(card);
|
||||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
||||||
deck.getSideboard().remove(card);
|
deck.getSideboard().remove(card);
|
||||||
cardSelector.removeCard(card.getId());
|
cardSelector.removeCard(card.getId());
|
||||||
|
cardSelector.setCardCount(deck.getSideboard().size());
|
||||||
cardSelector.refresh();
|
cardSelector.refresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (cardInfoPane instanceof CardInfoPane) {
|
if (cardInfoPane instanceof CardInfoPane) {
|
||||||
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
||||||
|
|
Loading…
Reference in a new issue