just a format
This commit is contained in:
@@ -97,7 +97,7 @@ GameState(parent, "duel")
|
|||||||
totalAIDecks++;
|
totalAIDecks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -117,13 +117,13 @@ void GameStateDuel::Start()
|
|||||||
|
|
||||||
|
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
if(!mParent->mpNetwork) {
|
if(!mParent->mpNetwork) {
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
game = NEW GameObserver(WResourceManager::Instance(), JGE::GetInstance());
|
game = NEW GameObserver(WResourceManager::Instance(), JGE::GetInstance());
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
} else {
|
} else {
|
||||||
game = NEW NetworkGameObserver(mParent->mpNetwork, WResourceManager::Instance(), JGE::GetInstance());
|
game = NEW NetworkGameObserver(mParent->mpNetwork, WResourceManager::Instance(), JGE::GetInstance());
|
||||||
}
|
}
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
@@ -154,8 +154,8 @@ void GameStateDuel::Start()
|
|||||||
|
|
||||||
if (nbDecks)
|
if (nbDecks)
|
||||||
decksneeded = 0;
|
decksneeded = 0;
|
||||||
|
|
||||||
if (nbDecks > 1)
|
if (nbDecks > 1)
|
||||||
deckmenu->Add(MENUITEM_RANDOM_PLAYER, "Random", "Play with a random deck.");
|
deckmenu->Add(MENUITEM_RANDOM_PLAYER, "Random", "Play with a random deck.");
|
||||||
|
|
||||||
renderDeckMenu(deckmenu, playerDeckList);
|
renderDeckMenu(deckmenu, playerDeckList);
|
||||||
@@ -191,7 +191,7 @@ void GameStateDuel::Start()
|
|||||||
}
|
}
|
||||||
deckmenu->Add(MENUITEM_CANCEL, _("Main Menu").c_str(), _("Return to Main Menu").c_str());
|
deckmenu->Add(MENUITEM_CANCEL, _("Main Menu").c_str(), _("Return to Main Menu").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
mEngine->ResetInput();
|
mEngine->ResetInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ bool GameStateDuel::MusicExist(string FileName)
|
|||||||
{
|
{
|
||||||
string musicFilename = WResourceManager::Instance()->musicFile(FileName);
|
string musicFilename = WResourceManager::Instance()->musicFile(FileName);
|
||||||
if (musicFilename.length() < 1) return false;
|
if (musicFilename.length() < 1) return false;
|
||||||
|
|
||||||
return FileExists(musicFilename);
|
return FileExists(musicFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,7 +459,7 @@ void GameStateDuel::Update(float dt)
|
|||||||
mParent->rules->postUpdateInit(game);
|
mParent->rules->postUpdateInit(game);
|
||||||
|
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
if(mParent->mpNetwork) ((NetworkGameObserver*)game)->synchronize();
|
if(mParent->mpNetwork) ((NetworkGameObserver*)game)->synchronize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (game->didWin())
|
if (game->didWin())
|
||||||
@@ -494,12 +494,12 @@ void GameStateDuel::Update(float dt)
|
|||||||
size_t thread_count = 1;
|
size_t thread_count = 1;
|
||||||
startTime = JGEGetTime();
|
startTime = JGEGetTime();
|
||||||
|
|
||||||
#ifdef QT_CONFIG
|
#ifdef QT_CONFIG
|
||||||
thread_count = QThread::idealThreadCount();
|
thread_count = QThread::idealThreadCount();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
thread_count = 4;
|
thread_count = 4;
|
||||||
#endif
|
#endif
|
||||||
for(size_t i = 0; i < (thread_count); i++)
|
for(size_t i = 0; i < (thread_count); i++)
|
||||||
mWorkerThread.push_back(boost::thread(ThreadProc, this));
|
mWorkerThread.push_back(boost::thread(ThreadProc, this));
|
||||||
}
|
}
|
||||||
@@ -522,7 +522,7 @@ void GameStateDuel::Update(float dt)
|
|||||||
//almosthumane - mulligan
|
//almosthumane - mulligan
|
||||||
if ((game->turn < 1) && (cardsinhand != 0) && game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|
if ((game->turn < 1) && (cardsinhand != 0) && game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|
||||||
&& game->currentPlayer->game->inPlay->nb_cards == 0 && game->currentPlayer->game->graveyard->nb_cards == 0
|
&& game->currentPlayer->game->inPlay->nb_cards == 0 && game->currentPlayer->game->graveyard->nb_cards == 0
|
||||||
&& game->currentPlayer->game->exile->nb_cards == 0 && game->currentlyActing() == (Player*)game->currentPlayer) //1st Play Check
|
&& game->currentPlayer->game->exile->nb_cards == 0 && game->currentlyActing() == (Player*)game->currentPlayer) //1st Play Check
|
||||||
//IF there was no play at the moment automatically mulligan
|
//IF there was no play at the moment automatically mulligan
|
||||||
{
|
{
|
||||||
menu->Add(MENUITEM_MULLIGAN, "Mulligan");
|
menu->Add(MENUITEM_MULLIGAN, "Mulligan");
|
||||||
@@ -542,26 +542,26 @@ void GameStateDuel::Update(float dt)
|
|||||||
break;
|
break;
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
case DUEL_STATE_OPPONENT_WAIT:
|
case DUEL_STATE_OPPONENT_WAIT:
|
||||||
{
|
{
|
||||||
if(game->players.size() > 1)
|
if(game->players.size() > 1)
|
||||||
{ // Player loaded
|
{ // Player loaded
|
||||||
menu->Close();
|
menu->Close();
|
||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(menu);
|
||||||
setGamePhase(DUEL_STATE_PLAY);
|
setGamePhase(DUEL_STATE_PLAY);
|
||||||
} else if(menu == NULL)
|
} else if(menu == NULL)
|
||||||
{
|
{
|
||||||
menu = NEW SimpleMenu(JGE::GetInstance(), DUEL_STATE_OPPONENT_WAIT, this, Fonts::MENU_FONT, 150, 60);
|
menu = NEW SimpleMenu(JGE::GetInstance(), DUEL_STATE_OPPONENT_WAIT, this, Fonts::MENU_FONT, 150, 60);
|
||||||
if (menu)
|
if (menu)
|
||||||
{
|
{
|
||||||
menu->Add(MENUITEM_MAIN_MENU, "Back to main menu");
|
menu->Add(MENUITEM_MAIN_MENU, "Back to main menu");
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
game->Update(dt);
|
game->Update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
case DUEL_STATE_MENU:
|
case DUEL_STATE_MENU:
|
||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
@@ -580,8 +580,8 @@ void GameStateDuel::Update(float dt)
|
|||||||
#ifdef AI_CHANGE_TESTING
|
#ifdef AI_CHANGE_TESTING
|
||||||
while(mWorkerThread.size())
|
while(mWorkerThread.size())
|
||||||
{
|
{
|
||||||
mWorkerThread.back().join();
|
mWorkerThread.back().join();
|
||||||
mWorkerThread.pop_back();
|
mWorkerThread.pop_back();
|
||||||
}
|
}
|
||||||
#endif //AI_CHANGE_TESTING
|
#endif //AI_CHANGE_TESTING
|
||||||
|
|
||||||
@@ -612,28 +612,28 @@ void GameStateDuel::Render()
|
|||||||
if (game) game->Render();
|
if (game) game->Render();
|
||||||
|
|
||||||
#ifdef AI_CHANGE_TESTING
|
#ifdef AI_CHANGE_TESTING
|
||||||
if (game && totalTestGames)
|
if (game && totalTestGames)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
int currentTime = JGEGetTime();
|
int currentTime = JGEGetTime();
|
||||||
|
|
||||||
if (totalTestGames < 2.5 * totalAIDecks)
|
if (totalTestGames < 2.5 * totalAIDecks)
|
||||||
{
|
{
|
||||||
mFont->SetColor(ARGB(255,255,255,0));
|
mFont->SetColor(ARGB(255,255,255,0));
|
||||||
sprintf(buf, " Results are not significant, you should let at least %i more games run", (int)(totalAIDecks * 2.5) - totalTestGames);
|
sprintf(buf, " Results are not significant, you should let at least %i more games run", (int)(totalAIDecks * 2.5) - totalTestGames);
|
||||||
mFont->DrawString(buf,0,SCREEN_HEIGHT/2 - 20);
|
mFont->DrawString(buf,0,SCREEN_HEIGHT/2 - 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
float ratio = float(testPlayer2Victories) / float(totalTestGames);
|
float ratio = float(testPlayer2Victories) / float(totalTestGames);
|
||||||
if (ratio < 0.48)
|
if (ratio < 0.48)
|
||||||
mFont->SetColor(ARGB(255,255,0,0));
|
mFont->SetColor(ARGB(255,255,0,0));
|
||||||
if (ratio > 0.52)
|
if (ratio > 0.52)
|
||||||
mFont->SetColor(ARGB(255,0,255,0));
|
mFont->SetColor(ARGB(255,0,255,0));
|
||||||
sprintf(buf, " Victories Player 2/total Games: %i/%i - Game Turn: %i",
|
sprintf(buf, " Victories Player 2/total Games: %i/%i - Game Turn: %i",
|
||||||
testPlayer2Victories, totalTestGames, /*(float)(1000*totalTestGames)/(currentTime - startTime)*/game->turn);
|
testPlayer2Victories, totalTestGames, /*(float)(1000*totalTestGames)/(currentTime - startTime)*/game->turn);
|
||||||
mFont->DrawString(buf,0,SCREEN_HEIGHT/2);
|
mFont->DrawString(buf,0,SCREEN_HEIGHT/2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (mGamePhase)
|
switch (mGamePhase)
|
||||||
@@ -663,7 +663,7 @@ void GameStateDuel::Render()
|
|||||||
{
|
{
|
||||||
sprintf(buf, "%i tests out of %i FAILED!", nbFailed, nbTests);
|
sprintf(buf, "%i tests out of %i FAILED!", nbFailed, nbTests);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFont->DrawString(buf,0,SCREEN_HEIGHT/2);
|
mFont->DrawString(buf,0,SCREEN_HEIGHT/2);
|
||||||
nbFailed = testSuite->nbAIFailed;
|
nbFailed = testSuite->nbAIFailed;
|
||||||
nbTests = testSuite->nbAITests;
|
nbTests = testSuite->nbAITests;
|
||||||
@@ -697,10 +697,10 @@ void GameStateDuel::Render()
|
|||||||
case DUEL_STATE_DECK2_DETAILED_INFO:
|
case DUEL_STATE_DECK2_DETAILED_INFO:
|
||||||
if (mParent->gameType != GAME_TYPE_CLASSIC
|
if (mParent->gameType != GAME_TYPE_CLASSIC
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
&& mParent->gameType != GAME_TYPE_SLAVE
|
&& mParent->gameType != GAME_TYPE_SLAVE
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
&& mParent->gameType != GAME_TYPE_STONEHEWER
|
&& mParent->gameType != GAME_TYPE_STONEHEWER
|
||||||
&& mParent->gameType != GAME_TYPE_HERMIT)
|
&& mParent->gameType != GAME_TYPE_HERMIT)
|
||||||
mFont->DrawString(_("LOADING DECKS").c_str(), 0, SCREEN_HEIGHT / 2);
|
mFont->DrawString(_("LOADING DECKS").c_str(), 0, SCREEN_HEIGHT / 2);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -741,16 +741,16 @@ void GameStateDuel::Render()
|
|||||||
if (menu)
|
if (menu)
|
||||||
{
|
{
|
||||||
menu->Render();
|
menu->Render();
|
||||||
|
|
||||||
// display the player deck names in their respective corners
|
// display the player deck names in their respective corners
|
||||||
string playerDeckName = game->players[0]->deckName;
|
string playerDeckName = game->players[0]->deckName;
|
||||||
float playerDeckNamePixelLength = mFont->GetStringWidth(playerDeckName.c_str());
|
float playerDeckNamePixelLength = mFont->GetStringWidth(playerDeckName.c_str());
|
||||||
mFont->DrawString( playerDeckName, SCREEN_WIDTH_F - playerDeckNamePixelLength, SCREEN_HEIGHT_F - 50);
|
mFont->DrawString( playerDeckName, SCREEN_WIDTH_F - playerDeckNamePixelLength, SCREEN_HEIGHT_F - 50);
|
||||||
if(game->players.size()>1)
|
if(game->players.size()>1)
|
||||||
{
|
{
|
||||||
string opponentDeckName = game->players[1]->deckName;
|
string opponentDeckName = game->players[1]->deckName;
|
||||||
mFont->DrawString( opponentDeckName, 0, 50);
|
mFont->DrawString( opponentDeckName, 0, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -855,7 +855,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
|||||||
if (controlId == MENUITEM_RANDOM_PLAYER) // Random Player Deck Selection
|
if (controlId == MENUITEM_RANDOM_PLAYER) // Random Player Deck Selection
|
||||||
{
|
{
|
||||||
deckmenu->selectRandomDeck(false);
|
deckmenu->selectRandomDeck(false);
|
||||||
|
|
||||||
game->loadPlayer(0, mParent->players[0], deckmenu->getSelectedDeckId(), premadeDeck);
|
game->loadPlayer(0, mParent->players[0], deckmenu->getSelectedDeckId(), premadeDeck);
|
||||||
deckmenu->Close();
|
deckmenu->Close();
|
||||||
setGamePhase(DUEL_STATE_CHOOSE_DECK2_TO_PLAY);
|
setGamePhase(DUEL_STATE_CHOOSE_DECK2_TO_PLAY);
|
||||||
@@ -936,32 +936,32 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
|||||||
case MENUITEM_MULLIGAN:
|
case MENUITEM_MULLIGAN:
|
||||||
//almosthumane - mulligan
|
//almosthumane - mulligan
|
||||||
game->Mulligan();
|
game->Mulligan();
|
||||||
|
|
||||||
menu->Close();
|
menu->Close();
|
||||||
setGamePhase(DUEL_STATE_CANCEL);
|
setGamePhase(DUEL_STATE_CANCEL);
|
||||||
break;
|
break;
|
||||||
case MENUITEM_UNDO:
|
case MENUITEM_UNDO:
|
||||||
{
|
{
|
||||||
game->undo();
|
game->undo();
|
||||||
menu->Close();
|
menu->Close();
|
||||||
setGamePhase(DUEL_STATE_CANCEL);
|
setGamePhase(DUEL_STATE_CANCEL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
case MENUITEM_LOAD:
|
case MENUITEM_LOAD:
|
||||||
{
|
{
|
||||||
std::string theGame;
|
std::string theGame;
|
||||||
if (JFileSystem::GetInstance()->readIntoString("test/game/timetwister.txt", theGame))
|
if (JFileSystem::GetInstance()->readIntoString("test/game/timetwister.txt", theGame))
|
||||||
{
|
{
|
||||||
game->load(theGame);
|
game->load(theGame);
|
||||||
}
|
}
|
||||||
menu->Close();
|
menu->Close();
|
||||||
setGamePhase(DUEL_STATE_CANCEL);
|
setGamePhase(DUEL_STATE_CANCEL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
mEngine->ReleaseKey( JGE_BTN_MENU );
|
mEngine->ReleaseKey( JGE_BTN_MENU );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user