- Modified gameObserver and related classes to be able to work with a precise JGE instance given at construction and not the static global one. That allows to run gameObserver without JGE instance (for example in a worker thread).
- Added an "ACTION_LOGGING_TESTING" mode in the gameObserver. When this is defined, the game reloads itself in every update. I want to use that to track undo problems. Be aware that it kills performances and crashes with the testsuite if you want to activate it. - Various cleanup/refactor of the game observer. - Added a gameObserver == operator to compare two games - Added player mode to the player serialization - Added a multi-threaded mode to AI_CHANGE_TESTING. For the moment it's only useable with Qt. If you want to use it without, just defined a thread_count higher than 1. - Refactored random generator class to use list intead of queue - Defined a specific type for interrupt decision instead of int
This commit is contained in:
@@ -190,9 +190,18 @@ public:
|
||||
|
||||
class ActionStack :public GuiLayer
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
NOT_DECIDED = 0,
|
||||
INTERRUPT = -1,
|
||||
DONT_INTERRUPT = 1,
|
||||
DONT_INTERRUPT_ALL = 2
|
||||
} InterruptDecision;
|
||||
|
||||
protected:
|
||||
JQuadPtr pspIcons[8];
|
||||
int interruptDecision[2];
|
||||
InterruptDecision interruptDecision[2];
|
||||
float timer;
|
||||
int currentState;
|
||||
int mode;
|
||||
@@ -201,13 +210,6 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
NOT_DECIDED = 0,
|
||||
INTERRUPT = -1,
|
||||
DONT_INTERRUPT = 1,
|
||||
DONT_INTERRUPT_ALL = 2,
|
||||
};
|
||||
Player * lastActionController;
|
||||
int setIsInterrupting(Player * player, bool log = true);
|
||||
int count( int type = 0 , int state = 0 , int display = -1);
|
||||
@@ -218,7 +220,7 @@ public:
|
||||
int getNextIndex(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
|
||||
void Fizzle(Interruptible * action);
|
||||
Interruptible * getAt(int id);
|
||||
void cancelInterruptOffer(int cancelMode = 1, bool log = true);
|
||||
void cancelInterruptOffer(InterruptDecision cancelMode = DONT_INTERRUPT, bool log = true);
|
||||
void endOfInterruption(bool log = true);
|
||||
Interruptible * getLatest(int state);
|
||||
Player * askIfWishesToInterrupt;
|
||||
@@ -245,6 +247,7 @@ public:
|
||||
#endif
|
||||
void setCurrentTutorial(ATutorialMessage* message) {currentTutorial = message;};
|
||||
ATutorialMessage* getCurrentTutorial() {return currentTutorial;};
|
||||
bool isCalm() {return interruptDecision[0] == NOT_DECIDED && interruptDecision[1] == NOT_DECIDED;};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,10 +34,16 @@ class GameObserver{
|
||||
// used when we're loading to know what to load
|
||||
list<string> loadingList;
|
||||
list<string>::iterator loadingite;
|
||||
RandomGenerator randomGenerator;
|
||||
WResourceManager* mResourceManager;
|
||||
JGE* mJGE;
|
||||
size_t updateCtr;
|
||||
#ifdef ACTION_LOGGING_TESTING
|
||||
GameObserver* oldGame;
|
||||
#endif //ACTION_LOGGING_TESTING
|
||||
|
||||
int untap(MTGCardInstance * card);
|
||||
bool WaitForExtraPayment(MTGCardInstance* card);
|
||||
void initialize();
|
||||
void cleanup();
|
||||
string startupGameSerialized;
|
||||
bool parseLine(const string& s);
|
||||
@@ -47,8 +53,7 @@ class GameObserver{
|
||||
bool mLoading;
|
||||
void nextGamePhase();
|
||||
void shuffleLibrary(Player* p);
|
||||
RandomGenerator randomGenerator;
|
||||
WResourceManager* mResourceManager;
|
||||
void createPlayer(const string& playerMode);
|
||||
|
||||
public:
|
||||
int currentPlayerId;
|
||||
@@ -97,7 +102,7 @@ class GameObserver{
|
||||
Player * isInterrupting;
|
||||
Player * opponent();
|
||||
Player * currentlyActing();
|
||||
GameObserver(WResourceManager* resourceManager = NULL);
|
||||
GameObserver(WResourceManager* output = 0, JGE* input = 0);
|
||||
~GameObserver();
|
||||
void gameStateBasedEffects();
|
||||
void enchantmentStatus();
|
||||
@@ -132,6 +137,9 @@ class GameObserver{
|
||||
RandomGenerator* getRandomGenerator() { return &randomGenerator; };
|
||||
WResourceManager* getResourceManager() { if(this) return mResourceManager;else return 0;};
|
||||
CardSelectorBase* getCardSelector() { return mLayers->mCardSelector;};
|
||||
bool operator==(const GameObserver& aGame);
|
||||
JGE* getInput(){return mJGE;};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#include "DeckMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "GameObserver.h"
|
||||
#ifdef AI_CHANGE_TESTING
|
||||
#include "Threading.h"
|
||||
#endif //AI_CHANGE_TESTING
|
||||
|
||||
|
||||
#define CHOOSE_OPPONENT 7
|
||||
|
||||
@@ -56,6 +60,16 @@ public:
|
||||
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);
|
||||
|
||||
@@ -11,7 +11,7 @@ class IconButtonsController: public JGuiController, public JGuiListener
|
||||
public:
|
||||
float mX;
|
||||
float mY;
|
||||
IconButtonsController(float x, float y);
|
||||
IconButtonsController(JGE* jge, float x, float y);
|
||||
void SetColor(PIXEL_TYPE color);
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ protected:
|
||||
bool premade;
|
||||
|
||||
public:
|
||||
enum ENUM_PLAY_MODE
|
||||
enum Mode
|
||||
{
|
||||
MODE_TEST_SUITE,
|
||||
MODE_HUMAN,
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
};
|
||||
|
||||
string mAvatarName;
|
||||
int playMode;
|
||||
Mode playMode;
|
||||
bool nomaxhandsize;
|
||||
MTGPlayerCards * game;
|
||||
MTGDeck * mDeck;
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
public:
|
||||
bool autoTranslate;
|
||||
bool isMultipleChoice;
|
||||
SimpleMenu(int id, JGuiListener* listener, int fontId, float x, float y, const char * _title = "", int _maxItems = 7, bool centerHorizontal = true, bool centerVertical = true);
|
||||
SimpleMenu(JGE*, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title = "", int _maxItems = 7, bool centerHorizontal = true, bool centerVertical = true);
|
||||
virtual ~SimpleMenu();
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
|
||||
@@ -69,8 +69,8 @@ unsigned long hash_djb2(const char *str);
|
||||
class RandomGenerator
|
||||
{
|
||||
protected:
|
||||
queue<int> loadedRandomValues;
|
||||
queue<int> usedRandomValues;
|
||||
list<int> loadedRandomValues;
|
||||
list<int> usedRandomValues;
|
||||
bool log;
|
||||
public:
|
||||
RandomGenerator(bool doLog = false) : log(doLog) {};
|
||||
|
||||
Reference in New Issue
Block a user