From 8737aec0056c8c481721479baaadcc61eea46359 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Mon, 9 May 2011 18:10:10 +0000 Subject: [PATCH] couple tweaks to transforms to it doesn't add subkeywords as types.... 2nd, removed a peice of code which was originally added i imagine before list mentioner was created which added cards whos names ended in "s" to the subtypes list, this is completely unrelated to the "s" charector added to targetchooser. this was actually a really nasty hack.... previous subtypes list contained 1200 variables...the new one after this removel is about 237ish.... this does not impact foreach, or any targetchoosers ability to target a card by name, targetchooser is coded to add card names to the subtypes list as it needs them, so using foreach(arbor elf) will add this to subtypes list for targeting purposes, in the future we might want to have this kind of check done and handled outside of the subtypes list, adding card names to that list for the purpose of targeting is just dirty. this fixes a ugly lag spike introduced with the change to subtypes...for now...we need to consider a better way to sort these in the future to avoid this returning as subtypeslist gets bigger. --- projects/mtg/src/AllAbilities.cpp | 44 +++++++++++++++------------- projects/mtg/src/CardPrimitive.cpp | 4 --- projects/mtg/src/MTGCardInstance.cpp | 8 ++--- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index fd8438bf5..dfb2a1727 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2420,7 +2420,7 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t //this subkeyword adds a color without removing the existing colors. addNewColors = (sabilities.find("newcolors") != string::npos); - remove = (stypes.find("removesubtypes") != string::npos); + remove = (stypes.find("removealltypes") != string::npos); removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos); removeTypes = (stypes.find("removetypes") != string::npos); @@ -2432,8 +2432,9 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t continue; //Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way? - //I think this is releated to the fact that "Pestilence Rats" is a type for some reason, maybe we don't need that anymore - //TODO Remove the following block if possible + //this check is related to targetchooser instances of cards dynamically loaded subtypes. + //example(foreach(arbor elf)) adds this as a subtype for list ment. + //TODO find cheaper method string s = Subtypes::subtypesList->find(i); if (s.find(" ") != string::npos) continue; @@ -2502,27 +2503,29 @@ int ATransformer::addToGame() _target->removeType(*it); } } - for (it = types.begin(); it != types.end(); it++) + else { - if(removeCreatureSubtypes) + for (it = types.begin(); it != types.end(); it++) { - _target->removeType(*it); - } - else if(_target->hasSubtype(*it)) - { - //we generally don't want to give a creature type creature again - //all it does is create a sloppy mess of the subtype line on alternative quads - //also creates instances where a card gained a type from an ability like this one - //then loses the type through another ability, when this effect is destroyed the creature regains - //the type, which is wrong. - dontremove.push_back(*it); - } - else - { - _target->addType(*it); + if(removeCreatureSubtypes) + { + _target->removeType(*it); + } + else if(_target->hasSubtype(*it)) + { + //we generally don't want to give a creature type creature again + //all it does is create a sloppy mess of the subtype line on alternative quads + //also creates instances where a card gained a type from an ability like this one + //then loses the type through another ability, when this effect is destroyed the creature regains + //the type, which is wrong. + dontremove.push_back(*it); + } + else + { + _target->addType(*it); + } } } - for (it = colors.begin(); it != colors.end(); it++) { _target->setColor(*it); @@ -2663,7 +2666,6 @@ int ATransformer::destroy() { for (it = oldtypes.begin(); it != oldtypes.end(); it++) { - if (!_target->hasSubtype(*it)) _target->addType(*it); } } diff --git a/projects/mtg/src/CardPrimitive.cpp b/projects/mtg/src/CardPrimitive.cpp index 106baec54..c32e12bb0 100644 --- a/projects/mtg/src/CardPrimitive.cpp +++ b/projects/mtg/src/CardPrimitive.cpp @@ -272,10 +272,6 @@ void CardPrimitive::setName(const string& value) name = value; lcname = value; std::transform(lcname.begin(), lcname.end(), lcname.begin(), ::tolower); - //This is a bug fix for plague rats and the "foreach ability" - //Right now we add names as types, so that they get recognized - if (value.length() && lcname.at(value.length() - 1) == 's') - Subtypes::subtypesList->find(lcname); } const string& CardPrimitive::getName() const diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 9f5ad71f5..fe5ccca7d 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -182,14 +182,12 @@ void MTGCardInstance::initMTGCI() continue; //Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way? - //I think this is releated to the fact that "Pestilence Rats" is a type for some reason, maybe we don't need that anymore - //TODO Remove the following block if possible - { + //this check is related to targetchooser instances of cards dynamically loaded subtypes. + //example(foreach(arbor elf)) adds this as a subtype for list ment. + //TODO find cheaper method string s = Subtypes::subtypesList->find(i); - if (s.find(" ") != string::npos) continue; - } addType(i); }