From 26b30cb20d22c73dabb159d76368032c3d13d4ac Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Tue, 31 May 2016 18:41:36 -0400 Subject: [PATCH] ok sorry about the confusion, so the issue was with {1}{c} and how its handled. we only need to replace the adding of colorless in the manapool, the old colorless is still very very valid and should be left in place as is. {1} can be paid with anything {c} is a mana supertype, it pays for diamond and colorless. however all card such as "sol ring" now add diamond instead of old colorless. reverted waste to {c}, but moved it under counters to avoid crashes. parse for a counter if its not a counter than parse {c} otherwise we would end up with case where it was parsing {c} instead of building counters or vice versa. --- projects/mtg/src/ManaCost.cpp | 83 ++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 0c3a133b7..3ef4327a3 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -254,35 +254,43 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan { manaCost->addExtraCost(NEW CycleCost(tc)); } - else - { - size_t counter_start = value.find("("); - size_t counter_end = value.find(")", counter_start); - AbilityFactory abf(g); - string counterString = value.substr(counter_start + 1, counter_end - counter_start - 1); - Counter * counter = abf.parseCounter(counterString, c); - size_t separator = value.find(",", counter_start); - size_t separator2 = string::npos; - if (separator != string::npos) - { - separator2 = value.find(",", counter_end + 1); - } - SAFE_DELETE(tc); - size_t target_start = string::npos; - if (separator2 != string::npos) - { - target_start = value.find(",", counter_end + 1); - } - size_t target_end = value.length(); - if (target_start != string::npos && target_end != string::npos) - { - string target = value.substr(target_start + 1, target_end - 1 - target_start); - tc = tcf.createTargetChooser(target, c); - } - manaCost->addExtraCost(NEW CounterCost(counter, tc)); - } - break; - } + else if(size_t counterCheck = value.find("(") != string::npos) + { + size_t counter_start = value.find("("); + size_t counter_end = value.find(")", counter_start); + AbilityFactory abf(g); + string counterString = value.substr(counter_start + 1, counter_end - counter_start - 1); + Counter * counter = abf.parseCounter(counterString, c); + size_t separator = value.find(",", counter_start); + size_t separator2 = string::npos; + if (separator != string::npos) + { + separator2 = value.find(",", counter_end + 1); + } + SAFE_DELETE(tc); + size_t target_start = string::npos; + if (separator2 != string::npos) + { + target_start = value.find(",", counter_end + 1); + } + size_t target_end = value.length(); + if (target_start != string::npos && target_end != string::npos) + { + string target = value.substr(target_start + 1, target_end - 1 - target_start); + tc = tcf.createTargetChooser(target, c); + } + manaCost->addExtraCost(NEW CounterCost(counter, tc)); + break; + } + else if (value == "c") + { + manaCost->add(Constants::MTG_COLOR_WASTE, 1); + break; + + } + + break; + } default: //uncolored cost and hybrid costs and special cost { if(value == "unattach") @@ -290,12 +298,6 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan manaCost->addExtraCost(NEW UnattachCost(c)); break; } - if (value == "waste") - { - manaCost->add(Constants::MTG_COLOR_WASTE, 1); - break; - - } int intvalue = atoi(value.c_str()); int colors[2]; int values[2]; @@ -1103,6 +1105,8 @@ int ManaPool::remove(int color, int value) int ManaPool::add(int color, int value, MTGCardInstance * source) { + if (color == Constants::MTG_COLOR_ARTIFACT) + color = Constants::MTG_COLOR_WASTE; int result = ManaCost::add(color, value); for (int i = 0; i < value; ++i) { @@ -1116,6 +1120,15 @@ int ManaPool::add(ManaCost * _cost, MTGCardInstance * source) { if (!_cost) return 0; + //while colorless is still exactly the same, there are now cards that require + //true colorless mana, ei:eldrazi. so whenever we add mana, we now replace it with the + //new type. keeping the old type intact for payment methods {1}{c} .... + int replaceArtifact = _cost->getCost(Constants::MTG_COLOR_ARTIFACT); + if (replaceArtifact) + { + _cost->add(Constants::MTG_COLOR_WASTE, replaceArtifact); + _cost->remove(Constants::MTG_COLOR_ARTIFACT, replaceArtifact); + } int result = ManaCost::add(_cost); for (int i = 0; i < Constants::NB_Colors; i++) {