From 6af545a7978a0f087c7d6e945a4d0fe15abfaa8e Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Fri, 28 Jan 2011 18:26:34 +0000 Subject: [PATCH] fixed a bug that arose from giving the Ai the ability to actually interupt with something. found that ai was allowed to run "chooseBlockers()" and has been running this function EVERYTIME even before the update i made, when ever it was choosing actions during blockers. even when its blockers were already choosen and it no longer had proirity. --- projects/mtg/src/AIPlayer.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 23fcdae8c..7700fb357 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -990,6 +990,14 @@ int AIPlayer::canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy int AIPlayer::chooseBlockers() { + GameObserver * g = GameObserver::GetInstance(); + if (g->currentActionPlayer != this) + return 0; + //ai should not be allowed to run this if it is not legally allowed to do so + //this fixes a bug where ai would try to use this as an interupt + //when ai is given priority to select blockers it is allowed to run this as normal. + //but as soon as its selected it blockers and proirity switch back to other player + //kick the ai out of this function. map opponentsToughness; int opponentForce = getCreaturesInfo(opponent(), INFO_CREATURESPOWER); CardDescriptor cd; @@ -997,9 +1005,9 @@ int AIPlayer::chooseBlockers() cd.setType("Creature"); cd.unsecureSetTapped(-1); MTGCardInstance * card = NULL; - GameObserver * g = GameObserver::GetInstance(); MTGAbility * a = g->mLayers->actionLayer()->getAbility(MTGAbility::MTG_BLOCK_RULE); + while ((card = cd.nextmatch(game->inPlay, card))) { g->mLayers->actionLayer()->reactToClick(a, card); @@ -1303,12 +1311,12 @@ int AIPlayerBaka::computeActions() { findingCard = true; CardDescriptor cd; - ManaCost * currentMana = getPotentialMana(); - bool potential = false; - if (currentMana->getConvertedCost()) + ManaCost * icurrentMana = getPotentialMana(); + bool ipotential = false; + if (icurrentMana->getConvertedCost()) { //if theres mana i can use there then potential is true. - potential = true; + ipotential = true; } //look for an instant of ability to interupt with if((castrestrictedspell == false && nospellinstant == false)&& @@ -1317,18 +1325,18 @@ int AIPlayerBaka::computeActions() if (!nextCardToPlay) { - nextCardToPlay = FindCardToPlay(currentMana, "instant"); + nextCardToPlay = FindCardToPlay(icurrentMana, "instant"); } if (!nextCardToPlay) { selectAbility(); } } - if (currentMana != NULL) - delete (currentMana); + if (icurrentMana != NULL) + delete (icurrentMana); if (nextCardToPlay) { - if (potential) + if (ipotential) { tapLandsForMana(nextCardToPlay->getManaCost()); } @@ -1340,7 +1348,7 @@ int AIPlayerBaka::computeActions() } nextCardToPlay = NULL; findingCard = false; - return 0; + return 1; } else if(p == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) { //standard actions @@ -1451,7 +1459,7 @@ int AIPlayerBaka::computeActions() Checked = false; break; default: - selectAbility(); + selectAbility(); break; } }