Files
wagic/projects/mtg/include/TestSuiteAI.h
Xawotihs 9adb9d625d - reworked the testsuite and the rules (storyflow) to use the same game deserialization code, moved that code to the players and zone classes
- removed every references to the gameobserver singleton. This object can now be instantiated several times as it's needed for minmax. To be able to do that, I mostly added a reference to a gameobserver from any targetable object (cards, players, spells) and abilities.
2011-10-01 13:30:30 +00:00

97 lines
1.9 KiB
C++

#ifndef _TESTSUITE_AI_H_
#define _TESTSUITE_AI_H_
#ifdef TESTSUITE
#define MAX_TESTSUITE_ACTIONS 100
#define MAX_TESTUITE_CARDS 100
#include "AIPlayerBaka.h"
class TestSuiteActions
{
public:
int nbitems;
string actions[MAX_TESTSUITE_ACTIONS];
void add(string action);
TestSuiteActions();
void cleanup();
};
class TestSuite;
class TestSuiteAI;
class TestSuiteState
{
public:
int phase;
void parsePlayerState(int playerId, string s);
TestSuiteState();
TestSuiteAI* players[2];
void cleanup(TestSuite*);
};
class TestSuitePregame
{
public:
virtual void performTest() = 0;
};
class TestSuite
{
private:
int currentfile;
int nbfiles;
string files[1024];
TestSuiteState endState;
TestSuiteActions actions;
bool forceAbility;
int load(const char * filename);
void cleanup();
public:
/* but only used by the testsuite classes */
float timerLimit;
int aiMaxCalls;
int currentAction;
int summoningSickness;
TestSuiteState initState;
string getNextAction();
MTGPlayerCards * buildDeck(Player*, int playerId);
Interruptible * getActionByMTGId(GameObserver* observer, int mtgid);
int assertGame(GameObserver*);
public:
int startTime, endTime;
int gameType;
unsigned int seed;
int nbFailed, nbTests, nbAIFailed, nbAITests;
TestSuite(const char * filename);
void initGame(GameObserver* g);
void pregameTests();
int loadNext();
static int Log(const char * text);
};
// TODO This should inherit from AIPlayer instead!
class TestSuiteAI:public AIPlayerBaka
{
private:
MTGCardInstance * getCard(string action);
float timer;
TestSuite * suite;
public:
TestSuiteAI(GameObserver *observer, TestSuite * suite, int playerId);
virtual int Act(float dt);
virtual int displayStack();
bool summoningSickness() {return (suite->summoningSickness == 1); }
};
#endif
#endif