diff --git a/projects/mtg/include/ThisDescriptor.h b/projects/mtg/include/ThisDescriptor.h index c58caaaa7..e1b68ae03 100644 --- a/projects/mtg/include/ThisDescriptor.h +++ b/projects/mtg/include/ThisDescriptor.h @@ -98,6 +98,13 @@ class ThisAttacked:public ThisDescriptor{ ThisAttacked(int attack); }; +class ThisBlocked:public ThisDescriptor{ + public: + virtual int match(MTGCardInstance * card); + + ThisBlocked(int block); +}; + class ThisNotBlocked:public ThisDescriptor{ public: virtual int match(MTGCardInstance * card); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index b20d63ff8..16bbe84ad 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1817,7 +1817,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return tok; } } - + size_t realEnd = s.find(")", found); end = s.find(",", found); string sname = s.substr(found + 6, end - found - 6); size_t previous = end + 1; @@ -1825,6 +1825,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG string stypes = s.substr(previous, end - previous); previous = end + 1; end = s.find(",", previous); + if(end == string::npos) + end = realEnd; string spt = s.substr(previous, end - previous); int value = 0; int power, toughness; diff --git a/projects/mtg/src/ThisDescriptor.cpp b/projects/mtg/src/ThisDescriptor.cpp index 570de788e..0db634d5a 100644 --- a/projects/mtg/src/ThisDescriptor.cpp +++ b/projects/mtg/src/ThisDescriptor.cpp @@ -214,7 +214,19 @@ ThisDescriptor * ThisDescriptorFactory::createThisDescriptor(string s) } return NULL; } - + //whenever this creature blocks do effect + found = s.find("blocking"); + if (found != string::npos) + { + ThisBlocked * td = NEW ThisBlocked(criterion); + if (td) + { + td->comparisonMode = mode; + return td; + } + return NULL; + } + //whenever this creature attacks do effect found = s.find("notblocked"); if (found != string::npos) @@ -444,6 +456,18 @@ int ThisAttacked::match(MTGCardInstance * card) return matchValue(card->didattacked); } +ThisBlocked::ThisBlocked(int block) +{ + + comparisonCriterion = block; +} + +int ThisBlocked::match(MTGCardInstance * card) +{ + + return matchValue(card->didblocked); +} + ThisNotBlocked::ThisNotBlocked(int unblocked) {