refactor canproducemana
This commit is contained in:
@@ -70,12 +70,12 @@ class CardDescriptor: public MTGCardInstance
|
||||
int CDdamager;
|
||||
int CDgeared;
|
||||
int CDblocked;
|
||||
/*int CDcanProduceC;
|
||||
int CDcanProduceC;
|
||||
int CDcanProduceG;
|
||||
int CDcanProduceU;
|
||||
int CDcanProduceR;
|
||||
int CDcanProduceB;
|
||||
int CDcanProduceW;*/
|
||||
int CDcanProduceW;
|
||||
int CDnocolor;
|
||||
};
|
||||
|
||||
|
||||
@@ -285,12 +285,7 @@ public:
|
||||
int imprintR;
|
||||
int imprintB;
|
||||
int imprintW;
|
||||
int canproduceG;
|
||||
int canproduceU;
|
||||
int canproduceR;
|
||||
int canproduceB;
|
||||
int canproduceW;
|
||||
int canproduceC;
|
||||
int canproduceMana(int color = -1);
|
||||
int entersBattlefield;
|
||||
string currentimprintName;
|
||||
vector<string>imprintedNames;
|
||||
|
||||
@@ -28,12 +28,12 @@ CardDescriptor::CardDescriptor()
|
||||
CDdamager = 0;
|
||||
CDgeared = 0;
|
||||
CDblocked = 0;
|
||||
/*CDcanProduceC = 0;
|
||||
CDcanProduceC = 0;
|
||||
CDcanProduceG = 0;
|
||||
CDcanProduceU = 0;
|
||||
CDcanProduceR = 0;
|
||||
CDcanProduceB = 0;
|
||||
CDcanProduceW = 0;*/
|
||||
CDcanProduceW = 0;
|
||||
CDnocolor = 0;
|
||||
}
|
||||
|
||||
@@ -262,37 +262,45 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
|
||||
match = NULL;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if ((CDcanProduceC == -1 && card->canproduceC == 1) || (CDcanProduceC == 1 && card->canproduceC == 0))
|
||||
|
||||
if (CDcanProduceC == -1)
|
||||
{
|
||||
int count = card->canproduceMana(Constants::MTG_COLOR_ARTIFACT) + card->canproduceMana(Constants::MTG_COLOR_WASTE);
|
||||
if (count)
|
||||
match = NULL;
|
||||
}
|
||||
if (CDcanProduceC == 1)
|
||||
{
|
||||
int count = card->canproduceMana(Constants::MTG_COLOR_ARTIFACT) + card->canproduceMana(Constants::MTG_COLOR_WASTE);
|
||||
if (!count)
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((CDcanProduceG == -1 && card->canproduceMana(Constants::MTG_COLOR_GREEN) == 1) || (CDcanProduceG == 1 && card->canproduceMana(Constants::MTG_COLOR_GREEN) == 0))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((CDcanProduceG == -1 && card->canproduceG == 1) || (CDcanProduceG == 1 && card->canproduceG == 0))
|
||||
if ((CDcanProduceU == -1 && card->canproduceMana(Constants::MTG_COLOR_BLUE) == 1) || (CDcanProduceU == 1 && card->canproduceMana(Constants::MTG_COLOR_BLUE) == 0))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((CDcanProduceU == -1 && card->canproduceU == 1) || (CDcanProduceU == 1 && card->canproduceU == 0))
|
||||
if ((CDcanProduceR == -1 && card->canproduceMana(Constants::MTG_COLOR_RED) == 1) || (CDcanProduceR == 1 && card->canproduceMana(Constants::MTG_COLOR_RED) == 0))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((CDcanProduceR == -1 && card->canproduceR == 1) || (CDcanProduceR == 1 && card->canproduceR == 0))
|
||||
if ((CDcanProduceB == -1 && card->canproduceMana(Constants::MTG_COLOR_BLACK) == 1) || (CDcanProduceB == 1 && card->canproduceMana(Constants::MTG_COLOR_BLACK) == 0))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((CDcanProduceB == -1 && card->canproduceB == 1) || (CDcanProduceB == 1 && card->canproduceB == 0))
|
||||
if ((CDcanProduceW == -1 && card->canproduceMana(Constants::MTG_COLOR_WHITE) == 1) || (CDcanProduceW == 1 && card->canproduceMana(Constants::MTG_COLOR_WHITE) == 0))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((CDcanProduceW == -1 && card->canproduceW == 1) || (CDcanProduceW == 1 && card->canproduceW == 0))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((CDnocolor == -1 && card->getColor() == 0))
|
||||
{
|
||||
match = NULL;
|
||||
|
||||
@@ -98,7 +98,11 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
||||
void MTGCardInstance::copy(MTGCardInstance * card)
|
||||
{
|
||||
MTGCard * source = NULL;
|
||||
if(card->isToken || card->hasCopiedToken)
|
||||
if(card->isACopier && card->copiedID)
|
||||
{
|
||||
source = MTGCollection()->getCardById(card->copiedID);
|
||||
}
|
||||
else if(card->isToken || card->hasCopiedToken)
|
||||
{
|
||||
if(card->getMTGId() > 0)//not generated token
|
||||
source = MTGCollection()->getCardById(card->getMTGId());
|
||||
@@ -263,12 +267,6 @@ void MTGCardInstance::initMTGCI()
|
||||
imprintR = 0;
|
||||
imprintB = 0;
|
||||
imprintW = 0;
|
||||
canproduceG = 0;
|
||||
canproduceU = 0;
|
||||
canproduceR = 0;
|
||||
canproduceB = 0;
|
||||
canproduceW = 0;
|
||||
canproduceC = 0;
|
||||
entersBattlefield = 0;
|
||||
currentimprintName = "";
|
||||
imprintedNames.clear();
|
||||
@@ -851,6 +849,37 @@ int MTGCardInstance::countDuplicateCardNames()
|
||||
return count;
|
||||
}
|
||||
|
||||
//check can produce mana
|
||||
int MTGCardInstance::canproduceMana(int color)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
//start
|
||||
if(hasSubtype("forest") && color == 1)
|
||||
count++;
|
||||
if(hasSubtype("island") && color == 2)
|
||||
count++;
|
||||
if(hasSubtype("mountain") && color == 3)
|
||||
count++;
|
||||
if(hasSubtype("swamp") && color == 4)
|
||||
count++;
|
||||
if(hasSubtype("plains") && color == 5)
|
||||
count++;
|
||||
if(cardsAbilities.size())
|
||||
{
|
||||
for(unsigned int j = 0; j < cardsAbilities.size(); j++)
|
||||
{
|
||||
if(dynamic_cast<AManaProducer*> (cardsAbilities[j]) && dynamic_cast<AManaProducer*> (cardsAbilities[j])->output->hasColor(color))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if(count)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//check stack
|
||||
bool MTGCardInstance::StackIsEmptyandSorcerySpeed()
|
||||
{
|
||||
|
||||
@@ -579,7 +579,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->CDdamager = 1;
|
||||
}
|
||||
}/*
|
||||
}
|
||||
//can produce mana
|
||||
else if (attribute.find("cmana") != string::npos)
|
||||
{
|
||||
@@ -591,6 +591,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->CDcanProduceC = 1;
|
||||
}
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
else if (attribute.find("manag") != string::npos)
|
||||
{
|
||||
@@ -602,6 +603,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->CDcanProduceG = 1;
|
||||
}
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
else if (attribute.find("manau") != string::npos)
|
||||
{
|
||||
@@ -613,6 +615,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->CDcanProduceU = 1;
|
||||
}
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
else if (attribute.find("manar") != string::npos)
|
||||
{
|
||||
@@ -624,6 +627,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->CDcanProduceR = 1;
|
||||
}
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
else if (attribute.find("manab") != string::npos)
|
||||
{
|
||||
@@ -635,6 +639,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->CDcanProduceB = 1;
|
||||
}
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
else if (attribute.find("manaw") != string::npos)
|
||||
{
|
||||
@@ -646,7 +651,8 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->CDcanProduceW = 1;
|
||||
}
|
||||
}*/
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
else if (attribute.find("multicolor") != string::npos)
|
||||
{
|
||||
//card is multicolored?
|
||||
|
||||
Reference in New Issue
Block a user