fixed issues with "else" support in ifthen.

This commit is contained in:
omegablast2002@yahoo.com
2012-03-14 11:41:39 +00:00
parent 9c1fcacd1f
commit 1c28ee3d4d
2 changed files with 7 additions and 4 deletions
+2 -1
View File
@@ -3003,7 +3003,7 @@ int IfThenAbility::resolve()
} }
else if(delayedElseAbility) else if(delayedElseAbility)
{ {
delayedElseAbility->clone(); a1 = delayedElseAbility->clone();
} }
if (!a1) if (!a1)
return 0; return 0;
@@ -3039,6 +3039,7 @@ IfThenAbility * IfThenAbility::clone() const
IfThenAbility::~IfThenAbility() IfThenAbility::~IfThenAbility()
{ {
SAFE_DELETE(delayedAbility); SAFE_DELETE(delayedAbility);
SAFE_DELETE(delayedElseAbility);
} }
// //
+4 -2
View File
@@ -1208,11 +1208,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{ {
string s2 = s.substr(foundElse+6); string s2 = s.substr(foundElse+6);
if(s2.size()) if(s2.size())
{
s.erase(s.find(" else ")+1); s.erase(s.find(" else ")+1);
a2 = parseMagicLine(s2, id, spell, card); a2 = parseMagicLine(s2, id, spell, card);
} }
string s1 = s.substr(foundElse+6); }
MTGAbility * a1 = parseMagicLine(s1, id, spell, card); string s1 = s;
MTGAbility * a1 = parseMagicLine(s1.substr(s1.find(" then "+1)), id, spell, card);
if(!a1) return NULL; if(!a1) return NULL;
MTGAbility * a = NEW IfThenAbility(observer, id, a1,a2, card,(Targetable*)target,checkIf[i],cond); MTGAbility * a = NEW IfThenAbility(observer, id, a1,a2, card,(Targetable*)target,checkIf[i],cond);