From 5b365e53f0a03b6d5113fc3b4b26f2ac2150dc19 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Mon, 14 Feb 2011 13:29:27 +0000 Subject: [PATCH] Erwan - submit a fix for TestSuiteAI, I don't understand why it wasn't submitted with my other changes yesterday. This fixes a bug in the test suite (One storm test would fail without this) - minor refactor to AI code --- projects/mtg/src/AIPlayer.cpp | 17 +++++++---------- projects/mtg/src/TestSuiteAI.cpp | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index e1e6aca63..1e94adc13 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -994,9 +994,9 @@ int AIPlayer::chooseBlockers() { GameObserver * g = GameObserver::GetInstance(); if (g->currentActionPlayer != this) - return 0; + return 0; if(g->isInterrupting == this) - return 0; + 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. @@ -1337,13 +1337,15 @@ int AIPlayerBaka::computeActions() if (game->playRestrictions->canPutIntoZone(nextCardToPlay, game->stack) == PlayRestriction::CANT_PLAY) nextCardToPlay = NULL; } + SAFE_DELETE (icurrentMana); + if (!nextCardToPlay) { selectAbility(); } - if (icurrentMana != NULL) - delete (icurrentMana); + + if (nextCardToPlay) { if (ipotential) @@ -1389,13 +1391,8 @@ int AIPlayerBaka::computeActions() count++; } - if (!nextCardToPlay) - { - selectAbility(); - } + SAFE_DELETE(currentMana); - if (currentMana != NULL) - delete (currentMana); if (nextCardToPlay) { if (potential) diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index 367c15050..7ed5f4ab1 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -423,6 +423,7 @@ void TestSuite::initGame() } zone->cardsSeenThisTurn.clear(); //don't consider those cards as having moved in this area during this turn } + p->game->stack->cardsSeenThisTurn.clear(); //don't consider those cards as having moved in this area during this turn } DebugTrace("TESTUITE Init Game Done !"); }