This commit is contained in:
LevelX2 2013-09-26 21:39:07 +02:00
commit 8841cca120
9 changed files with 278 additions and 174 deletions

View file

@ -74,28 +74,39 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
* Max amount of cards in card grid for which card images will be drawn.
* Done so to solve issue with memory for big piles of cards.
*/
private static final int MAX_IMAGES = 250;
public static final int MAX_IMAGES = 300;
public CardGrid() {
initComponents();
setOpaque(false);
}
@Override
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
this.loadCards(showCards, sortBy, piles, bigCard, gameId, true);
}
@Override
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId, boolean merge) {
boolean drawImage = showCards.size() < MAX_IMAGES;
this.bigCard = bigCard;
this.gameId = gameId;
for (CardView card: showCards.values()) {
if (!cards.containsKey(card.getId())) {
addCard(card, bigCard, gameId, drawImage);
if (merge) {
for (CardView card: showCards.values()) {
if (!cards.containsKey(card.getId())) {
addCard(card, bigCard, gameId, drawImage);
}
}
}
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
Entry<UUID, MageCard> entry = i.next();
if (!showCards.containsKey(entry.getKey())) {
removeCardImg(entry.getKey());
i.remove();
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
Entry<UUID, MageCard> entry = i.next();
if (!showCards.containsKey(entry.getKey())) {
removeCardImg(entry.getKey());
i.remove();
}
}
} else {
this.clear();
for (CardView card: showCards.values()) {
addCard(card, bigCard, gameId, drawImage);
}
}
System.gc();
@ -144,8 +155,9 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
MageCard lastCard = null;
for (MageCard cardImg: sortedCards) {
if (piles) {
if (lastCard == null)
if (lastCard == null) {
lastCard = cardImg;
}
switch (sortBy) {
case NAME:
if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
@ -203,6 +215,19 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
repaint();
}
private void clear() {
this.cards.clear();
removeAllCardImg();
}
private void removeAllCardImg() {
for (Component comp: getComponents()) {
if (comp instanceof Card || comp instanceof MageCard) {
remove(comp);
}
}
}
private void removeCardImg(UUID cardId) {
for (Component comp: getComponents()) {
if (comp instanceof Card) {
@ -307,6 +332,11 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
revalidate();
repaint();
}
@Override
public int cardsSize() {
return cards.size();
}
}
class CardNameComparator implements Comparator<MageCard> {

View file

@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
@ -35,7 +35,7 @@
<Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="305" max="32767" attributes="0"/>
<Component id="jScrollPane1" pref="23" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View file

@ -163,6 +163,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
return list;
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
this.cards = showCards;
this.bigCard = bigCard;
@ -317,6 +318,11 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
@Override
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
this.loadCards(showCards, sortBy, piles, bigCard, gameId, true);
}
@Override
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId, boolean merge) {
cards = showCards;
this.bigCard = bigCard;
this.gameId = gameId;
@ -534,4 +540,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
public void setDisplayNoCopies(boolean value) {
mainModel.setDisplayNoCopies(value);
}
@Override
public int cardsSize() {
return cards.size();
}
}

View file

@ -46,5 +46,7 @@ public interface ICardGrid {
void addCardEventListener(Listener<Event> listener);
void drawCards(Constants.SortBy sortBy, boolean piles);
void loadCards(CardsView showCards, Constants.SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId);
void loadCards(CardsView showCards, Constants.SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId, boolean merge);
void refresh();
int cardsSize();
}

View file

@ -34,7 +34,23 @@
package mage.client.deckeditor;
import mage.constants.CardType;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer;
import mage.MageObject;
import mage.ObjectColor;
import mage.cards.Card;
@ -49,6 +65,7 @@ import mage.client.cards.ICardGrid;
import mage.client.constants.Constants.SortBy;
import mage.client.deckeditor.table.TableModel;
import mage.client.util.sets.ConstructedFormats;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
@ -59,12 +76,6 @@ import mage.filter.predicate.other.CardTextPredicate;
import mage.filter.predicate.other.ExpansionSetPredicate;
import mage.view.CardsView;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.*;
import java.util.*;
/**
*
@ -92,7 +103,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
currentView = mainModel; // by default we use List View
}
public void makeTransparent() {
private void makeTransparent() {
this.addComponentListener(this);
setOpaque(false);
cardGrid.setOpaque(false);
@ -107,7 +118,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbTypes.setOpaque(true); // false = transparent
}
public void initListViewComponents() {
private void initListViewComponents() {
mainTable = new JTable();
mainModel = new TableModel();
@ -135,6 +146,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
chkPiles.setEnabled(false);
mainTable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2 && !e.isConsumed()) {
e.consume();
@ -178,70 +190,73 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.btnClear.setVisible(true);
this.cbExpansionSet.setVisible(true);
cbExpansionSet.setModel(new DefaultComboBoxModel(ConstructedFormats.getTypes()));
// Action event on Expansion set triggers loadCards method
cbExpansionSet.setSelectedIndex(0);
filterCards();
}
private FilterCard buildFilter() {
FilterCard filter = new FilterCard();
ArrayList<Predicate<MageObject>> predicates = new ArrayList<Predicate<MageObject>>();
if (this.rdoGreen.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (this.rdoRed.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.RED));
}
if (this.rdoBlack.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (this.rdoBlue.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (this.rdoWhite.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.WHITE));
}
if (this.rdoColorless.isSelected()) {
predicates.add(new ColorlessPredicate());
}
filter.add(Predicates.or(predicates));
predicates.clear();
if (this.rdoLand.isSelected()) {
predicates.add(new CardTypePredicate(CardType.LAND));
}
if (this.rdoArtifacts.isSelected()) {
predicates.add(new CardTypePredicate(CardType.ARTIFACT));
}
if (this.rdoCreatures.isSelected()) {
predicates.add(new CardTypePredicate(CardType.CREATURE));
}
if (this.rdoEnchantments.isSelected()) {
predicates.add(new CardTypePredicate(CardType.ENCHANTMENT));
}
if (this.rdoInstants.isSelected()) {
predicates.add(new CardTypePredicate(CardType.INSTANT));
}
if (this.rdoSorceries.isSelected()) {
predicates.add(new CardTypePredicate(CardType.SORCERY));
}
if (this.rdoPlaneswalkers.isSelected()) {
predicates.add(new CardTypePredicate(CardType.PLANESWALKER));
}
filter.add(Predicates.or(predicates));
String name = jTextFieldSearch.getText().trim();
filter.add(new CardTextPredicate(name));
if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) {
ArrayList<Predicate<Card>> expansionPredicates = new ArrayList<Predicate<Card>>();
for (String setCode : ConstructedFormats.getSetsByFormat(expansionSelection)) {
expansionPredicates.add(new ExpansionSetPredicate(setCode));
if (limited) {
ArrayList<Predicate<MageObject>> predicates = new ArrayList<Predicate<MageObject>>();
if (this.rdoGreen.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (this.rdoRed.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.RED));
}
if (this.rdoBlack.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (this.rdoBlue.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (this.rdoWhite.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.WHITE));
}
if (this.rdoColorless.isSelected()) {
predicates.add(new ColorlessPredicate());
}
filter.add(Predicates.or(predicates));
predicates.clear();
if (this.rdoLand.isSelected()) {
predicates.add(new CardTypePredicate(CardType.LAND));
}
if (this.rdoArtifacts.isSelected()) {
predicates.add(new CardTypePredicate(CardType.ARTIFACT));
}
if (this.rdoCreatures.isSelected()) {
predicates.add(new CardTypePredicate(CardType.CREATURE));
}
if (this.rdoEnchantments.isSelected()) {
predicates.add(new CardTypePredicate(CardType.ENCHANTMENT));
}
if (this.rdoInstants.isSelected()) {
predicates.add(new CardTypePredicate(CardType.INSTANT));
}
if (this.rdoSorceries.isSelected()) {
predicates.add(new CardTypePredicate(CardType.SORCERY));
}
if (this.rdoPlaneswalkers.isSelected()) {
predicates.add(new CardTypePredicate(CardType.PLANESWALKER));
}
filter.add(Predicates.or(predicates));
if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) {
ArrayList<Predicate<Card>> expansionPredicates = new ArrayList<Predicate<Card>>();
for (String setCode : ConstructedFormats.getSetsByFormat(expansionSelection)) {
expansionPredicates.add(new ExpansionSetPredicate(setCode));
}
filter.add(Predicates.or(expansionPredicates));
}
filter.add(Predicates.or(expansionPredicates));
}
}
@ -279,11 +294,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
criteria.types(CardType.PLANESWALKER);
}
String text = jTextFieldSearch.getText().trim();
if (!text.isEmpty()) {
// criteria.rules(text);
}
if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) {
@ -314,9 +324,12 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
if (filter.match(card, null)) {
filteredCards.add(card);
}
}
}
}
this.currentView.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null);
if (currentView instanceof CardGrid && filteredCards.size() > CardGrid.MAX_IMAGES) {
this.toggleViewMode();
}
this.currentView.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null, false);
this.cardCount.setText(String.valueOf(filteredCards.size()));
}
finally {
@ -328,10 +341,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.cardCount.setText(String.valueOf(value));
}
public ICardGrid getCardsList() {
return this.currentView;
}
public List<ICardGrid> getCardGridComponents() {
List<ICardGrid> components = new ArrayList<ICardGrid>();
components.add(mainModel);
@ -807,13 +816,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}//GEN-LAST:event_rdoPlaneswalkersActionPerformed
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
if (this.cbExpansionSet.getSelectedItem().equals("-- Standard")) {
filterCards();
} else {
// auto switch for ListView for "All sets" (too many cards to load)
jToggleListView.doClick();
jToggleListView.setSelected(true);
}
filterCards();
}//GEN-LAST:event_cbExpansionSetActionPerformed
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
@ -841,35 +844,39 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}//GEN-LAST:event_btnBoosterActionPerformed
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
if (cbSortBy.getSelectedItem() instanceof SortBy)
if (cbSortBy.getSelectedItem() instanceof SortBy) {
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
}//GEN-LAST:event_cbSortByActionPerformed
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
if (cbSortBy.getSelectedItem() instanceof SortBy)
if (cbSortBy.getSelectedItem() instanceof SortBy) {
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
}//GEN-LAST:event_chkPilesActionPerformed
private void jToggleListViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleListViewActionPerformed
jToggleCardView.setSelected(false);
currentView = mainModel;
jScrollPane1.setViewportView(mainTable);
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
jButtonAddToMain.setEnabled(true);
jButtonAddToSideboard.setEnabled(true);
if (!(currentView instanceof TableModel)) {
toggleViewMode();
} else {
jToggleListView.setSelected(true);
}
filterCards();
}//GEN-LAST:event_jToggleListViewActionPerformed
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
jToggleListView.setSelected(false);
currentView = cardGrid;
jScrollPane1.setViewportView(cardGrid);
cbSortBy.setEnabled(true);
chkPiles.setEnabled(true);
jButtonAddToMain.setEnabled(false);
jButtonAddToSideboard.setEnabled(false);
filterCards();
if (currentView.cardsSize() > CardGrid.MAX_IMAGES) {
jToggleCardView.setSelected(false);
JOptionPane.showMessageDialog(this, new StringBuilder("The card view can't be used for more than ").append(CardGrid.MAX_IMAGES).append(" cards.").toString());
} else {
if (!(currentView instanceof CardGrid)) {
toggleViewMode();
} else {
jToggleCardView.setSelected(true);
}
filterCards();
}
}//GEN-LAST:event_jToggleCardViewActionPerformed
private void jButtonAddToMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddToMainActionPerformed
@ -881,8 +888,9 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
mainModel.doubleClick(index);
}
//if (!mode.equals(Constants.DeckEditorMode.Constructed))
if (limited)
if (limited) {
mainModel.fireTableDataChanged();
}
}
}//GEN-LAST:event_jButtonAddToMainActionPerformed
@ -895,8 +903,9 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
mainModel.shiftDoubleClick(index);
}
//if (!mode.equals(Constants.DeckEditorMode.Constructed))
if (limited)
if (limited) {
mainModel.fireTableDataChanged();
}
}
}//GEN-LAST:event_jButtonAddToSideboardActionPerformed
@ -918,9 +927,33 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
filterCards();
}//GEN-LAST:event_jButtonCleanActionPerformed
private void toggleViewMode() {
if (currentView instanceof CardGrid) {
jToggleListView.setSelected(true);
jToggleCardView.setSelected(false);
currentView = mainModel;
jScrollPane1.setViewportView(mainTable);
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
jButtonAddToMain.setEnabled(true);
jButtonAddToSideboard.setEnabled(true);
} else {
jToggleCardView.setSelected(true);
jToggleListView.setSelected(false);
currentView = cardGrid;
jScrollPane1.setViewportView(cardGrid);
cbSortBy.setEnabled(true);
chkPiles.setEnabled(true);
jButtonAddToMain.setEnabled(false);
jButtonAddToSideboard.setEnabled(false);
}
}
public List<Integer> asList(final int[] is) {
List<Integer> list = new ArrayList<Integer>();
for (int i : is) list.add(i);
for (int i : is) {
list.add(i);
}
return list;
}
@ -978,26 +1011,30 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
@Override
public void componentResized(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
if (cbSortBy.getSelectedItem() instanceof SortBy) {
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
}
@Override
public void componentMoved(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
if (cbSortBy.getSelectedItem() instanceof SortBy) {
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
}
@Override
public void componentShown(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
if (cbSortBy.getSelectedItem() instanceof SortBy) {
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
}
@Override
public void componentHidden(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
if (cbSortBy.getSelectedItem() instanceof SortBy) {
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
}
}

View file

@ -84,69 +84,84 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
@Override
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
this.loadCards(showCards, sortBy, piles, bigCard, gameId, true);
}
@Override
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId, boolean merge) {
this.bigCard = bigCard;
this.gameId = gameId;
int landCount = 0;
int creatureCount = 0;
for (CardView card : showCards.values()) {
if (!cards.containsKey(card.getId())) {
if (!merge) {
this.clear();
for (CardView card : showCards.values()) {
addCard(card, bigCard, gameId);
}
if (updateCountsCallback != null) {
if (card.getCardTypes().contains(CardType.LAND))
landCount++;
if (card.getCardTypes().contains(CardType.CREATURE))
creatureCount++;
} else {
for (CardView card : showCards.values()) {
if (!cards.containsKey(card.getId())) {
addCard(card, bigCard, gameId);
}
if (updateCountsCallback != null) {
if (card.getCardTypes().contains(CardType.LAND)) {
landCount++;
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
creatureCount++;
}
}
}
}
// not easy logic for merge :)
for (Iterator<Entry<UUID, CardView>> i = cards.entrySet().iterator(); i.hasNext();) {
Entry<UUID, CardView> entry = i.next();
if (!showCards.containsKey(entry.getKey())) {
i.remove();
if (displayNoCopies) {
String key = entry.getValue().getName() + entry.getValue().getExpansionSetCode() + entry.getValue().getCardNumber();
if (cardsNoCopies.containsKey(key)) {
Integer count = cardsNoCopies.get(key);
count--;
if (count > 0) {
cardsNoCopies.put(key, count);
} else {
cardsNoCopies.remove(key);
}
for (int j = 0; j < view.size(); j++) {
CardView cv = view.get(j);
if (cv.getId().equals(entry.getValue().getId())) {
if (count > 0) {
// replace by another card with the same name+setCode
String key1 = cv.getName()+cv.getExpansionSetCode()+cv.getCardNumber();
for (CardView cardView : cards.values()) {
String key2 = cardView.getName()+cardView.getExpansionSetCode()+cardView.getCardNumber();
if ((key1).equals(key2)) {
view.set(j, cardView);
break;
// no easy logic for merge :)
for (Iterator<Entry<UUID, CardView>> i = cards.entrySet().iterator(); i.hasNext();) {
Entry<UUID, CardView> entry = i.next();
if (!showCards.containsKey(entry.getKey())) {
i.remove();
if (displayNoCopies) {
String key = entry.getValue().getName() + entry.getValue().getExpansionSetCode() + entry.getValue().getCardNumber();
if (cardsNoCopies.containsKey(key)) {
Integer count = cardsNoCopies.get(key);
count--;
if (count > 0) {
cardsNoCopies.put(key, count);
} else {
cardsNoCopies.remove(key);
}
for (int j = 0; j < view.size(); j++) {
CardView cv = view.get(j);
if (cv.getId().equals(entry.getValue().getId())) {
if (count > 0) {
// replace by another card with the same name+setCode
String key1 = cv.getName()+cv.getExpansionSetCode()+cv.getCardNumber();
for (CardView cardView : cards.values()) {
String key2 = cardView.getName()+cardView.getExpansionSetCode()+cardView.getCardNumber();
if ((key1).equals(key2)) {
view.set(j, cardView);
break;
}
}
} else {
view.remove(j);
}
} else {
view.remove(j);
break;
}
}
}
} else {
for (CardView cv : view) {
if (cv.getId().equals(entry.getKey())) {
view.remove(cv);
break;
}
}
}
} else {
for (CardView cv : view) {
if (cv.getId().equals(entry.getKey())) {
view.remove(cv);
break;
}
}
}
}
}
if (updateCountsCallback != null) {
updateCountsCallback.update(cards.size(), creatureCount, landCount);
if (updateCountsCallback != null) {
updateCountsCallback.update(cards.size(), creatureCount, landCount);
}
}
sort(1, true);
@ -384,4 +399,9 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
public void setUpdateCountsCallback(UpdateCountsCallback callback) {
this.updateCountsCallback = callback;
}
@Override
public int cardsSize() {
return cards.size();
}
}

View file

@ -54,7 +54,7 @@ import mage.watchers.common.DamagedByWatcher;
public class KumanosPupils extends CardImpl<KumanosPupils> {
public KumanosPupils(UUID ownerId) {
super(ownerId, 177, "Kumano's Pupils", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{R}");
super(ownerId, 177, "Kumano's Pupils", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{4}{R}");
this.expansionSetCode = "CHK";
this.subtype.add("Human");
this.subtype.add("Shaman");

View file

@ -204,12 +204,15 @@ public class CardCriteria {
clausesCount++;
}
for (CardType type : types) {
where.like("types", new SelectArg('%' + type.name() + '%'));
}
if (!types.isEmpty()) {
where.or(types.size());
clausesCount++;
if (types.size() != 7) { //if all types selected - no selection needed
for (CardType type : types) {
where.like("types", new SelectArg('%' + type.name() + '%'));
}
if (!types.isEmpty()) {
where.or(types.size());
clausesCount++;
}
}
for (CardType type : notTypes) {
@ -277,6 +280,6 @@ public class CardCriteria {
qb.limit(count);
}
qb.orderBy("cardNumber", true);
// qb.orderBy("cardNumber", true);
}
}

View file

@ -44,6 +44,7 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import mage.constants.CardType;
import org.apache.log4j.Logger;
/**
*
@ -265,7 +266,7 @@ public enum CardRepository {
try {
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
criteria.buildQuery(queryBuilder);
return cardDao.query(queryBuilder.prepare());
} catch (SQLException ex) {
}