diff --git a/src/engine/enginefactory.h b/src/engine/enginefactory.h index 34d00cdf..4e6fcb09 100644 --- a/src/engine/enginefactory.h +++ b/src/engine/enginefactory.h @@ -36,7 +36,7 @@ public: virtual HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) =0; virtual BoardInterface* createBoard() =0; virtual boost::shared_ptr createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0; - virtual std::vector > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) =0; + virtual std::vector > createBeRo(HandInterface* hi, int id, int dP, int sB) =0; }; #endif diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index 7d96698b..55fa232b 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -37,6 +37,9 @@ public: virtual void start() = 0; virtual std::vector > getPlayerArray() const =0; + virtual PlayerList getActivePlayerList() const =0; + virtual PlayerList getRunningPlayerList() const =0; + virtual BoardInterface* getBoard() const =0; virtual boost::shared_ptr getPreflop() const =0; virtual boost::shared_ptr getFlop() const =0; @@ -48,9 +51,6 @@ public: virtual void setMyID(int theValue) =0; virtual int getMyID() const =0; - virtual void setActualQuantityPlayers(int theValue) =0; - virtual int getActualQuantityPlayers() const =0; - virtual void setStartQuantityPlayers(int theValue) =0; virtual int getStartQuantityPlayers() const =0; @@ -69,9 +69,6 @@ public: virtual void setStartCash(int theValue) =0; virtual int getStartCash() const =0; - virtual void setActivePlayersCounter(int theValue) =0; - virtual int getActivePlayersCounter() const =0; - virtual void setBettingRoundsPlayed(int theValue) =0; virtual int getBettingRoundsPlayed() const =0; diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index ae4f3747..cac06181 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -13,8 +13,8 @@ using namespace std; -LocalBeRo::LocalBeRo(HandInterface* hi, int id, int qP, int dP, int sB, GameState gS) -: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), firstRun(1), firstRound(1), firstHeadsUpRound(1), playersTurn(dP), logBoardCardsDone(0) +LocalBeRo::LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS) +: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), firstRun(1), firstRound(1), firstHeadsUpRound(1), playersTurn(dP), logBoardCardsDone(0) { int i; @@ -145,8 +145,8 @@ void LocalBeRo::run() { // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende // ausnahme bei heads up !!! --> TODO - if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind && myHand->getActualQuantityPlayers() >= 3) { firstRound = 0; } - if(myHand->getActualQuantityPlayers() < 3 && (myHand->getPlayerArray()[playersTurn]->getMyID() == dealerPosition || myHand->getPlayerArray()[playersTurn]->getMyID() == smallBlindPosition)) { firstRound = 0; } + if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind && myHand->getActivePlayerList().size() >= 3) { firstRound = 0; } + if(myHand->getActivePlayerList().size() < 3 && (myHand->getPlayerArray()[playersTurn]->getMyID() == dealerPosition || myHand->getPlayerArray()[playersTurn]->getMyID() == smallBlindPosition)) { firstRound = 0; } if(playersTurn == 0) { // Wir sind dran diff --git a/src/engine/local_engine/localbero.h b/src/engine/local_engine/localbero.h index 42fe9b32..5154b6af 100644 --- a/src/engine/local_engine/localbero.h +++ b/src/engine/local_engine/localbero.h @@ -24,7 +24,7 @@ */ class LocalBeRo : public BeRoInterface{ public: - LocalBeRo(HandInterface* hi, int id, int qP, int dP, int sB, GameState gS); + LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS); ~LocalBeRo(); GameState getMyBeRoID() const { return myBeRoID; } @@ -77,7 +77,6 @@ private: const GameState myBeRoID; int myID; - int actualQuantityPlayers; int dealerPosition; int smallBlindPosition; diff --git a/src/engine/local_engine/localberoflop.cpp b/src/engine/local_engine/localberoflop.cpp index ddd1f048..53dda8d8 100644 --- a/src/engine/local_engine/localberoflop.cpp +++ b/src/engine/local_engine/localberoflop.cpp @@ -24,7 +24,7 @@ using namespace std; -LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_FLOP) +LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_FLOP) { } diff --git a/src/engine/local_engine/localberoflop.h b/src/engine/local_engine/localberoflop.h index 0471ca1b..3b7eeee9 100644 --- a/src/engine/local_engine/localberoflop.h +++ b/src/engine/local_engine/localberoflop.h @@ -28,7 +28,7 @@ class HandInterface; class LocalBeRoFlop : public LocalBeRo{ public: - LocalBeRoFlop(HandInterface*, int, int, int, int); + LocalBeRoFlop(HandInterface*, int, int, int); ~LocalBeRoFlop(); }; diff --git a/src/engine/local_engine/localberopostriver.cpp b/src/engine/local_engine/localberopostriver.cpp index 97ce2246..b3e17457 100644 --- a/src/engine/local_engine/localberopostriver.cpp +++ b/src/engine/local_engine/localberopostriver.cpp @@ -25,7 +25,7 @@ using namespace std; -LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_POST_RIVER), highestCardsValue(0) +LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_POST_RIVER), highestCardsValue(0) { } @@ -49,7 +49,7 @@ void LocalBeRoPostRiver::postRiverRun() { } // Durchschnittsets des human player ermitteln - getMyHand()->getPlayerArray()[0]->setMyAverageSets(((getMyHand()->getPlayerArray()[0]->getMyRoundStartCash())-(getMyHand()->getPlayerArray()[0]->getMyCash()))/(getMyHand()->getBettingRoundsPlayed()+1)); +// getMyHand()->getPlayerArray()[0]->setMyAverageSets(((getMyHand()->getPlayerArray()[0]->getMyRoundStartCash())-(getMyHand()->getPlayerArray()[0]->getMyCash()))/(getMyHand()->getBettingRoundsPlayed()+1)); // Aggressivität des human player ermitteln // anzahl der player die möglichkeit haben am pot teilzuhaben diff --git a/src/engine/local_engine/localberopostriver.h b/src/engine/local_engine/localberopostriver.h index a6e4bde1..03a1e96f 100644 --- a/src/engine/local_engine/localberopostriver.h +++ b/src/engine/local_engine/localberopostriver.h @@ -28,7 +28,7 @@ class HandInterface; class LocalBeRoPostRiver : public LocalBeRo{ public: - LocalBeRoPostRiver(HandInterface*, int, int, int, int); + LocalBeRoPostRiver(HandInterface*, int, int, int); ~LocalBeRoPostRiver(); void setHighestCardsValue(int theValue) { highestCardsValue = theValue;} diff --git a/src/engine/local_engine/localberopreflop.cpp b/src/engine/local_engine/localberopreflop.cpp index ca999dac..809d6b95 100644 --- a/src/engine/local_engine/localberopreflop.cpp +++ b/src/engine/local_engine/localberopreflop.cpp @@ -24,7 +24,7 @@ using namespace std; -LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_PREFLOP), bigBlindPosition(0) +LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP), bigBlindPosition(0) { setHighestSet(2*getSmallBlind()); diff --git a/src/engine/local_engine/localberopreflop.h b/src/engine/local_engine/localberopreflop.h index 6cf9fb82..5e97c4c5 100644 --- a/src/engine/local_engine/localberopreflop.h +++ b/src/engine/local_engine/localberopreflop.h @@ -28,7 +28,7 @@ class HandInterface; class LocalBeRoPreflop : public LocalBeRo{ public: - LocalBeRoPreflop(HandInterface*, int, int, int, int); + LocalBeRoPreflop(HandInterface*, int, int, int); ~LocalBeRoPreflop(); void run(); diff --git a/src/engine/local_engine/localberoriver.cpp b/src/engine/local_engine/localberoriver.cpp index 593a409b..afcdd850 100644 --- a/src/engine/local_engine/localberoriver.cpp +++ b/src/engine/local_engine/localberoriver.cpp @@ -25,7 +25,7 @@ using namespace std; -LocalBeRoRiver::LocalBeRoRiver(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_RIVER) +LocalBeRoRiver::LocalBeRoRiver(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_RIVER) { } diff --git a/src/engine/local_engine/localberoriver.h b/src/engine/local_engine/localberoriver.h index cadd935e..b6335545 100644 --- a/src/engine/local_engine/localberoriver.h +++ b/src/engine/local_engine/localberoriver.h @@ -28,7 +28,7 @@ class HandInterface; class LocalBeRoRiver : public LocalBeRo{ public: - LocalBeRoRiver(HandInterface*, int, int, int, int); + LocalBeRoRiver(HandInterface*, int, int, int); ~LocalBeRoRiver(); }; diff --git a/src/engine/local_engine/localberoturn.cpp b/src/engine/local_engine/localberoturn.cpp index 4e5ddf54..de0652b0 100644 --- a/src/engine/local_engine/localberoturn.cpp +++ b/src/engine/local_engine/localberoturn.cpp @@ -24,7 +24,7 @@ using namespace std; -LocalBeRoTurn::LocalBeRoTurn(HandInterface* hi, int id, int qP, int dP, int sB) : LocalBeRo(hi, id, qP, dP, sB, GAME_STATE_TURN) +LocalBeRoTurn::LocalBeRoTurn(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_TURN) { } diff --git a/src/engine/local_engine/localberoturn.h b/src/engine/local_engine/localberoturn.h index c40c6905..be87b881 100644 --- a/src/engine/local_engine/localberoturn.h +++ b/src/engine/local_engine/localberoturn.h @@ -27,7 +27,7 @@ class HandInterface; class LocalBeRoTurn : public LocalBeRo{ public: - LocalBeRoTurn(HandInterface*, int, int, int, int); + LocalBeRoTurn(HandInterface*, int, int, int); ~LocalBeRoTurn(); }; diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index c27de3c8..fab9d61c 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -48,19 +48,19 @@ BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } boost::shared_ptr LocalEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) { return boost::shared_ptr (new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB)); } -std::vector > LocalEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) { +std::vector > LocalEngineFactory::createBeRo(HandInterface* hi, int id, 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 LocalBeRoPreflop(hi, id, dP, sB))); - myBeRo.push_back(boost::shared_ptr(new LocalBeRoFlop(hi, id, aP, dP, sB))); + myBeRo.push_back(boost::shared_ptr(new LocalBeRoFlop(hi, id, dP, sB))); - myBeRo.push_back(boost::shared_ptr(new LocalBeRoTurn(hi, id, aP, dP, sB))); + myBeRo.push_back(boost::shared_ptr(new LocalBeRoTurn(hi, id, dP, sB))); - myBeRo.push_back(boost::shared_ptr(new LocalBeRoRiver(hi, id, aP, dP, sB))); + myBeRo.push_back(boost::shared_ptr(new LocalBeRoRiver(hi, id, dP, sB))); - myBeRo.push_back(boost::shared_ptr(new LocalBeRoPostRiver(hi, id, aP, dP, sB))); + myBeRo.push_back(boost::shared_ptr(new LocalBeRoPostRiver(hi, id, dP, sB))); return myBeRo; diff --git a/src/engine/local_engine/localenginefactory.h b/src/engine/local_engine/localenginefactory.h index 0ed0db7d..6fc6d6c6 100644 --- a/src/engine/local_engine/localenginefactory.h +++ b/src/engine/local_engine/localenginefactory.h @@ -40,7 +40,7 @@ public: HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC); BoardInterface* createBoard(); boost::shared_ptr createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); - std::vector > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB); + std::vector > createBeRo(HandInterface* hi, int id, int dP, int sB); private: ConfigFile *myConfig; diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 04e49a76..c9473fac 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -27,11 +27,12 @@ using namespace std; LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) -: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0), +: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0), cardsShown(false), bettingRoundsPlayed(0) { int i, j, k; + PlayerList::iterator it; CardsValue myCardsValue; @@ -55,6 +56,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI int tempBoardArray[5]; int tempPlayerArray[2]; int tempPlayerAndBoardArray[7]; + int bestHandPos[5]; int sBluff; for(i=0; i<5; i++) { tempBoardArray[i] = cardsArray[i]; @@ -63,40 +65,37 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI k = 0; myBoard->setMyCards(tempBoardArray); - for(i=0; igetMyActiveStatus() != 0) { + for(it=activePlayerList.begin(); it!=activePlayerList.end(); it++, k++) { - int bestHandPos[5]; - playerArray[i]->getMyBestHandPosition(bestHandPos); + (*it)->getMyBestHandPosition(bestHandPos); - for(j=0; j<2; j++) { - tempPlayerArray[j] = cardsArray[2*k+j+5]; - tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5]; + for(j=0; j<2; j++) { + tempPlayerArray[j] = cardsArray[2*k+j+5]; + tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5]; + } + + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos)); + (*it)->setMyBestHandPosition(bestHandPos); + + // myBestHandPosition auf Fehler ueberpruefen + for(j=0; j<5; j++) { + if (bestHandPos[j] == -1) { + cout << "ERROR getMyBestHandPosition in localhand.cpp" << endl; } - playerArray[i]->setMyCards(tempPlayerArray); - playerArray[i]->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos)); - playerArray[i]->setMyBestHandPosition(bestHandPos); + } - // myBestHandPosition auf Fehler ueberpruefen - for(j=0; j<5; j++) { - if (bestHandPos[j] == -1) { - cout << "ERROR getMyBestHandPosition in localhand.cpp" << endl; - } - } - - // sBluff für alle aktiver Spieler außer human player setzen - if(i) { - Tools::getRandNumber(1,100,1,&sBluff,0); - playerArray[i]->setSBluff(sBluff); - playerArray[i]->setSBluffStatus(0); - } - - k++; + // sBluff für alle aktiver Spieler außer human player setzen + if(it!=activePlayerList.begin()) { + Tools::getRandNumber(1,100,1,&sBluff,0); + (*it)->setSBluff(sBluff); + (*it)->setSBluffStatus(0); } } + delete[] cardsArray; - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! DEBUGGER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if(DEBUG_MODE) { @@ -260,7 +259,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI // Dealer, SB, BB bestimmen assignButtons(); - myBeRo = myFactory->createBeRo(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); + myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind); } @@ -286,12 +285,7 @@ void LocalHand::start() { void LocalHand::assignButtons() { int i,j; - - //Aktive Spieler zählen - int activePlayersCounter = 0; - for (i=0; igetMyActiveStatus() == 1) activePlayersCounter++; - } + PlayerList::iterator it; // alle Buttons loeschen for (i=0; isetMyButton(0); } @@ -306,7 +300,7 @@ void LocalHand::assignButtons() { i = (i+1)%(MAX_NUMBER_OF_PLAYERS); if(playerArray[i]->getMyActiveStatus()) { - if(activePlayersCounter > 2) playerArray[i]->setMyButton(2); //small blind normal + if(activePlayerList.size() > 2) playerArray[i]->setMyButton(2); //small blind normal else playerArray[i]->setMyButton(3); //big blind in heads up } } @@ -316,41 +310,45 @@ void LocalHand::assignButtons() { i = (i+1)%(MAX_NUMBER_OF_PLAYERS); if(playerArray[i]->getMyActiveStatus()) { - if(activePlayersCounter > 2) playerArray[i]->setMyButton(3); //big blind normal + if(activePlayerList.size() > 2) playerArray[i]->setMyButton(3); //big blind normal else playerArray[i]->setMyButton(2); //small blind in heads up } } //do sets - for (i=0; igetMyButton() == 2) { //small blind - // mit SmallBlind All In ? - if(playerArray[i]->getMyCash() <= smallBlind) { + if((*it)->getMyButton() == 2) { - playerArray[i]->setMySet(playerArray[i]->getMyCash()); + // All in ? + if((*it)->getMyCash() <= smallBlind) { + + (*it)->setMySet((*it)->getMyCash()); // 1 to do not log this - playerArray[i]->setMyAction(6,1); + (*it)->setMyAction(6,1); + // delete this player from runningPlayerList + it = runningPlayerList.erase(it); } - // sonst - else { playerArray[i]->setMySet(smallBlind); } + else { (*it)->setMySet(smallBlind); } } - if(playerArray[i]->getMyButton() == 3) { //big blind - // mit BigBlind All In ? - if(playerArray[i]->getMyCash() <= 2*smallBlind) { + if((*it)->getMyButton() == 3) { - playerArray[i]->setMySet(playerArray[i]->getMyCash()); + // all in ? + if((*it)->getMyCash() <= 2*smallBlind) { + + (*it)->setMySet((*it)->getMyCash()); // 1 to do not log this - playerArray[i]->setMyAction(6,1); + (*it)->setMyAction(6,1); + // delete this player from runningPlayerList + it = runningPlayerList.erase(it); } - // sonst - else { playerArray[i]->setMySet(2*smallBlind); } + else { (*it)->setMySet(2*smallBlind); } } } @@ -359,25 +357,17 @@ void LocalHand::assignButtons() { void LocalHand::switchRounds() { - int i; - -// cout <<" ------- HandID: " << myID << " | actualround: " << actualRound << " ---------" << endl; - - //Aktive Spieler z�len - activePlayersCounter = 0; - for (i=0; igetMyAction() != 1 && playerArray[i]->getMyActiveStatus() == 1) activePlayersCounter++; - } + PlayerList::iterator it; // Anzahl der Spieler ermitteln, welche All In sind int allInPlayersCounter = 0; - for (i=0; igetMyAction() == 6) allInPlayersCounter++; + for (it=activePlayerList.begin(); it!=activePlayerList.end(); it++) { + if ((*it)->getMyAction() == 6) allInPlayersCounter++; } //wenn nur noch einer nicht-folded dann gleich den Pot verteilen - if(activePlayersCounter==1) { + if(activePlayerList.size()==1) { myBoard->collectPot(); myGui->refreshPot(); myGui->refreshSet(); @@ -387,31 +377,22 @@ void LocalHand::switchRounds() { // fr All In Prozedur mssen mindestens zwei aktive Player vorhanden sein else { -// cout << "activplayerscounter: " << activePlayersCounter << " | allInPlayersCounter: " << allInPlayersCounter << " | " << endl; - // 1) wenn alle All In - if(allInPlayersCounter == activePlayersCounter) { - allInCondition = 1; + if(allInPlayersCounter == activePlayerList.size()) { + allInCondition = true; } // 2) alle bis auf einen All In und der hat HighestSet - int tempHighestSet; - if(allInPlayersCounter+1 == activePlayersCounter) { - for (i=0; igetMyAction() != 1 && playerArray[i]->getMyAction() != 6 && playerArray[i]->getMyActiveStatus() == 1) { - tempHighestSet = 0; - tempHighestSet = myBeRo[actualRound]->getHighestSet(); -// cout << "tempHighestSet: " << tempHighestSet << "playerArray[i]->getMySet(): " << playerArray[i]->getMySet() << endl; - - if(playerArray[i]->getMySet() >= tempHighestSet) { - allInCondition = 1; - } + if(allInPlayersCounter+1 == activePlayerList.size()) { - } + if( (*(runningPlayerList.begin()))->getMySet() >= myBeRo[actualRound]->getHighestSet() ) { + allInCondition = 1; + } - // HeadsUp-Ausnahme -> spieler ermitteln, der all in ist und als bb nur weniger als sb setzen konnte - if(activePlayersCounter==2 && playerArray[i]->getMyAction() == 6 && playerArray[i]->getMyActiveStatus() == 1 && playerArray[i]->getMyButton()==3 && playerArray[i]->getMySet()<=smallBlind) { + // HeadsUp-Ausnahme -> spieler ermitteln, der all in ist und als bb nur weniger als sb setzen konnte + for(i=0; igetMyAction() == 6 && playerArray[i]->getMyActiveStatus() == 1 && playerArray[i]->getMyButton()==3 && playerArray[i]->getMySet()<=smallBlind) { allInCondition = 1; } @@ -439,7 +420,7 @@ void LocalHand::switchRounds() { } - //unhighlight actual players groupbox + //unhighlight current players groupbox if(playerArray[lastPlayersTurn]->getMyActiveStatus() == 1) myGui->refreshGroupbox(lastPlayersTurn,1); myGui->refreshGameLabels((GameState)getActualRound()); diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 521bff2f..d1f1fa15 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -40,6 +40,9 @@ public: void start(); std::vector > getPlayerArray() const { return playerArray; } + PlayerList getActivePlayerList() const {return activePlayerList;} + PlayerList getRunningPlayerList() const {return runningPlayerList;} + BoardInterface* getBoard() const { return myBoard; } boost::shared_ptr getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; } boost::shared_ptr getFlop() const { return myBeRo[GAME_STATE_FLOP]; } @@ -50,9 +53,6 @@ public: void setMyID(int theValue) { myID = theValue; } int getMyID() const { return myID; } - - void setActualQuantityPlayers(int theValue) { actualQuantityPlayers = theValue; } - int getActualQuantityPlayers() const { return actualQuantityPlayers; } void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } int getStartQuantityPlayers() const { return startQuantityPlayers; } @@ -71,9 +71,6 @@ public: void setStartCash(int theValue) { startCash = theValue; } int getStartCash() const { return startCash; } - - void setActivePlayersCounter(int theValue) { activePlayersCounter = theValue; } - int getActivePlayersCounter() const { return activePlayersCounter; } void setBettingRoundsPlayed(int theValue) { bettingRoundsPlayed = theValue; } int getBettingRoundsPlayed() const { return bettingRoundsPlayed; } @@ -102,13 +99,11 @@ private: std::vector > myBeRo; int myID; - int actualQuantityPlayers; int startQuantityPlayers; int dealerPosition; // -1 -> neutral int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river int smallBlind; int startCash; - int activePlayersCounter; int lastPlayersTurn; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index be42fba3..9503027b 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -987,7 +987,7 @@ void LocalPlayer::preflopEngine() { int cBluff; // temporär solange preflopValue und flopValue noch nicht bereinigt für sechs und sieben spieler - int players = actualHand->getActualQuantityPlayers(); + int players = actualHand->getActivePlayerList().size(); if(players > 5) players = 5; // myOdds auslesen @@ -1018,7 +1018,7 @@ void LocalPlayer::preflopEngine() { // cout << myID << ": " << myHoleCardsValue << " - " << myNiveau[0] << " " << myNiveau[2] << " - " << myCards[0] << " " << myCards[1] << endl; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActualQuantityPlayers())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); // cout << aggValue << " "; @@ -1122,7 +1122,7 @@ void LocalPlayer::preflopEngine() { // cout << sBluff << endl; // auf sBluff testen --> raise statt call oder fold - if((sBluff < 100/(((actualHand->getActualQuantityPlayers()-2)*6)+3) && myOdds < myNiveau[2] && actualHand->getCurrentBeRo()->getHighestSet() == 2*actualHand->getSmallBlind() && sBluffStatus == 0) || sBluffStatus == 1) { + if((sBluff < 100/(((actualHand->getActivePlayerList().size()-2)*6)+3) && myOdds < myNiveau[2] && actualHand->getCurrentBeRo()->getHighestSet() == 2*actualHand->getSmallBlind() && sBluffStatus == 0) || sBluffStatus == 1) { // cout << "sBLUFF!" << endl; sBluffStatus = 1; @@ -1143,7 +1143,7 @@ void LocalPlayer::preflopEngine() { // Standard-Raise-Routine else { // raise-Betrag ermitteln - raise = (sBluff/(8-actualHand->getActualQuantityPlayers()))*actualHand->getSmallBlind(); + raise = (sBluff/(8-actualHand->getActivePlayerList().size()))*actualHand->getSmallBlind(); // raise-Betrag zu klein -> mindestens Standard-raise // if(raise < actualHand->getCurrentBeRo()->getHighestSet()) { // raise = actualHand->getCurrentBeRo()->getHighestSet(); @@ -1255,7 +1255,7 @@ void LocalPlayer::flopEngine() { int rand; // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = actualHand->getActualQuantityPlayers(); + int players = actualHand->getActivePlayerList().size(); if(players > 5) players = 5; calcMyOdds(); @@ -1273,7 +1273,7 @@ void LocalPlayer::flopEngine() { if(individualHighestSet > myCash) individualHighestSet = myCash; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActualQuantityPlayers())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); if(actualHand->getPlayerArray()[0]->getMyActiveStatus() && actualHand->getPlayerArray()[0]->getMyAction() != 1) { for(i=0; i<3; i++) { @@ -1716,7 +1716,7 @@ void LocalPlayer::flopEngine() { // switch(info[3]) { // case 2: {} // case 1: { -// if(actualHand->getActualQuantityPlayers() == 2) { +// if(actualHand->getActivePlayerList().size() == 2) { // bet = (1-myDude4)*2*actualHand->getSmallBlind(); // if(bet < 2*actualHand->getSmallBlind()) bet = 2*actualHand->getSmallBlind(); // myAction = 4; @@ -1836,14 +1836,14 @@ void LocalPlayer::turnEngine() { // Niveaus setzen + Dude + Anzahl Gegenspieler // 1. Fold -- Call - myNiveau[0] = 53 + myDude4/* - 6*(actualHand->getActualQuantityPlayers() - 2)*/; + myNiveau[0] = 53 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // 2. Check -- Bet - myNiveau[1] = 56 + myDude4/* - 6*(actualHand->getActualQuantityPlayers() - 2)*/; + myNiveau[1] = 56 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // 3. Call -- Raise - myNiveau[2] = 69 + myDude4/* - 6*(actualHand->getActualQuantityPlayers() - 2)*/; + myNiveau[2] = 69 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActualQuantityPlayers())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); if(actualHand->getPlayerArray()[0]->getMyActiveStatus() && actualHand->getPlayerArray()[0]->getMyAction() != 1) { for(i=0; i<3; i++) { @@ -2172,14 +2172,14 @@ void LocalPlayer::riverEngine() { // Niveaus setzen + Dude + Anzahl Gegenspieler // 1. Fold -- Call - myNiveau[0] = 53 + myDude4/* - 6*(actualHand->getActualQuantityPlayers() - 2)*/; + myNiveau[0] = 53 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // 2. Check -- Bet - myNiveau[1] = 56 + myDude4/* - 6*(actualHand->getActualQuantityPlayers() - 2)*/; + myNiveau[1] = 56 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // 3. Call -- Raise - myNiveau[2] = 69 + myDude4/* - 6*(actualHand->getActualQuantityPlayers() - 2)*/; + myNiveau[2] = 69 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActualQuantityPlayers())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); if(actualHand->getPlayerArray()[0]->getMyActiveStatus() && actualHand->getPlayerArray()[0]->getMyAction() != 1) { for(i=0; i<3; i++) { @@ -3226,7 +3226,7 @@ void LocalPlayer::calcMyOdds() { handCode = preflopCardsValue(myCards); // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = actualHand->getActualQuantityPlayers(); + int players = actualHand->getActivePlayerList().size(); if(players > 5) players = 5; // paranoia if(players < 2) players = 2; @@ -3259,7 +3259,7 @@ void LocalPlayer::calcMyOdds() { // cout << "\t" << handCode << endl; // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = actualHand->getActualQuantityPlayers(); + int players = actualHand->getActivePlayerList().size(); if(players > 5) players = 5; // paranoia if(players < 2) players = 2; diff --git a/src/engine/network_engine/clientbero.cpp b/src/engine/network_engine/clientbero.cpp index 24e0e4c1..7525e063 100644 --- a/src/engine/network_engine/clientbero.cpp +++ b/src/engine/network_engine/clientbero.cpp @@ -11,7 +11,7 @@ // #include "clientbero.h" -ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, int /*qP*/, int dP, int sB, GameState gS) +ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, int dP, int sB, GameState gS) : BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), playersTurn(dP), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(0) { } diff --git a/src/engine/network_engine/clientbero.h b/src/engine/network_engine/clientbero.h index 6dd2e201..759d6845 100644 --- a/src/engine/network_engine/clientbero.h +++ b/src/engine/network_engine/clientbero.h @@ -22,7 +22,7 @@ class HandInterface; */ class ClientBeRo : public BeRoInterface{ public: - ClientBeRo(HandInterface* hi, int id, int qP, int dP, int sB, GameState gS); + ClientBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS); ~ClientBeRo(); GameState getMyBeRoID() const; diff --git a/src/engine/network_engine/clientenginefactory.cpp b/src/engine/network_engine/clientenginefactory.cpp index 7c3a10c8..6c37ade4 100644 --- a/src/engine/network_engine/clientenginefactory.cpp +++ b/src/engine/network_engine/clientenginefactory.cpp @@ -50,15 +50,15 @@ boost::shared_ptr ClientEngineFactory::createPlayer(BoardInter return boost::shared_ptr (new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB)); } -std::vector > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) { +std::vector > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int dP, int sB) { std::vector > myBeRo; - myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, aP, dP, sB, GAME_STATE_PREFLOP))); - myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, aP, dP, sB, GAME_STATE_FLOP))); - myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, aP, dP, sB, GAME_STATE_TURN))); - myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, aP, dP, sB, GAME_STATE_RIVER))); - myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, aP, dP, sB, GAME_STATE_POST_RIVER))); + myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP))); + myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, dP, sB, GAME_STATE_FLOP))); + myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, dP, sB, GAME_STATE_TURN))); + myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, dP, sB, GAME_STATE_RIVER))); + myBeRo.push_back(boost::shared_ptr(new ClientBeRo(hi, id, dP, sB, GAME_STATE_POST_RIVER))); return myBeRo; diff --git a/src/engine/network_engine/clientenginefactory.h b/src/engine/network_engine/clientenginefactory.h index 2a2d7885..c3022f38 100644 --- a/src/engine/network_engine/clientenginefactory.h +++ b/src/engine/network_engine/clientenginefactory.h @@ -40,7 +40,7 @@ public: HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC); BoardInterface* createBoard(); boost::shared_ptr createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); - std::vector > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB); + std::vector > createBeRo(HandInterface* hi, int id, int dP, int sB); }; diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index 44cd85c4..c0c70f54 100644 --- a/src/engine/network_engine/clienthand.cpp +++ b/src/engine/network_engine/clienthand.cpp @@ -22,7 +22,7 @@ using namespace std; ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) -: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), +: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0), cardsShown(false), bettingRoundsPlayed(0) { @@ -54,7 +54,7 @@ ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, Boar // the rest of the buttons are assigned later as received from the server. // Preflop, Flop, Turn und River erstellen - myBeRo = myFactory->createBeRo(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); + myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind); } @@ -131,20 +131,6 @@ ClientHand::getMyID() const return myID; } -void -ClientHand::setActualQuantityPlayers(int theValue) -{ - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - actualQuantityPlayers = theValue; -} - -int -ClientHand::getActualQuantityPlayers() const -{ - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - return actualQuantityPlayers; -} - void ClientHand::setStartQuantityPlayers(int theValue) { @@ -229,20 +215,6 @@ ClientHand::getStartCash() const return startCash; } -void -ClientHand::setActivePlayersCounter(int theValue) -{ - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - activePlayersCounter = theValue; -} - -int -ClientHand::getActivePlayersCounter() const -{ - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - return activePlayersCounter; -} - void ClientHand::setBettingRoundsPlayed(int theValue) { diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index 7b281bfd..ec5f1fdb 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -38,6 +38,9 @@ class ClientHand : public HandInterface void start(); std::vector > getPlayerArray() const; + PlayerList getActivePlayerList() const {return activePlayerList;} + PlayerList getRunningPlayerList() const {return runningPlayerList;} + BoardInterface* getBoard() const; boost::shared_ptr getPreflop() const; boost::shared_ptr getFlop() const; @@ -70,9 +73,6 @@ class ClientHand : public HandInterface void setStartCash ( int theValue ); int getStartCash() const; - void setActivePlayersCounter ( int theValue ); - int getActivePlayersCounter() const; - void setBettingRoundsPlayed ( int theValue ); int getBettingRoundsPlayed() const; @@ -99,7 +99,6 @@ class ClientHand : public HandInterface std::vector > myBeRo; int myID; - int actualQuantityPlayers; int startQuantityPlayers; int dealerPosition; // -1 -> neutral int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river diff --git a/src/game.h b/src/game.h index 2771dc70..b17ef3ea 100755 --- a/src/game.h +++ b/src/game.h @@ -52,9 +52,9 @@ public: HandInterface *getCurrentHand(); const HandInterface *getCurrentHand() const; - std::vector > getPlayerArray() {return playerArray;} - std::list > getActivePlayerList() {return activePlayerList;} - std::list > getRunningPlayerList() {return runningPlayerList;} + std::vector > getPlayerArray() const {return playerArray;} + PlayerList getActivePlayerList() const {return activePlayerList;} + PlayerList getRunningPlayerList() const {return runningPlayerList;} //Zufgriff Startvariablen void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } @@ -89,8 +89,8 @@ private: BoardInterface *actualBoard; std::vector > playerArray; // available seats --> seatList !!! TODO - std::list > activePlayerList; // used seats - std::list > runningPlayerList; // nonfolded and nonallin active players + PlayerList activePlayerList; // used seats + PlayerList runningPlayerList; // nonfolded and nonallin active players // boost::shared_ptr playerArray[MAX_NUMBER_OF_PLAYERS]; diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 2804138c..4b5d095f 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -2083,7 +2083,7 @@ void mainWindowImpl::postRiverRunAnimation3() { actionLabelArray[i]->setPixmap(QPixmap(myAppDataPath +"gfx/gui/table/default/action_winner.png")); //show winnercards if more than one player is active - if ( currentHand->getActivePlayersCounter() != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) { + if ( currentHand->getActivePlayerList().size() != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) { int j; int bestHandPos[5]; @@ -2150,7 +2150,7 @@ void mainWindowImpl::postRiverRunAnimation3() { } else { - if( currentHand->getActivePlayersCounter() != 1 && currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyActiveStatus() && myConfig->readConfigInt("ShowFadeOutCardsAnimation") ) { + if( currentHand->getActivePlayerList().size() != 1 && currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyActiveStatus() && myConfig->readConfigInt("ShowFadeOutCardsAnimation") ) { //aufgedeckte Gegner auch ausblenden holeCardsArray[i][0]->startFadeOut(guiGameSpeed);