diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 56192ff0b..c929d817b 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -387,62 +387,66 @@ int AIAction::getEfficiency() break; } case MTGAbility::STANDARD_LEVELUP: + { + MTGCardInstance * _target = (MTGCardInstance *) target; + efficiency = 0; + Counter * targetCounter = NULL; + int currentlevel = 0; + + if (_target) + { + if (_target->counters && _target->counters->hasCounter("level", 0, 0)) + { + targetCounter = _target->counters->hasCounter("level", 0, 0); + currentlevel = targetCounter->nb; + } + } + if (currentlevel < _target->MaxLevelUp) + { + efficiency = 85; + //increase the efficeincy of leveling up by a small amount equal to current level. + efficiency += currentlevel; + + if (p->game->hand->nb_cards > 0 && p->isAI()) + { + efficiency -= (10 * p->game->hand->nb_cards);//reduce the eff if by 10 times the amount of cards in Ais hand. + //it should always try playing more cards before deciding + } + + if (g->getCurrentGamePhase() == Constants::MTG_PHASE_SECONDMAIN) + { + efficiency = 100; + //in 2nd main, go all out and try to max stuff. + } + } + break; + } case MTGAbility::COUNTERS: - { - MTGCardInstance * _target = (MTGCardInstance *) target; - efficiency = 0; - Counter * targetCounter = NULL; - int currentlevel = 0; - - if (_target) { - if (_target->counters && _target->counters->hasCounter("level", 0, 0)) + MTGCardInstance * _target = (MTGCardInstance *) target; + efficiency = 0; + if(AACounter * cc = dynamic_cast (a)) { - targetCounter = _target->counters->hasCounter("level", 0, 0); - currentlevel = targetCounter->nb; - } - } - if(AACounter * cc = dynamic_cast (a)) - { - if(cc && !targetCounter) - { - if(_target && _target->controller()->isAI() && cc->toughness>=0) + if(cc && _target) { - efficiency = 90; + if(_target && _target->controller()->isAI() && cc->toughness>=0) + { + efficiency = 90; - } - if(_target && !_target->controller()->isAI() && ((_target->toughness + cc->toughness <= 0 && _target->toughness) || (cc->toughness < 0 && cc->power < 0))) - { - efficiency = 90; + } + if(_target && !_target->controller()->isAI() && ((_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) + { + efficiency = _target->counters->hasCounter(cc->power,cc->toughness)->nb; + } } - if(_target && _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; - } - break; } + break; } - if (currentlevel < _target->MaxLevelUp) - { - efficiency = 85; - //increase the efficeincy of leveling up by a small amount equal to current level. - efficiency += currentlevel; - - if (p->game->hand->nb_cards > 0 && p->isAI()) - { - efficiency -= (10 * p->game->hand->nb_cards);//reduce the eff if by 10 times the amount of cards in Ais hand. - //it should always try playing more cards before deciding - } - - if (g->getCurrentGamePhase() == Constants::MTG_PHASE_SECONDMAIN) - { - efficiency = 100; - //in 2nd main, go all out and try to max stuff. - } - } - break; - } case MTGAbility::STANDARD_PUMP: { MTGCardInstance * _target = (MTGCardInstance *) (a->target); diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 7b7f90132..64430d16c 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -537,12 +537,6 @@ int ActionStack::addDraw(Player * player, int nb_cards) { DrawAction * draw = NEW DrawAction(mCount, player, nb_cards); addAction(draw); - GameObserver *g = GameObserver::GetInstance(); - for(int i = nb_cards; i > 0;i--) - { - WEvent * e = NEW WEventcardDraw(player, nb_cards); - g->receiveEvent(e); - } return 1; } diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index f49f5107b..e53c58362 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -292,7 +292,7 @@ AACounter::AACounter(int id, MTGCardInstance * source, MTGCardInstance * target, ActivatedAbility(id, source, cost, 0),counterstring(counterstring), nb(nb),maxNb(maxNb), power(power), toughness(toughness), name(_name) { this->target = target; - if (name.find("Level")) + if (name.find("Level") != string::npos || name.find("level") != string::npos) aType = MTGAbility::STANDARD_LEVELUP; else aType = MTGAbility::COUNTERS; @@ -677,6 +677,12 @@ AADrawer::AADrawer(int _id, MTGCardInstance * card, Targetable * _target, ManaCo } game->mLayers->stackLayer()->addDraw(player, numCards.getValue()); game->mLayers->stackLayer()->resolve(); + GameObserver *g = GameObserver::GetInstance(); + for(int i = numCards.getValue(); i > 0;i--) + { + WEvent * e = NEW WEventcardDraw(player, 1); + g->receiveEvent(e); + } } return 1; }