refactor canproducemana
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user