diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 3ff0b6bea..af4c865ff 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -45917,6 +45917,15 @@ mana={4}{U}{U} type=Instant [/card] [card] +name=Ovinize +text=Target creature loses all abilities and becomes 0/1 until end of turn. +target=creature +auto=ueot loseabilities +auto=ueot transforms((,setpower=0,settoughness=1)) +mana={1}{U} +type=Instant +[/card] +[card] name=Owl Familiar abilities=flying auto=draw:1 diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index be530e8d0..52bf5dffc 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -15892,12 +15892,6 @@ power=0 toughness=1 [/card] [card] -name=Ovinize -text=Target creature loses all abilities and becomes 0/1 until end of turn. -mana={1}{U} -type=Instant -[/card] -[card] name=Pack Hunt text=Search your library for up to three cards with the same name as target creature, reveal them, and put them into your hand. Then shuffle your library. mana={3}{G} diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index f4a3d0570..8c15bef1f 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -424,6 +424,8 @@ orcish_lumberjack.txt orims_chant_i595.txt orims_chant2.txt overrun.txt +ovinize.txt +ovinize2.txt paradise_mantle.txt paralysis.txt paralysis2.txt diff --git a/projects/mtg/bin/Res/test/ovinize.txt b/projects/mtg/bin/Res/test/ovinize.txt new file mode 100644 index 000000000..f7decb7fd --- /dev/null +++ b/projects/mtg/bin/Res/test/ovinize.txt @@ -0,0 +1,19 @@ +#Testing Ovinize: target creature loses its abilities and becomes 0/1 ueot +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:Llanowar elves +hand:Ovinize +manapool:{1}{U} +[PLAYER2] +[DO] +Ovinize +Llanowar elves +Llanowar elves +[ASSERT] +FIRSTMAIN +[PLAYER1] +inplay:Llanowar elves +graveyard:Ovinize +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/ovinize2.txt b/projects/mtg/bin/Res/test/ovinize2.txt new file mode 100644 index 000000000..8b3f665d7 --- /dev/null +++ b/projects/mtg/bin/Res/test/ovinize2.txt @@ -0,0 +1,23 @@ +#Testing Ovinize: target creature loses its abilities and becomes 0/1 ueot +# Testing the ueot effect +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:Llanowar elves +hand:Ovinize +manapool:{1}{U} +[PLAYER2] +[DO] +Ovinize +Llanowar elves +eot +eot +Llanowar elves +[ASSERT] +UNTAP +[PLAYER1] +inplay:Llanowar elves +graveyard:Ovinize +manapool:{G} +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index bf811e464..d7fe8262b 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -198,7 +198,7 @@ public: intValue = intValue/2; } if(halfdown) - intValue = intValue/2;//got lucky here, by default C++ rounds down. + intValue = intValue/2; } intValue *= multiplier; } diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 3f6cdff10..e3e60fc09 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -472,8 +472,6 @@ private: MTGAbility * getAlternateCost( string s, int id, Spell *spell, MTGCardInstance *card ); MTGAbility * getManaReduxAbility(string s, int id, Spell *spell, MTGCardInstance *card, MTGCardInstance *target); TargetChooser * parseSimpleTC(const std::string& s, const std::string& starter, MTGCardInstance *card, bool forceNoTarget = true); - std::vector& parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector& elems); - std::vector parseBetween(const std::string& s, string start, string stop, bool stopRequired = true); public: int parseRestriction(string s); diff --git a/projects/mtg/include/utils.h b/projects/mtg/include/utils.h index 90e6254d4..71b3b3976 100644 --- a/projects/mtg/include/utils.h +++ b/projects/mtg/include/utils.h @@ -87,6 +87,17 @@ std::string join(vector& v, string delim = " "); std::vector& split(const std::string& s, char delim, std::vector& elems); std::vector split(const std::string& s, char delim); //splits a string with "delim" and returns a vector of strings. + +// A simple parsing function +// splits string s by finding the first occurence of start, and the first occurence of stop, and returning +// a vector of 3 strings. The first string is everything before the first occurence of start, the second string is everything between start and stop +// the third string is everything after stop. +// for example, parseBetween ("this is a function(foo) call", "function(", ")") will return: ["this is a ", "foo", " call"]; +//If an error occurs, returns an empty vector. +// if "stopRequired" is set to false, the function will return a vector of 3 strings even if "stop" is not found in the string. +std::vector& parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector& elems); +std::vector parseBetween(const std::string& s, string start, string stop, bool stopRequired = true); + std::string wordWrap(const std::string& s, float width, int fontId); int loadRandValues(string s); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 90747a9b5..e1c1e909b 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -687,38 +687,6 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a) return a; } -std::vector& AbilityFactory::parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector& elems) -{ - size_t found = s.find(start); - if (found == string::npos) - return elems; - - size_t offset = found + start.size(); - size_t end = s.find(stop, offset); - if (end == string::npos && stopRequired) - return elems; - - elems.push_back(s.substr(0,found)); - if (end != string::npos) - { - elems.push_back(s.substr(offset, end - offset)); - elems.push_back(s.substr(end + 1)); - } - else - { - elems.push_back(s.substr(offset)); - elems.push_back(""); - } - - return elems; -} - -std::vector AbilityFactory::parseBetween(const std::string& s, string start, string stop, bool stopRequired) -{ - std::vector elems; - return parseBetween(s, start, stop, stopRequired, elems); -} - //Parses a string and returns the corresponding MTGAbility object //Returns NULL if parsing failed //Beware, Spell CAN be null when the function is called by the AI trying to analyze the effects of a given card @@ -925,6 +893,17 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return NEW MayAbility(id, a1, card,mayMust[i]); } } + + // Generic "Until end of turn" effect + if (s.find("ueot ") == 0) + { + string s1 = s.substr(5); + MTGAbility * a1 = parseMagicLine(s1, id, spell, card); + if (!a1) + return NULL; + + return NEW GenericInstantAbility(1, card, (Damageable *) target, a1); + } //Upkeep Cost found = s.find("upcostmulti"); diff --git a/projects/mtg/src/utils.cpp b/projects/mtg/src/utils.cpp index 8d5bd2e56..115428d90 100644 --- a/projects/mtg/src/utils.cpp +++ b/projects/mtg/src/utils.cpp @@ -302,6 +302,38 @@ std::vector split(const std::string& s, char delim) return split(s, delim, elems); } +std::vector& parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector& elems) +{ + size_t found = s.find(start); + if (found == string::npos) + return elems; + + size_t offset = found + start.size(); + size_t end = s.find(stop, offset); + if (end == string::npos && stopRequired) + return elems; + + elems.push_back(s.substr(0,found)); + if (end != string::npos) + { + elems.push_back(s.substr(offset, end - offset)); + elems.push_back(s.substr(end + 1)); + } + else + { + elems.push_back(s.substr(offset)); + elems.push_back(""); + } + + return elems; +} + +std::vector parseBetween(const std::string& s, string start, string stop, bool stopRequired) +{ + std::vector elems; + return parseBetween(s, start, stop, stopRequired, elems); +} + // This is a customized word wrap based on pixel width. It tries it's best // to wrap strings using spaces as delimiters. // Not sure how this translates into non-english fonts.