diff --git a/projects/mtg/include/AIPlayer.h b/projects/mtg/include/AIPlayer.h index 3f9492130..5f5eebe24 100644 --- a/projects/mtg/include/AIPlayer.h +++ b/projects/mtg/include/AIPlayer.h @@ -59,6 +59,7 @@ protected: //Variables used by Test suite MTGCardInstance * nextCardToPlay; queue clickstream; + bool findingAbility; void tapLandsForMana(ManaCost * cost, MTGCardInstance * card = NULL); int orderBlockers(); int combatDamages(); diff --git a/projects/mtg/src/AIMomirPlayer.cpp b/projects/mtg/src/AIMomirPlayer.cpp index a5ca2bdc5..952e771ba 100644 --- a/projects/mtg/src/AIMomirPlayer.cpp +++ b/projects/mtg/src/AIMomirPlayer.cpp @@ -95,7 +95,11 @@ int AIMomirPlayer::computeActions() int currentGamePhase = g->getCurrentGamePhase(); if (g->isInterrupting == this) { // interrupting - selectAbility(); + if(!findingAbility) + { + AIPlayer::findingAbility = true; + selectAbility(); + } return 1; } else if (p == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) @@ -129,7 +133,11 @@ int AIMomirPlayer::computeActions() break; } case Constants::MTG_PHASE_SECONDMAIN: - selectAbility(); + if(!findingAbility) + { + AIPlayer::findingAbility = true; + selectAbility(); + } return 1; break; default: diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index b58f34329..7c9e5620f 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -629,17 +629,25 @@ int AIPlayer::selectAbility() } else { + if(!clickstream.size()) + { DebugTrace("AIPlayer:Using Activated ability"); tapLandsForMana(a->ability->cost, a->click); - clickstream.push(a); + clickstream.push(a); + } + else + { + a = NULL; + } } map::iterator it2; for (it2 = ranking.begin(); it2 != ranking.end(); it2++) { - if (a != it2->first) + if (a && a != it2->first) delete (it2->first); } } + AIPlayer::findingAbility = false; return 1; } @@ -1145,6 +1153,7 @@ int AIPlayerBaka::computeActions() { GameObserver * g = GameObserver::GetInstance(); Player * p = g->currentPlayer; + AIPlayer::findingAbility = false; if (!(g->currentlyActing() == this)) return 0; if (g->mLayers->actionLayer()->menuObject) @@ -1157,7 +1166,11 @@ int AIPlayerBaka::computeActions() int currentGamePhase = g->getCurrentGamePhase(); if (g->isInterrupting == this) { // interrupting - selectAbility(); + if(!findingAbility) + { + AIPlayer::findingAbility = true; + selectAbility(); + } return 1; } else if (p == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) @@ -1178,7 +1191,11 @@ int AIPlayerBaka::computeActions() potential = true; } nextCardToPlay = FindCardToPlay(currentMana, "land"); + if(!findingAbility) + { + AIPlayer::findingAbility = true; selectAbility(); + } //look for the most expensive creature we can afford if (castrestrictedspell == 0 && nospellinstant == 0) { @@ -1212,7 +1229,11 @@ int AIPlayerBaka::computeActions() } if (!nextCardToPlay) { - selectAbility(); + if(!findingAbility) + { + AIPlayer::findingAbility = true; + selectAbility(); + } } } } @@ -1261,7 +1282,11 @@ int AIPlayerBaka::computeActions() } else { - selectAbility(); + if(!findingAbility) + { + AIPlayer::findingAbility = true; + selectAbility(); + } } if (p->getManaPool()->getConvertedCost() > 0 && Checked == false)//not the best thing ever, but allows the Ai a chance to double check if its mana pool has something before moving on, atleast one time. { @@ -1277,7 +1302,11 @@ int AIPlayerBaka::computeActions() Checked = false; break; default: - selectAbility(); + if(!findingAbility) + { + AIPlayer::findingAbility = true; + selectAbility(); + } break; } }