Jeck - Added filter for mana-producing abilities.

This commit is contained in:
wagic.jeck
2010-02-08 06:08:29 +00:00
parent 07ebd926fe
commit bf4595ee70
4 changed files with 45 additions and 1 deletions

View File

@@ -110,6 +110,13 @@ public:
bool isMatch(MTGCard * c);
string getCode();
};
class WCFilterProducesColor: public WCFilterColor{
public:
WCFilterProducesColor(int _c) : WCFilterColor(_c) {};
WCFilterProducesColor(string arg) : WCFilterColor(arg) {};
bool isMatch(MTGCard * c);
string getCode();
};
class WCFilterNumeric: public WCardFilter{
public:
WCFilterNumeric(int _num) {number = _num;};

View File

@@ -454,6 +454,7 @@ public:
FILTER_SET = BEGIN_FILTERS,
FILTER_RARITY,
FILTER_COLOR,
FILTER_PRODUCE,
FILTER_TYPE,
FILTER_BASIC,
FILTER_CMC,

View File

@@ -136,6 +136,8 @@ WCardFilter * WCFilterFactory::Terminal(string type, string arg){
return NEW WCFilterAbility(arg);
else if(type == "cmc")
return NEW WCFilterCMC(arg);
else if(type == "produces" || type == "ma")
return NEW WCFilterProducesColor(arg);
else if(type == "pow" || type == "power")
return NEW WCFilterPower(arg);
else if(type == "tgh" || type == "tough" || type == "toughness")
@@ -197,6 +199,25 @@ string WCFilterOnlyColor::getCode(){
sprintf(buf,"xcolor:%c;",c);
return buf;
}
//WCFilterProducesColor
bool WCFilterProducesColor::isMatch(MTGCard * c){
if(!c || !c->data)
return false;
string s = c->data->magicText;
size_t t = s.find("add");
if(t == string::npos)
return false;
ManaCost * mc = ManaCost::parseManaCost(s.substr(t));
return (mc->hasColor(color) > 0);
}
string WCFilterProducesColor::getCode(){
char buf[12];
char c = '?';
if(color < 0 || color >= Constants::MTG_NB_COLORS)
c = Constants::MTGColorChars[color];
sprintf(buf,"produces:%c;",c);
return buf;
}
//WCFilterNumeric
WCFilterNumeric::WCFilterNumeric(string arg){
number = atoi(arg.c_str());

View File

@@ -1446,7 +1446,7 @@ if(!list) return false;
}
bool WGuiFilters::isAvailable(int type){
if(!list) return false;
int colors = 0;
int colors = 0, ma = 0;
WGuiList * wgl = dynamic_cast<WGuiList*>(list->Current());
if(wgl){
vector<WGuiBase*>::iterator it;
@@ -1456,6 +1456,9 @@ bool WGuiFilters::isAvailable(int type){
switch(type){
case WGuiFilterItem::FILTER_BASIC:
return true;
case WGuiFilterItem::FILTER_PRODUCE:
if(wgfi->filterType == type)
ma++;
case WGuiFilterItem::FILTER_COLOR:
if(wgfi->filterType == type)
colors++;
@@ -1467,6 +1470,8 @@ bool WGuiFilters::isAvailable(int type){
}
if(colors >= 5)
return false;
if(ma >= 5)
return false;
return true;
}
return false; //For some reason, we don't have any rows?
@@ -1499,6 +1504,10 @@ void WGuiFilterItem::updateValue(){
mParent->subMenu->Add(FILTER_COLOR,"Color");
delMenu = false;
}
if(mParent->isAvailable(FILTER_PRODUCE)){
mParent->subMenu->Add(FILTER_PRODUCE,"Mana Ability");
delMenu = false;
}
if(mParent->isAvailable(FILTER_TYPE)){
mParent->subMenu->Add(FILTER_TYPE,"Type");
delMenu = false;
@@ -1574,6 +1583,12 @@ void WGuiFilterItem::updateValue(){
addArg("Red","c:r;");
addArg("Green","c:g;");
addArg("Black","c:b;");
}else if(filterType == FILTER_PRODUCE){
addArg("White mana abiltity","ma:w;");
addArg("Blue mana abiltity","ma:u;");
addArg("Red mana abiltity","ma:r;");
addArg("Green mana abiltity","ma:g;");
addArg("Black mana abiltity","ma:b;");
}else if(filterType == FILTER_BASIC){
char buf[512];
for(int i=0;i<Constants::NB_BASIC_ABILITIES;i++){