- 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
This commit is contained in:
Xawotihs
2011-11-23 19:11:48 +00:00
parent dca6d3ad38
commit 29132073de
20 changed files with 153 additions and 73 deletions
+1
View File
@@ -37,6 +37,7 @@ public:
int receiveEventPlus(WEvent * event);
int reactToTargetClick(Targetable * card);
int isReactingToClick(MTGCardInstance * card);
bool getMenuIdFromCardAbility(MTGCardInstance *card, MTGAbility *ability, int& menuId);
int reactToClick(MTGCardInstance * card);
int reactToClick(ActionElement * ability, MTGCardInstance * card);
int reactToTargetClick(ActionElement * ability, Targetable * card);
+8 -10
View File
@@ -8,21 +8,19 @@ using namespace std;
class DeckManager
{
private:
static bool instanceFlag;
vector<DeckMetaData*> playerDeckOrderList;
vector<DeckMetaData*> aiDeckOrderList;
map<string, StatsWrapper*> playerDeckStatsMap;
map<string, StatsWrapper*> aiDeckStatsMap;
static DeckManager *mInstance;
public:
DeckManager()
{
//private constructor
}
public:
vector<DeckMetaData*> playerDeckOrderList;
vector<DeckMetaData*> aiDeckOrderList;
map<string, StatsWrapper*> playerDeckStatsMap;
map<string, StatsWrapper*> aiDeckStatsMap;
void updateMetaDataList(vector<DeckMetaData*>* refList, bool isAI);
vector<DeckMetaData*> * getPlayerDeckOrderList();
vector<DeckMetaData*> * getAIDeckOrderList();
@@ -40,7 +38,7 @@ public:
//convenience method to get the difficulty rating between two decks. This should be refined a little more
//since the eventual move of all deck meta data should be managed by this class
static int getDifficultyRating(Player *statsPlayer, Player *player);
int getDifficultyRating(Player *statsPlayer, Player *player);
~DeckManager();
+3
View File
@@ -14,6 +14,7 @@ class GuiCombat;
class GuiAvatars;
class CardSelectorBase;
struct Pos;
class MTGGamePhase;
class DuelLayers
{
@@ -27,6 +28,7 @@ protected:
GuiHandSelf *hand;
GuiAvatars * avatars;
GameObserver* observer;
MTGGamePhase* phaseHandler;
public:
DuelLayers();
@@ -36,6 +38,7 @@ public:
ActionStack * stackLayer();
GuiCombat * combatLayer();
GuiAvatars * GetAvatars();
MTGGamePhase* getPhaseHandler() {return phaseHandler;};
void init(GameObserver* go);
virtual void Update(float dt, Player * player);
void CheckUserInput(int isAI);
+5
View File
@@ -23,6 +23,7 @@ class TargetChooser;
class Rules;
class TestSuiteGame;
class Trash;
class DeckManager;
using namespace std;
class GameObserver{
@@ -37,6 +38,8 @@ class GameObserver{
RandomGenerator randomGenerator;
WResourceManager* mResourceManager;
JGE* mJGE;
DeckManager* mDeckManager;
size_t updateCtr;
#ifdef ACTION_LOGGING_TESTING
GameObserver* oldGame;
@@ -139,6 +142,8 @@ class GameObserver{
CardSelectorBase* getCardSelector() { return mLayers->mCardSelector;};
bool operator==(const GameObserver& aGame);
JGE* getInput(){return mJGE;};
DeckManager* getDeckManager(){ return mDeckManager; };
void dumpAssert(bool val);
};
+1
View File
@@ -57,6 +57,7 @@ public:
#endif
#ifdef AI_CHANGE_TESTING
int startTime;
int totalTestGames;
int testPlayer2Victories;
int totalAIDecks;
-2
View File
@@ -13,12 +13,10 @@ protected:
float animation;
int currentState;
WFont * mFont;
static MTGGamePhase* instance;
GameObserver* observer;
public:
MTGGamePhase(GameObserver* g, int id);
static MTGGamePhase* GetInstance() { return instance; };
virtual void Update(float dt);
bool CheckUserInput(JButton key);
virtual MTGGamePhase * clone() const;
+3 -2
View File
@@ -14,15 +14,16 @@ using std::vector;
class TargetsList
{
private:
protected:
size_t iterateTarget(Targetable * previous);
vector<Targetable*> targets;
public:
TargetsList();
TargetsList(Targetable * _targets[], int nbtargets);
vector<Targetable*> targets;
int alreadyHasTarget(Targetable * target);
int removeTarget(Targetable * _card);
int toggleTarget(Targetable * _card);
size_t getNbTargets() {return targets.size();};
virtual int addTarget(Targetable * _target);
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
Player * getNextPlayerTarget(Player * previous = 0);