refactor canproducemana

This commit is contained in:
Anthony Calosa
2017-02-16 16:55:13 +08:00
parent 5a3a32462d
commit 0a68a056d8
5 changed files with 69 additions and 31 deletions

View File

@@ -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()
{