diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 5a1de1d4d..120ac0e84 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -439,20 +439,22 @@ int AIAction::getEfficiency() { if(cc && _target) { - if(_target && _target->controller() == p && cc->toughness>=0) + if(_target->controller() == p && cc->toughness>=0) { efficiency = 90; } - if(_target && _target->controller() != p && ((_target->toughness + cc->toughness <= 0 && _target->toughness) || (cc->toughness < 0 && cc->power < 0))) + if(_target->controller() != p && ((_target->toughness + cc->toughness <= 0 && _target->toughness) || (cc->toughness < 0 && cc->power < 0))) { efficiency = 90; } - if(_target && _target->counters && _target->counters->counters && _target->counters->hasCounter(cc->power,cc->toughness) && _target->counters->hasCounter(cc->power,cc->toughness)->nb > 15) + if(_target->counters && _target->counters->counters && _target->counters->hasCounter(cc->power,cc->toughness) && _target->counters->hasCounter(cc->power,cc->toughness)->nb > 15) { efficiency = _target->counters->hasCounter(cc->power,cc->toughness)->nb; } + if(cc->maxNb && _target->counters && _target->counters->counters && _target->counters->hasCounter(cc->power,cc->toughness)->nb >= cc->maxNb) + efficiency = 0; } } break; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index f6449cee7..9d1bc4d36 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2559,6 +2559,8 @@ int ATransformer::addToGame() { AbilityFactory af; MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k], 0, NULL, _target); + if(!aNew) + continue; aNew->isClone = 1; GenericTargetAbility * gta = dynamic_cast (aNew); if (gta) @@ -2578,6 +2580,7 @@ int ATransformer::addToGame() ((MultiAbility *)aNew)->source = _target; ((MultiAbility *)aNew)->abilities[0]->source = _target; } + aNew->target = _target; aNew->source = (MTGCardInstance *) _target; if(aNew->oneShot) @@ -2586,8 +2589,10 @@ int ATransformer::addToGame() delete aNew; } else + { aNew->addToGame(); - newAbilities[_target].push_back(aNew); + newAbilities[_target].push_back(aNew); + } } } if(newpowerfound ) @@ -2691,7 +2696,10 @@ int ATransformer::destroy() { for (unsigned int i = 0;i < newAbilities[_target].size(); i++) { - newAbilities[_target].at(i)->forceDestroy = 1; + if(newAbilities[_target].at(i)) + { + newAbilities[_target].at(i)->forceDestroy = 1; + } } if (newAbilities.find(_target) != newAbilities.end()) {