- modified gameOver to be protected and defined two new operations to do the same thing (didWin and setLoser)

- removed ACTION_LOGGING_TESTING code
- Fixed AIvsAI games multithreaded games
- Activated undo when testsuite is enable
- Defined an initial player comparison operator
- Fixed multi-threaded modification to subtypes
- Fixed gameTurn cleanup for gameObserver reuse
This commit is contained in:
Xawotihs@gmail.com
2012-03-20 23:10:05 +00:00
parent 865bc7e494
commit cb8af6d6c0
14 changed files with 80 additions and 58 deletions
+20 -6
View File
@@ -41,11 +41,7 @@ class GameObserver{
WResourceManager* mResourceManager;
JGE* mJGE;
DeckManager* mDeckManager;
size_t updateCtr;
#ifdef ACTION_LOGGING_TESTING
GameObserver* oldGame;
#endif //ACTION_LOGGING_TESTING
Player * gameOver;
int untap(MTGCardInstance * card);
bool WaitForExtraPayment(MTGCardInstance* card);
@@ -83,7 +79,6 @@ class GameObserver{
TargetChooser * targetChooser;
DuelLayers * mLayers;
ReplacementEffects *replacementEffects;
Player * gameOver;
vector<Player *> players; //created outside
time_t startedAt;
Rules * mRules;
@@ -165,6 +160,25 @@ class GameObserver{
DeckManager* getDeckManager(){ return mDeckManager; };
void dumpAssert(bool val);
void resetStartupGame();
void setLoser(Player* aPlayer) {
gameOver = aPlayer;
};
bool didWin(Player* aPlayer = 0) const {
if(!gameOver) {
// nobody won
return false;
} else if(!aPlayer) {
// somebody won and we don't care who
return true;
} else if(gameOver == aPlayer) {
// aPlayer lost
return false;
} else {
// aPlayer won
return true;
}
};
};
#endif
+1 -1
View File
@@ -67,7 +67,7 @@ public:
void handleResults(GameObserver* aGame){
mMutex.lock();
totalTestGames++;
if (aGame->gameOver == aGame->players[0])
if (aGame->didWin(aGame->players[1]))
testPlayer2Victories++;
mMutex.unlock();
};
+2 -1
View File
@@ -164,7 +164,8 @@ public:
static void sortSubtypeList()
{
return instance->subtypesList.sortSubTypes();
boost::mutex::scoped_lock lock(instance->mMutex);
instance->subtypesList.sortSubTypes();
}
static int findSubtypeId(string value){
+2
View File
@@ -102,6 +102,8 @@ public:
std::string GetCurrentDeckStatsFile();
virtual bool parseLine(const string& s);
friend ostream& operator<<(ostream&, const Player&);
bool operator<(Player& aPlayer);
bool isDead();
};
class HumanPlayer: public Player