From c8207f9b8ee30be19c5026175d4d768023308f67 Mon Sep 17 00:00:00 2001 From: doitux Date: Mon, 6 Aug 2007 22:39:46 +0000 Subject: [PATCH] BeRo refactoring --- src/engine/enginefactory.h | 7 +----- src/engine/local_engine/localberoflop.cpp | 17 +++++--------- src/engine/local_engine/localberoriver.cpp | 9 -------- src/engine/local_engine/localberoturn.cpp | 9 -------- .../local_engine/localenginefactory.cpp | 22 +++++++++++++++++++ src/engine/local_engine/localenginefactory.h | 1 + src/engine/local_engine/localhand.cpp | 6 +---- .../network_engine/clientenginefactory.cpp | 18 +++++++++++++++ .../network_engine/clientenginefactory.h | 3 ++- 9 files changed, 51 insertions(+), 41 deletions(-) diff --git a/src/engine/enginefactory.h b/src/engine/enginefactory.h index e3e8aea2..76c398b3 100644 --- a/src/engine/enginefactory.h +++ b/src/engine/enginefactory.h @@ -47,12 +47,7 @@ public: virtual RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB) =0; // virtual BeRoInterface* createBeRo() =0; virtual BeRoFactoryInterface* createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB) =0; + virtual std::vector > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) =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/local_engine/localberoflop.cpp b/src/engine/local_engine/localberoflop.cpp index 4194312c..c1e06779 100644 --- a/src/engine/local_engine/localberoflop.cpp +++ b/src/engine/local_engine/localberoflop.cpp @@ -48,23 +48,26 @@ LocalBeRoFlop::~LocalBeRoFlop() void LocalBeRoFlop::run() { cout << "LocalBeroFlopRun!!!" << endl; - + int i; if (firstFlopRun) { + myHand->getGuiInterface()->dealFlopCards(); firstFlopRun = 0; - + } else { //log the turned cards if(!logBoardCardsDone) { + int tempBoardCardsArray[5]; - + myHand->getBoard()->getMyCards(tempBoardCardsArray); myHand->getGuiInterface()->logDealBoardCardsMsg(1, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]); logBoardCardsDone = 1; + } bool allHighestSet = 1; @@ -76,8 +79,6 @@ void LocalBeRoFlop::run() { } } -// cout << "firstflopround " << firstFlopRound << endl; - // prfen, ob Flop wirklich dran ist if(!firstFlopRound && allHighestSet) { @@ -127,21 +128,15 @@ void LocalBeRoFlop::run() { myHand->getGuiInterface()->refreshGroupbox(playersTurn,2); myHand->getGuiInterface()->refreshAction(playersTurn,0); -// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl; -// cout << "playersTurn " << playersTurn << endl; - // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstFlopRound = 0; } if(playersTurn == 0) { // Wir sind dran -// cout << "actualRound " << myHand->getActualRound() << endl; -// cout << "highestSet vor meInAction " << highestSet << endl; myHand->getGuiInterface()->meInAction(); } else { //Gegner sind dran -// cout << "NextPlayerSpeed3 start" << endl; myHand->getGuiInterface()->flopAnimation2(); } } diff --git a/src/engine/local_engine/localberoriver.cpp b/src/engine/local_engine/localberoriver.cpp index 7189ff31..7d3506fb 100644 --- a/src/engine/local_engine/localberoriver.cpp +++ b/src/engine/local_engine/localberoriver.cpp @@ -71,13 +71,9 @@ void LocalBeRoRiver::run() { // prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 ) for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) { -// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl; if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } } } -// cout << "allHighestSet " << allHighestSet << endl; - -// cout << "firstflopround " << firstRiverRound << endl; // prfen, ob River wirklich dran ist if(!firstRiverRound && allHighestSet) { @@ -99,7 +95,6 @@ void LocalBeRoRiver::run() { myHand->getGuiInterface()->refreshCash(); for(i=0; igetGuiInterface()->refreshAction(i,0); } - myHand->switchRounds(); } else { @@ -129,15 +124,11 @@ void LocalBeRoRiver::run() { myHand->getGuiInterface()->refreshGroupbox(playersTurn,2); myHand->getGuiInterface()->refreshAction(playersTurn,0); -// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl; -// cout << "playersTurn " << playersTurn << endl; // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; } if(playersTurn == 0) { // Wir sind dran -// cout << "actualRound " << myHand->getActualRound() << endl; -// cout << "highestSet vor meInAction " << highestSet << endl; myHand->getGuiInterface()->meInAction(); } else { diff --git a/src/engine/local_engine/localberoturn.cpp b/src/engine/local_engine/localberoturn.cpp index a7fe85b8..f006b40d 100644 --- a/src/engine/local_engine/localberoturn.cpp +++ b/src/engine/local_engine/localberoturn.cpp @@ -72,13 +72,9 @@ void LocalBeRoTurn::run() { // prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 ) for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) { -// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl; if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } } } -// cout << "allHighestSet " << allHighestSet << endl; - -// cout << "firstflopround " << firstTurnRound << endl; // prfen, ob Turn wirklich dran ist if(!firstTurnRound && allHighestSet) { @@ -129,20 +125,15 @@ void LocalBeRoTurn::run() { myHand->getGuiInterface()->refreshGroupbox(playersTurn,2); myHand->getGuiInterface()->refreshAction(playersTurn,0); -// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl; -// cout << "playersTurn " << playersTurn << endl; // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstTurnRound = 0; } if(playersTurn == 0) { // Wir sind dran -// cout << "actualRound " << myHand->getActualRound() << endl; -// cout << "highestSet vor meInAction " << highestSet << endl; myHand->getGuiInterface()->meInAction(); } else { //Gegner sind dran -// cout << "NextPlayerSpeed3 start" << endl; myHand->getGuiInterface()->turnAnimation2(); } } diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index 13c0baff..81846726 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -27,6 +27,11 @@ #include "localturn.h" #include "localriver.h" #include "localberofactory.h" +#include "localberopreflop.h" +#include "localberoflop.h" +#include "localberoturn.h" +#include "localberoriver.h" +#include "localberopostriver.h" #include @@ -58,3 +63,20 @@ RiverInterface* LocalEngineFactory::createRiver(HandInterface* hi, int id, int a BeRoFactoryInterface* LocalEngineFactory::createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalBeRoFactory(hi, id, aP, dP, sB); } +std::vector > LocalEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) { + + std::vector > myBeRo; + + myBeRo.push_back(boost::shared_ptr(new LocalBeRoPreflop(hi, id, aP, dP, sB))); + + myBeRo.push_back(boost::shared_ptr(new LocalBeRoFlop(hi, id, aP, dP, sB))); + + myBeRo.push_back(boost::shared_ptr(new LocalBeRoTurn(hi, id, aP, dP, sB))); + + myBeRo.push_back(boost::shared_ptr(new LocalBeRoRiver(hi, id, aP, dP, sB))); + + myBeRo.push_back(boost::shared_ptr(new LocalBeRoPostRiver(hi, id, aP, dP, sB))); + + return myBeRo; + +} diff --git a/src/engine/local_engine/localenginefactory.h b/src/engine/local_engine/localenginefactory.h index e1ab7180..4bcc41d4 100644 --- a/src/engine/local_engine/localenginefactory.h +++ b/src/engine/local_engine/localenginefactory.h @@ -47,6 +47,7 @@ public: TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB); RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB); BeRoFactoryInterface* createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB); + std::vector > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB); private: ConfigFile *myConfig; diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 2a9803f3..51a5ea60 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -165,11 +165,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI // Dealer, SB, BB bestimmen assignButtons(); - myBeRoFactory = myFactory->createBeRoFactory(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); - - int currentRound = actualRound; // for Lothar ;-) - - myBeRo = myBeRoFactory->createBeRo(); + myBeRo = myFactory->createBeRo(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); } diff --git a/src/engine/network_engine/clientenginefactory.cpp b/src/engine/network_engine/clientenginefactory.cpp index c869c069..f6e9b6cc 100644 --- a/src/engine/network_engine/clientenginefactory.cpp +++ b/src/engine/network_engine/clientenginefactory.cpp @@ -79,3 +79,21 @@ BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory(HandInterface* hi, return new ClientBeRoFactory(hi, id, aP, dP, sB); } +std::vector > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) { + + std::vector > myBeRo; + + myBeRo.push_back(boost::shared_ptr(new ClientBeRoPreflop(hi, id, aP, dP, sB))); + + myBeRo.push_back(boost::shared_ptr(new ClientBeRoFlop(hi, id, aP, dP, sB))); + + myBeRo.push_back(boost::shared_ptr(new ClientBeRoTurn(hi, id, aP, dP, sB))); + + myBeRo.push_back(boost::shared_ptr(new ClientBeRoRiver(hi, id, aP, dP, sB))); + +// myBeRo.push_back(boost::shared_ptr(new ClientBeRoPostRiver(hi, id, aP, dP, sB))); + + return myBeRo; + +} + diff --git a/src/engine/network_engine/clientenginefactory.h b/src/engine/network_engine/clientenginefactory.h index 41bff97c..4544dc2e 100644 --- a/src/engine/network_engine/clientenginefactory.h +++ b/src/engine/network_engine/clientenginefactory.h @@ -28,7 +28,7 @@ #include #include #include -#include +// #include class ConfigFile; @@ -47,6 +47,7 @@ public: TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB); RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB); BeRoFactoryInterface* createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB); + std::vector > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB); };