From 8d7b9293b57f4f4ad7e03c0ebdd85c82b5fdb3b3 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 19 Aug 2016 20:29:41 +0800 Subject: [PATCH 1/4] change naming convention to avoid confusion --- projects/mtg/bin/Res/sets/primitives/borderline.txt | 4 ++-- projects/mtg/bin/Res/sets/primitives/mtg.txt | 12 ++++++------ projects/mtg/src/TargetChooser.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index bb8b47f1d..754a903a5 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -241,8 +241,8 @@ toughness=2 [card] name=Rayne, Academy Chancellor #missing parser for player/controller/opponent -auto=this(auras >= 1) transforms((,newability[@targeted(*|mybattlefield) from(*|oppzones):draw:2])) -auto=this(auras < 1) transforms((,newability[@targeted(*|mybattlefield) from(*|oppzones):draw:1])) +auto=this(auras >= 1) transforms((,newability[@targeted(*|mybattlefield) from(*|opponentzones):draw:2])) +auto=this(auras < 1) transforms((,newability[@targeted(*|mybattlefield) from(*|opponentzones):draw:1])) text=Whenever you or a permanent you control becomes the target of a spell or ability an opponent controls, you may draw a card. You may draw an additional card if Rayne, Academy Chancellor is enchanted. mana={2}{U} type=Legendary Creature diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 7b2fe9a35..a775531f7 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -6562,8 +6562,8 @@ subtype=Aura [/card] [card] name=Aura of Silence -auto=lord(artifact|oppcastingzone) altercost(colorless, +2) -auto=lord(enchantment|oppcastingzone) altercost(colorless, +2) +auto=lord(artifact|opponentcastingzone) altercost(colorless, +2) +auto=lord(enchantment|opponentcastingzone) altercost(colorless, +2) auto={S}:destroy target(artifact,enchantment) text=Artifact and enchantment spells your opponents cast cost {2} more to cast. -- Sacrifice Aura of Silence: Destroy target artifact or enchantment. mana={1}{W}{W} @@ -18538,7 +18538,7 @@ type=Instant [card] name=Chill auto=lord(*[red]|mycastingzone) altercost(colorless, +2) -auto=lord(*[red]|oppcastingzone) altercost(colorless, +2) +auto=lord(*[red]|opponentcastingzone) altercost(colorless, +2) text=Red spells cost {2} more to cast. mana={1}{U} type=Enchantment @@ -44936,7 +44936,7 @@ toughness=3 [card] name=Glowrider auto=lord(*[-creature]|mycastingzone) altercost(colorless,+1) -auto=lord(*[-creature]|oppcastingzone) altercost(colorless, +1) +auto=lord(*[-creature]|opponentcastingzone) altercost(colorless, +1) text=Noncreature spells cost {1} more to cast. mana={2}{W} type=Creature @@ -46916,7 +46916,7 @@ toughness=2 name=Grand Arbiter Augustin IV auto=lord(*[white]|mycastingzone) altercost(colorless,-1) auto=lord(*[blue]|mycastingzone) altercost(colorless,-1) -auto=lord(*|oppcastingzone) altercost( colorless,+1) +auto=lord(*|opponentcastingzone) altercost( colorless,+1) text=White spells you cast cost {1} less to cast. -- Blue spells you cast cost {1} less to cast. -- Spells your opponents cast cost {1} more to cast. mana={2}{W}{U} type=Legendary Creature @@ -113313,7 +113313,7 @@ toughness=2 name=Thalia, Guardian of Thraben abilities=first strike auto=lord(*[-creature]|mycastingzone) altercost(colorless,+1) -auto=lord(*[-creature]|oppcastingzone) altercost(colorless, +1) +auto=lord(*[-creature]|opponentcastingzone) altercost(colorless, +1) text=First Strike -- Noncreature spells cost {1} more to cast. mana={1}{W} type=Legendary Creature diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index e88d7d7c6..e466a254a 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -209,7 +209,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta zones[nbzones++] = MTGGameZone::MY_HAND; zones[nbzones++] = MTGGameZone::MY_EXILE; } - else if (zoneName.compare("oppcastingzone") == 0) + else if (zoneName.compare("opponentcastingzone") == 0) { zones[nbzones++] = MTGGameZone::OPPONENT_GRAVEYARD; zones[nbzones++] = MTGGameZone::OPPONENT_LIBRARY; @@ -225,7 +225,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta zones[nbzones++] = MTGGameZone::MY_HAND; zones[nbzones++] = MTGGameZone::MY_EXILE; } - else if (zoneName.compare("oppzones") == 0) + else if (zoneName.compare("opponentzones") == 0) { zones[nbzones++] = MTGGameZone::OPPONENT_BATTLEFIELD; zones[nbzones++] = MTGGameZone::OPPONENT_STACK; From 60411027cabd32b0aec092a4e73931733a19396f Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 19 Aug 2016 23:34:01 +0800 Subject: [PATCH 2/4] 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; From cec4494ce6b0087765c4daf8556889d7cd4a4c9d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 20 Aug 2016 00:21:58 +0800 Subject: [PATCH 3/4] fix can produce mana limited for land... --- .../mtg/bin/Res/missing_cards_by_sets/VIS.txt | 6 -- .../bin/Res/sets/primitives/borderline.txt | 12 ++++ projects/mtg/include/AllAbilities.h | 12 ++-- projects/mtg/include/CardDescriptor.h | 6 ++ projects/mtg/src/CardDescriptor.cpp | 36 ++++++++++ projects/mtg/src/TargetChooser.cpp | 67 +++++++++++++++++++ 6 files changed, 127 insertions(+), 12 deletions(-) diff --git a/projects/mtg/bin/Res/missing_cards_by_sets/VIS.txt b/projects/mtg/bin/Res/missing_cards_by_sets/VIS.txt index 92a7e58f2..6617eb80b 100644 --- a/projects/mtg/bin/Res/missing_cards_by_sets/VIS.txt +++ b/projects/mtg/bin/Res/missing_cards_by_sets/VIS.txt @@ -204,12 +204,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Squandered Resources -text=Sacrifice a land: Add to your mana pool one mana of any type the sacrificed land could produce. -mana={B}{G} -type=Enchantment -[/card] -[card] name=Talruum Piper text=All creatures with flying able to block Talruum Piper do so. mana={4}{R} diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index 754a903a5..e2cb7cc20 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -351,6 +351,18 @@ power=2 toughness=1 [/card] [card] +name=Squandered Resources +auto=this(variable{plandg}>0) {S(land[manag]|mybattlefield)}:Add{G} +auto=this(variable{plandu}>0) {S(land[manau]|mybattlefield)}:Add{U} +auto=this(variable{plandr}>0) {S(land[manar]|mybattlefield)}:Add{R} +auto=this(variable{plandb}>0) {S(land[manab]|mybattlefield)}:Add{B} +auto=this(variable{plandw}>0) {S(land[manaw]|mybattlefield)}:Add{W} +auto=this(variable{plandc}>0) {S(land[manac]|mybattlefield)}:Add{C} +text=Sacrifice a land: Add to your mana pool one mana of any type the sacrificed land could produce. +mana={B}{G} +type=Enchantment +[/card] +[card] name=Staggershock target=creature,player auto=damage:2 diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 2a8c55330..96e8a8201 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1080,17 +1080,17 @@ public: 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)) + if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((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) + if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((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) + if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((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) + if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((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) + if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((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) + if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceW && color == Constants::MTG_COLOR_WHITE) count += 1; } return count; diff --git a/projects/mtg/include/CardDescriptor.h b/projects/mtg/include/CardDescriptor.h index b4808d2bb..81f803beb 100644 --- a/projects/mtg/include/CardDescriptor.h +++ b/projects/mtg/include/CardDescriptor.h @@ -67,6 +67,12 @@ class CardDescriptor: public MTGCardInstance int CDdamager; int CDgeared; int CDblocked; + int CDcanProduceC; + int CDcanProduceG; + int CDcanProduceU; + int CDcanProduceR; + int CDcanProduceB; + int CDcanProduceW; }; #endif diff --git a/projects/mtg/src/CardDescriptor.cpp b/projects/mtg/src/CardDescriptor.cpp index 149e4cdee..b62b7499e 100644 --- a/projects/mtg/src/CardDescriptor.cpp +++ b/projects/mtg/src/CardDescriptor.cpp @@ -26,6 +26,12 @@ CardDescriptor::CardDescriptor() CDdamager = 0; CDgeared = 0; CDblocked = 0; + CDcanProduceC = 0; + CDcanProduceG = 0; + CDcanProduceU = 0; + CDcanProduceR = 0; + CDcanProduceB = 0; + CDcanProduceW = 0; } int CardDescriptor::init() @@ -239,6 +245,36 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card) match = NULL; } } + + if ((CDcanProduceC == -1 && card->canproduceC == 1) || (CDcanProduceC == 1 && card->canproduceC == 0)) + { + match = NULL; + } + + if ((CDcanProduceG == -1 && card->canproduceG == 1) || (CDcanProduceG == 1 && card->canproduceG == 0)) + { + match = NULL; + } + + if ((CDcanProduceU == -1 && card->canproduceU == 1) || (CDcanProduceU == 1 && card->canproduceU == 0)) + { + match = NULL; + } + + if ((CDcanProduceR == -1 && card->canproduceR == 1) || (CDcanProduceR == 1 && card->canproduceR == 0)) + { + match = NULL; + } + + if ((CDcanProduceB == -1 && card->canproduceB == 1) || (CDcanProduceB == 1 && card->canproduceB == 0)) + { + match = NULL; + } + + if ((CDcanProduceW == -1 && card->canproduceW == 1) || (CDcanProduceW == 1 && card->canproduceW == 0)) + { + match = NULL; + } if ((isMultiColored == -1 && card->isMultiColored) || (isMultiColored == 1 && !card->isMultiColored)) { diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index e466a254a..8fb854b39 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -557,6 +557,73 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta cd->CDdamager = 1; } } + //can produce mana + else if (attribute.find("manac") != string::npos) + { + if (minus) + { + cd->CDcanProduceC = -1; + } + else + { + cd->CDcanProduceC = 1; + } + } + else if (attribute.find("manag") != string::npos) + { + if (minus) + { + cd->CDcanProduceG = -1; + } + else + { + cd->CDcanProduceG = 1; + } + } + else if (attribute.find("manau") != string::npos) + { + if (minus) + { + cd->CDcanProduceU = -1; + } + else + { + cd->CDcanProduceU = 1; + } + } + else if (attribute.find("manar") != string::npos) + { + if (minus) + { + cd->CDcanProduceR = -1; + } + else + { + cd->CDcanProduceR = 1; + } + } + else if (attribute.find("manab") != string::npos) + { + if (minus) + { + cd->CDcanProduceB = -1; + } + else + { + cd->CDcanProduceB = 1; + } + } + else if (attribute.find("manaw") != string::npos) + { + if (minus) + { + cd->CDcanProduceW = -1; + } + else + { + cd->CDcanProduceW = 1; + } + } else if (attribute.find("multicolor") != string::npos) { //card is multicolored? From a63065b44fe24d655530365c3ad36f92b8ff1f6d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 20 Aug 2016 03:04:58 +0800 Subject: [PATCH 4/4] try to fix --- .../bin/Res/sets/primitives/borderline.txt | 2 +- projects/mtg/src/MTGRules.cpp | 24 ++++++++++++++++++- projects/mtg/src/TargetChooser.cpp | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index e2cb7cc20..0aeac5b65 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -357,7 +357,7 @@ auto=this(variable{plandu}>0) {S(land[manau]|mybattlefield)}:Add{U} auto=this(variable{plandr}>0) {S(land[manar]|mybattlefield)}:Add{R} auto=this(variable{plandb}>0) {S(land[manab]|mybattlefield)}:Add{B} auto=this(variable{plandw}>0) {S(land[manaw]|mybattlefield)}:Add{W} -auto=this(variable{plandc}>0) {S(land[manac]|mybattlefield)}:Add{C} +auto=this(variable{plandc}>0) {S(land[cmana]|mybattlefield)}:Add{C} text=Sacrifice a land: Add to your mana pool one mana of any type the sacrificed land could produce. mana={B}{G} type=Enchantment diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 12381e0f3..3493e0699 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -388,7 +388,29 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) if ((cost->hasX() || cost->hasSpecificX()) && card->setX == -1) { vectorselection; - int options = cost->hasSpecificX() ? 20 : (playerMana->getConvertedCost() - cost->getConvertedCost()) + 1; + int amountx = 0; + int colorlessx = 0; + int costcx = 0; + costcx = cost->getCost(0); + if (cost->xColor) + { + int thisxcolor = cost->xColor; + amountx = (playerMana->getCost(thisxcolor) - cost->getCost(thisxcolor)); + for(int kk = 0; kk < 7; kk++) + { + if(kk!=thisxcolor) + { + colorlessx += playerMana->getCost(kk); + } + } + } + if (amountx < 0) + amountx = 0; + if(colorlessx >= costcx) + colorlessx = 0; + else + colorlessx -= costcx; + int options = cost->hasSpecificX() ? amountx + 1 +colorlessx : (playerMana->getConvertedCost() - cost->getConvertedCost()) + 1; //you can set up to 20 for specific X, if you cant afford it, it cancels. I couldnt think of a equation that would //give me the correct amount sorry. for (int i = 0; i < options; ++i) diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 8fb854b39..35291897c 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -558,7 +558,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta } } //can produce mana - else if (attribute.find("manac") != string::npos) + else if (attribute.find("cmana") != string::npos) { if (minus) {