- Adding a generic "ueot" effect. This will be initially confusing, but the ultimate goal is to get rid of all the particular cases we handled with "until end of turn" effects. this "ueot " works like "may " and "choice ", it has to be at the very beginning of the ability(ies) it targets. The reason is to avoid conflicts with the existing "ueot" we have all over the place. I have only tested it with transforms and loseabilities for now (see "ovinize") but hopefully this will become the new norm. This should also reduce the code inside the parser, long term.

- Adding "Ovinize" as an example of this new keyword.
- moved "parseBetween" in utils as I am using it in other files for wome work in Progress.
This commit is contained in:
wagic.the.homebrew
2011-05-05 06:18:50 +00:00
parent 4c572a1ffa
commit 748af5b461
10 changed files with 108 additions and 41 deletions

View File

@@ -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

View File

@@ -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}

View File

@@ -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

View File

@@ -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]

View File

@@ -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]

View File

@@ -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;
}

View File

@@ -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<std::string>& parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector<std::string>& elems);
std::vector<std::string> parseBetween(const std::string& s, string start, string stop, bool stopRequired = true);
public:
int parseRestriction(string s);

View File

@@ -87,6 +87,17 @@ std::string join(vector<string>& v, string delim = " ");
std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems);
std::vector<std::string> 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<std::string>& parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector<std::string>& elems);
std::vector<std::string> 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);

View File

@@ -687,38 +687,6 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a)
return a;
}
std::vector<std::string>& AbilityFactory::parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector<std::string>& 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<std::string> AbilityFactory::parseBetween(const std::string& s, string start, string stop, bool stopRequired)
{
std::vector<std::string> 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");

View File

@@ -302,6 +302,38 @@ std::vector<std::string> split(const std::string& s, char delim)
return split(s, delim, elems);
}
std::vector<std::string>& parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector<std::string>& 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<std::string> parseBetween(const std::string& s, string start, string stop, bool stopRequired)
{
std::vector<std::string> 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.