Jeck - Added filtering by card's first letter. This is pretty much the last filter I can think of, except possibly some more complex ones like the mana producer filter.
This commit is contained in:
@@ -93,6 +93,15 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
int setid;
|
int setid;
|
||||||
};
|
};
|
||||||
|
class WCFilterLetter: public WCardFilter{
|
||||||
|
public:
|
||||||
|
WCFilterLetter(string arg);
|
||||||
|
bool isMatch(MTGCard * c);
|
||||||
|
string getCode();
|
||||||
|
float filterFee() {return 1.0f;}; //Alpha searches are expensive!
|
||||||
|
protected:
|
||||||
|
char alpha;
|
||||||
|
};
|
||||||
class WCFilterColor: public WCardFilter{
|
class WCFilterColor: public WCardFilter{
|
||||||
public:
|
public:
|
||||||
WCFilterColor(int _c) {color = _c;};
|
WCFilterColor(int _c) {color = _c;};
|
||||||
|
|||||||
@@ -452,6 +452,7 @@ public:
|
|||||||
STATE_CANCEL,
|
STATE_CANCEL,
|
||||||
BEGIN_FILTERS = 0,
|
BEGIN_FILTERS = 0,
|
||||||
FILTER_SET = BEGIN_FILTERS,
|
FILTER_SET = BEGIN_FILTERS,
|
||||||
|
FILTER_ALPHA,
|
||||||
FILTER_RARITY,
|
FILTER_RARITY,
|
||||||
FILTER_COLOR,
|
FILTER_COLOR,
|
||||||
FILTER_PRODUCE,
|
FILTER_PRODUCE,
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ WCardFilter * WCFilterFactory::Terminal(string type, string arg){
|
|||||||
return NEW WCFilterOnlyColor(arg);
|
return NEW WCFilterOnlyColor(arg);
|
||||||
else if(type == "s" || type == "set")
|
else if(type == "s" || type == "set")
|
||||||
return NEW WCFilterSet(arg);
|
return NEW WCFilterSet(arg);
|
||||||
|
else if(type == "alpha")
|
||||||
|
return NEW WCFilterLetter(arg);
|
||||||
else if(type == "t" || type == "type")
|
else if(type == "t" || type == "type")
|
||||||
return NEW WCFilterType(arg);
|
return NEW WCFilterType(arg);
|
||||||
else if(type == "a" || type == "ability")
|
else if(type == "a" || type == "ability")
|
||||||
@@ -145,7 +147,28 @@ WCardFilter * WCFilterFactory::Terminal(string type, string arg){
|
|||||||
|
|
||||||
return NEW WCFilterNULL();
|
return NEW WCFilterNULL();
|
||||||
}
|
}
|
||||||
|
//WCFilterLetter
|
||||||
|
WCFilterLetter::WCFilterLetter(string arg){
|
||||||
|
if(!arg.size())
|
||||||
|
alpha = 'a';
|
||||||
|
else
|
||||||
|
alpha = tolower(arg[0]);
|
||||||
|
}
|
||||||
|
bool WCFilterLetter::isMatch(MTGCard * c){
|
||||||
|
if(!c || !c->data)
|
||||||
|
return false;
|
||||||
|
string s = c->data->getLCName();
|
||||||
|
if(!s.size())
|
||||||
|
return false;
|
||||||
|
if(s[0] == alpha || (alpha == '#' && (isdigit(s[0]) || ispunct(s[0]))))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
string WCFilterLetter::getCode(){
|
||||||
|
char buf[24];
|
||||||
|
sprintf(buf,"alpha:%c;",alpha);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
//WCFilterSet
|
//WCFilterSet
|
||||||
WCFilterSet::WCFilterSet(string arg){
|
WCFilterSet::WCFilterSet(string arg){
|
||||||
setid = setlist.findSet(arg);
|
setid = setlist.findSet(arg);
|
||||||
|
|||||||
@@ -1532,6 +1532,10 @@ void WGuiFilterItem::updateValue(){
|
|||||||
mParent->subMenu->Add(FILTER_TOUGH,"Toughness");
|
mParent->subMenu->Add(FILTER_TOUGH,"Toughness");
|
||||||
delMenu = false;
|
delMenu = false;
|
||||||
}
|
}
|
||||||
|
if(mParent->isAvailable(FILTER_ALPHA)){
|
||||||
|
mParent->subMenu->Add(FILTER_ALPHA,"First Letter");
|
||||||
|
delMenu = false;
|
||||||
|
}
|
||||||
if(!mNew)
|
if(!mNew)
|
||||||
mParent->subMenu->Add(-2,"Remove");
|
mParent->subMenu->Add(-2,"Remove");
|
||||||
mParent->subMenu->Add(-1,"Cancel");
|
mParent->subMenu->Add(-1,"Cancel");
|
||||||
@@ -1605,6 +1609,14 @@ void WGuiFilterItem::updateValue(){
|
|||||||
sprintf(buf,"s:%s;",setlist[i].c_str());
|
sprintf(buf,"s:%s;",setlist[i].c_str());
|
||||||
addArg((setlist.getInfo(i))->getName(),buf);
|
addArg((setlist.getInfo(i))->getName(),buf);
|
||||||
}
|
}
|
||||||
|
}else if(filterType == FILTER_ALPHA){
|
||||||
|
char buf[24], pretty[16];
|
||||||
|
for(char c='a';c<='z';c++){
|
||||||
|
sprintf(buf,"alpha:%c;",c);
|
||||||
|
sprintf(pretty,"Letter %c",toupper(c));
|
||||||
|
addArg(pretty,buf);
|
||||||
|
}
|
||||||
|
addArg("Digit","alpha:#;");
|
||||||
}
|
}
|
||||||
mParent->subMenu->Add(-1,"Cancel");
|
mParent->subMenu->Add(-1,"Cancel");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user