diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index 3622dcbc..bb20e010 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -52,8 +52,8 @@ public: virtual void setStartQuantityPlayers(int theValue) =0; virtual int getStartQuantityPlayers() const =0; - virtual void setCurrentRound(int theValue) =0; - virtual int getCurrentRound() const =0; + virtual void setCurrentRound(GameState theValue) =0; + virtual GameState getCurrentRound() const =0; virtual void setDealerPosition(int theValue) =0; virtual int getDealerPosition() const =0; diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index 2ee1c5b9..423e1704 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -176,7 +176,7 @@ void LocalBeRo::run() // aktuelle bero nicht dran, weil alle Sets gleich sind //also gehe in naechste bero - myHand->setCurrentRound(myBeRoID+1); + myHand->setCurrentRound(GameState(myBeRoID+1)); //Action loeschen und ActionButtons refresh for(it_c=myHand->getRunningPlayerList()->begin(); it_c!=myHand->getRunningPlayerList()->end(); ++it_c) { diff --git a/src/engine/local_engine/localberopostriver.cpp b/src/engine/local_engine/localberopostriver.cpp index 1d4d74b7..33b7a5a9 100644 --- a/src/engine/local_engine/localberopostriver.cpp +++ b/src/engine/local_engine/localberopostriver.cpp @@ -83,7 +83,7 @@ void LocalBeRoPostRiver::postRiverRun() //Pot auf 0 setzen getMyHand()->getBoard()->setPot(0); - // Logging hole Cards / Hands + // logging hole Cards / Hands int nonfoldPlayersCounter = 0; for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) { if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++; @@ -92,6 +92,20 @@ void LocalBeRoPostRiver::postRiverRun() getMyHand()->getLog()->logHoleCardsHandName(5,getMyHand()->getActivePlayerList()); } + // logging winner if game is over + // wenn nur noch ein Spieler aktive "neues Spiel"-Dialog anzeigen + int playersPositiveCashCounter = 0; + for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) { + if ((*it_c)->getMyCash() > 0) playersPositiveCashCounter++; + } + if (playersPositiveCashCounter==1) { + for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) { + if ((*it_c)->getMyCash() > 0) { + getMyHand()->getLog()->logPlayerAction(5,(*it_c)->getMyID()+1,LOG_ACTION_WIN_GAME); + } + } + } + //starte die Animaionsreihe getMyHand()->getGuiInterface()->postRiverRunAnimation1(); } diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 6acd9c54..fe11ce49 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -30,7 +30,7 @@ using namespace std; LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost::shared_ptr b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC) - : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false), + : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(GAME_STATE_PREFLOP), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false), cardsShown(false), bettingRoundsPlayed(0) { @@ -566,7 +566,7 @@ void LocalHand::switchRounds() myBoard->collectPot(); myGui->refreshPot(); myGui->refreshSet(); - currentRound = 4; + currentRound = GAME_STATE_POST_RIVER; } // check for all in condition @@ -627,13 +627,15 @@ void LocalHand::switchRounds() myGui->refreshSet(); myGui->flipHolecardsAllIn(); // Logging HoleCards - myLog->logHoleCards(currentRound+1,activePlayerList); + if(currentRoundlogHoleCardsHandName(currentRound+1,activePlayerList); + } - if (currentRound < 4) // do not increment past 4 - currentRound++; + if (currentRound < GAME_STATE_POST_RIVER) // do not increment past 4 + currentRound = GameState(currentRound + 1); //log board cards for allin - if(currentRound >= 1) { + if(currentRound >= GAME_STATE_FLOP) { int tempBoardCardsArray[5]; myBoard->getMyCards(tempBoardCardsArray); diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index c3acec38..f39649ee 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -88,10 +88,10 @@ public: return startQuantityPlayers; } - void setCurrentRound(int theValue) { + void setCurrentRound(GameState theValue) { currentRound = theValue; } - int getCurrentRound() const { + GameState getCurrentRound() const { return currentRound; } @@ -177,7 +177,7 @@ private: unsigned dealerPosition; unsigned smallBlindPosition; unsigned bigBlindPosition; - int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river + GameState currentRound; int smallBlind; int startCash; diff --git a/src/engine/log.cpp b/src/engine/log.cpp index 13f50675..d96386a7 100644 --- a/src/engine/log.cpp +++ b/src/engine/log.cpp @@ -359,71 +359,6 @@ void Log::logBoardCards(int bero, int boardCards[5]) } } -void Log::logHoleCards(int bero, PlayerList activePlayerList) -{ - - if(SQLITE_LOG) { - - if(myConfig->readConfigInt("LogOnOff") & !logHoleCardsDone) { - //if write logfiles is enabled - - if( mySqliteLogDb != 0 ) { - // sqlite-db is open - - PlayerListConstIterator it_c; - int myCards[2]; - - for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - (*it_c)->getMyCards(myCards); - sql += "UPDATE Hand SET "; - sql += "Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast(myCards[0]); - sql += ",Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Card_2=" + boost::lexical_cast(myCards[1]); - sql += " WHERE "; - sql += "GameID=" + boost::lexical_cast(curGameID) + " AND "; - sql += "HandID=" + boost::lexical_cast(curHandID); - sql += ";"; - if(myConfig->readConfigInt("LogInterval") == 0) { - exec_transaction(&sql); - } - - logPlayerAction(bero,(*it_c)->getMyID()+1,LOG_ACTION_SHOW); - } - } - - logHoleCardsDone = true; - } - } - } -} - -//void Log::logHandName(int seat, int cardsValueInt, PlayerList activePlayerList) -//{ -// if(SQLITE_LOG) { - -// if(myConfig->readConfigInt("LogOnOff")) { -// //if write logfiles is enabled - -// if( mySqliteLogDb != 0 ) { -// // sqlite-db is open - -// sql += "UPDATE Hand SET "; -// sql += "Seat_" + boost::lexical_cast(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\""; -// sql += ",Seat_" + boost::lexical_cast(seat) + "_Hand_int=" + boost::lexical_cast(cardsValueInt); -// sql += " WHERE "; -// sql += "GameID=" + boost::lexical_cast(curGameID) + " AND "; -// sql += "HandID=" + boost::lexical_cast(curHandID); -// sql += ";"; -// if(myConfig->readConfigInt("LogInterval") == 0) { -// exec_transaction(&sql); -// } - -// logPlayerAction(5,seat,LOG_ACTION_HAS); -// } -// } -// } -//} - void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList) { if(SQLITE_LOG) { @@ -431,8 +366,8 @@ void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList) if(myConfig->readConfigInt("LogOnOff")) { //if write logfiles is enabled - if( mySqliteLogDb != 0 ) { - // sqlite-db is open + if( mySqliteLogDb != 0 && (bero==5 || !logHoleCardsDone)) { + // sqlite-db is open and we are in postriver or before postriver doesn't log hole cards til now PlayerListConstIterator it_c; int myCards[2]; @@ -441,10 +376,15 @@ void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList) if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { (*it_c)->getMyCards(myCards); sql += "UPDATE Hand SET "; - sql += "Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Hand_text=\"" + CardsValue::determineHandName((*it_c)->getMyCardsValueInt(),activePlayerList) + "\""; - sql += ",Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Hand_int=" + boost::lexical_cast((*it_c)->getMyCardsValueInt()); + if(bero==5) { + sql += "Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Hand_text=\"" + CardsValue::determineHandName((*it_c)->getMyCardsValueInt(),activePlayerList) + "\""; + sql += ",Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Hand_int=" + boost::lexical_cast((*it_c)->getMyCardsValueInt()); + } + if(bero==5 && !logHoleCardsDone) { + sql+= ","; + } if(!logHoleCardsDone) { - sql += ",Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast(myCards[0]); + sql += "Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast(myCards[0]); sql += ",Seat_" + boost::lexical_cast((*it_c)->getMyID()+1) + "_Card_2=" + boost::lexical_cast(myCards[1]); } sql += " WHERE "; @@ -462,6 +402,8 @@ void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList) } } } + + logHoleCardsDone = true; } } } diff --git a/src/engine/log.h b/src/engine/log.h index 742b6b44..60891ea2 100644 --- a/src/engine/log.h +++ b/src/engine/log.h @@ -38,8 +38,6 @@ public: void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList); void logPlayerAction(int bero, int seat, PlayerActionLog action, int amount = 0); void logBoardCards(int bero, int boardCards[5]); - void logHoleCards(int bero, PlayerList activePlayerList); -// void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList); void logHoleCardsHandName(int bero, PlayerList activePlayerList); void exec_transaction(std::string *sql); // void closeLogDbAtExit(); diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index 9d5dd4d4..d16f2f6a 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, boost::shared_ptr b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) - : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0), + : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(GAME_STATE_PREFLOP), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0), cardsShown(false), bettingRoundsPlayed(0) { @@ -203,13 +203,13 @@ ClientHand::getStartQuantityPlayers() const } void -ClientHand::setCurrentRound(int theValue) +ClientHand::setCurrentRound(GameState theValue) { boost::recursive_mutex::scoped_lock lock(m_syncMutex); currentRound = theValue; } -int +GameState ClientHand::getCurrentRound() const { boost::recursive_mutex::scoped_lock lock(m_syncMutex); diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index 380acbeb..30820dd4 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -63,8 +63,8 @@ public: void setStartQuantityPlayers ( int theValue ); int getStartQuantityPlayers() const; - void setCurrentRound ( int theValue ); - int getCurrentRound() const; + void setCurrentRound ( GameState theValue ); + GameState getCurrentRound() const; void setDealerPosition ( int theValue ); int getDealerPosition() const; @@ -115,7 +115,7 @@ private: int myID; int startQuantityPlayers; unsigned dealerPosition; - int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river + GameState currentRound; int smallBlind; int startCash; diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 36a921bd..bdaaa3e7 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -2651,11 +2651,12 @@ void gameTableImpl::showHoleCards(unsigned playerId, bool allIn) } } //set Player value (logging) - if(currentHand->getCurrentRound() < 3 || allIn) { + if(currentHand->getCurrentRound() < GAME_STATE_RIVER || allIn) { (*it_c)->setMyCardsFlip(1,2); //for bero before postriver or allin just log the hole cards - } else { - (*it_c)->setMyCardsFlip(1,1); //for postriver log the value - } + } + else { + (*it_c)->setMyCardsFlip(1,1); //for postriver log the value + } } } } @@ -2665,7 +2666,7 @@ void gameTableImpl::flipHolecardsAllIn() boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - if(!flipHolecardsAllInAlreadyDone) { + if(!flipHolecardsAllInAlreadyDone && currentGame->getCurrentHand()->getCurrentRound() < GAME_STATE_RIVER) { //Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen int nonfoldPlayersCounter = 0; PlayerListConstIterator it_c; diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 53fdd66c..1f52e7f1 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -1799,7 +1799,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, // Set round. if (curGame->getCurrentHand()->getCurrentRound() != netPlayersTurn->gameState) { ResetPlayerActions(*curGame); - curGame->getCurrentHand()->setCurrentRound(netPlayersTurn->gameState); + curGame->getCurrentHand()->setCurrentRound(GameState(netPlayersTurn->gameState)); // Refresh actions. client->GetGui().refreshSet(); client->GetGui().refreshAction();