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:
omegablast2002@yahoo.com
2012-03-26 11:48:22 +00:00
parent 08b6975300
commit c5128b35e0
2 changed files with 34 additions and 30 deletions
+1
View File
@@ -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 );
+33 -30
View File
@@ -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;
} }