Fix so Pack and Multicolor filter buttons work correctly when only they are toggled off

This commit is contained in:
drdev
2013-12-21 17:33:30 +00:00
parent 1ea41edd6a
commit d8511c92c0
3 changed files with 24 additions and 5 deletions

View File

@@ -54,7 +54,12 @@ public class CardCMCFilter extends StatTypeFilter<PaperCard> {
}
if (cmcs.size() == buttonMap.size()) {
return Predicates.alwaysTrue();
return new Predicate<PaperCard>() { //use custom return true delegate to validate the item is a card
@Override
public boolean apply(PaperCard card) {
return true;
}
};
}
return Predicates.compose(Predicates.or(cmcs), PaperCard.FN_GET_RULES);
}

View File

@@ -78,8 +78,11 @@ public class CardColorFilter extends StatTypeFilter<PaperCard> {
preFinal = CardRulesPredicates.canCastWithAvailable(colors);
}
}
else if (colors != MagicColor.ALL_COLORS) {
preFinal = Predicates.and(CardRulesPredicates.canCastWithAvailable(colors), Predicates.not(Presets.IS_MULTICOLOR));
else {
preFinal = Predicates.not(Presets.IS_MULTICOLOR);
if (colors != MagicColor.ALL_COLORS) {
preFinal = Predicates.and(CardRulesPredicates.canCastWithAvailable(colors), preFinal);
}
}
if (!wantColorless) {
if (colors != 0 && colors != MagicColor.ALL_COLORS) {
@@ -91,7 +94,12 @@ public class CardColorFilter extends StatTypeFilter<PaperCard> {
}
if (preFinal == null) {
return Predicates.alwaysTrue();
return new Predicate<PaperCard>() { //use custom return true delegate to validate the item is a card
@Override
public boolean apply(PaperCard card) {
return true;
}
};
}
return Predicates.compose(preFinal, PaperCard.FN_GET_RULES);
}

View File

@@ -2,6 +2,7 @@ package forge.gui.toolbox.itemmanager.filters;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import com.google.common.base.Predicate;
@@ -53,7 +54,12 @@ public class CardTypeFilter extends StatTypeFilter<PaperCard> {
}
if (types.size() == buttonMap.size()) {
return Predicates.alwaysTrue();
return new Predicate<PaperCard>() { //use custom return true delegate to validate the item is a card
@Override
public boolean apply(PaperCard card) {
return true;
}
};
}
return Predicates.compose(Predicates.or(types), PaperCard.FN_GET_RULES);
}