From a958c4916ee715492500a1eea25181b28cd36305 Mon Sep 17 00:00:00 2001 From: floty Date: Sat, 22 Oct 2011 14:00:33 +0000 Subject: [PATCH] some changes in hole cards logging --- .../local_engine/localberopostriver.cpp | 12 +- src/engine/local_engine/localhand.cpp | 8 +- src/engine/log.cpp | 138 ++++++++++-------- src/engine/log.h | 6 +- 4 files changed, 87 insertions(+), 77 deletions(-) diff --git a/src/engine/local_engine/localberopostriver.cpp b/src/engine/local_engine/localberopostriver.cpp index 1aa9d4a9..1d4d74b7 100644 --- a/src/engine/local_engine/localberopostriver.cpp +++ b/src/engine/local_engine/localberopostriver.cpp @@ -84,12 +84,12 @@ void LocalBeRoPostRiver::postRiverRun() getMyHand()->getBoard()->setPot(0); // Logging hole Cards / Hands - int myCards[2]; - for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) { - if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - (*it_c)->getMyCards(myCards); - getMyHand()->getLog()->logHoleCardsHandName((*it_c)->getMyID()+1,myCards,(*it_c)->getMyCardsValueInt(),getMyHand()->getActivePlayerList()); - } + int nonfoldPlayersCounter = 0; + for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) { + if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++; + } + if(nonfoldPlayersCounter>1) { + getMyHand()->getLog()->logHoleCardsHandName(5,getMyHand()->getActivePlayerList()); } //starte die Animaionsreihe diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index a7a44e37..6acd9c54 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -627,13 +627,7 @@ void LocalHand::switchRounds() myGui->refreshSet(); myGui->flipHolecardsAllIn(); // Logging HoleCards - 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); - myLog->logHoleCards(currentRound+1,(*it_c)->getMyID()+1,myCards); - } - } + myLog->logHoleCards(currentRound+1,activePlayerList); if (currentRound < 4) // do not increment past 4 currentRound++; diff --git a/src/engine/log.cpp b/src/engine/log.cpp index dd5fba2b..13f50675 100644 --- a/src/engine/log.cpp +++ b/src/engine/log.cpp @@ -28,7 +28,7 @@ using namespace std; -Log::Log(ConfigFile *c) : myConfig(c), curGameID(0), curHandID(0), sql(""), logHoleCardsDone(false) +Log::Log(ConfigFile *c) : mySqliteLogDb(0), myConfig(c), curGameID(0), curHandID(0), sql(""), logHoleCardsDone(false) { if(SQLITE_LOG) { @@ -183,6 +183,7 @@ void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, uns { curHandID = handID; + logHoleCardsDone = false; if(SQLITE_LOG) { @@ -358,37 +359,72 @@ void Log::logBoardCards(int bero, int boardCards[5]) } } -void Log::logHoleCards(int bero, int seat, int cards[2]) +void Log::logHoleCards(int bero, PlayerList activePlayerList) { - logHoleCardsDone = false; - if(SQLITE_LOG) { - if(myConfig->readConfigInt("LogOnOff")) { + if(myConfig->readConfigInt("LogOnOff") & !logHoleCardsDone) { //if write logfiles is enabled if( mySqliteLogDb != 0 ) { // sqlite-db is open - sql += "UPDATE Hand SET "; - sql += "Seat_" + boost::lexical_cast(seat) + "_Card_1=" + boost::lexical_cast(cards[0]); - sql += ",Seat_" + boost::lexical_cast(seat) + "_Card_2=" + boost::lexical_cast(cards[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); + 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); + } } - logPlayerAction(bero,seat,LOG_ACTION_SHOW); + logHoleCardsDone = true; } } } } -void Log::logHandName(int seat, int cardsValueInt, PlayerList activePlayerList) +//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) { @@ -398,53 +434,33 @@ void Log::logHandName(int seat, int cardsValueInt, PlayerList activePlayerList) 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); - } + PlayerListConstIterator it_c; + int myCards[2]; - logPlayerAction(5,seat,LOG_ACTION_HAS); - } - } - } -} + 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) + "_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(!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_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); + } -void Log::logHoleCardsHandName(int seat, int cards[2], 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); - if(!logHoleCardsDone) { - sql += ",Seat_" + boost::lexical_cast(seat) + "_Card_1=" + boost::lexical_cast(cards[0]); - sql += ",Seat_" + boost::lexical_cast(seat) + "_Card_2=" + boost::lexical_cast(cards[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(5,seat,LOG_ACTION_SHOW); - if(!logHoleCardsDone) { - logPlayerAction(5,seat,LOG_ACTION_SHOW); - } else { - logPlayerAction(5,seat,LOG_ACTION_HAS); + if(!logHoleCardsDone) { + logPlayerAction(bero,(*it_c)->getMyID()+1,LOG_ACTION_SHOW); + } else { + logPlayerAction(bero,(*it_c)->getMyID()+1,LOG_ACTION_HAS); + } + } } } } diff --git a/src/engine/log.h b/src/engine/log.h index 405236f1..742b6b44 100644 --- a/src/engine/log.h +++ b/src/engine/log.h @@ -38,9 +38,9 @@ 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, int seat, int cards[2]); - void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList); - void logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, PlayerList activePlayerList); + 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();