forked from External/mage
* Non creature tokens - fixed rollback errors in AI games (example: Food token, see #6331);
Fixed other potentially NPE errors with rarity;
This commit is contained in:
parent
1b60dfc258
commit
cb8d4dc340
12 changed files with 88 additions and 70 deletions
|
|
@ -1,19 +1,30 @@
|
|||
|
||||
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
import mage.constants.Rarity;
|
||||
import mage.view.CardView;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardViewRarityComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
return o1.getRarity().compareTo(o2.getRarity());
|
||||
Rarity r1 = o1.getRarity();
|
||||
Rarity r2 = o2.getRarity();
|
||||
|
||||
int val = Integer.compare(
|
||||
r1 == null ? 0 : r1.getSorting(),
|
||||
r2 == null ? 0 : r2.getSorting()
|
||||
);
|
||||
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue