diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 0614bfef0..6fe516e39 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -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; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 6c0832edc..bcdc2cb5e 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -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(); diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index c80138da7..2ea38bab9 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -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; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 3f4f9e58b..8aff0a0f4 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -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)