From 60411027cabd32b0aec092a4e73931733a19396f Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 19 Aug 2016 23:34:01 +0800 Subject: [PATCH] change plandtype & olandtype parsing --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 62 ++++++++++---------- projects/mtg/include/AllAbilities.h | 51 +++++++++++----- projects/mtg/include/MTGCardInstance.h | 6 ++ projects/mtg/src/GameObserver.cpp | 19 ++++++ projects/mtg/src/MTGAbility.cpp | 29 +++++++++ projects/mtg/src/MTGCardInstance.cpp | 6 ++ 6 files changed, 127 insertions(+), 46 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index a775531f7..3ca838d6d 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -36031,11 +36031,11 @@ type=Sorcery [/card] [card] name=Exotic Orchard -auto=this(variable{olandg}>0) {t}:add{g} -auto=this(variable{olandu}>0) {t}:add{u} -auto=this(variable{olandr}>0) {t}:add{r} -auto=this(variable{olandb}>0) {t}:add{b} -auto=this(variable{olandw}>0) {t}:add{w} +auto=this(variable{olandg}>0) {t}:out{g} +auto=this(variable{olandu}>0) {t}:out{u} +auto=this(variable{olandr}>0) {t}:out{r} +auto=this(variable{olandb}>0) {t}:out{b} +auto=this(variable{olandw}>0) {t}:out{w} text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. type=Land [/card] @@ -37789,11 +37789,11 @@ toughness=6 [/card] [card] name=Fellwar Stone -auto=this(variable{olandg}>0) {t}:add{g} -auto=this(variable{olandu}>0) {t}:add{u} -auto=this(variable{olandr}>0) {t}:add{r} -auto=this(variable{olandb}>0) {t}:add{b} -auto=this(variable{olandw}>0) {t}:add{w} +auto=this(variable{olandg}>0) {t}:out{g} +auto=this(variable{olandu}>0) {t}:out{u} +auto=this(variable{olandr}>0) {t}:out{r} +auto=this(variable{olandb}>0) {t}:out{b} +auto=this(variable{olandw}>0) {t}:out{w} text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. mana={2} type=Artifact @@ -50008,11 +50008,11 @@ toughness=2 [/card] [card] name=Harvester Druid -auto=this(variable{plandg}>0) {t}:add{g} -auto=this(variable{plandu}>0) {t}:add{u} -auto=this(variable{plandr}>0) {t}:add{r} -auto=this(variable{plandb}>0) {t}:add{b} -auto=this(variable{plandw}>0) {t}:add{w} +auto=this(variable{plandg}>0) {t}:out{g} +auto=this(variable{plandu}>0) {t}:out{u} +auto=this(variable{plandr}>0) {t}:out{r} +auto=this(variable{plandb}>0) {t}:out{b} +auto=this(variable{plandw}>0) {t}:out{w} text={T}: Add to your mana pool one mana of any color that a land you control could produce. mana={1}{G} type=Creature @@ -85877,11 +85877,11 @@ toughness=1 [/card] [card] name=Quirion Explorer -auto=this(variable{olandg}>0) {t}:add{g} -auto=this(variable{olandu}>0) {t}:add{u} -auto=this(variable{olandr}>0) {t}:add{r} -auto=this(variable{olandb}>0) {t}:add{b} -auto=this(variable{olandw}>0) {t}:add{w} +auto=this(variable{olandg}>0) {t}:out{g} +auto=this(variable{olandu}>0) {t}:out{u} +auto=this(variable{olandr}>0) {t}:out{r} +auto=this(variable{olandb}>0) {t}:out{b} +auto=this(variable{olandw}>0) {t}:out{w} text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. mana={1}{G} type=Creature @@ -88419,12 +88419,12 @@ toughness=2 [/card] [card] name=Reflecting Pool -auto=this(variable{plandg}>0) {t}:add{g} -auto=this(variable{plandu}>0) {t}:add{u} -auto=this(variable{plandr}>0) {t}:add{r} -auto=this(variable{plandb}>0) {t}:add{b} -auto=this(variable{plandw}>0) {t}:add{w} -auto=this(variable{plandc}>0) {t}:add{1} +auto=this(variable{plandg}>0) {t}:out{g} +auto=this(variable{plandu}>0) {t}:out{u} +auto=this(variable{plandr}>0) {t}:out{r} +auto=this(variable{plandb}>0) {t}:out{b} +auto=this(variable{plandw}>0) {t}:out{w} +auto=this(variable{plandc}>0) {t}:out{1} text={T}: Add to your mana pool one mana of any type that a land you control could produce. type=Land [/card] @@ -110856,11 +110856,11 @@ toughness=4 [/card] [card] name=Sylvok Explorer -auto=this(variable{olandg}>0) {t}:add{g} -auto=this(variable{olandu}>0) {t}:add{u} -auto=this(variable{olandr}>0) {t}:add{r} -auto=this(variable{olandb}>0) {t}:add{b} -auto=this(variable{olandw}>0) {t}:add{w} +auto=this(variable{olandg}>0) {t}:out{g} +auto=this(variable{olandu}>0) {t}:out{u} +auto=this(variable{olandr}>0) {t}:out{r} +auto=this(variable{olandb}>0) {t}:out{b} +auto=this(variable{olandw}>0) {t}:out{w} text={T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. mana={1}{G} type=Creature diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 4669d6a8f..2a8c55330 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -748,53 +748,53 @@ private: } else if (s == "olandg") { - intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target->controller()->opponent()); } else if (s == "olandu") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target->controller()->opponent()); } else if (s == "olandr") { - intValue = countManaProducedby(Constants::MTG_COLOR_RED, target, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_RED, target->controller()->opponent()); } else if (s == "olandb") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target->controller()->opponent()); } else if (s == "olandw") { - intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target->controller()->opponent()); } else if (s == "olandc") { - intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target, target->controller()->opponent()) + - countManaProducedby(Constants::MTG_COLOR_WASTE, target, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target->controller()->opponent()) + + countManaProducedby(Constants::MTG_COLOR_WASTE, target->controller()->opponent()); } else if (s == "plandg") { - intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target->controller()); } else if (s == "plandu") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target->controller()); } else if (s == "plandr") { - intValue = countManaProducedby(Constants::MTG_COLOR_RED, target, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_RED, target->controller()); } else if (s == "plandb") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target->controller()); } else if (s == "plandw") { - intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target->controller()); } else if (s == "plandc") { - intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target, target->controller()) + - countManaProducedby(Constants::MTG_COLOR_WASTE, target, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target->controller()) + + countManaProducedby(Constants::MTG_COLOR_WASTE, target->controller()); } else if (s == "cantargetmycre")// can target my creature { @@ -1061,7 +1061,7 @@ public: return count; } - int countManaProducedby(int color, MTGCardInstance * target, Player * player) + /*int countManaProducedby(int color, MTGCardInstance * target, Player * player) { int count = 0; for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) @@ -1073,6 +1073,27 @@ public: count += 1; } return count; + }*/ + + int countManaProducedby(int color, Player * player) + { + int count = 0; + for (int i = 0; i < player->game->battlefield->nb_cards; i++) + { + if(((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceC && (color == Constants::MTG_COLOR_ARTIFACT || color == Constants::MTG_COLOR_WASTE)) + count += 1; + if(((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceG && color == Constants::MTG_COLOR_GREEN) + count += 1; + if(((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceU && color == Constants::MTG_COLOR_BLUE) + count += 1; + if(((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceR && color == Constants::MTG_COLOR_RED) + count += 1; + if(((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceB && color == Constants::MTG_COLOR_BLACK) + count += 1; + if(((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceW && color == Constants::MTG_COLOR_WHITE) + count += 1; + } + return count; } WParsedInt(int value = 0) diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index cd18151a5..06028107c 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -277,6 +277,12 @@ public: int imprintR; int imprintB; int imprintW; + int canproduceG; + int canproduceU; + int canproduceR; + int canproduceB; + int canproduceW; + int canproduceC; string currentimprintName; vectorimprintedNames; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index d5769a4cd..38c89ff69 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -702,6 +702,25 @@ void GameObserver::gameStateBasedEffects() card->myPair->myPair = NULL; card->myPair = NULL; } + ///set basic land mana objects canproduce + for (size_t gg = 0; gg < mLayers->actionLayer()->manaObjects.size(); gg++) + { + if (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])) && + (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])))->source->isLand() && + (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])))->source == card) + { + if (card->hasType("forest") && (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])))->output->hasColor(Constants::MTG_COLOR_GREEN)) + card->canproduceG = 1; + if (card->hasType("island") && (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])))->output->hasColor(Constants::MTG_COLOR_BLUE)) + card->canproduceU = 1; + if (card->hasType("mountain") && (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])))->output->hasColor(Constants::MTG_COLOR_RED)) + card->canproduceR = 1; + if (card->hasType("swamp") && (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])))->output->hasColor(Constants::MTG_COLOR_BLACK)) + card->canproduceB = 1; + if (card->hasType("plains") && (dynamic_cast (((MTGAbility *) mLayers->actionLayer()->manaObjects[gg])))->output->hasColor(Constants::MTG_COLOR_WHITE)) + card->canproduceW = 1; + } + } ///clear imprints if(isInPlay(card) && card->imprintedCards.size()) { diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 3ff78a543..e61f99875 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3449,6 +3449,35 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG //Mana Producer found = s.find("add"); if (found != string::npos) + { + 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()) + ((AManaProducer*)a)->menutext = newName; + return a; + } + + //another mana producer exempted for canproduce + found = s.find("out"); + if (found != string::npos) { bool doesntEmptyTilueot = s.find("doesntempty") != string::npos; ManaCost * output = ManaCost::parseManaCost(s.substr(found),NULL,card); diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 14175e732..0134ea33c 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -252,6 +252,12 @@ void MTGCardInstance::initMTGCI() imprintR = 0; imprintB = 0; imprintW = 0; + canproduceG = 0; + canproduceU = 0; + canproduceR = 0; + canproduceB = 0; + canproduceW = 0; + canproduceC = 0; currentimprintName = ""; imprintedNames.clear(); CountedObjects = 0;