diff --git a/src/engine/local_engine/localboard.h b/src/engine/local_engine/localboard.h index 4272c29b..6f76a034 100755 --- a/src/engine/local_engine/localboard.h +++ b/src/engine/local_engine/localboard.h @@ -20,9 +20,7 @@ #ifndef LOCALBOARD_H #define LOCALBOARD_H -#include "boardinterface.h" - -#include +#include class PlayerInterface; class HandInterface; @@ -30,9 +28,8 @@ class HandInterface; class LocalBoard : public BoardInterface{ public: - LocalBoard(); - - ~LocalBoard(); + LocalBoard(); + ~LocalBoard(); void setPlayer(PlayerInterface**); void setHand(HandInterface*); diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index b48fcdb7..391bc0cc 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -19,9 +19,19 @@ ***************************************************************************/ #include "localenginefactory.h" +#include "localhand.h" +#include "localboard.h" +#include "localplayer.h" +#include "localpreflop.h" +#include "localflop.h" +#include "localturn.h" +#include "localriver.h" + +#include + LocalEngineFactory::LocalEngineFactory(ConfigFile *c) - : EngineFactory(), myConfig(c) +: myConfig(c) { } diff --git a/src/engine/local_engine/localenginefactory.h b/src/engine/local_engine/localenginefactory.h index 39fe3fe8..0fd13d65 100644 --- a/src/engine/local_engine/localenginefactory.h +++ b/src/engine/local_engine/localenginefactory.h @@ -22,22 +22,21 @@ #include -#include "localhand.h" -#include "localboard.h" -#include "localplayer.h" -#include "localpreflop.h" -#include "localflop.h" -#include "localturn.h" -#include "localriver.h" +#include +#include +#include +#include +#include +#include +#include -#include "configfile.h" +class ConfigFile; class LocalEngineFactory : public EngineFactory { public: - LocalEngineFactory(ConfigFile*); - - ~LocalEngineFactory(); + LocalEngineFactory(ConfigFile*); + ~LocalEngineFactory(); HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC); BoardInterface* createBoard(); @@ -46,8 +45,8 @@ public: FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB); TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB); RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB); -private: +private: ConfigFile *myConfig; }; diff --git a/src/engine/local_engine/localflop.cpp b/src/engine/local_engine/localflop.cpp index 7911bf2b..b394bd32 100755 --- a/src/engine/local_engine/localflop.cpp +++ b/src/engine/local_engine/localflop.cpp @@ -19,8 +19,9 @@ ***************************************************************************/ #include "localflop.h" #include +#include -using namespace std; +//using namespace std; LocalFlop::LocalFlop(HandInterface* bR, int id, int qP, int dP, int sB) : FlopInterface(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), playersTurn(dP) @@ -83,7 +84,6 @@ void LocalFlop::flopRun() { myHand->getGuiInterface()->refreshAction(); myHand->switchRounds(); - } else { // Flop ist wirklich dran diff --git a/src/engine/local_engine/localflop.h b/src/engine/local_engine/localflop.h index 8ec7c9b1..8d771817 100755 --- a/src/engine/local_engine/localflop.h +++ b/src/engine/local_engine/localflop.h @@ -20,17 +20,15 @@ #ifndef LOCALFLOP_H #define LOCALFLOP_H -#include "flopinterface.h" -#include "handinterface.h" +#include -#include +class HandInterface; class LocalFlop : public FlopInterface{ - -public: - LocalFlop(HandInterface*, int, int, int, int); - ~LocalFlop(); +public: + LocalFlop(HandInterface*, int, int, int, int); + ~LocalFlop(); void setPlayersTurn(const int& theValue) { playersTurn = theValue; } diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 55c1425e..2c25b90b 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -18,6 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "localhand.h" +#include "tools.h" +#include "cardsvalue.h" #include using namespace std; diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 376573bd..84f46ae3 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -17,28 +17,23 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef HandInterface_H -#define HandInterface_H - -#include "enginefactory.h" - -#include "handinterface.h" -#include "guiinterface.h" - - -#include "tools.h" -#include "cardsvalue.h" -#include "localpreflop.h" -#include "localflop.h" -#include "localturn.h" -#include "localriver.h" +#ifndef LOCALHAND_H +#define LOCALHAND_H +#include +#include +#include +#include +#include +#include +#include +#include +#include class LocalHand : public HandInterface{ public: LocalHand(EngineFactory*, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int); - ~LocalHand(); void start(); @@ -89,13 +84,6 @@ public: void highlightRoundLabel(); void switchRounds(); - - - - - - - private: diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 5e5ef3ab..4392c4a4 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -18,8 +18,12 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "localplayer.h" - #include "localhand.h" +#include "tools.h" +#include "cardsvalue.h" +#include + +#include using namespace std; diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index 00bf7b48..d36daae0 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -20,17 +20,14 @@ #ifndef LOCALPLAYER_H #define LOCALPLAYER_H -#include "playerinterface.h" - -#include "cardsvalue.h" - -#include "configfile.h" +#include +#include #include -#include class CardsValue; +class ConfigFile; class HandInterface; class BoardInterface; diff --git a/src/engine/local_engine/localpreflop.cpp b/src/engine/local_engine/localpreflop.cpp index ea408bf9..d6cffce6 100755 --- a/src/engine/local_engine/localpreflop.cpp +++ b/src/engine/local_engine/localpreflop.cpp @@ -19,10 +19,10 @@ ***************************************************************************/ #include "localpreflop.h" -#include "handinterface.h" +#include #include -using namespace std; +//using namespace std; LocalPreflop::LocalPreflop(HandInterface* bR, int id, int qP, int dP, int sB) : PreflopInterface(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0) @@ -86,7 +86,6 @@ void LocalPreflop::preflopRun() { myHand->getGuiInterface()->refreshAction(); myHand->switchRounds(); - } else { // Preflop ist wirklich dran diff --git a/src/engine/local_engine/localpreflop.h b/src/engine/local_engine/localpreflop.h index 5fb7900f..b4fcb618 100755 --- a/src/engine/local_engine/localpreflop.h +++ b/src/engine/local_engine/localpreflop.h @@ -20,18 +20,15 @@ #ifndef LOCALPREFLOP_H #define LOCALPREFLOP_H -#include "preflopinterface.h" - -#include +#include class HandInterface; class LocalPreflop : public PreflopInterface{ public: - LocalPreflop(HandInterface*, int, int, int, int); - - ~LocalPreflop(); + LocalPreflop(HandInterface*, int, int, int, int); + ~LocalPreflop(); void setPlayersTurn(const int& theValue) { playersTurn = theValue; } diff --git a/src/engine/local_engine/localriver.cpp b/src/engine/local_engine/localriver.cpp index e7952f21..e11546c6 100755 --- a/src/engine/local_engine/localriver.cpp +++ b/src/engine/local_engine/localriver.cpp @@ -18,8 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "localriver.h" +#include #include +#include using namespace std; @@ -84,7 +86,6 @@ void LocalRiver::riverRun() { myHand->getGuiInterface()->refreshAction(); myHand->switchRounds(); - } else { // River ist wirklich dran diff --git a/src/engine/local_engine/localriver.h b/src/engine/local_engine/localriver.h index 963c4cf4..9c1807c1 100755 --- a/src/engine/local_engine/localriver.h +++ b/src/engine/local_engine/localriver.h @@ -20,18 +20,15 @@ #ifndef LOCALRIVER_H #define LOCALRIVER_H -#include "riverinterface.h" +#include -#include +class HandInterface; -#include "handinterface.h" class LocalRiver : public RiverInterface{ - public: - LocalRiver(HandInterface*, int, int, int, int); - - ~LocalRiver(); + LocalRiver(HandInterface*, int, int, int, int); + ~LocalRiver(); void setPlayersTurn(const int& theValue) { playersTurn = theValue; } int getPlayersTurn() const { return playersTurn; } diff --git a/src/engine/local_engine/localturn.cpp b/src/engine/local_engine/localturn.cpp index 537da1a2..4e925bdd 100755 --- a/src/engine/local_engine/localturn.cpp +++ b/src/engine/local_engine/localturn.cpp @@ -18,10 +18,11 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "localturn.h" +#include #include -using namespace std; +//using namespace std; LocalTurn::LocalTurn(HandInterface* bR, int id, int qP, int dP, int sB) : TurnInterface(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstTurnRun(1), firstTurnRound(1), playersTurn(dP) @@ -85,7 +86,6 @@ void LocalTurn::turnRun() { myHand->getGuiInterface()->refreshAction(); myHand->switchRounds(); - } else { // Turn ist wirklich dran diff --git a/src/engine/local_engine/localturn.h b/src/engine/local_engine/localturn.h index a97d48ad..853fa0cc 100755 --- a/src/engine/local_engine/localturn.h +++ b/src/engine/local_engine/localturn.h @@ -20,18 +20,14 @@ #ifndef LOCALTURN_H #define LOCALTURN_H -#include "turninterface.h" +#include -#include "handinterface.h" - -#include +class HandInterface; class LocalTurn : public TurnInterface{ - public: - LocalTurn(HandInterface*, int, int, int, int); - - ~LocalTurn(); + LocalTurn(HandInterface*, int, int, int, int); + ~LocalTurn(); void setPlayersTurn(const int& theValue) { playersTurn = theValue; } int getPlayersTurn() const { return playersTurn; } diff --git a/src/game.cpp b/src/game.cpp index 296b78cc..e566b16a 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -20,13 +20,9 @@ #include "game.h" #include "gamedata.h" -#include "enginefactory.h" -#include "localenginefactory.h" - -#include "guiinterface.h" -#include "boardinterface.h" -#include "playerinterface.h" -#include "handinterface.h" +#include +#include +#include using namespace std; diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 7c9aa72a..56f9de04 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -81,8 +81,6 @@ public: // virtual void postRiverAnimation2()=0; virtual void flipHolecardsAllIn()=0; -// virtual void handSwitchRounds() const=0; -// // virtual void startNewHand() const=0; virtual void nextRoundCleanGui()=0; // diff --git a/src/net/common/serverrecvstate.cpp b/src/net/common/serverrecvstate.cpp index 348c3860..4afbd7ef 100644 --- a/src/net/common/serverrecvstate.cpp +++ b/src/net/common/serverrecvstate.cpp @@ -318,41 +318,24 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server) Game &curGame = server.GetGame(); curGame.getCurrentHand()->switchRounds(); - int playersTurn = 0; - // TODO: no switch needed here if game states are polymorphic - switch(curGame.getCurrentHand()->getActualRound()) { - case 0: { - // Preflop starten - curGame.getCurrentHand()->getPreflop()->preflopRun(); - playersTurn = curGame.getCurrentHand()->getPreflop()->getPlayersTurn(); - } break; - case 1: { - // Flop starten - curGame.getCurrentHand()->getFlop()->flopRun(); - playersTurn = curGame.getCurrentHand()->getFlop()->getPlayersTurn(); - } break; - case 2: { - // Turn starten - curGame.getCurrentHand()->getTurn()->turnRun(); - playersTurn = curGame.getCurrentHand()->getTurn()->getPlayersTurn(); - } break; - case 3: { - // River starten - curGame.getCurrentHand()->getRiver()->riverRun(); - playersTurn = curGame.getCurrentHand()->getRiver()->getPlayersTurn(); - } break; - default: { - // TODO - } - } + // Call main loop - if state changes, call again. + int newRound = curGame.getCurrentHand()->getActualRound(); + int curRound; + do + { + curRound = newRound; + GameRun(curGame, curRound); + newRound = curGame.getCurrentHand()->getActualRound(); + } while (newRound != curRound); - assert(playersTurn < curGame.getActualQuantityPlayers()); + // Retrieve current player. + PlayerInterface *curPlayer = GetCurrentPlayer(curGame); boost::shared_ptr notification(new NetPacketPlayersTurn); NetPacketPlayersTurn::Data playersTurnData; playersTurnData.gameState = (GameState)curGame.getCurrentHand()->getActualRound(); - playersTurnData.playerId = curGame.getPlayerArray()[playersTurn]->getMyUniqueID(); + playersTurnData.playerId = curPlayer->getMyUniqueID(); static_cast(notification.get())->SetData(playersTurnData); server.SendToAllPlayers(notification); @@ -362,6 +345,60 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server) return MSG_NET_GAME_SERVER_ROUND; } +void +ServerRecvStateStartRound::GameRun(Game &curGame, int state) +{ + // TODO: no switch needed here if game states are polymorphic + switch(state) { + case 0: { + // Preflop starten + curGame.getCurrentHand()->getPreflop()->preflopRun(); + } break; + case 1: { + // Flop starten + curGame.getCurrentHand()->getFlop()->flopRun(); + } break; + case 2: { + // Turn starten + curGame.getCurrentHand()->getTurn()->turnRun(); + } break; + case 3: { + // River starten + curGame.getCurrentHand()->getRiver()->riverRun(); + } break; + default: { + // TODO + } + } +} + +PlayerInterface * +ServerRecvStateStartRound::GetCurrentPlayer(Game &curGame) +{ + int curPlayerNum = 0; + // TODO: no switch needed here if game states are polymorphic + switch(curGame.getCurrentHand()->getActualRound()) { + case 0: { + curPlayerNum = curGame.getCurrentHand()->getPreflop()->getPlayersTurn(); + } break; + case 1: { + curPlayerNum = curGame.getCurrentHand()->getFlop()->getPlayersTurn(); + } break; + case 2: { + curPlayerNum = curGame.getCurrentHand()->getTurn()->getPlayersTurn(); + } break; + case 3: { + curPlayerNum = curGame.getCurrentHand()->getRiver()->getPlayersTurn(); + } break; + default: { + // TODO + } + } + assert(curPlayerNum < curGame.getActualQuantityPlayers()); + return curGame.getPlayerArray()[curPlayerNum]; +} + + //----------------------------------------------------------------------------- ServerRecvStateFinal & diff --git a/src/net/serverrecvstate.h b/src/net/serverrecvstate.h index 4b649d9c..c594129a 100644 --- a/src/net/serverrecvstate.h +++ b/src/net/serverrecvstate.h @@ -27,6 +27,8 @@ #define SERVER_INITIAL_STATE ServerRecvStateInit #define SERVER_START_GAME_STATE ServerRecvStateStartGame +class Game; +class PlayerInterface; class ServerRecvThread; class ServerCallback; @@ -128,6 +130,9 @@ protected: // Protected constructor - this is a singleton. ServerRecvStateStartRound(); + + void GameRun(Game &curGame, int state); + PlayerInterface *GetCurrentPlayer(Game &curGame); }; // State: Final.