Fix so multi-color cards containing a filtered color no longer show up in catalogs

This commit is contained in:
drdev
2013-11-29 06:52:51 +00:00
parent 7e37495b49
commit 1a8fe19c88
2 changed files with 8 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ public class SFilterUtil {
*/
public static Predicate<PaperCard> buildColorAndTypeFilter(Map<SItemManagerUtil.StatTypes, FLabel> statLabels) {
final List<Predicate<CardRules>> colors = new ArrayList<Predicate<CardRules>>();
final List<Predicate<CardRules>> notColors = new ArrayList<Predicate<CardRules>>();
final List<Predicate<CardRules>> types = new ArrayList<Predicate<CardRules>>();
boolean wantMulticolor = false;
@@ -41,6 +42,7 @@ public class SFilterUtil {
switch (s) {
case WHITE: case BLUE: case BLACK: case RED: case GREEN: case COLORLESS:
if (statLabels.get(s).getSelected()) { colors.add(s.predicate); }
else { notColors.add(Predicates.not(s.predicate)); }
break;
case MULTICOLOR:
wantMulticolor = statLabels.get(s).getSelected();
@@ -58,6 +60,10 @@ public class SFilterUtil {
throw new RuntimeException("unhandled enum value: " + s);
}
}
if (wantMulticolor && !colors.isEmpty() && !notColors.isEmpty()) {
preExceptMulti = Predicates.and(notColors); //ensure multicolor cards with filtered colors don't show up
}
Predicate<CardRules> preColors = colors.size() == 6 ? null : Predicates.or(colors);
Predicate<CardRules> preFinal = colors.isEmpty() && wantMulticolor ?