fix for sorins destroy andability, actually a fix for and(( in general..have to hide the and(( string from the parser till we need it.
This commit is contained in:
@@ -445,6 +445,7 @@ class AbilityFactory
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
string storedString;
|
string storedString;
|
||||||
|
string storedAndAbility;
|
||||||
int countCards(TargetChooser * tc, Player * player = NULL, int option = 0);
|
int countCards(TargetChooser * tc, Player * player = NULL, int option = 0);
|
||||||
TriggeredAbility * parseTrigger(string s, string magicText, int id, Spell * spell, MTGCardInstance *card, Targetable * target);
|
TriggeredAbility * parseTrigger(string s, string magicText, int id, Spell * spell, MTGCardInstance *card, Targetable * target);
|
||||||
MTGAbility * getAlternateCost( string s, int id, Spell *spell, MTGCardInstance *card );
|
MTGAbility * getAlternateCost( string s, int id, Spell *spell, MTGCardInstance *card );
|
||||||
|
|||||||
@@ -1018,6 +1018,19 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
s.erase(sIndex, real_end - sIndex);
|
s.erase(sIndex, real_end - sIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found = s.find("and((");
|
||||||
|
if (found != string::npos && found + 6 != ')' && storedAndAbility.empty())
|
||||||
|
{
|
||||||
|
vector<string> splitAnd = parseBetween(s, "and((", " ))",false);
|
||||||
|
if(splitAnd.size())
|
||||||
|
{
|
||||||
|
storedAndAbility.append(splitAnd[1]);
|
||||||
|
size_t real_end = s.find("))", found);
|
||||||
|
size_t sIndex = found + 5;
|
||||||
|
s.erase(sIndex, real_end - sIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vector<string> splitTrigger = parseBetween(s, "@", ":");
|
vector<string> splitTrigger = parseBetween(s, "@", ":");
|
||||||
if (splitTrigger.size())
|
if (splitTrigger.size())
|
||||||
{
|
{
|
||||||
@@ -1867,13 +1880,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
|
|
||||||
MTGAbility * a = NEW AAMover(observer, id, card, target, splitMove[1]);
|
MTGAbility * a = NEW AAMover(observer, id, card, target, splitMove[1]);
|
||||||
a->oneShot = true;
|
a->oneShot = true;
|
||||||
if(s.find("and(") != string::npos)
|
if(storedAndAbility.size())
|
||||||
{
|
{
|
||||||
vector<string> splitAnd = parseBetween(s, "and((", " ))",false);
|
string stored = storedAndAbility;
|
||||||
if(splitAnd.size())
|
storedAndAbility.clear();
|
||||||
{
|
((AAMover*)a)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||||
((AAMover*)a)->andAbility = parseMagicLine(splitAnd[1], id, spell, card);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -1944,13 +1955,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
{
|
{
|
||||||
MTGAbility *a = NEW AABuryCard(observer, id, card, target);
|
MTGAbility *a = NEW AABuryCard(observer, id, card, target);
|
||||||
a->oneShot = 1;
|
a->oneShot = 1;
|
||||||
if(s.find("and(") != string::npos)
|
if(storedAndAbility.size())
|
||||||
{
|
{
|
||||||
vector<string> splitAnd = parseBetween(s, "and((", " ))",false);
|
string stored = storedAndAbility;
|
||||||
if(splitAnd.size())
|
storedAndAbility.clear();
|
||||||
{
|
((AABuryCard*)a)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||||
((AABuryCard*)a)->andAbility = parseMagicLine(splitAnd[1], id, spell, card);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -1959,13 +1968,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
{
|
{
|
||||||
MTGAbility * a = NEW AADestroyCard(observer, id, card, target);
|
MTGAbility * a = NEW AADestroyCard(observer, id, card, target);
|
||||||
a->oneShot = 1;
|
a->oneShot = 1;
|
||||||
if(s.find("and(") != string::npos)
|
if(storedAndAbility.size())
|
||||||
{
|
{
|
||||||
vector<string> splitAnd = parseBetween(s, "and((", " ))",false);
|
string stored = storedAndAbility;
|
||||||
if(splitAnd.size())
|
storedAndAbility.clear();
|
||||||
{
|
((AADestroyCard*)a)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||||
((AADestroyCard*)a)->andAbility = parseMagicLine(splitAnd[1], id, spell, card);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -1974,13 +1981,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
{
|
{
|
||||||
MTGAbility *a = NEW AASacrificeCard(observer, id, card, target);
|
MTGAbility *a = NEW AASacrificeCard(observer, id, card, target);
|
||||||
a->oneShot = 1;
|
a->oneShot = 1;
|
||||||
if(s.find("and(") != string::npos)
|
if(storedAndAbility.size())
|
||||||
{
|
{
|
||||||
vector<string> splitAnd = parseBetween(s, "and((", " ))",false);
|
string stored = storedAndAbility;
|
||||||
if(splitAnd.size())
|
storedAndAbility.clear();
|
||||||
{
|
((AASacrificeCard*)a)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||||
((AASacrificeCard*)a)->andAbility = parseMagicLine(splitAnd[1], id, spell, card);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -1989,13 +1994,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
{
|
{
|
||||||
MTGAbility *a = NEW AADiscardCard(observer, id, card, target);
|
MTGAbility *a = NEW AADiscardCard(observer, id, card, target);
|
||||||
a->oneShot = 1;
|
a->oneShot = 1;
|
||||||
if(s.find("and(") != string::npos)
|
if(storedAndAbility.size())
|
||||||
{
|
{
|
||||||
vector<string> splitAnd = parseBetween(s, "and((", " ))",false);
|
string stored = storedAndAbility;
|
||||||
if(splitAnd.size())
|
storedAndAbility.clear();
|
||||||
{
|
((AADiscardCard*)a)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||||
((AADiscardCard*)a)->andAbility = parseMagicLine(splitAnd[1], id, spell, card);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user