ifthen ability sometimes wasn't grabbing the right target, i now pass it through MTGAbility creations target.

also, i see now why targeted counter cost were left broken for so long. i think this way fixes it in all cases. what a pain.
This commit is contained in:
omegablast2002@yahoo.com
2011-09-15 11:50:04 +00:00
parent d04b4eca38
commit a6c458d0cb
4 changed files with 17 additions and 11 deletions
+1 -1
View File
@@ -839,7 +839,7 @@ public:
MTGAbility * delayedAbility; MTGAbility * delayedAbility;
int type; int type;
string Cond; string Cond;
IfThenAbility(int _id,MTGAbility * delayedAbility = NULL, MTGCardInstance * _source=NULL, int type = 1,string Cond = ""); IfThenAbility(int _id,MTGAbility * delayedAbility = NULL, MTGCardInstance * _source=NULL, Targetable * target = NULL, int type = 1,string Cond = "");
int resolve(); int resolve();
const char * getMenuText(); const char * getMenuText();
IfThenAbility * clone() const; IfThenAbility * clone() const;
+4 -6
View File
@@ -2164,8 +2164,8 @@ AAWinGame * AAWinGame::clone() const
//IfThenEffect //IfThenEffect
IfThenAbility::IfThenAbility(int _id, MTGAbility * delayedAbility, MTGCardInstance * _source, int type,string Cond) : IfThenAbility::IfThenAbility(int _id, MTGAbility * delayedAbility, MTGCardInstance * _source, Targetable * _target, int type,string Cond) :
MTGAbility(_id, _source),delayedAbility(delayedAbility), type(type),Cond(Cond) MTGAbility(_id, _source,_target),delayedAbility(delayedAbility), type(type),Cond(Cond)
{ {
} }
@@ -2173,6 +2173,7 @@ int IfThenAbility::resolve()
{ {
MTGCardInstance * card = (MTGCardInstance*)source; MTGCardInstance * card = (MTGCardInstance*)source;
AbilityFactory af; AbilityFactory af;
Targetable* aTarget = (Targetable*)target;
int checkCond = af.parseCastRestrictions(card,card->controller(),Cond); int checkCond = af.parseCastRestrictions(card,card->controller(),Cond);
if(Cond.find("cantargetcard(") != string::npos) if(Cond.find("cantargetcard(") != string::npos)
{ {
@@ -2194,10 +2195,7 @@ int IfThenAbility::resolve()
MTGAbility * a1 = delayedAbility->clone(); MTGAbility * a1 = delayedAbility->clone();
if (!a1) if (!a1)
return 0; return 0;
if(target) a1->target = aTarget;
a1->target = target;
if(!a1->target)
a1->target = source->target;
if(a1->oneShot) if(a1->oneShot)
{ {
a1->resolve(); a1->resolve();
+11 -3
View File
@@ -626,11 +626,19 @@ int CounterCost::canPay()
if (counter->nb >= 0) if (counter->nb >= 0)
return 1; //add counters always possible return 1; //add counters always possible
// otherwise, move on only if target has enough counters // otherwise, move on only if target has enough counters
Counter * targetCounter = NULL;
if(target) if(target)
{ {
Counter * targetCounter = target->counters->hasCounter(counter->name.c_str(), counter->power, counter->toughness); targetCounter = target->counters->hasCounter(counter->name.c_str(), counter->power, counter->toughness);
if (targetCounter && targetCounter->nb >= -counter->nb)
return 1; }
else
{
targetCounter = source->counters->hasCounter(counter->name.c_str(), counter->power, counter->toughness);
}
if (targetCounter && targetCounter->nb >= -counter->nb)
{
return 1;
} }
return 0; return 0;
} }
+1 -1
View File
@@ -978,7 +978,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
string s1 = s.substr(s.find(" then ")+6); string s1 = s.substr(s.find(" then ")+6);
MTGAbility * a1 = parseMagicLine(s1, id, spell, card); MTGAbility * a1 = parseMagicLine(s1, id, spell, card);
if(!a1) return NULL; if(!a1) return NULL;
MTGAbility * a = NEW IfThenAbility(id, a1, card,checkIf[i],cond); MTGAbility * a = NEW IfThenAbility(id, a1, card,(Targetable*)target,checkIf[i],cond);
a->canBeInterrupted = false; a->canBeInterrupted = false;
a->oneShot = true; a->oneShot = true;
if(tc) if(tc)