Files
wagic/projects/mtg/include/GameStateDuel.h
Xawotihs 29132073de - Modified DeckManager class to not use a global instance anymore when used within the game engine
- Modified DuelLayers to not use a global MTGPhaseGame instance anymore
- Moved the reset of currentActionCard out of the ActionLayer render function : that fixes the remaing problematic tests in the multithreaded testsuite
- Added a method in ActionLayer converting a card ability into a menu index
- Used this new method in the game observer to log correctly AI ability actions
- Added a DumpAssert method in the game observer, it can be used to dump the game and assert in order to easy crash reproduction
- Cleaned up TargetList properties access
- Added an optimisation in GuiMana to not compute update code if the rendering is not used (multi-threaded mode)
- Added a deadlock detection in the test AI vs AI multithreaded mode
- Fixed minor bugs in test AI vs AI multithreaded mode
- Added a games/second counter in the test AI vs AI rendering
2011-11-23 19:11:48 +00:00

109 lines
2.5 KiB
C++

#ifndef _GAME_STATE_DUEL_H_
#define _GAME_STATE_DUEL_H_
#include "GameState.h"
#include "SimpleMenu.h"
#include "SimplePopup.h"
#include "DeckMenu.h"
#include "MTGDeck.h"
#include "GameObserver.h"
#ifdef AI_CHANGE_TESTING
#include "Threading.h"
#endif //AI_CHANGE_TESTING
#define CHOOSE_OPPONENT 7
#ifdef TESTSUITE
class TestSuite;
#endif
class Credits;
#ifdef NETWORK_SUPPORT
class JNetwork;
#endif
class GameStateDuel: public GameState, public JGuiListener
{
private:
#ifdef TESTSUITE
TestSuite * testSuite;
#endif
Credits * credits;
int mGamePhase;
Player * mCurrentPlayer;
GameObserver * game;
DeckMenu * deckmenu;
DeckMenu * opponentMenu;
SimpleMenu * menu;
SimplePopup * popupScreen; // used for informational screens, modal
static int selectedPlayerDeckId;
static int selectedAIDeckId;
bool premadeDeck;
int OpponentsDeckid;
string musictrack;
bool MusicExist(string FileName);
void ConstructOpponentMenu(); //loads the opponentMenu if it doesn't exist
void initScroller();
void setGamePhase(int newGamePhase);
public:
GameStateDuel(GameApp* parent);
virtual ~GameStateDuel();
#ifdef TESTSUITE
void loadTestSuitePlayers();
#endif
#ifdef AI_CHANGE_TESTING
int startTime;
int totalTestGames;
int testPlayer2Victories;
int totalAIDecks;
static boost::mutex mMutex;
vector<boost::thread> mWorkerThread;
static void ThreadProc(void* inParam);
void handleResults(GameObserver* aGame){
mMutex.lock();
totalTestGames++;
if (aGame->gameOver == aGame->players[0])
testPlayer2Victories++;
mMutex.unlock();
};
#endif
virtual void ButtonPressed(int ControllerId, int ControlId);
virtual void Start();
virtual void End();
virtual void Update(float dt);
virtual void Render();
void initRand(unsigned seed = 0);
void OnScroll(int inXVelocity, int inYVelocity);
enum ENUM_DUEL_STATE_MENU_ITEM
{
MENUITEM_CANCEL = kCancelMenuID,
MENUITEM_NEW_DECK = -10,
MENUITEM_RANDOM_PLAYER = kRandomPlayerMenuID,
MENUITEM_RANDOM_AI = kRandomAIPlayerMenuID,
MENUITEM_MAIN_MENU = -13,
MENUITEM_EVIL_TWIN = kEvilTwinMenuID,
MENUITEM_MULLIGAN = -15,
MENUITEM_UNDO = -16,
#ifdef TESTSUITE
MENUITEM_LOAD = -17,
#endif
#ifdef NETWORK_SUPPORT
MENUITEM_REMOTE_CLIENT = -18,
MENUITEM_REMOTE_SERVER = -19,
#endif
MENUITEM_MORE_INFO = kInfoMenuID
};
};
#endif