mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Deck editor - Fixed a bug that prevented users to add cards to deck or sideboard (was caused by creatures with negative toughness and it was sorted by p/t - fixes #1414).
This commit is contained in:
parent
d9b20298b7
commit
ea0ba76736
1 changed files with 24 additions and 20 deletions
|
@ -1,15 +1,15 @@
|
|||
/* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -19,41 +19,42 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.deckeditor.table;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.view.CardView;
|
||||
|
||||
/**
|
||||
* {@link MageCard} comparator. Used to sort cards in Deck Editor Table View pane.
|
||||
*
|
||||
* {@link MageCard} comparator. Used to sort cards in Deck Editor Table View
|
||||
* pane.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class MageCardComparator implements Comparator<CardView> {
|
||||
|
||||
private final int column;
|
||||
private boolean ascending;
|
||||
private final boolean ascending;
|
||||
|
||||
public MageCardComparator(int column, boolean ascending) {
|
||||
this.column = column;
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(CardView a, CardView b) {
|
||||
Comparable aCom = null;
|
||||
Comparable bCom = null;
|
||||
|
||||
if (column == 0)// #skip
|
||||
{
|
||||
aCom = Integer.valueOf(1);
|
||||
bCom = Integer.valueOf(1);
|
||||
aCom = 1;
|
||||
bCom = 1;
|
||||
} else if (column == 1)// Name
|
||||
{
|
||||
aCom = a.getName();
|
||||
|
@ -76,13 +77,15 @@ public class MageCardComparator implements Comparator<CardView> {
|
|||
bCom = CardHelper.getType(b);
|
||||
} else if (column == 5)// Stats, attack and defense
|
||||
{
|
||||
aCom = new Float(-1);
|
||||
bCom = new Float(-1);
|
||||
aCom = (float) -1;
|
||||
bCom = (float) -1;
|
||||
|
||||
if (CardHelper.isCreature(a))
|
||||
aCom = new Float(a.getPower() + "." + a.getToughness());
|
||||
if (CardHelper.isCreature(b))
|
||||
bCom = new Float(b.getPower() + "." + b.getToughness());
|
||||
if (CardHelper.isCreature(a)) {
|
||||
aCom = new Float(a.getPower() + "." + (a.getToughness().startsWith("-") ? "0" : a.getToughness()));
|
||||
}
|
||||
if (CardHelper.isCreature(b)) {
|
||||
bCom = new Float(b.getPower() + "." + (b.getToughness().startsWith("-") ? "0" : b.getToughness()));
|
||||
}
|
||||
} else if (column == 6)// Rarity
|
||||
{
|
||||
aCom = a.getRarity().toString();
|
||||
|
@ -93,9 +96,10 @@ public class MageCardComparator implements Comparator<CardView> {
|
|||
bCom = b.getExpansionSetCode();
|
||||
}
|
||||
|
||||
if (ascending)
|
||||
if (ascending) {
|
||||
return aCom.compareTo(bCom);
|
||||
else
|
||||
} else {
|
||||
return bCom.compareTo(aCom);
|
||||
}
|
||||
}// compare()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue