Merge pull request #924 from kevlahnota/master

Refactor countManaProducedby
This commit is contained in:
Anthony Calosa
2017-02-05 06:38:05 +08:00
committed by GitHub
3 changed files with 23 additions and 23 deletions

View File

@@ -3065,7 +3065,7 @@ type=Artifact
[/card]
[card]
name=Amulet of Vigor
auto=lord(*|mybattlefield) transforms((,newability[untap])) forever
auto=lord(*[recent]|mybattlefield) transforms((,newability[untap])) forever
text=Whenever a permanent enters the battlefield tapped and under your control, untap it.
mana={1}
type=Artifact
@@ -109171,7 +109171,7 @@ toughness=2
[/card]
[card]
name=Spirespine
auto=mustblock
abilities=mustblock
auto=bestow bstw
auto=bestow teach(creature) mustblock
auto=bestow teach(creature) +3/+2

View File

@@ -1125,14 +1125,29 @@ public:
int countManaProducedby(int color, MTGCardInstance * target, Player * player)
{
int count = 0;
for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++)
MTGGameZone * zone = player->game->battlefield;
for(int k = 0; k < zone->nb_cards; k++)
{
MTGCardInstance * card = zone->cards[k];
if(card->isLand() && (card != target) && card->hasSubtype("forest") && color == 1)
count++;
if(card->isLand() && (card != target) && card->hasSubtype("island") && color == 2)
count++;
if(card->isLand() && (card != target) && card->hasSubtype("mountain") && color == 3)
count++;
if(card->isLand() && (card != target) && card->hasSubtype("swamp") && color == 4)
count++;
if(card->isLand() && (card != target) && card->hasSubtype("plains") && color == 5)
count++;
if(card->isLand() && (card != target) && card->cardsAbilities.size())
{
if (dynamic_cast<AManaProducer*> (((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i])) &&
(dynamic_cast<AManaProducer*> (((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i])))->source->isLand() &&
(dynamic_cast<AManaProducer*> (((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i])))->source->controller() == player &&
(dynamic_cast<AManaProducer*> (((MTGAbility *) target->getObserver()->mLayers->actionLayer()->manaObjects[i])))->output->hasColor(color))
count += 1;
for(unsigned int j = 0; j < card->cardsAbilities.size(); j++)
{
if(dynamic_cast<AManaProducer*> (card->cardsAbilities[j]) && dynamic_cast<AManaProducer*> (card->cardsAbilities[j])->output->hasColor(color) )
count++;
}
}
}
return count;
}

View File

@@ -3760,21 +3760,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
bool doesntEmptyTilueot = s.find("doesntempty") != string::npos;
ManaCost * output = ManaCost::parseManaCost(s.substr(found),NULL,card);
Targetable * t = spell ? spell->getNextTarget() : NULL;
if(output->getConvertedCost() > 0)
{
if(output->hasColor(Constants::MTG_COLOR_ARTIFACT)||output->hasColor(Constants::MTG_COLOR_WASTE))
card->canproduceC = 1;
if(output->hasColor(Constants::MTG_COLOR_GREEN))
card->canproduceG = 1;
if(output->hasColor(Constants::MTG_COLOR_BLUE))
card->canproduceU = 1;
if(output->hasColor(Constants::MTG_COLOR_RED))
card->canproduceR = 1;
if(output->hasColor(Constants::MTG_COLOR_BLACK))
card->canproduceB = 1;
if(output->hasColor(Constants::MTG_COLOR_WHITE))
card->canproduceW = 1;
}
MTGAbility * a = NEW AManaProducer(observer, id, card, t, output, NULL, who,s.substr(found),doesntEmptyTilueot);
a->oneShot = 1;
if(newName.size())