From f8a26d4e7e5a463f15a9307f370afd3df9bcd5c8 Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Sun, 13 Feb 2011 23:48:43 -0500 Subject: [PATCH] sub-sort on name when editing decks --- .../main/java/mage/client/cards/CardGrid.java | 24 ++++++++++++++++--- .../java/mage/client/cards/CardsList.form | 2 +- .../java/mage/client/cards/CardsList.java | 24 ++++++++++++++++--- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/CardGrid.java b/Mage.Client/src/main/java/mage/client/cards/CardGrid.java index 7a7547e5fb..a602188b04 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/CardGrid.java @@ -256,7 +256,13 @@ class CardRarityComparator implements Comparator { @Override public int compare(MageCard o1, MageCard o2) { - return o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity()); + int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity()); + if (val == 0) { + return o1.getOriginal().getName().compareTo(o2.getOriginal().getName()); + } + else { + return val; + } } } @@ -265,7 +271,13 @@ class CardCostComparator implements Comparator { @Override public int compare(MageCard o1, MageCard o2) { - return Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost())); + int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost())); + if (val == 0) { + return o1.getOriginal().getName().compareTo(o2.getOriginal().getName()); + } + else { + return val; + } } } @@ -274,7 +286,13 @@ class CardColorComparator implements Comparator { @Override public int compare(MageCard o1, MageCard o2) { - return o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor()); + int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor()); + if (val == 0) { + return o1.getOriginal().getName().compareTo(o2.getOriginal().getName()); + } + else { + return val; + } } } \ No newline at end of file diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.form b/Mage.Client/src/main/java/mage/client/cards/CardsList.form index 773addc57e..38981bdff1 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardsList.form +++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.form @@ -35,7 +35,7 @@ - + diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.java b/Mage.Client/src/main/java/mage/client/cards/CardsList.java index 3b9ca08f00..60556eafef 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardsList.java +++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.java @@ -292,7 +292,13 @@ class CardViewRarityComparator implements Comparator { @Override public int compare(CardView o1, CardView o2) { - return o1.getRarity().compareTo(o2.getRarity()); + int val = o1.getRarity().compareTo(o2.getRarity()); + if (val == 0) { + return o1.getName().compareTo(o2.getName()); + } + else { + return val; + } } } @@ -301,7 +307,13 @@ class CardViewCostComparator implements Comparator { @Override public int compare(CardView o1, CardView o2) { - return Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost())); + int val = Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost())); + if (val == 0) { + return o1.getName().compareTo(o2.getName()); + } + else { + return val; + } } } @@ -310,7 +322,13 @@ class CardViewColorComparator implements Comparator { @Override public int compare(CardView o1, CardView o2) { - return o1.getColor().compareTo(o2.getColor()); + int val = o1.getColor().compareTo(o2.getColor()); + if (val == 0) { + return o1.getName().compareTo(o2.getName()); + } + else { + return val; + } } } \ No newline at end of file