mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Integrating foil card filter by Seravy.
This commit is contained in:
@@ -3,6 +3,8 @@ package forge.itemmanager;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.StaticData;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.card.ColorSet;
|
||||
@@ -95,7 +97,7 @@ public class SFilterUtil {
|
||||
case '\\':
|
||||
if (i < text.length() - 1 && text.charAt(i + 1) == '"') {
|
||||
ch = '"'; //allow appending escaped quotation character
|
||||
i++; //prevent chaging inQuotes for that character
|
||||
i++; //prevent changing inQuotes for that character
|
||||
}
|
||||
break;
|
||||
case ',':
|
||||
@@ -138,6 +140,38 @@ public class SFilterUtil {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Predicate<PaperCard> buildFoilFilter(Map<SItemManagerUtil.StatTypes, ? extends IButton> buttonMap) {
|
||||
|
||||
// final Map<StatTypes, ? extends IButton> buttonMap2 =buttonMap;
|
||||
final int Foil = (((buttonMap.get(StatTypes.FOIL_OLD).isSelected()) ? 1 : 0) +
|
||||
((buttonMap.get(StatTypes.FOIL_NEW).isSelected()) ? 2 : 0) +
|
||||
((buttonMap.get(StatTypes.FOIL_NONE).isSelected()) ? 4 : 0));
|
||||
|
||||
return new Predicate<PaperCard>() {
|
||||
@Override
|
||||
public boolean apply(PaperCard card) {
|
||||
|
||||
|
||||
boolean result=false;
|
||||
|
||||
CardEdition edition = StaticData.instance().getEditions().get(card.getEdition());
|
||||
if ((Foil & 1)==1) {
|
||||
// Old Style Foil
|
||||
if (edition.getFoilType()==CardEdition.FoilType.OLD_STYLE) {result=result || card.isFoil();}
|
||||
}
|
||||
if ((Foil & 2)==2) {
|
||||
// New Style Foil
|
||||
if (edition.getFoilType()==CardEdition.FoilType.MODERN) {result=result || card.isFoil();}
|
||||
}
|
||||
if ((Foil & 4)==4)
|
||||
{ result=result || !card.isFoil(); }
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static Predicate<PaperCard> buildColorFilter(Map<SItemManagerUtil.StatTypes, ? extends IButton> buttonMap) {
|
||||
byte colors0 = 0;
|
||||
|
||||
@@ -60,7 +60,12 @@ public final class SItemManagerUtil {
|
||||
DECK_RED (FSkinProp.IMG_MANA_R, null, "Red decks"),
|
||||
DECK_GREEN (FSkinProp.IMG_MANA_G, null, "Green decks"),
|
||||
DECK_COLORLESS (FSkinProp.IMG_MANA_COLORLESS, null, "Colorless decks"),
|
||||
DECK_MULTICOLOR (FSkinProp.IMG_MULTI, null, "Multicolor decks");
|
||||
DECK_MULTICOLOR (FSkinProp.IMG_MULTI, null, "Multicolor decks"),
|
||||
|
||||
FOIL_OLD (FSkinProp.FOIL_11, null, "Old style Foil cards"),
|
||||
FOIL_NEW (FSkinProp.FOIL_01, null, "New style Foil cards"),
|
||||
FOIL_NONE (FSkinProp.ICO_CLOSE, null, "non-Foil cards");
|
||||
|
||||
|
||||
public final FSkinProp skinProp;
|
||||
public final Predicate<CardRules> predicate;
|
||||
|
||||
Reference in New Issue
Block a user