CardPredicates: add compareByCounterType to sort by the amount of counters of a given Type

This commit is contained in:
Hanmac
2016-11-20 11:45:16 +00:00
parent 07cb03889f
commit 88d919cb81

View File

@@ -17,6 +17,8 @@
*/ */
package forge.game.card; package forge.game.card;
import java.util.Comparator;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Iterables; 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 { public static class Presets {
/** /**