- 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
|
class ActionStack :public GuiLayer
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
NOT_DECIDED = 0,
|
||||||
|
INTERRUPT = -1,
|
||||||
|
DONT_INTERRUPT = 1,
|
||||||
|
DONT_INTERRUPT_ALL = 2
|
||||||
|
} InterruptDecision;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
JQuadPtr pspIcons[8];
|
JQuadPtr pspIcons[8];
|
||||||
int interruptDecision[2];
|
InterruptDecision interruptDecision[2];
|
||||||
float timer;
|
float timer;
|
||||||
int currentState;
|
int currentState;
|
||||||
int mode;
|
int mode;
|
||||||
@@ -201,13 +210,6 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
NOT_DECIDED = 0,
|
|
||||||
INTERRUPT = -1,
|
|
||||||
DONT_INTERRUPT = 1,
|
|
||||||
DONT_INTERRUPT_ALL = 2,
|
|
||||||
};
|
|
||||||
Player * lastActionController;
|
Player * lastActionController;
|
||||||
int setIsInterrupting(Player * player, bool log = true);
|
int setIsInterrupting(Player * player, bool log = true);
|
||||||
int count( int type = 0 , int state = 0 , int display = -1);
|
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);
|
int getNextIndex(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
|
||||||
void Fizzle(Interruptible * action);
|
void Fizzle(Interruptible * action);
|
||||||
Interruptible * getAt(int id);
|
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);
|
void endOfInterruption(bool log = true);
|
||||||
Interruptible * getLatest(int state);
|
Interruptible * getLatest(int state);
|
||||||
Player * askIfWishesToInterrupt;
|
Player * askIfWishesToInterrupt;
|
||||||
@@ -245,6 +247,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
void setCurrentTutorial(ATutorialMessage* message) {currentTutorial = message;};
|
void setCurrentTutorial(ATutorialMessage* message) {currentTutorial = message;};
|
||||||
ATutorialMessage* getCurrentTutorial() {return currentTutorial;};
|
ATutorialMessage* getCurrentTutorial() {return currentTutorial;};
|
||||||
|
bool isCalm() {return interruptDecision[0] == NOT_DECIDED && interruptDecision[1] == NOT_DECIDED;};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -34,10 +34,16 @@ class GameObserver{
|
|||||||
// used when we're loading to know what to load
|
// used when we're loading to know what to load
|
||||||
list<string> loadingList;
|
list<string> loadingList;
|
||||||
list<string>::iterator loadingite;
|
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);
|
int untap(MTGCardInstance * card);
|
||||||
bool WaitForExtraPayment(MTGCardInstance* card);
|
bool WaitForExtraPayment(MTGCardInstance* card);
|
||||||
void initialize();
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
string startupGameSerialized;
|
string startupGameSerialized;
|
||||||
bool parseLine(const string& s);
|
bool parseLine(const string& s);
|
||||||
@@ -47,8 +53,7 @@ class GameObserver{
|
|||||||
bool mLoading;
|
bool mLoading;
|
||||||
void nextGamePhase();
|
void nextGamePhase();
|
||||||
void shuffleLibrary(Player* p);
|
void shuffleLibrary(Player* p);
|
||||||
RandomGenerator randomGenerator;
|
void createPlayer(const string& playerMode);
|
||||||
WResourceManager* mResourceManager;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int currentPlayerId;
|
int currentPlayerId;
|
||||||
@@ -97,7 +102,7 @@ class GameObserver{
|
|||||||
Player * isInterrupting;
|
Player * isInterrupting;
|
||||||
Player * opponent();
|
Player * opponent();
|
||||||
Player * currentlyActing();
|
Player * currentlyActing();
|
||||||
GameObserver(WResourceManager* resourceManager = NULL);
|
GameObserver(WResourceManager* output = 0, JGE* input = 0);
|
||||||
~GameObserver();
|
~GameObserver();
|
||||||
void gameStateBasedEffects();
|
void gameStateBasedEffects();
|
||||||
void enchantmentStatus();
|
void enchantmentStatus();
|
||||||
@@ -132,6 +137,9 @@ class GameObserver{
|
|||||||
RandomGenerator* getRandomGenerator() { return &randomGenerator; };
|
RandomGenerator* getRandomGenerator() { return &randomGenerator; };
|
||||||
WResourceManager* getResourceManager() { if(this) return mResourceManager;else return 0;};
|
WResourceManager* getResourceManager() { if(this) return mResourceManager;else return 0;};
|
||||||
CardSelectorBase* getCardSelector() { return mLayers->mCardSelector;};
|
CardSelectorBase* getCardSelector() { return mLayers->mCardSelector;};
|
||||||
|
bool operator==(const GameObserver& aGame);
|
||||||
|
JGE* getInput(){return mJGE;};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
#include "DeckMenu.h"
|
#include "DeckMenu.h"
|
||||||
#include "MTGDeck.h"
|
#include "MTGDeck.h"
|
||||||
#include "GameObserver.h"
|
#include "GameObserver.h"
|
||||||
|
#ifdef AI_CHANGE_TESTING
|
||||||
|
#include "Threading.h"
|
||||||
|
#endif //AI_CHANGE_TESTING
|
||||||
|
|
||||||
|
|
||||||
#define CHOOSE_OPPONENT 7
|
#define CHOOSE_OPPONENT 7
|
||||||
|
|
||||||
@@ -56,6 +60,16 @@ public:
|
|||||||
int totalTestGames;
|
int totalTestGames;
|
||||||
int testPlayer2Victories;
|
int testPlayer2Victories;
|
||||||
int totalAIDecks;
|
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
|
#endif
|
||||||
|
|
||||||
virtual void ButtonPressed(int ControllerId, int ControlId);
|
virtual void ButtonPressed(int ControllerId, int ControlId);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class IconButtonsController: public JGuiController, public JGuiListener
|
|||||||
public:
|
public:
|
||||||
float mX;
|
float mX;
|
||||||
float mY;
|
float mY;
|
||||||
IconButtonsController(float x, float y);
|
IconButtonsController(JGE* jge, float x, float y);
|
||||||
void SetColor(PIXEL_TYPE color);
|
void SetColor(PIXEL_TYPE color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ protected:
|
|||||||
bool premade;
|
bool premade;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ENUM_PLAY_MODE
|
enum Mode
|
||||||
{
|
{
|
||||||
MODE_TEST_SUITE,
|
MODE_TEST_SUITE,
|
||||||
MODE_HUMAN,
|
MODE_HUMAN,
|
||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
string mAvatarName;
|
string mAvatarName;
|
||||||
int playMode;
|
Mode playMode;
|
||||||
bool nomaxhandsize;
|
bool nomaxhandsize;
|
||||||
MTGPlayerCards * game;
|
MTGPlayerCards * game;
|
||||||
MTGDeck * mDeck;
|
MTGDeck * mDeck;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
bool autoTranslate;
|
bool autoTranslate;
|
||||||
bool isMultipleChoice;
|
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();
|
virtual ~SimpleMenu();
|
||||||
void Render();
|
void Render();
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ unsigned long hash_djb2(const char *str);
|
|||||||
class RandomGenerator
|
class RandomGenerator
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
queue<int> loadedRandomValues;
|
list<int> loadedRandomValues;
|
||||||
queue<int> usedRandomValues;
|
list<int> usedRandomValues;
|
||||||
bool log;
|
bool log;
|
||||||
public:
|
public:
|
||||||
RandomGenerator(bool doLog = false) : log(doLog) {};
|
RandomGenerator(bool doLog = false) : log(doLog) {};
|
||||||
|
|||||||
@@ -29,12 +29,14 @@ AIAction::AIAction(AIPlayer * owner, MTGCardInstance * c, MTGCardInstance * t)
|
|||||||
if (owner->getObserver()->getCardSelector()->GetDrawMode() != DrawMode::kText)
|
if (owner->getObserver()->getCardSelector()->GetDrawMode() != DrawMode::kText)
|
||||||
{
|
{
|
||||||
//DebugTrace("Prefetching AI card going into play: " << c->getImageName());
|
//DebugTrace("Prefetching AI card going into play: " << c->getImageName());
|
||||||
owner->getObserver()->getResourceManager()->RetrieveCard(c, RETRIEVE_THUMB);
|
if(owner->getObserver()->getResourceManager())
|
||||||
|
owner->getObserver()->getResourceManager()->RetrieveCard(c, RETRIEVE_THUMB);
|
||||||
|
|
||||||
// also cache the large image if we're using kNormal mode
|
// also cache the large image if we're using kNormal mode
|
||||||
if (owner->getObserver()->getCardSelector()->GetDrawMode() == DrawMode::kNormal)
|
if (owner->getObserver()->getCardSelector()->GetDrawMode() == DrawMode::kNormal)
|
||||||
{
|
{
|
||||||
owner->getObserver()->getResourceManager()->RetrieveCard(c);
|
if(owner->getObserver()->getResourceManager())
|
||||||
|
owner->getObserver()->getResourceManager()->RetrieveCard(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1223,7 +1223,7 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank
|
|||||||
if(!realTargets.size() || (int(realTargets.size()) < a->getActionTc()->maxtargets && a->getActionTc()->targetMin))
|
if(!realTargets.size() || (int(realTargets.size()) < a->getActionTc()->maxtargets && a->getActionTc()->targetMin))
|
||||||
return 0;
|
return 0;
|
||||||
OrderedAIAction aiAction(this, a, c,realTargets);
|
OrderedAIAction aiAction(this, a, c,realTargets);
|
||||||
aiAction.target = (MTGCardInstance*)realTargets[0];
|
aiAction.target = dynamic_cast<MTGCardInstance*>(realTargets[0]);
|
||||||
ranking[aiAction] = 1;
|
ranking[aiAction] = 1;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1770,6 +1770,7 @@ int AIPlayerBaka::computeActions()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef AI_CHANGE_TESTING
|
||||||
static bool findingCard = false;
|
static bool findingCard = false;
|
||||||
//this guard is put in place to prevent Ai from
|
//this guard is put in place to prevent Ai from
|
||||||
//ever running computeActions() function WHILE its already doing so.
|
//ever running computeActions() function WHILE its already doing so.
|
||||||
@@ -1779,6 +1780,8 @@ int AIPlayerBaka::computeActions()
|
|||||||
{//is already looking kick me out of this function!
|
{//is already looking kick me out of this function!
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif //AI_CHANGE_TESTING
|
||||||
|
|
||||||
Interruptible * action = observer->mLayers->stackLayer()->getAt(-1);
|
Interruptible * action = observer->mLayers->stackLayer()->getAt(-1);
|
||||||
Spell * spell = dynamic_cast<Spell *>(action);
|
Spell * spell = dynamic_cast<Spell *>(action);
|
||||||
Player * lastStackActionController = spell ? spell->source->controller() : NULL;
|
Player * lastStackActionController = spell ? spell->source->controller() : NULL;
|
||||||
@@ -1791,7 +1794,9 @@ int AIPlayerBaka::computeActions()
|
|||||||
bool ipotential = false;
|
bool ipotential = false;
|
||||||
if(p->game->hand->hasType("instant") || p->game->hand->hasAbility(Constants::FLASH))
|
if(p->game->hand->hasType("instant") || p->game->hand->hasAbility(Constants::FLASH))
|
||||||
{
|
{
|
||||||
|
#ifndef AI_CHANGE_TESTING
|
||||||
findingCard = true;
|
findingCard = true;
|
||||||
|
#endif //AI_CHANGE_TESTING
|
||||||
ManaCost * icurrentMana = getPotentialMana();
|
ManaCost * icurrentMana = getPotentialMana();
|
||||||
icurrentMana->add(this->getManaPool());
|
icurrentMana->add(this->getManaPool());
|
||||||
if (icurrentMana->getConvertedCost())
|
if (icurrentMana->getConvertedCost())
|
||||||
@@ -1822,12 +1827,16 @@ int AIPlayerBaka::computeActions()
|
|||||||
gotPayments.clear();
|
gotPayments.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef AI_CHANGE_TESTING
|
||||||
findingCard = false;
|
findingCard = false;
|
||||||
|
#endif //AI_CHANGE_TESTING
|
||||||
nextCardToPlay = NULL;
|
nextCardToPlay = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
nextCardToPlay = NULL;
|
nextCardToPlay = NULL;
|
||||||
|
#ifndef AI_CHANGE_TESTING
|
||||||
findingCard = false;
|
findingCard = false;
|
||||||
|
#endif //AI_CHANGE_TESTING
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if(observer->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
|
else if(observer->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ void ActionLayer::setMenuObject(Targetable * object, bool must)
|
|||||||
|
|
||||||
SAFE_DELETE(abilitiesMenu);
|
SAFE_DELETE(abilitiesMenu);
|
||||||
|
|
||||||
abilitiesMenu = NEW SimpleMenu(10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str());
|
abilitiesMenu = NEW SimpleMenu(observer->getInput(), 10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str());
|
||||||
currentActionCard = NULL;
|
currentActionCard = NULL;
|
||||||
for (size_t i = 0; i < mObjects.size(); i++)
|
for (size_t i = 0; i < mObjects.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -375,7 +375,7 @@ void ActionLayer::setCustomMenuObject(Targetable * object, bool must,vector<MTGA
|
|||||||
}
|
}
|
||||||
menuObject = object;
|
menuObject = object;
|
||||||
SAFE_DELETE(abilitiesMenu);
|
SAFE_DELETE(abilitiesMenu);
|
||||||
abilitiesMenu = NEW SimpleMenu(10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str());
|
abilitiesMenu = NEW SimpleMenu(observer->getInput(), 10, this, Fonts::MAIN_FONT, 100, 100, object->getDisplayName().c_str());
|
||||||
currentActionCard = NULL;
|
currentActionCard = NULL;
|
||||||
abilitiesMenu->isMultipleChoice = false;
|
abilitiesMenu->isMultipleChoice = false;
|
||||||
if(abilities.size())
|
if(abilities.size())
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ int ActionStack::AddNextGamePhase()
|
|||||||
NextGamePhase * next = NEW NextGamePhase(observer, mObjects.size());
|
NextGamePhase * next = NEW NextGamePhase(observer, mObjects.size());
|
||||||
addAction(next);
|
addAction(next);
|
||||||
int playerId = (observer->currentActionPlayer == observer->players[1]) ? 1 : 0;
|
int playerId = (observer->currentActionPlayer == observer->players[1]) ? 1 : 0;
|
||||||
interruptDecision[playerId] = 1;
|
interruptDecision[playerId] = DONT_INTERRUPT;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,7 +573,7 @@ int ActionStack::setIsInterrupting(Player * player, bool log)
|
|||||||
|
|
||||||
if (!gModRules.game.canInterrupt())
|
if (!gModRules.game.canInterrupt())
|
||||||
{
|
{
|
||||||
cancelInterruptOffer(1, log);
|
cancelInterruptOffer(DONT_INTERRUPT, log);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +586,7 @@ int ActionStack::setIsInterrupting(Player * player, bool log)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int playerId = (player == observer->players[1]) ? 1 : 0;
|
int playerId = (player == observer->players[1]) ? 1 : 0;
|
||||||
interruptDecision[playerId] = -1;
|
interruptDecision[playerId] = INTERRUPT;
|
||||||
observer->isInterrupting = player;
|
observer->isInterrupting = player;
|
||||||
if(log)
|
if(log)
|
||||||
observer->logAction(player, "yes");
|
observer->logAction(player, "yes");
|
||||||
@@ -597,7 +597,7 @@ int ActionStack::addAction(Interruptible * action)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
interruptDecision[i] = 0;
|
interruptDecision[i] = NOT_DECIDED;
|
||||||
}
|
}
|
||||||
Add(action);
|
Add(action);
|
||||||
lastActionController = observer->currentlyActing();
|
lastActionController = observer->currentlyActing();
|
||||||
@@ -634,7 +634,7 @@ ActionStack::ActionStack(GameObserver* game)
|
|||||||
: GuiLayer(game), currentTutorial(0)
|
: GuiLayer(game), currentTutorial(0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
interruptDecision[i] = 0;
|
interruptDecision[i] = NOT_DECIDED;
|
||||||
askIfWishesToInterrupt = NULL;
|
askIfWishesToInterrupt = NULL;
|
||||||
timer = -1;
|
timer = -1;
|
||||||
currentState = -1;
|
currentState = -1;
|
||||||
@@ -698,15 +698,15 @@ int ActionStack::resolve()
|
|||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
if (interruptDecision[i] != 2)
|
if (interruptDecision[i] != 2)
|
||||||
interruptDecision[i] = 0;
|
interruptDecision[i] = NOT_DECIDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
if (interruptDecision[i] != 2)
|
if (interruptDecision[i] != DONT_INTERRUPT_ALL)
|
||||||
interruptDecision[i] = 0;
|
interruptDecision[i] = NOT_DECIDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastActionController = NULL;
|
lastActionController = NULL;
|
||||||
@@ -955,7 +955,7 @@ void ActionStack::Update(float dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionStack::cancelInterruptOffer(int cancelMode, bool log)
|
void ActionStack::cancelInterruptOffer(InterruptDecision cancelMode, bool log)
|
||||||
{
|
{
|
||||||
int playerId = (observer->isInterrupting == observer->players[1]) ? 1 : 0;
|
int playerId = (observer->isInterrupting == observer->players[1]) ? 1 : 0;
|
||||||
interruptDecision[playerId] = cancelMode;
|
interruptDecision[playerId] = cancelMode;
|
||||||
@@ -969,7 +969,7 @@ void ActionStack::cancelInterruptOffer(int cancelMode, bool log)
|
|||||||
void ActionStack::endOfInterruption(bool log)
|
void ActionStack::endOfInterruption(bool log)
|
||||||
{
|
{
|
||||||
int playerId = (observer->isInterrupting == observer->players[1]) ? 1 : 0;
|
int playerId = (observer->isInterrupting == observer->players[1]) ? 1 : 0;
|
||||||
interruptDecision[playerId] = 0;
|
interruptDecision[playerId] = NOT_DECIDED;
|
||||||
observer->isInterrupting = NULL;
|
observer->isInterrupting = NULL;
|
||||||
if(log)
|
if(log)
|
||||||
observer->logAction(playerId, "endinterruption");
|
observer->logAction(playerId, "endinterruption");
|
||||||
@@ -994,7 +994,7 @@ bool ActionStack::CheckUserInput(JButton key)
|
|||||||
}
|
}
|
||||||
else if ((JGE_BTN_PRI == key))
|
else if ((JGE_BTN_PRI == key))
|
||||||
{
|
{
|
||||||
cancelInterruptOffer(2);
|
cancelInterruptOffer(DONT_INTERRUPT_ALL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2359,7 +2359,7 @@ int MenuAbility::reactToChoiceClick(Targetable * object,int choice,int control)
|
|||||||
mClone->resolve();
|
mClone->resolve();
|
||||||
SAFE_DELETE(mClone);
|
SAFE_DELETE(mClone);
|
||||||
if (source->controller() == game->isInterrupting)
|
if (source->controller() == game->isInterrupting)
|
||||||
game->mLayers->stackLayer()->cancelInterruptOffer(1, false);
|
game->mLayers->stackLayer()->cancelInterruptOffer(ActionStack::DONT_INTERRUPT, false);
|
||||||
this->forceDestroy = 1;
|
this->forceDestroy = 1;
|
||||||
removeMenu = true;
|
removeMenu = true;
|
||||||
return reactToTargetClick(object);
|
return reactToTargetClick(object);
|
||||||
@@ -3913,7 +3913,7 @@ AAConnect * AAConnect::clone() const
|
|||||||
//Tutorial Messaging
|
//Tutorial Messaging
|
||||||
|
|
||||||
ATutorialMessage::ATutorialMessage(GameObserver* observer, MTGCardInstance * source, string message, int limit)
|
ATutorialMessage::ATutorialMessage(GameObserver* observer, MTGCardInstance * source, string message, int limit)
|
||||||
: MTGAbility(observer, 0, source), IconButtonsController(0, 0), mLimit(limit)
|
: MTGAbility(observer, 0, source), IconButtonsController(observer->getInput(), 0, 0), mLimit(limit)
|
||||||
{
|
{
|
||||||
mBgTex = NULL;
|
mBgTex = NULL;
|
||||||
|
|
||||||
@@ -3923,16 +3923,19 @@ ATutorialMessage::ATutorialMessage(GameObserver* observer, MTGCardInstance * sou
|
|||||||
for (int i = 0; i < 9; i++)
|
for (int i = 0; i < 9; i++)
|
||||||
mBg[i] = NULL;
|
mBg[i] = NULL;
|
||||||
|
|
||||||
string gfx = game->getResourceManager()->graphicsFile(message);
|
if(game->getResourceManager())
|
||||||
if (fileExists(gfx.c_str()))
|
|
||||||
{
|
{
|
||||||
mIsImage = true;
|
string gfx = game->getResourceManager()->graphicsFile(message);
|
||||||
mMessage = message;
|
if (fileExists(gfx.c_str()))
|
||||||
}
|
{
|
||||||
else
|
mIsImage = true;
|
||||||
{
|
mMessage = message;
|
||||||
mMessage = _(message); //translate directly here, remove this and translate at rendering time if it bites us
|
}
|
||||||
boost::replace_all(mMessage, "\\n", "\n");
|
else
|
||||||
|
{
|
||||||
|
mMessage = _(message); //translate directly here, remove this and translate at rendering time if it bites us
|
||||||
|
boost::replace_all(mMessage, "\\n", "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsImage)
|
if (mIsImage)
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ bool CardDisplay::CheckUserInput(JButton key)
|
|||||||
int n = mCurr;
|
int n = mCurr;
|
||||||
int x1,y1;
|
int x1,y1;
|
||||||
JButton key;
|
JButton key;
|
||||||
if (JGE::GetInstance()->GetLeftClickCoordinates(x1, y1))
|
JGE* jge = observer->getInput();
|
||||||
|
if (jge && jge->GetLeftClickCoordinates(x1, y1))
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < mObjects.size(); i++)
|
for (size_t i = 0; i < mObjects.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -218,7 +219,7 @@ bool CardDisplay::CheckUserInput(JButton key)
|
|||||||
mObjects[mCurr]->Entering();
|
mObjects[mCurr]->Entering();
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,7 +187,9 @@ bool CardSelector::CheckUserInput(JButton key)
|
|||||||
Target* oldactive = active;
|
Target* oldactive = active;
|
||||||
|
|
||||||
int x,y;
|
int x,y;
|
||||||
if(JGE::GetInstance()->GetLeftClickCoordinates(x, y))
|
JGE* jge = observer->getInput();
|
||||||
|
if(!jge) return false;
|
||||||
|
if(jge->GetLeftClickCoordinates(x, y))
|
||||||
{
|
{
|
||||||
active = closest<True> (cards, limitor, static_cast<float> (x), static_cast<float> (y));
|
active = closest<True> (cards, limitor, static_cast<float> (x), static_cast<float> (y));
|
||||||
}
|
}
|
||||||
@@ -223,7 +225,7 @@ bool CardSelector::CheckUserInput(JButton key)
|
|||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if(!JGE::GetInstance()->GetLeftClickCoordinates(x, y))
|
if(!jge->GetLeftClickCoordinates(x, y))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ hgeParticleSystem* DeckMenu::stars = NULL;
|
|||||||
// *** Need to make this configurable in a file somewhere to allow for class reuse
|
// *** Need to make this configurable in a file somewhere to allow for class reuse
|
||||||
|
|
||||||
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title, const int& startIndex, bool showDetailsOverride) :
|
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title, const int& startIndex, bool showDetailsOverride) :
|
||||||
JGuiController(id, listener), fontId(fontId), mShowDetailsScreen( showDetailsOverride )
|
JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsScreen( showDetailsOverride )
|
||||||
{
|
{
|
||||||
|
|
||||||
backgroundName = "DeckMenuBackdrop";
|
backgroundName = "DeckMenuBackdrop";
|
||||||
|
|||||||
@@ -43,36 +43,39 @@ void DuelLayers::CheckUserInput(int isAI)
|
|||||||
{
|
{
|
||||||
JButton key;
|
JButton key;
|
||||||
int x, y;
|
int x, y;
|
||||||
while ((key = JGE::GetInstance()->ReadButton()) || JGE::GetInstance()->GetLeftClickCoordinates(x, y))
|
JGE* jge = observer->getInput();
|
||||||
|
if(!jge) return;
|
||||||
|
|
||||||
|
while ((key = jge->ReadButton()) || jge->GetLeftClickCoordinates(x, y))
|
||||||
{
|
{
|
||||||
if ((!isAI) && ((0 != key) || JGE::GetInstance()->GetLeftClickCoordinates(x, y)))
|
if ((!isAI) && ((0 != key) || jge->GetLeftClickCoordinates(x, y)))
|
||||||
{
|
{
|
||||||
if (stack->CheckUserInput(key)) {
|
if (stack->CheckUserInput(key)) {
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (combat->CheckUserInput(key)) {
|
if (combat->CheckUserInput(key)) {
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (avatars->CheckUserInput(key)) {
|
if (avatars->CheckUserInput(key)) {
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
break; //avatars need to check their input before action (CTRL_CROSS)
|
break; //avatars need to check their input before action (CTRL_CROSS)
|
||||||
}
|
}
|
||||||
if (action->CheckUserInput(key)) {
|
if (action->CheckUserInput(key)) {
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (hand->CheckUserInput(key)) {
|
if (hand->CheckUserInput(key)) {
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mCardSelector->CheckUserInput(key)) {
|
if (mCardSelector->CheckUserInput(key)) {
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JGE::GetInstance()->LeftClickedProcessed();
|
jge->LeftClickedProcessed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,28 +17,6 @@
|
|||||||
#include "TestSuiteAI.h"
|
#include "TestSuiteAI.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void GameObserver::initialize()
|
|
||||||
{
|
|
||||||
mGameType = GAME_TYPE_CLASSIC;
|
|
||||||
currentPlayer = NULL;
|
|
||||||
currentActionPlayer = NULL;
|
|
||||||
isInterrupting = NULL;
|
|
||||||
currentPlayerId = 0;
|
|
||||||
currentGamePhase = -1;
|
|
||||||
targetChooser = NULL;
|
|
||||||
cardWaitingForTargets = NULL;
|
|
||||||
mExtraPayment = NULL;
|
|
||||||
gameOver = NULL;
|
|
||||||
phaseRing = NULL;
|
|
||||||
replacementEffects = NEW ReplacementEffects();
|
|
||||||
combatStep = BLOCKERS;
|
|
||||||
mRules = NULL;
|
|
||||||
connectRule = false;
|
|
||||||
mLoading = false;
|
|
||||||
mLayers = NULL;
|
|
||||||
mTrash = new Trash();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameObserver::cleanup()
|
void GameObserver::cleanup()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(targetChooser);
|
SAFE_DELETE(targetChooser);
|
||||||
@@ -69,6 +47,10 @@ void GameObserver::cleanup()
|
|||||||
|
|
||||||
GameObserver::~GameObserver()
|
GameObserver::~GameObserver()
|
||||||
{
|
{
|
||||||
|
#ifdef ACTION_LOGGING_TESTING
|
||||||
|
if(oldGame) SAFE_DELETE(oldGame);
|
||||||
|
#endif //ACTION_LOGGING_TESTING
|
||||||
|
|
||||||
LOG("==Destroying GameObserver==");
|
LOG("==Destroying GameObserver==");
|
||||||
for (size_t i = 0; i < players.size(); ++i)
|
for (size_t i = 0; i < players.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -89,13 +71,34 @@ GameObserver::~GameObserver()
|
|||||||
SAFE_DELETE(mTrash);
|
SAFE_DELETE(mTrash);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObserver::GameObserver(WResourceManager *resourceManager)
|
GameObserver::GameObserver(WResourceManager *output, JGE* input)
|
||||||
: randomGenerator(true), mResourceManager(resourceManager)
|
: randomGenerator(true), mResourceManager(output), mJGE(input)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
updateCtr = 0;
|
||||||
|
#ifdef ACTION_LOGGING_TESTING
|
||||||
|
oldGame = 0;
|
||||||
|
#endif //ACTION_LOGGING_TESTING
|
||||||
ExtraRules = new MTGCardInstance[2]();
|
ExtraRules = new MTGCardInstance[2]();
|
||||||
|
|
||||||
initialize();
|
mGameType = GAME_TYPE_CLASSIC;
|
||||||
|
currentPlayer = NULL;
|
||||||
|
currentActionPlayer = NULL;
|
||||||
|
isInterrupting = NULL;
|
||||||
|
currentPlayerId = 0;
|
||||||
|
currentGamePhase = -1;
|
||||||
|
targetChooser = NULL;
|
||||||
|
cardWaitingForTargets = NULL;
|
||||||
|
mExtraPayment = NULL;
|
||||||
|
gameOver = NULL;
|
||||||
|
phaseRing = NULL;
|
||||||
|
replacementEffects = NEW ReplacementEffects();
|
||||||
|
combatStep = BLOCKERS;
|
||||||
|
mRules = NULL;
|
||||||
|
connectRule = false;
|
||||||
|
mLoading = false;
|
||||||
|
mLayers = NULL;
|
||||||
|
mTrash = new Trash();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameObserver::getCurrentGamePhase()
|
int GameObserver::getCurrentGamePhase()
|
||||||
@@ -417,9 +420,80 @@ bool GameObserver::removeObserver(ActionElement * observer)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameObserver::operator==(const GameObserver& aGame)
|
||||||
|
{
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
if (aGame.currentGamePhase != currentGamePhase)
|
||||||
|
{
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
TestSuiteAI * p = (TestSuiteAI *) (aGame.players[i]);
|
||||||
|
|
||||||
|
if (p->life != players[i]->life)
|
||||||
|
{
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
if (p->poisonCount != players[i]->poisonCount)
|
||||||
|
{
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
if (!p->getManaPool()->canAfford(players[i]->getManaPool()))
|
||||||
|
{
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
if (!players[i]->getManaPool()->canAfford(p->getManaPool()))
|
||||||
|
{
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
MTGGameZone * aZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
|
||||||
|
MTGGameZone * thisZones[] = { players[i]->game->graveyard,
|
||||||
|
players[i]->game->library,
|
||||||
|
players[i]->game->hand,
|
||||||
|
players[i]->game->inPlay };
|
||||||
|
for (int j = 0; j < 4; j++)
|
||||||
|
{
|
||||||
|
MTGGameZone * zone = aZones[j];
|
||||||
|
if (zone->nb_cards != thisZones[j]->nb_cards)
|
||||||
|
{
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
for (size_t k = 0; k < (size_t)thisZones[j]->nb_cards; k++)
|
||||||
|
{
|
||||||
|
MTGCardInstance* cardToCheck = (k<thisZones[j]->cards.size())?thisZones[j]->cards[k]:0;
|
||||||
|
MTGCardInstance* card = (k<aZones[j]->cards.size())?aZones[j]->cards[k]:0;
|
||||||
|
if(!card || !cardToCheck || cardToCheck->getId() != card->getId())
|
||||||
|
{
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (error == 0);
|
||||||
|
}
|
||||||
|
|
||||||
void GameObserver::Update(float dt)
|
void GameObserver::Update(float dt)
|
||||||
{
|
{
|
||||||
|
/*******************/
|
||||||
|
updateCtr++;
|
||||||
|
#ifdef ACTION_LOGGING_TESTING
|
||||||
|
if(!oldGame || (!(*oldGame == *this) &&
|
||||||
|
!mLoading && mLayers->stackLayer()->isCalm()))
|
||||||
|
{ // constant game check
|
||||||
|
stringstream stream;
|
||||||
|
stream << *this;
|
||||||
|
if(oldGame) SAFE_DELETE(oldGame);
|
||||||
|
oldGame = new GameObserver();
|
||||||
|
oldGame->mRules = mRules;
|
||||||
|
oldGame->load(stream.str());
|
||||||
|
assert(*this == *oldGame);
|
||||||
|
}
|
||||||
|
#endif // ACTION_LOGGING_TESTING
|
||||||
|
|
||||||
|
/*******************/
|
||||||
Player * player = currentPlayer;
|
Player * player = currentPlayer;
|
||||||
if (Constants::MTG_PHASE_COMBATBLOCKERS == currentGamePhase && BLOCKERS == combatStep)
|
if (Constants::MTG_PHASE_COMBATBLOCKERS == currentGamePhase && BLOCKERS == combatStep)
|
||||||
{
|
{
|
||||||
@@ -1368,7 +1442,12 @@ bool GameObserver::load(const string& ss, bool undo)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(players.size() == 0 || !players[0])
|
if(players.size() == 0 || !players[0])
|
||||||
players.push_back(new HumanPlayer(this, deckFile, deckFileSmall));
|
{
|
||||||
|
if (s.find("mode=") == 0)
|
||||||
|
{
|
||||||
|
createPlayer(s.substr(5));
|
||||||
|
}
|
||||||
|
}
|
||||||
players[0]->parseLine(s);
|
players[0]->parseLine(s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1379,9 +1458,12 @@ bool GameObserver::load(const string& ss, bool undo)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(players.size() == 1 || !players[1]) {
|
if(players.size() == 1 || !players[1])
|
||||||
AIPlayerFactory playerCreator;
|
{
|
||||||
players.push_back(playerCreator.createAIPlayer(this, MTGCollection(), players[0]));
|
if (s.find("mode=") == 0)
|
||||||
|
{
|
||||||
|
createPlayer(s.substr(5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
players[1]->parseLine(s);
|
players[1]->parseLine(s);
|
||||||
}
|
}
|
||||||
@@ -1556,6 +1638,27 @@ void GameObserver::Mulligan(Player* player)
|
|||||||
player->takeMulligan();
|
player->takeMulligan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameObserver::createPlayer(const string& playerMode)
|
||||||
|
{
|
||||||
|
Player::Mode aMode = (Player::Mode)atoi(playerMode.c_str());
|
||||||
|
switch(aMode)
|
||||||
|
{
|
||||||
|
case Player::MODE_AI:
|
||||||
|
AIPlayerFactory playerCreator;
|
||||||
|
// FIXME: gonna break in AI vs AI mode
|
||||||
|
players.push_back(playerCreator.createAIPlayer(this, MTGCollection(), players[0]));
|
||||||
|
break;
|
||||||
|
case Player::MODE_HUMAN:
|
||||||
|
players.push_back(new HumanPlayer(this, "", ""));
|
||||||
|
break;
|
||||||
|
case Player::MODE_TEST_SUITE:
|
||||||
|
// FIXME, not real TestPlayer, but we don't care here.
|
||||||
|
players.push_back(new Player(this, "", ""));
|
||||||
|
players.back()->playMode = Player::MODE_TEST_SUITE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
void GameObserver::loadTestSuitePlayer(int playerId, TestSuiteGame* testSuite)
|
void GameObserver::loadTestSuitePlayer(int playerId, TestSuiteGame* testSuite)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ void GameStateAwards::Update(float dt)
|
|||||||
case JGE_BTN_MENU:
|
case JGE_BTN_MENU:
|
||||||
showMenu = true;
|
showMenu = true;
|
||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(menu);
|
||||||
menu = NEW SimpleMenu(EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170);
|
menu = NEW SimpleMenu(JGE::GetInstance(), EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170);
|
||||||
if (mState == STATE_DETAILS)
|
if (mState == STATE_DETAILS)
|
||||||
menu->Add(kBackToTrophiesID, "Back to Trophies");
|
menu->Add(kBackToTrophiesID, "Back to Trophies");
|
||||||
menu->Add(kBackToMainMenuID, "Back to Main Menu");
|
menu->Add(kBackToMainMenuID, "Back to Main Menu");
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ void GameStateDeckViewer::Update(float dt)
|
|||||||
sprintf(buffer, "%s : %i %s", _(card->data->getName()).c_str(), price, _("credits").c_str());
|
sprintf(buffer, "%s : %i %s", _(card->data->getName()).c_str(), price, _("credits").c_str());
|
||||||
const float menuXOffset = SCREEN_WIDTH_F - 300;
|
const float menuXOffset = SCREEN_WIDTH_F - 300;
|
||||||
const float menuYOffset = SCREEN_HEIGHT_F / 2;
|
const float menuYOffset = SCREEN_HEIGHT_F / 2;
|
||||||
subMenu = NEW SimpleMenu(MENU_CARD_PURCHASE, this, Fonts::MAIN_FONT, menuXOffset, menuYOffset, buffer);
|
subMenu = NEW SimpleMenu(JGE::GetInstance(), MENU_CARD_PURCHASE, this, Fonts::MAIN_FONT, menuXOffset, menuYOffset, buffer);
|
||||||
subMenu->Add(MENU_ITEM_YES, "Yes");
|
subMenu->Add(MENU_ITEM_YES, "Yes");
|
||||||
subMenu->Add(MENU_ITEM_NO, "No", "", true);
|
subMenu->Add(MENU_ITEM_NO, "No", "", true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ void GameStateDuel::Start()
|
|||||||
renderer->EnableVSync(true);
|
renderer->EnableVSync(true);
|
||||||
OpponentsDeckid = 0;
|
OpponentsDeckid = 0;
|
||||||
|
|
||||||
game = NEW GameObserver(WResourceManager::Instance());
|
game = NEW GameObserver(WResourceManager::Instance(), JGE::GetInstance());
|
||||||
|
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
SAFE_DELETE(testSuite);
|
SAFE_DELETE(testSuite);
|
||||||
@@ -200,7 +200,7 @@ void GameStateDuel::loadTestSuitePlayers()
|
|||||||
if (!testSuite) return;
|
if (!testSuite) return;
|
||||||
initRand(testSuite->seed);
|
initRand(testSuite->seed);
|
||||||
SAFE_DELETE(game);
|
SAFE_DELETE(game);
|
||||||
game = new GameObserver(WResourceManager::Instance());
|
game = new GameObserver(WResourceManager::Instance(), JGE::GetInstance());
|
||||||
testSuite->setObserver(game);
|
testSuite->setObserver(game);
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
@@ -274,6 +274,28 @@ void GameStateDuel::setGamePhase(int newGamePhase) {
|
|||||||
JGE::GetInstance()->SendCommand("enterduelphase:" + string(stateStrings[mGamePhase]));
|
JGE::GetInstance()->SendCommand("enterduelphase:" + string(stateStrings[mGamePhase]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef AI_CHANGE_TESTING
|
||||||
|
boost::mutex GameStateDuel::mMutex;
|
||||||
|
|
||||||
|
void GameStateDuel::ThreadProc(void* inParam)
|
||||||
|
{
|
||||||
|
GameStateDuel* instance = reinterpret_cast<GameStateDuel*>(inParam);
|
||||||
|
float counter = 1.0f;
|
||||||
|
while(instance->mGamePhase != DUEL_STATE_BACK_TO_MAIN_MENU)
|
||||||
|
{
|
||||||
|
GameObserver observer;
|
||||||
|
observer.loadPlayer(0, PLAYER_TYPE_TESTSUITE);
|
||||||
|
observer.loadPlayer(1, PLAYER_TYPE_TESTSUITE);
|
||||||
|
observer.startGame(instance->mParent->gameType, instance->mParent->rules);
|
||||||
|
|
||||||
|
while(!observer.gameOver)
|
||||||
|
observer.Update(counter++);
|
||||||
|
|
||||||
|
instance->handleResults(&observer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //AI_CHANGE_TESTING
|
||||||
|
|
||||||
void GameStateDuel::Update(float dt)
|
void GameStateDuel::Update(float dt)
|
||||||
{
|
{
|
||||||
switch (mGamePhase)
|
switch (mGamePhase)
|
||||||
@@ -421,12 +443,20 @@ void GameStateDuel::Update(float dt)
|
|||||||
#ifdef AI_CHANGE_TESTING
|
#ifdef AI_CHANGE_TESTING
|
||||||
if (mParent->players[0] == PLAYER_TYPE_CPU_TEST && mParent->players[1] == PLAYER_TYPE_CPU_TEST)
|
if (mParent->players[0] == PLAYER_TYPE_CPU_TEST && mParent->players[1] == PLAYER_TYPE_CPU_TEST)
|
||||||
{
|
{
|
||||||
totalTestGames++;
|
handleResults(game);
|
||||||
if (game->gameOver == game->players[0])
|
|
||||||
testPlayer2Victories++;
|
|
||||||
End();
|
End();
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
if(mWorkerThread.empty())
|
||||||
|
{ // "I don't like to wait" mode
|
||||||
|
size_t thread_count = 1;
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
thread_count = QThread::idealThreadCount();
|
||||||
|
#endif
|
||||||
|
for(size_t i = 0; i < (thread_count-1); i++)
|
||||||
|
mWorkerThread.push_back(boost::thread(ThreadProc, this));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU)
|
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU)
|
||||||
{
|
{
|
||||||
@@ -438,7 +468,7 @@ void GameStateDuel::Update(float dt)
|
|||||||
{
|
{
|
||||||
if (!menu)
|
if (!menu)
|
||||||
{
|
{
|
||||||
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25,
|
menu = NEW SimpleMenu(JGE::GetInstance(), DUEL_MENU_GAME_MENU, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25,
|
||||||
game->players[1]->deckName.c_str());
|
game->players[1]->deckName.c_str());
|
||||||
int cardsinhand = game->currentPlayer->game->hand->nb_cards;
|
int cardsinhand = game->currentPlayer->game->hand->nb_cards;
|
||||||
|
|
||||||
@@ -498,6 +528,14 @@ void GameStateDuel::Update(float dt)
|
|||||||
case DUEL_STATE_BACK_TO_MAIN_MENU:
|
case DUEL_STATE_BACK_TO_MAIN_MENU:
|
||||||
if (menu)
|
if (menu)
|
||||||
{
|
{
|
||||||
|
#ifdef AI_CHANGE_TESTING
|
||||||
|
while(mWorkerThread.size())
|
||||||
|
{
|
||||||
|
mWorkerThread.back().join();
|
||||||
|
mWorkerThread.pop_back();
|
||||||
|
}
|
||||||
|
#endif //AI_CHANGE_TESTING
|
||||||
|
|
||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
if (menu->isClosed())
|
if (menu->isClosed())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ void GameStateMenu::setLang(int id)
|
|||||||
void GameStateMenu::loadLangMenu()
|
void GameStateMenu::loadLangMenu()
|
||||||
{
|
{
|
||||||
LOG("GameStateMenu::loadLangMenu");
|
LOG("GameStateMenu::loadLangMenu");
|
||||||
subMenuController = NEW SimpleMenu(MENU_LANGUAGE_SELECTION, this, Fonts::MENU_FONT, 150, 60);
|
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_LANGUAGE_SELECTION, this, Fonts::MENU_FONT, 150, 60);
|
||||||
if (!subMenuController)
|
if (!subMenuController)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ void GameStateMenu::ensureMGuiController()
|
|||||||
{
|
{
|
||||||
if (!mGuiController)
|
if (!mGuiController)
|
||||||
{
|
{
|
||||||
mGuiController = NEW JGuiController(100, this);
|
mGuiController = NEW JGuiController(JGE::GetInstance(), 100, this);
|
||||||
if (mGuiController)
|
if (mGuiController)
|
||||||
{
|
{
|
||||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT);
|
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT);
|
||||||
@@ -617,7 +617,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
if (!hasChosenGameType)
|
if (!hasChosenGameType)
|
||||||
{
|
{
|
||||||
currentState = MENU_STATE_MAJOR_SUBMENU;
|
currentState = MENU_STATE_MAJOR_SUBMENU;
|
||||||
subMenuController = NEW SimpleMenu(MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
|
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
|
||||||
if (subMenuController)
|
if (subMenuController)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < Rules::RulesList.size(); ++i)
|
for (size_t i = 0; i < Rules::RulesList.size(); ++i)
|
||||||
@@ -791,7 +791,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
|||||||
switch (controlId)
|
switch (controlId)
|
||||||
{
|
{
|
||||||
case MENUITEM_PLAY:
|
case MENUITEM_PLAY:
|
||||||
subMenuController = NEW SimpleMenu(MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
|
subMenuController = NEW SimpleMenu(JGE::GetInstance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
|
||||||
if (subMenuController)
|
if (subMenuController)
|
||||||
{
|
{
|
||||||
subMenuController->Add(SUBMENUITEM_1PLAYER, "1 Player");
|
subMenuController->Add(SUBMENUITEM_1PLAYER, "1 Player");
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ void GameStateOptions::Start()
|
|||||||
optionsList->failMsg = "";
|
optionsList->failMsg = "";
|
||||||
optionsTabs->Add(optionsList);
|
optionsTabs->Add(optionsList);
|
||||||
|
|
||||||
optionsMenu = NEW SimpleMenu(-102, this, Fonts::MENU_FONT, 50, 170);
|
optionsMenu = NEW SimpleMenu(JGE::GetInstance(), -102, this, Fonts::MENU_FONT, 50, 170);
|
||||||
optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu");
|
optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu");
|
||||||
optionsMenu->Add(kSaveAndBackToMainMenuID, "Save & Back to Main Menu");
|
optionsMenu->Add(kSaveAndBackToMainMenuID, "Save & Back to Main Menu");
|
||||||
optionsMenu->Add(kCancelMenuID, "Cancel");
|
optionsMenu->Add(kCancelMenuID, "Cancel");
|
||||||
|
|||||||
@@ -214,12 +214,12 @@ void GameStateShop::beginPurchase(int controlId)
|
|||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(menu);
|
||||||
if (mInventory[controlId] <= 0)
|
if (mInventory[controlId] <= 0)
|
||||||
{
|
{
|
||||||
menu = NEW SimpleMenu(-145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Sold Out").c_str());
|
menu = NEW SimpleMenu(JGE::GetInstance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Sold Out").c_str());
|
||||||
menu->Add(-1, "Ok");
|
menu->Add(-1, "Ok");
|
||||||
}
|
}
|
||||||
else if (playerdata->credits - mPrices[controlId] < 0)
|
else if (playerdata->credits - mPrices[controlId] < 0)
|
||||||
{
|
{
|
||||||
menu = NEW SimpleMenu(-145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Not enough credits").c_str());
|
menu = NEW SimpleMenu(JGE::GetInstance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Not enough credits").c_str());
|
||||||
menu->Add(-1, "Ok");
|
menu->Add(-1, "Ok");
|
||||||
if (options[Options::CHEATMODE].number)
|
if (options[Options::CHEATMODE].number)
|
||||||
{
|
{
|
||||||
@@ -233,7 +233,7 @@ void GameStateShop::beginPurchase(int controlId)
|
|||||||
sprintf(buf, _("Purchase Booster: %i credits").c_str(), mPrices[controlId]);
|
sprintf(buf, _("Purchase Booster: %i credits").c_str(), mPrices[controlId]);
|
||||||
else
|
else
|
||||||
sprintf(buf, _("Purchase Card: %i credits").c_str(), mPrices[controlId]);
|
sprintf(buf, _("Purchase Card: %i credits").c_str(), mPrices[controlId]);
|
||||||
menu = NEW SimpleMenu(-145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, buf);
|
menu = NEW SimpleMenu(JGE::GetInstance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, buf);
|
||||||
|
|
||||||
menu->Add(controlId, "Yes");
|
menu->Add(controlId, "Yes");
|
||||||
menu->Add(-1, "No");
|
menu->Add(-1, "No");
|
||||||
@@ -495,7 +495,7 @@ void GameStateShop::Update(float dt)
|
|||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menu = NEW SimpleMenu(11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20);
|
menu = NEW SimpleMenu(JGE::GetInstance(), 11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20);
|
||||||
menu->Add(22, "Ask about...");
|
menu->Add(22, "Ask about...");
|
||||||
menu->Add(14, "Check task board");
|
menu->Add(14, "Check task board");
|
||||||
if (options[Options::CHEATMODE].number)
|
if (options[Options::CHEATMODE].number)
|
||||||
@@ -525,7 +525,7 @@ void GameStateShop::Update(float dt)
|
|||||||
{
|
{
|
||||||
if (!menu)
|
if (!menu)
|
||||||
{
|
{
|
||||||
menu = NEW SimpleMenu(11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20);
|
menu = NEW SimpleMenu(JGE::GetInstance(), 11, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 20);
|
||||||
menu->Add(15, "Return to shop");
|
menu->Add(15, "Return to shop");
|
||||||
menu->Add(12, "Save & Back to Main Menu");
|
menu->Add(12, "Save & Back to Main Menu");
|
||||||
menu->Add(kCancelMenuID, "Cancel");
|
menu->Add(kCancelMenuID, "Cancel");
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ void GameStateStory::loadStoriesMenu(const char * root)
|
|||||||
flow = NEW StoryFlow(stories[0]);
|
flow = NEW StoryFlow(stories[0]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
menu = NEW SimpleMenu(103, this, Fonts::MENU_FONT, 150, 60);
|
menu = NEW SimpleMenu(JGE::GetInstance(), 103, this, Fonts::MENU_FONT, 150, 60);
|
||||||
for (size_t i = 0; i < stories.size(); ++i)
|
for (size_t i = 0; i < stories.size(); ++i)
|
||||||
{
|
{
|
||||||
menu->Add(i, stories[i].c_str());
|
menu->Add(i, stories[i].c_str());
|
||||||
@@ -64,7 +64,7 @@ void GameStateStory::Update(float dt)
|
|||||||
{
|
{
|
||||||
if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU))
|
if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU))
|
||||||
{
|
{
|
||||||
menu = NEW SimpleMenu(100, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25);
|
menu = NEW SimpleMenu(JGE::GetInstance(), 100, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25);
|
||||||
menu->Add(0, "Back to main menu");
|
menu->Add(0, "Back to main menu");
|
||||||
menu->Add(kCancelMenuID, "Cancel");
|
menu->Add(kCancelMenuID, "Cancel");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ bool GuiCombat::CheckUserInput(JButton key)
|
|||||||
DamagerDamaged* oldActive = active;
|
DamagerDamaged* oldActive = active;
|
||||||
/*
|
/*
|
||||||
int x,y;
|
int x,y;
|
||||||
if(JGE::GetInstance()->GetLeftClickCoordinates(x, y))
|
if(observer->getInput()->GetLeftClickCoordinates(x, y))
|
||||||
{
|
{
|
||||||
DamagerDamaged* old = active;
|
DamagerDamaged* old = active;
|
||||||
active = closest<True> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
|
active = closest<True> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#define SCALE_SELECTED 1.2f
|
#define SCALE_SELECTED 1.2f
|
||||||
#define SCALE_NORMAL 1.0f
|
#define SCALE_NORMAL 1.0f
|
||||||
|
|
||||||
IconButtonsController::IconButtonsController(float x, float y): JGuiController(0, NULL), mX(x), mY(y)
|
IconButtonsController::IconButtonsController(JGE* jge, float x, float y): JGuiController(jge, 0, NULL), mX(x), mY(y)
|
||||||
{
|
{
|
||||||
mListener = this;
|
mListener = this;
|
||||||
|
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ void OptionKey::KeyPressed(LocalKeySym key)
|
|||||||
g->UngrabKeyboard(this);
|
g->UngrabKeyboard(this);
|
||||||
grabbed = false;
|
grabbed = false;
|
||||||
|
|
||||||
btnMenu = NEW SimpleMenu(0, this, Fonts::MENU_FONT, 80, 10);
|
btnMenu = NEW SimpleMenu(JGE::GetInstance(), 0, this, Fonts::MENU_FONT, 80, 10);
|
||||||
for (int i = sizeof(btnList) / sizeof(btnList[0]) - 1; i >= 0; --i)
|
for (int i = sizeof(btnList) / sizeof(btnList[0]) - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
const KeyRep& rep = translateKey(btnList[i]);
|
const KeyRep& rep = translateKey(btnList[i]);
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ bool Player::parseLine(const string& s)
|
|||||||
|
|
||||||
ostream& operator<<(ostream& out, const Player& p)
|
ostream& operator<<(ostream& out, const Player& p)
|
||||||
{
|
{
|
||||||
|
out << "mode=" << p.playMode << endl;
|
||||||
out << *(Damageable*)&p;
|
out << *(Damageable*)&p;
|
||||||
string manapoolstring = p.manaPool->toString();
|
string manapoolstring = p.manaPool->toString();
|
||||||
if(manapoolstring != "")
|
if(manapoolstring != "")
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ JTexture* SimpleMenu::spadeLTex = NULL;
|
|||||||
JTexture* SimpleMenu::jewelTex = NULL;
|
JTexture* SimpleMenu::jewelTex = NULL;
|
||||||
JTexture* SimpleMenu::sideTex = NULL;
|
JTexture* SimpleMenu::sideTex = NULL;
|
||||||
|
|
||||||
SimpleMenu::SimpleMenu(int id, JGuiListener* listener, int fontId, float x, float y, const char * _title, int _maxItems, bool centerHorizontal, bool centerVertical)
|
SimpleMenu::SimpleMenu(JGE* jge, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title, int _maxItems, bool centerHorizontal, bool centerVertical)
|
||||||
: JGuiController(id, listener), fontId(fontId), mCenterHorizontal(centerHorizontal), mCenterVertical(centerVertical)
|
: JGuiController(jge, id, listener), fontId(fontId), mCenterHorizontal(centerHorizontal), mCenterVertical(centerVertical)
|
||||||
{
|
{
|
||||||
autoTranslate = true;
|
autoTranslate = true;
|
||||||
isMultipleChoice = false;
|
isMultipleChoice = false;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title, DeckMetaData* deckMetaData, MTGAllCards * collection) :
|
SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title, DeckMetaData* deckMetaData, MTGAllCards * collection) :
|
||||||
JGuiController(id, listener), mFontId(fontId), mCollection(collection)
|
JGuiController(JGE::GetInstance(), id, listener), mFontId(fontId), mCollection(collection)
|
||||||
{
|
{
|
||||||
mX = 19;
|
mX = 19;
|
||||||
mY = 66;
|
mY = 66;
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ StoryChoice::StoryChoice(string pageId, string text, int JGOid, float mX, float
|
|||||||
//Actually loads a duel
|
//Actually loads a duel
|
||||||
void StoryDuel::init()
|
void StoryDuel::init()
|
||||||
{
|
{
|
||||||
game = new GameObserver();
|
game = new GameObserver(WResourceManager::Instance(), JGE::GetInstance());
|
||||||
|
|
||||||
char folder[255], deckFile[255], deckFileSmall[255];
|
char folder[255], deckFile[255], deckFileSmall[255];
|
||||||
sprintf(folder, CAMPAIGNS_FOLDER"%s/%s", mParent->folder.c_str(), pageId.c_str());
|
sprintf(folder, CAMPAIGNS_FOLDER"%s/%s", mParent->folder.c_str(), pageId.c_str());
|
||||||
@@ -410,7 +410,7 @@ int StoryPage::loadElement(TiXmlElement* element)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) :
|
StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) :
|
||||||
StoryPage(mParent), JGuiListener(), JGuiController(1, NULL)
|
StoryPage(mParent), JGuiListener(), JGuiController(JGE::GetInstance(), 1, NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
currentY = 0;
|
currentY = 0;
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ void WDecoConfirm::Entering(JButton key)
|
|||||||
|
|
||||||
SAFE_DELETE(confirmMenu);
|
SAFE_DELETE(confirmMenu);
|
||||||
mState = OP_CONFIRMED;
|
mState = OP_CONFIRMED;
|
||||||
confirmMenu = NEW SimpleMenu(444, listener, Fonts::MENU_FONT, 50, 170);
|
confirmMenu = NEW SimpleMenu(JGE::GetInstance(), 444, listener, Fonts::MENU_FONT, 50, 170);
|
||||||
confirmMenu->Add(1, confirm.c_str());
|
confirmMenu->Add(1, confirm.c_str());
|
||||||
confirmMenu->Add(2, cancel.c_str());
|
confirmMenu->Add(2, cancel.c_str());
|
||||||
}
|
}
|
||||||
@@ -1965,7 +1965,7 @@ void WGuiFilterItem::updateValue()
|
|||||||
SAFE_DELETE(mParent->subMenu);
|
SAFE_DELETE(mParent->subMenu);
|
||||||
mState = STATE_CHOOSE_TYPE;
|
mState = STATE_CHOOSE_TYPE;
|
||||||
SAFE_DELETE(mParent->subMenu);
|
SAFE_DELETE(mParent->subMenu);
|
||||||
mParent->subMenu = NEW SimpleMenu(-1234, this, Fonts::MENU_FONT, 20, 20, "Filter By...", 10);
|
mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), -1234, this, Fonts::MENU_FONT, 20, 20, "Filter By...", 10);
|
||||||
if (mParent->isAvailable(FILTER_SET))
|
if (mParent->isAvailable(FILTER_SET))
|
||||||
{
|
{
|
||||||
mParent->subMenu->Add(FILTER_SET, "Set");
|
mParent->subMenu->Add(FILTER_SET, "Set");
|
||||||
@@ -2033,7 +2033,7 @@ void WGuiFilterItem::updateValue()
|
|||||||
SAFE_DELETE(mParent->subMenu);
|
SAFE_DELETE(mParent->subMenu);
|
||||||
mParent->clearArgs();
|
mParent->clearArgs();
|
||||||
mState = STATE_CHOOSE_VAL;
|
mState = STATE_CHOOSE_VAL;
|
||||||
mParent->subMenu = NEW SimpleMenu(-1234, this, Fonts::MENU_FONT, 20, 20, "Filter:");
|
mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), -1234, this, Fonts::MENU_FONT, 20, 20, "Filter:");
|
||||||
if (filterType == FILTER_TYPE)
|
if (filterType == FILTER_TYPE)
|
||||||
{
|
{
|
||||||
mParent->addArg("Artifact", "t:Artifact;");
|
mParent->addArg("Artifact", "t:Artifact;");
|
||||||
@@ -2341,7 +2341,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm()
|
|||||||
confirmationString = ss.str();
|
confirmationString = ss.str();
|
||||||
|
|
||||||
// Then create the menu.
|
// Then create the menu.
|
||||||
confirmMenu = NEW SimpleMenu(0, this, Fonts::MENU_FONT, 40, 130, "Conflict");
|
confirmMenu = NEW SimpleMenu(JGE::GetInstance(), 0, this, Fonts::MENU_FONT, 40, 130, "Conflict");
|
||||||
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
|
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
|
||||||
confirmMenu->Add(2, _("This is okay, validate and save").c_str());
|
confirmMenu->Add(2, _("This is okay, validate and save").c_str());
|
||||||
return CONFIRM_NEED;
|
return CONFIRM_NEED;
|
||||||
@@ -2369,7 +2369,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm()
|
|||||||
confirmationString = s;
|
confirmationString = s;
|
||||||
|
|
||||||
confirmingButton = btnToCheck[i];
|
confirmingButton = btnToCheck[i];
|
||||||
confirmMenu = NEW SimpleMenu(1, this, Fonts::MENU_FONT, 40, 130, "Binding missing");
|
confirmMenu = NEW SimpleMenu(JGE::GetInstance(), 1, this, Fonts::MENU_FONT, 40, 130, "Binding missing");
|
||||||
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
|
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
|
||||||
confirmMenu->Add(2, _("This is okay, validate and save").c_str());
|
confirmMenu->Add(2, _("This is okay, validate and save").c_str());
|
||||||
return CONFIRM_NEED;
|
return CONFIRM_NEED;
|
||||||
|
|||||||
+11
-19
@@ -31,22 +31,19 @@ int RandomGenerator::random()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = loadedRandomValues.front();
|
result = loadedRandomValues.front();
|
||||||
loadedRandomValues.pop();
|
loadedRandomValues.pop_front();
|
||||||
}
|
}
|
||||||
if(log)
|
if(log)
|
||||||
usedRandomValues.push(result);
|
usedRandomValues.push_back(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& RandomGenerator::saveUsedRandValues(ostream& out)
|
ostream& RandomGenerator::saveUsedRandValues(ostream& out)
|
||||||
{
|
{
|
||||||
while(usedRandomValues.size())
|
list<int>::iterator ite;
|
||||||
|
for(ite=usedRandomValues.begin(); ite != usedRandomValues.end(); ite++)
|
||||||
{
|
{
|
||||||
out << usedRandomValues.front();
|
out << *ite << ",";
|
||||||
if(usedRandomValues.size() >= 1)
|
|
||||||
out << ",";
|
|
||||||
|
|
||||||
usedRandomValues.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -54,13 +51,10 @@ ostream& RandomGenerator::saveUsedRandValues(ostream& out)
|
|||||||
|
|
||||||
ostream& RandomGenerator::saveLoadedRandValues(ostream& out)
|
ostream& RandomGenerator::saveLoadedRandValues(ostream& out)
|
||||||
{
|
{
|
||||||
while(loadedRandomValues.size())
|
list<int>::iterator ite;
|
||||||
|
for(ite=loadedRandomValues.begin(); ite != loadedRandomValues.end(); ite++)
|
||||||
{
|
{
|
||||||
out << loadedRandomValues.front();
|
out << *ite << ",";
|
||||||
if(loadedRandomValues.size() >= 1)
|
|
||||||
out << ",";
|
|
||||||
|
|
||||||
loadedRandomValues.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -68,10 +62,8 @@ ostream& RandomGenerator::saveLoadedRandValues(ostream& out)
|
|||||||
|
|
||||||
void RandomGenerator::loadRandValues(string s)
|
void RandomGenerator::loadRandValues(string s)
|
||||||
{
|
{
|
||||||
while(loadedRandomValues.size())
|
loadedRandomValues.clear();
|
||||||
loadedRandomValues.pop();
|
usedRandomValues.clear();
|
||||||
while(usedRandomValues.size())
|
|
||||||
usedRandomValues.pop();
|
|
||||||
|
|
||||||
while (s.size())
|
while (s.size())
|
||||||
{
|
{
|
||||||
@@ -87,7 +79,7 @@ void RandomGenerator::loadRandValues(string s)
|
|||||||
value = atoi(s.c_str());
|
value = atoi(s.c_str());
|
||||||
s = "";
|
s = "";
|
||||||
}
|
}
|
||||||
if (value) loadedRandomValues.push(value);
|
if (value) loadedRandomValues.push_back(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user