From db4aea3f78bd0a8225ef83ee6294e66323293a5b Mon Sep 17 00:00:00 2001 From: lotodore Date: Fri, 8 Jun 2007 22:14:05 +0000 Subject: [PATCH] Automatic action when for player timeout. First try, not finished yet. --- src/gui/generic/serverguiwrapper.cpp | 1 + src/gui/generic/serverguiwrapper.h | 5 +++-- src/gui/guiinterface.h | 1 + src/gui/qt/guiwrapper.cpp | 1 + src/gui/qt/guiwrapper.h | 1 + src/gui/qt/mainwindow/mainwindowimpl.cpp | 13 ++++--------- src/gui/qt/mainwindow/mainwindowimpl.h | 6 +++--- src/net/common/clientstate.cpp | 2 ++ src/net/common/serverrecvstate.cpp | 9 +++++++++ 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/gui/generic/serverguiwrapper.cpp b/src/gui/generic/serverguiwrapper.cpp index 324b1d5c..b133b464 100644 --- a/src/gui/generic/serverguiwrapper.cpp +++ b/src/gui/generic/serverguiwrapper.cpp @@ -89,6 +89,7 @@ void ServerGuiWrapper::flipHolecardsAllIn() {} void ServerGuiWrapper::nextRoundCleanGui() {} void ServerGuiWrapper::meInAction() {} +void ServerGuiWrapper::disableMyButtons() {} void ServerGuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) {} void ServerGuiWrapper::stopTimeoutAnimation(int playerId) {} diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index 614ad14d..adf99bb1 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -73,8 +73,9 @@ public: void nextRoundCleanGui(); void meInAction(); - void startTimeoutAnimation(int playerId, int timeoutSec); - void stopTimeoutAnimation(int playerId); + void disableMyButtons(); + void startTimeoutAnimation(int playerId, int timeoutSec); + void stopTimeoutAnimation(int playerId); void logPlayerActionMsg(std::string playerName, int action, int setValue) ; void logNewGameHandMsg(int gameID, int handID) ; diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 61663c15..e6b8e1be 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -82,6 +82,7 @@ public: // virtual void userWidgetsBackgroudColor() const=0; // virtual void timerBlockerFalse() const=0; virtual void meInAction()=0; + virtual void disableMyButtons()=0; virtual void startTimeoutAnimation(int playerId, int timeoutSec) =0; virtual void stopTimeoutAnimation(int playerId) =0; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 36042e8c..ab07ec78 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -87,6 +87,7 @@ void GuiWrapper::flipHolecardsAllIn() { myW->signalFlipHolecardsAllIn(); } void GuiWrapper::nextRoundCleanGui() { myW->signalNextRoundCleanGui(); } void GuiWrapper::meInAction() { myW->signalMeInAction(); } +void GuiWrapper::disableMyButtons() { myW->signalDisableMyButtons(); } void GuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) { myW->signalStartTimeoutAnimation(playerId, timeoutSec); } void GuiWrapper::stopTimeoutAnimation(int playerId) { myW->signalStopTimeoutAnimation(playerId); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 493c2acd..c913feb3 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -80,6 +80,7 @@ public: void nextRoundCleanGui(); void meInAction(); + void disableMyButtons(); void startTimeoutAnimation(int playerId, int timeoutSec); void stopTimeoutAnimation(int playerId); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 42b32a84..de9bc60f 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -585,6 +585,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalRefreshGameLabels(int)), this, SLOT(refreshGameLabels(int))); connect(this, SIGNAL(signalMeInAction()), this, SLOT(meInAction())); + connect(this, SIGNAL(signalDisableMyButtons()), this, SLOT(disableMyButtons())); connect(this, SIGNAL(signalStartTimeoutAnimation(int, int)), this, SLOT(startTimeoutAnimation(int, int))); connect(this, SIGNAL(signalStopTimeoutAnimation(int)), this, SLOT(stopTimeoutAnimation(int))); @@ -1551,7 +1552,6 @@ void mainWindowImpl::myFold(){ holeCardsArray[0][0]->startFadeOut(10); holeCardsArray[0][1]->startFadeOut(10); - disableMyButtons(); //set that i was the last active player. need this for unhighlighting groupbox currentHand->setLastPlayersTurn(0); @@ -1568,8 +1568,6 @@ void mainWindowImpl::myCheck() { currentHand->getPlayerArray()[0]->setMyTurn(0); currentHand->getPlayerArray()[0]->setMyAction(2); - disableMyButtons(); - //set that i was the last active player. need this for unhighlighting groupbox currentHand->setLastPlayersTurn(0); @@ -1611,8 +1609,6 @@ void mainWindowImpl::myCall(){ currentHand->getBoard()->collectSets(); refreshPot(); - disableMyButtons(); - //set that i was the last active player. need this for unhighlighting groupbox currentHand->setLastPlayersTurn(0); @@ -1723,8 +1719,6 @@ void mainWindowImpl::mySet(){ currentHand->getBoard()->collectSets(); refreshPot(); - disableMyButtons(); - statusBar()->clearMessage(); //set that i was the last active player. need this for unhighlighting groupbox @@ -1760,8 +1754,6 @@ void mainWindowImpl::myAllIn(){ currentHand->getBoard()->collectSets(); refreshPot(); - disableMyButtons(); - statusBar()->clearMessage(); //set that i was the last active player. need this for unhighlighting groupbox @@ -1777,6 +1769,9 @@ void mainWindowImpl::myActionDone() { // to transfer the action to the server. mySession->sendClientPlayerAction(); + // TODO: Should not call in networking game. + disableMyButtons(); + nextPlayerAnimation(); } diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 6ece0be9..e616c4ec 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -86,6 +86,7 @@ signals: void signalRefreshGameLabels(int); void signalMeInAction(); + void signalDisableMyButtons(); void signalStartTimeoutAnimation(int playerId, int timeoutSec); void signalStopTimeoutAnimation(int playerId); @@ -145,6 +146,8 @@ public slots: //Spieler-Funktionen void meInAction(); void disableMyButtons(); + void startTimeoutAnimation(int playerId, int timoutSec); + void stopTimeoutAnimation(int playerId); void setGameSpeed(const int theValue) { guiGameSpeed = theValue; setSpeeds(); } // Achtung Faktor 10!!! @@ -154,9 +157,6 @@ public slots: void callCreateNetworkGameDialog(); void callJoinNetworkGameDialog(); - void startTimeoutAnimation(int playerId, int timoutSec); - void stopTimeoutAnimation(int playerId); - void myBetRaise(); void myFoldAllin(); void myCallCheckSet(); diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 8c31c42d..254e9db7 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -638,6 +638,8 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrgetMyID(), 3); // Refresh GUI + if (tmpPlayer->getMyID() == 0) + client.GetGui().disableMyButtons(); client.GetGui().refreshPot(); client.GetGui().refreshSet(); client.GetGui().refreshAction(); diff --git a/src/net/common/serverrecvstate.cpp b/src/net/common/serverrecvstate.cpp index ef62024f..96b78286 100644 --- a/src/net/common/serverrecvstate.cpp +++ b/src/net/common/serverrecvstate.cpp @@ -39,6 +39,7 @@ using namespace std; #define SERVER_DEAL_RIVER_CARD_DELAY_SEC 2 #define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 1 #define SERVER_SHOW_CARDS_DELAY_SEC 2 +#define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 2 // Helper functions // TODO: these are hacks. @@ -728,6 +729,14 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server) server.SetState(ServerRecvStateStartRound::Instance()); retVal = MSG_NET_GAME_SERVER_ACTION; } + else if (GetTimer().elapsed().seconds() >= server.GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC) + { + // Player did not act fast enough. Act for him. + PerformPlayerAction(server, tmpPlayer, PLAYER_ACTION_FOLD, 0); + + server.SetState(ServerRecvStateStartRound::Instance()); + retVal = MSG_NET_GAME_SERVER_ACTION; + } else retVal = ServerRecvStateReceiving::Process(server);