diff --git a/projects/mtg/src/GameStateDeckViewer.cpp b/projects/mtg/src/GameStateDeckViewer.cpp index 1601625f0..800e352d1 100644 --- a/projects/mtg/src/GameStateDeckViewer.cpp +++ b/projects/mtg/src/GameStateDeckViewer.cpp @@ -1087,48 +1087,34 @@ void GameStateDeckViewer::updateStats() { } // Lets look for mana producing abilities - MTGCardInstance * cin; - MTGAbility * ab = NULL; int found; - // TODO: Creating card instance for the sole purpose of getting the card abilities is dirty. Do something about it. - cin = new MTGCardInstance(current, NULL); - vector abilityStrings; string thisstring = current->data->magicText; StringExplode(thisstring, "\n", &abilityStrings); - /*char buf[4096]; - sprintf(buf, "Card: %s Ability count:%i Iterating....", (current->name).c_str(),(int)abilityStrings.size()); - OutputDebugString(buf);*/ - - for (int i=0; i<(int)abilityStrings.size(); i++) { - found = abilityStrings.at(i).find("add"); - if (found != (int)string::npos){ //Parse only mana abilities - AbilityFactory af; - ab = af.parseMagicLine(abilityStrings.at(i),0,0,cin); - AManaProducer * amp = dynamic_cast(ab); - - if (amp){ - //OutputDebugString("M "); - for (int j=0; joutput->hasColor(j)) { - if (current->data->isLand()) { - if (current->data->hasType("Basic")) { - stw.countBasicLandsPerColor[j] += currentCount; - } else { - stw.countLandsPerColor[j] += currentCount; - } + for(int v=0;vhasColor(j)){ + if (current->data->isLand()) { + if (current->data->hasType("Basic")) { + stw.countBasicLandsPerColor[j] += currentCount; } else { - stw.countNonLandProducersPerColor[j] += currentCount; + stw.countLandsPerColor[j] += currentCount; } + } else { + stw.countNonLandProducersPerColor[j] += currentCount; } } } - SAFE_DELETE(ab); + SAFE_DELETE(mc); } } - SAFE_DELETE(cin); // Add to the per color counters // a. regular costs @@ -1388,6 +1374,7 @@ int GameStateDeckViewer::loadDeck(int deckid){ myDeck->validate(); myCollection->validate(); } + // Load deck statistics // TODO: Code cleanup (Copypasted with slight changes from GameStateMenu.cpp) char buffer[512]; @@ -1521,7 +1508,8 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId) pricelist->setPrice(card->getMTGId(),price*2); playerdata->collection->remove(card->getMTGId()); displayed_deck->Remove(card,1); - displayed_deck->validate(); + displayed_deck->validate(); + stw.needUpdate = true; loadIndexes(); } } diff --git a/projects/mtg/src/WFilter.cpp b/projects/mtg/src/WFilter.cpp index a76fd0ca1..f3a2c0e77 100644 --- a/projects/mtg/src/WFilter.cpp +++ b/projects/mtg/src/WFilter.cpp @@ -229,14 +229,19 @@ string WCFilterOnlyColor::getCode(){ } //WCFilterProducesColor bool WCFilterProducesColor::isMatch(MTGCard * c){ + bool bMatch = false; if(!c || !c->data) return false; string s = c->data->magicText; size_t t = s.find("add"); - if(t == string::npos) - return false; - ManaCost * mc = ManaCost::parseManaCost(s.substr(t)); - return (mc->hasColor(color) > 0); + while(t != string::npos){ + s = s.substr(t+3); + ManaCost * mc = ManaCost::parseManaCost(s); + if(mc->hasColor(color) > 0) {bMatch = true; SAFE_DELETE(mc); break;} + SAFE_DELETE(mc); + t = s.find("add"); + } + return bMatch; } string WCFilterProducesColor::getCode(){ char buf[12];