- adding tests for issue 489 and issue 491
- check for null pointers in Credits.cpp
- Test suite can now select tokens by their name
- Fixed Dragon Broodmothere's token name
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-10-17 10:21:08 +00:00
parent d9f5b1586c
commit 8fdb64e9ce
7 changed files with 97 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
#include "../include/TestSuiteAI.h"
#include "../include/config.h"
#include "../include/DebugRoutines.h"
#include "../include/MTGAbility.h"
#include "../include/MTGRules.h"
#include "../include/ActionLayer.h"
@@ -23,6 +24,31 @@ TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayerBaka(NULL, "t
}
MTGCardInstance * TestSuiteAI::getCard(string action){
int mtgid = Rules::getMTGId(action);
if (mtgid) return Rules::getCardByMTGId(mtgid);
//This mostly handles tokens
GameObserver * g = GameObserver::GetInstance();
std::transform(action.begin(), action.end(), action.begin(),::tolower );
for (int i = 0; i < 2; i++){
Player * p = g->players[i];
MTGGameZone * zones[] = {p->game->library,p->game->hand, p->game->inPlay, p->game->graveyard};
for (int j = 0; j < 4; j++){
MTGGameZone * zone = zones[j];
for (int k = 0; k < zone->nb_cards; k++){
MTGCardInstance * card = zone->cards[k];
if (!card) return NULL;
string name = card->getLCName();
if (name.compare(action) == 0) return card;
}
}
}
DebugTrace("TESTUISTEAI: Can't find card:" << action.c_str());
return NULL;
}
Interruptible * TestSuite::getActionByMTGId(int mtgid){
ActionStack * as= GameObserver::GetInstance()->mLayers->stackLayer();
Interruptible * action = NULL;
@@ -125,29 +151,31 @@ int TestSuiteAI::Act(float dt){
g->cardClick(NULL, p);
}else{
int mtgid = Rules::getMTGId(action);
Interruptible * toInterrupt = NULL;
if (mtgid){
char buffe[512];
sprintf(buffe, "TESTSUITE CARD ID : %i\n", mtgid);
OutputDebugString(buffe);
Interruptible * toInterrupt = suite->getActionByMTGId(mtgid);
if (toInterrupt)
g->stackObjectClicked(toInterrupt);
else{
MTGCardInstance * card = Rules::getCardByMTGId(mtgid);
if (card) {
OutputDebugString("TESTSUITE Clicking ON: ");
OutputDebugString(card->name.c_str());
OutputDebugString("\n");
card->currentZone->needShuffle = true; //mimic library shuffle
g->cardClick(card,card);
g->forceShuffleLibraries(); //mimic library shuffle
}
}
}else{
return 0;
toInterrupt = suite->getActionByMTGId(mtgid);
}
if (toInterrupt) {
g->stackObjectClicked(toInterrupt);
return 1;
}
MTGCardInstance * card = getCard(action);
if (card) {
OutputDebugString("TESTSUITE Clicking ON: ");
OutputDebugString(card->name.c_str());
OutputDebugString("\n");
card->currentZone->needShuffle = true; //mimic library shuffle
g->cardClick(card,card);
g->forceShuffleLibraries(); //mimic library shuffle
return 1;
}
}
return 1;
return 0;
}