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:
@@ -839,7 +839,7 @@ public:
|
||||
MTGAbility * delayedAbility;
|
||||
int type;
|
||||
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();
|
||||
const char * getMenuText();
|
||||
IfThenAbility * clone() const;
|
||||
|
||||
@@ -2164,8 +2164,8 @@ AAWinGame * AAWinGame::clone() const
|
||||
|
||||
|
||||
//IfThenEffect
|
||||
IfThenAbility::IfThenAbility(int _id, MTGAbility * delayedAbility, MTGCardInstance * _source, int type,string Cond) :
|
||||
MTGAbility(_id, _source),delayedAbility(delayedAbility), type(type),Cond(Cond)
|
||||
IfThenAbility::IfThenAbility(int _id, MTGAbility * delayedAbility, MTGCardInstance * _source, Targetable * _target, int type,string Cond) :
|
||||
MTGAbility(_id, _source,_target),delayedAbility(delayedAbility), type(type),Cond(Cond)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2173,6 +2173,7 @@ int IfThenAbility::resolve()
|
||||
{
|
||||
MTGCardInstance * card = (MTGCardInstance*)source;
|
||||
AbilityFactory af;
|
||||
Targetable* aTarget = (Targetable*)target;
|
||||
int checkCond = af.parseCastRestrictions(card,card->controller(),Cond);
|
||||
if(Cond.find("cantargetcard(") != string::npos)
|
||||
{
|
||||
@@ -2194,10 +2195,7 @@ int IfThenAbility::resolve()
|
||||
MTGAbility * a1 = delayedAbility->clone();
|
||||
if (!a1)
|
||||
return 0;
|
||||
if(target)
|
||||
a1->target = target;
|
||||
if(!a1->target)
|
||||
a1->target = source->target;
|
||||
a1->target = aTarget;
|
||||
if(a1->oneShot)
|
||||
{
|
||||
a1->resolve();
|
||||
|
||||
@@ -626,11 +626,19 @@ int CounterCost::canPay()
|
||||
if (counter->nb >= 0)
|
||||
return 1; //add counters always possible
|
||||
// otherwise, move on only if target has enough counters
|
||||
Counter * targetCounter = NULL;
|
||||
if(target)
|
||||
{
|
||||
Counter * targetCounter = target->counters->hasCounter(counter->name.c_str(), counter->power, counter->toughness);
|
||||
if (targetCounter && targetCounter->nb >= -counter->nb)
|
||||
return 1;
|
||||
targetCounter = target->counters->hasCounter(counter->name.c_str(), counter->power, counter->toughness);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
targetCounter = source->counters->hasCounter(counter->name.c_str(), counter->power, counter->toughness);
|
||||
}
|
||||
if (targetCounter && targetCounter->nb >= -counter->nb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -978,7 +978,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
string s1 = s.substr(s.find(" then ")+6);
|
||||
MTGAbility * a1 = parseMagicLine(s1, id, spell, card);
|
||||
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->oneShot = true;
|
||||
if(tc)
|
||||
|
||||
Reference in New Issue
Block a user