Jeck - Added 4 additional filters: CMC, Power, Toughness, and "Exclusively this color". That last one isn't hooked into the gui, as it might be confusing for too little gain... but it's there for future use of filters as a deck/format validation tool.
This commit is contained in:
@@ -103,6 +103,48 @@ public:
|
||||
protected:
|
||||
int color;
|
||||
};
|
||||
class WCFilterOnlyColor: public WCFilterColor{
|
||||
public:
|
||||
WCFilterOnlyColor(int _c) : WCFilterColor(_c) {};
|
||||
WCFilterOnlyColor(string arg) : WCFilterColor(arg) {};
|
||||
bool isMatch(MTGCard * c);
|
||||
string getCode();
|
||||
};
|
||||
class WCFilterNumeric: public WCardFilter{
|
||||
public:
|
||||
WCFilterNumeric(int _num) {number = _num;};
|
||||
WCFilterNumeric(string arg);
|
||||
bool isMatch(MTGCard * c) = 0;
|
||||
string getCode() = 0;
|
||||
float filterFee() = 0;
|
||||
protected:
|
||||
int number;
|
||||
};
|
||||
class WCFilterCMC: public WCFilterNumeric{
|
||||
public:
|
||||
WCFilterCMC(int amt) : WCFilterNumeric(amt) {};
|
||||
WCFilterCMC(string arg) : WCFilterNumeric(arg) {};
|
||||
bool isMatch(MTGCard * c);
|
||||
string getCode();
|
||||
float filterFee() {return number/20.0f;};
|
||||
};
|
||||
class WCFilterPower: public WCFilterNumeric{
|
||||
public:
|
||||
WCFilterPower(int amt) : WCFilterNumeric(amt) {};
|
||||
WCFilterPower(string arg) : WCFilterNumeric(arg) {};
|
||||
bool isMatch(MTGCard * c);
|
||||
string getCode();
|
||||
float filterFee() {return number/12.0f;};
|
||||
};
|
||||
class WCFilterToughness: public WCFilterNumeric{
|
||||
public:
|
||||
WCFilterToughness(int amt) : WCFilterNumeric(amt) {};
|
||||
WCFilterToughness(string arg) : WCFilterNumeric(arg) {};
|
||||
bool isMatch(MTGCard * c);
|
||||
string getCode();
|
||||
float filterFee() {return number/12.0f;};
|
||||
};
|
||||
|
||||
class WCFilterType: public WCardFilter{
|
||||
public:
|
||||
WCFilterType(string arg) {type = arg;};
|
||||
|
||||
@@ -456,6 +456,9 @@ public:
|
||||
FILTER_COLOR,
|
||||
FILTER_TYPE,
|
||||
FILTER_BASIC,
|
||||
FILTER_CMC,
|
||||
FILTER_POWER,
|
||||
FILTER_TOUGH,
|
||||
END_FILTERS
|
||||
};
|
||||
protected:
|
||||
|
||||
@@ -125,13 +125,21 @@ WCardFilter * WCFilterFactory::Terminal(string type, string arg){
|
||||
if(type == "r" || type == "rarity")
|
||||
return NEW WCFilterRarity(arg);
|
||||
else if(type == "c" || type == "color")
|
||||
return NEW WCFilterColor(arg);
|
||||
return NEW WCFilterColor(arg);
|
||||
else if(type == "xc" || type == "xcolor")
|
||||
return NEW WCFilterOnlyColor(arg);
|
||||
else if(type == "s" || type == "set")
|
||||
return NEW WCFilterSet(arg);
|
||||
else if(type == "t" || type == "type")
|
||||
return NEW WCFilterType(arg);
|
||||
else if(type == "a" || type == "ability")
|
||||
return NEW WCFilterAbility(arg);
|
||||
else if(type == "cmc")
|
||||
return NEW WCFilterCMC(arg);
|
||||
else if(type == "pow" || type == "power")
|
||||
return NEW WCFilterPower(arg);
|
||||
else if(type == "tgh" || type == "tough" || type == "toughness")
|
||||
return NEW WCFilterToughness(arg);
|
||||
|
||||
return NEW WCFilterNULL();
|
||||
}
|
||||
@@ -170,6 +178,64 @@ WCFilterColor::WCFilterColor(string arg){
|
||||
}
|
||||
}
|
||||
}
|
||||
//WCFilterOnlyColor
|
||||
bool WCFilterOnlyColor::isMatch(MTGCard * c){
|
||||
if(!c || !c->data)
|
||||
return false;
|
||||
for(int i=0;i<Constants::MTG_NB_COLORS;i++){
|
||||
if(i == color) continue;
|
||||
if(c->data->hasColor(i) > 0)
|
||||
return false;
|
||||
}
|
||||
return (c->data->hasColor(color) > 0);
|
||||
}
|
||||
string WCFilterOnlyColor::getCode(){
|
||||
char buf[12];
|
||||
char c = '?';
|
||||
if(color < 0 || color >= Constants::MTG_NB_COLORS)
|
||||
c = Constants::MTGColorChars[color];
|
||||
sprintf(buf,"xcolor:%c;",c);
|
||||
return buf;
|
||||
}
|
||||
//WCFilterNumeric
|
||||
WCFilterNumeric::WCFilterNumeric(string arg){
|
||||
number = atoi(arg.c_str());
|
||||
}
|
||||
//WCFilterCMC
|
||||
bool WCFilterCMC::isMatch(MTGCard * c){
|
||||
if(!c || !c->data)
|
||||
return false;
|
||||
ManaCost * mc = c->data->getManaCost();
|
||||
return (mc->getConvertedCost() == number);
|
||||
}
|
||||
|
||||
string WCFilterCMC::getCode(){
|
||||
char buf[64];
|
||||
sprintf(buf,"cmc:%i;",number);
|
||||
return buf;
|
||||
}
|
||||
//WCFilterPower
|
||||
bool WCFilterPower::isMatch(MTGCard * c){
|
||||
if(!c || !c->data)
|
||||
return false;
|
||||
return (c->data->getPower() == number);
|
||||
}
|
||||
string WCFilterPower::getCode(){
|
||||
char buf[64];
|
||||
sprintf(buf,"power:%i;",number);
|
||||
return buf;
|
||||
}
|
||||
//WCFilterPower
|
||||
bool WCFilterToughness::isMatch(MTGCard * c){
|
||||
if(!c || !c->data)
|
||||
return false;
|
||||
return (c->data->getToughness() == number);
|
||||
}
|
||||
string WCFilterToughness::getCode(){
|
||||
char buf[64];
|
||||
sprintf(buf,"toughness:%i;",number);
|
||||
return buf;
|
||||
}
|
||||
//WCFilterRarity
|
||||
float WCFilterRarity::filterFee(){
|
||||
switch(rarity){
|
||||
|
||||
@@ -1478,6 +1478,8 @@ WGuiFilterItem::WGuiFilterItem(WGuiFilters * parent): WGuiItem("Cards..."){
|
||||
};
|
||||
void WGuiFilterItem::updateValue(){
|
||||
bool delMenu = true;
|
||||
char buf_name[512];
|
||||
char buf_code[512];
|
||||
if(!mParent)
|
||||
return;
|
||||
switch(mState){
|
||||
@@ -1504,10 +1506,23 @@ void WGuiFilterItem::updateValue(){
|
||||
if(mParent->isAvailable(FILTER_RARITY)){
|
||||
mParent->subMenu->Add(FILTER_RARITY,"Rarity");
|
||||
delMenu = false;
|
||||
}if(mParent->isAvailable(FILTER_BASIC)){
|
||||
}
|
||||
if(mParent->isAvailable(FILTER_BASIC)){
|
||||
mParent->subMenu->Add(FILTER_BASIC,"Ability");
|
||||
delMenu = false;
|
||||
}
|
||||
if(mParent->isAvailable(FILTER_CMC)){
|
||||
mParent->subMenu->Add(FILTER_CMC,"Mana Cost");
|
||||
delMenu = false;
|
||||
}
|
||||
if(mParent->isAvailable(FILTER_POWER)){
|
||||
mParent->subMenu->Add(FILTER_POWER,"Power");
|
||||
delMenu = false;
|
||||
}
|
||||
if(mParent->isAvailable(FILTER_TOUGH)){
|
||||
mParent->subMenu->Add(FILTER_TOUGH,"Toughness");
|
||||
delMenu = false;
|
||||
}
|
||||
if(!mNew)
|
||||
mParent->subMenu->Add(-2,"Remove");
|
||||
mParent->subMenu->Add(-1,"Cancel");
|
||||
@@ -1535,6 +1550,24 @@ void WGuiFilterItem::updateValue(){
|
||||
addArg("Rare","r:r;");
|
||||
addArg("Uncommon","r:u;");
|
||||
addArg("Common","r:c;");
|
||||
}else if(filterType == FILTER_CMC){
|
||||
for(int i=0;i<20;i++){
|
||||
sprintf(buf_code,"cmc:%i;",i);
|
||||
sprintf(buf_name,"%i Mana",i);
|
||||
addArg(buf_name,buf_code);
|
||||
}
|
||||
}else if(filterType == FILTER_POWER){
|
||||
for(int i=0;i<14;i++){
|
||||
sprintf(buf_code,"pow:%i;",i);
|
||||
sprintf(buf_name,"%i power",i);
|
||||
addArg(buf_name,buf_code);
|
||||
}
|
||||
}else if(filterType == FILTER_TOUGH){
|
||||
for(int i=0;i<14;i++){
|
||||
sprintf(buf_code,"tgh:%i;",i);
|
||||
sprintf(buf_name,"%i toughness",i);
|
||||
addArg(buf_name,buf_code);
|
||||
}
|
||||
}else if(filterType == FILTER_COLOR){
|
||||
addArg("White","c:w;");
|
||||
addArg("Blue","c:u;");
|
||||
|
||||
Reference in New Issue
Block a user