mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
CardPredicates: add compareByCounterType to sort by the amount of counters of a given Type
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package forge.game.card;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -261,6 +263,16 @@ public final class CardPredicates {
|
||||
};
|
||||
}
|
||||
|
||||
public static final Comparator<Card> compareByCounterType(final CounterType type) {
|
||||
return new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(Card arg0, Card arg1) {
|
||||
return Integer.compare(arg0.getCounters(type),
|
||||
arg1.getCounters(type));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static class Presets {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user