diff --git a/pokerth.pro b/pokerth.pro index a914bc48..ff465f60 100755 --- a/pokerth.pro +++ b/pokerth.pro @@ -104,6 +104,7 @@ HEADERS += src/game.h \ src/engine/local_engine/localhand.h \ src/engine/local_engine/localplayer.h \ src/engine/local_engine/localpreflop.h \ + src/engine/local_engine/localberopreflop.h \ src/engine/local_engine/localriver.h \ src/engine/local_engine/localturn.h \ src/engine/local_engine/tools.h \ @@ -185,7 +186,8 @@ SOURCES += src/game.cpp \ src/engine/local_engine/localhand.cpp \ src/engine/local_engine/localplayer.cpp \ src/engine/local_engine/localpreflop.cpp \ - src/engine/local_engine/localriver.cpp \ + src/engine/local_engine/localberopreflop.cpp \ + src/engine/local_engine/localriver.cpp \ src/engine/local_engine/localturn.cpp \ src/engine/local_engine/tools.cpp \ src/engine/local_engine/localbero.cpp \ diff --git a/src/engine/berofactoryinterface.cpp b/src/engine/berofactoryinterface.cpp index 60ec14d9..4d3f27ae 100644 --- a/src/engine/berofactoryinterface.cpp +++ b/src/engine/berofactoryinterface.cpp @@ -11,11 +11,6 @@ // #include "berofactoryinterface.h" -BeRoFactoryInterface::BeRoFactoryInterface() -{ -} - - BeRoFactoryInterface::~BeRoFactoryInterface() { } diff --git a/src/engine/berofactoryinterface.h b/src/engine/berofactoryinterface.h index 01b0e656..99ba2f12 100644 --- a/src/engine/berofactoryinterface.h +++ b/src/engine/berofactoryinterface.h @@ -15,11 +15,15 @@ /** @author FThauer FHammer */ + +#include + class BeRoFactoryInterface{ public: - BeRoFactoryInterface(); - ~BeRoFactoryInterface(); + virtual ~BeRoFactoryInterface(); + + virtual BeRoInterface* switchRounds() = 0; }; diff --git a/src/engine/berointerface.cpp b/src/engine/berointerface.cpp index fab3f92e..30976630 100644 --- a/src/engine/berointerface.cpp +++ b/src/engine/berointerface.cpp @@ -11,10 +11,6 @@ // #include "berointerface.h" -BeRoInterface::BeRoInterface() -{ -} - BeRoInterface::~BeRoInterface() { diff --git a/src/engine/berointerface.h b/src/engine/berointerface.h index 54b7cb83..e7f37408 100644 --- a/src/engine/berointerface.h +++ b/src/engine/berointerface.h @@ -17,9 +17,20 @@ */ class BeRoInterface{ public: - BeRoInterface(); - ~BeRoInterface(); + virtual ~BeRoInterface(); + + virtual void setPlayersTurn(int) =0; + virtual int getPlayersTurn() const =0; + + virtual void setHighestSet(int) =0; + virtual int getHighestSet() const =0; + + virtual void setPreflopFirstRound(bool) =0; + virtual bool setPreflopFirstRound() const =0; + + virtual void preflopRun() =0; + virtual void nextPlayer2() =0; }; diff --git a/src/engine/enginefactory.h b/src/engine/enginefactory.h index c49c4e28..fda370f3 100644 --- a/src/engine/enginefactory.h +++ b/src/engine/enginefactory.h @@ -45,8 +45,14 @@ public: virtual FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB) =0; virtual TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB) =0; virtual RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB) =0; - virtual BeRoInterface* createBeRo() =0; - virtual BeRoFactoryInterface* createBeRoFactory() =0; +// virtual BeRoInterface* createBeRo() =0; + virtual BeRoFactoryInterface* createBeRoFactory(HandInterface* hi) =0; }; #endif + +// The following code introduces the new BeRo interface step by step. This hint will be removed if refactorying was succesfull // + + + +// new BeRo Interface code stop here // diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index 0f5836c3..028b2c89 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -27,6 +27,7 @@ #include "flopinterface.h" #include "turninterface.h" #include "riverinterface.h" +#include "berointerface.h" class HandInterface{ public: @@ -37,7 +38,7 @@ public: virtual PlayerInterface** getPlayerArray() const =0; virtual BoardInterface* getBoard() const =0; - virtual PreflopInterface* getPreflop() const =0; + virtual BeRoInterface* getPreflop() const =0; virtual FlopInterface* getFlop() const =0; virtual TurnInterface* getTurn() const =0; virtual RiverInterface* getRiver() const =0; diff --git a/src/engine/local_engine/localberofactory.cpp b/src/engine/local_engine/localberofactory.cpp index ba2a38fb..f4ac46d0 100644 --- a/src/engine/local_engine/localberofactory.cpp +++ b/src/engine/local_engine/localberofactory.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: localberofactory // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -11,14 +11,23 @@ // #include "localberofactory.h" -LocalBeRoFactory::LocalBeRoFactory() - : BeRoFactoryInterface() -{ -} +LocalBeRoFactory::LocalBeRoFactory ( HandInterface* hi ) + : BeRoFactoryInterface() , myHand ( hi ) +{} LocalBeRoFactory::~LocalBeRoFactory() +{} + +BeRoInterface* LocalBeRoFactory::switchRounds() { + + BeRoInterface* myBeRo = 0; + + myBeRo = new LocalBeRoPreflop ( myHand, 0, 7, 0, 10 ); + + return myBeRo; } + diff --git a/src/engine/local_engine/localberofactory.h b/src/engine/local_engine/localberofactory.h index 84b2a380..c71fd532 100644 --- a/src/engine/local_engine/localberofactory.h +++ b/src/engine/local_engine/localberofactory.h @@ -13,6 +13,9 @@ #define LOCALBEROFACTORY_H #include +#include +#include +#include /** @author FThauer FHammer @@ -20,10 +23,16 @@ class LocalBeRoFactory : public BeRoFactoryInterface { public: - LocalBeRoFactory(); + LocalBeRoFactory(HandInterface* hi); ~LocalBeRoFactory(); + BeRoInterface* switchRounds(); + +private: + + HandInterface* myHand; + }; #endif diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index d21b04a5..d9f202ee 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -57,7 +57,7 @@ TurnInterface* LocalEngineFactory::createTurn(HandInterface* hi, int id, int aP, RiverInterface* LocalEngineFactory::createRiver(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalRiver(hi, id, aP, dP, sB); } -BeRoInterface* LocalEngineFactory::createBeRo() { return new LocalBeRo(); } +// BeRoInterface* LocalEngineFactory::createBeRo() { return new LocalBeRo(); } -BeRoFactoryInterface* LocalEngineFactory::createBeRoFactory() { return new LocalBeRoFactory(); } +BeRoFactoryInterface* LocalEngineFactory::createBeRoFactory(HandInterface* hi) { return new LocalBeRoFactory(hi); } diff --git a/src/engine/local_engine/localenginefactory.h b/src/engine/local_engine/localenginefactory.h index bd09bc3e..fd23a939 100644 --- a/src/engine/local_engine/localenginefactory.h +++ b/src/engine/local_engine/localenginefactory.h @@ -29,7 +29,7 @@ #include #include #include -#include +// #include #include class ConfigFile; @@ -47,8 +47,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); - BeRoInterface* createBeRo(); - BeRoFactoryInterface* createBeRoFactory(); +// BeRoInterface* createBeRo(); + BeRoFactoryInterface* createBeRoFactory(HandInterface* hi); private: ConfigFile *myConfig; diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index b3a36604..756aa3c6 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -172,7 +172,8 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI myTurn = myFactory->createTurn(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); myRiver = myFactory->createRiver(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); - myBeRo = myFactory->createBeRo(); + myBeRoFactory = myFactory->createBeRoFactory(this); + myBeRo = myBeRoFactory->switchRounds(); } @@ -324,7 +325,7 @@ void LocalHand::switchRounds() { if(playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyAction() != 6 && playerArray[i]->getMyActiveStatus() == 1) { tempHighestSet = 0; switch (actualRound) { - case 0: {tempHighestSet = myPreflop->getHighestSet();} + case 0: {tempHighestSet = myBeRo->getHighestSet();} break; case 1: {tempHighestSet = myFlop->getHighestSet();} break; diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index df163e6f..561cffb4 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -30,6 +30,7 @@ #include #include #include +#include class LocalHand : public HandInterface{ @@ -41,7 +42,7 @@ public: PlayerInterface** getPlayerArray() const { return playerArray; } BoardInterface* getBoard() const { return myBoard; } - PreflopInterface* getPreflop() const { return myPreflop; } + BeRoInterface* getPreflop() const { return myBeRo; } FlopInterface* getFlop() const { return myFlop; } TurnInterface* getTurn() const { return myTurn; } RiverInterface* getRiver() const { return myRiver; } @@ -99,6 +100,7 @@ private: TurnInterface *myTurn; RiverInterface *myRiver; BeRoInterface *myBeRo; + BeRoFactoryInterface *myBeRoFactory; int myID; int actualQuantityPlayers; diff --git a/src/engine/network_engine/clientberofactory.cpp b/src/engine/network_engine/clientberofactory.cpp index 7afb50c5..a8b6fac2 100644 --- a/src/engine/network_engine/clientberofactory.cpp +++ b/src/engine/network_engine/clientberofactory.cpp @@ -11,7 +11,7 @@ // #include "clientberofactory.h" -ClientBeRoFactory::ClientBeRoFactory() +ClientBeRoFactory::ClientBeRoFactory(HandInterface* hi) : BeRoFactoryInterface() { } @@ -22,3 +22,4 @@ ClientBeRoFactory::~ClientBeRoFactory() } +BeRoInterface* ClientBeRoFactory::switchRounds() {} diff --git a/src/engine/network_engine/clientberofactory.h b/src/engine/network_engine/clientberofactory.h index e9ca2ef7..427ca025 100644 --- a/src/engine/network_engine/clientberofactory.h +++ b/src/engine/network_engine/clientberofactory.h @@ -13,6 +13,7 @@ #define CLIENTBEROFACTORY_H #include +#include /** @author FThauer FHammer @@ -20,10 +21,12 @@ class ClientBeRoFactory : public BeRoFactoryInterface { public: - ClientBeRoFactory(); + ClientBeRoFactory(HandInterface* hi); ~ClientBeRoFactory(); + BeRoInterface* switchRounds(); + }; #endif diff --git a/src/engine/network_engine/clientenginefactory.cpp b/src/engine/network_engine/clientenginefactory.cpp index c33b44a7..500fce29 100644 --- a/src/engine/network_engine/clientenginefactory.cpp +++ b/src/engine/network_engine/clientenginefactory.cpp @@ -75,12 +75,12 @@ RiverInterface* ClientEngineFactory::createRiver(HandInterface* hi, int id, int return new ClientRiver(hi, id, aP, dP, sB); } -BeRoInterface* ClientEngineFactory::createBeRo() -{ - return new ClientBeRo(); -} +// BeRoInterface* ClientEngineFactory::createBeRo() +// { +// return new ClientBeRo(); +// } -BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory() +BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory(HandInterface* hi) { - return new ClientBeRoFactory(); + return new ClientBeRoFactory(hi); } diff --git a/src/engine/network_engine/clientenginefactory.h b/src/engine/network_engine/clientenginefactory.h index f3bb838b..70d1bfc3 100644 --- a/src/engine/network_engine/clientenginefactory.h +++ b/src/engine/network_engine/clientenginefactory.h @@ -28,7 +28,7 @@ #include #include #include -#include +// #include #include @@ -47,8 +47,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); - BeRoInterface* createBeRo(); - BeRoFactoryInterface* createBeRoFactory(); +// BeRoInterface* createBeRo(); + BeRoFactoryInterface* createBeRoFactory(HandInterface* hi); }; diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index 32eccc6f..c549d9bb 100644 --- a/src/engine/network_engine/clienthand.cpp +++ b/src/engine/network_engine/clienthand.cpp @@ -84,10 +84,10 @@ ClientHand::getBoard() const return myBoard; } -PreflopInterface* +BeRoInterface* ClientHand::getPreflop() const { - return myPreflop; + return myBeRo; } FlopInterface* diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index 7e89acdd..8f4993b6 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -41,7 +42,7 @@ public: PlayerInterface** getPlayerArray() const; BoardInterface* getBoard() const; - PreflopInterface* getPreflop() const; + BeRoInterface* getPreflop() const; FlopInterface* getFlop() const; TurnInterface* getTurn() const; RiverInterface* getRiver() const; @@ -97,6 +98,7 @@ private: FlopInterface *myFlop; TurnInterface *myTurn; RiverInterface *myRiver; + BeRoInterface *myBeRo; int myID; int actualQuantityPlayers;