this fixes 2 crashes I found, the first, 2 color random mode would crash on load. 2nd, ai vs ai testing would randomly crash, this should fix that also. I noticed 2 color random mode is now trying to search for it's rules and sometimes flashes for a brief moment "error cant read file" or something like that....I could not find the source of that, it doesn't cause it to crash however it causes it to take a sec longer to load, this is before this commit btw, so the issue is still there. it was trying to load the rules, flashed the error then crashes...i fixed the crash but not the rules error. please review, i might have left in useless stuff... I also did notice something, the way we are creating players is kind of all over the place. imo this is bad, it made this conversation extra hard becuase you create one player over here, another type over there, the human over in this direction, back track and create another somewhere else...this needs to be taken into account for a refactor, all player creation should happen in the same function, and at the same times... the reason these 2 crashes existed was becuase players were being created before "gameobserver" in some modes, and in other modes, no player would exist at the time game was creating to set the player. but we then later call the same function when we actually load the player using the method specific to a mode. this just leads to headaches, I mean no offense, just a general observation i made when converting this players array. unfortunately that kind of refactor is just a little beyond my coding ability.
92 lines
2.1 KiB
C++
92 lines
2.1 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"
|
|
|
|
#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;
|
|
vector<Player *> mPlayers;
|
|
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 loadPlayer(int playerId, int decknb = 0, bool isAI = false, bool isNetwork = false);
|
|
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 totalTestGames;
|
|
int testPlayer2Victories;
|
|
int totalAIDecks;
|
|
#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,
|
|
#ifdef NETWORK_SUPPORT
|
|
MENUITEM_REMOTE_CLIENT = -16,
|
|
MENUITEM_REMOTE_SERVER = -17,
|
|
#endif
|
|
MENUITEM_MORE_INFO = kInfoMenuID
|
|
};
|
|
|
|
};
|
|
|
|
#endif
|
|
|