some changes in hole cards logging

This commit is contained in:
floty
2011-10-22 14:00:33 +00:00
parent f707c5eb32
commit a958c4916e
4 changed files with 87 additions and 77 deletions
@@ -84,12 +84,12 @@ void LocalBeRoPostRiver::postRiverRun()
getMyHand()->getBoard()->setPot(0); getMyHand()->getBoard()->setPot(0);
// Logging hole Cards / Hands // Logging hole Cards / Hands
int myCards[2]; int nonfoldPlayersCounter = 0;
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) { for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++;
(*it_c)->getMyCards(myCards); }
getMyHand()->getLog()->logHoleCardsHandName((*it_c)->getMyID()+1,myCards,(*it_c)->getMyCardsValueInt(),getMyHand()->getActivePlayerList()); if(nonfoldPlayersCounter>1) {
} getMyHand()->getLog()->logHoleCardsHandName(5,getMyHand()->getActivePlayerList());
} }
//starte die Animaionsreihe //starte die Animaionsreihe
+1 -7
View File
@@ -627,13 +627,7 @@ void LocalHand::switchRounds()
myGui->refreshSet(); myGui->refreshSet();
myGui->flipHolecardsAllIn(); myGui->flipHolecardsAllIn();
// Logging HoleCards // Logging HoleCards
int myCards[2]; myLog->logHoleCards(currentRound+1,activePlayerList);
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);
}
}
if (currentRound < 4) // do not increment past 4 if (currentRound < 4) // do not increment past 4
currentRound++; currentRound++;
+77 -61
View File
@@ -28,7 +28,7 @@
using namespace std; 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) { if(SQLITE_LOG) {
@@ -183,6 +183,7 @@ void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, uns
{ {
curHandID = handID; curHandID = handID;
logHoleCardsDone = false;
if(SQLITE_LOG) { 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(SQLITE_LOG) {
if(myConfig->readConfigInt("LogOnOff")) { if(myConfig->readConfigInt("LogOnOff") & !logHoleCardsDone) {
//if write logfiles is enabled //if write logfiles is enabled
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
sql += "UPDATE Hand SET "; PlayerListConstIterator it_c;
sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Card_1=" + boost::lexical_cast<string>(cards[0]); int myCards[2];
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_2=" + boost::lexical_cast<string>(cards[1]);
sql += " WHERE "; for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND "; if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
sql += "HandID=" + boost::lexical_cast<string>(curHandID); (*it_c)->getMyCards(myCards);
sql += ";"; sql += "UPDATE Hand SET ";
if(myConfig->readConfigInt("LogInterval") == 0) { sql += "Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast<string>(myCards[0]);
exec_transaction(&sql); sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_2=" + boost::lexical_cast<string>(myCards[1]);
sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(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<string>(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\"";
// sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_int=" + boost::lexical_cast<string>(cardsValueInt);
// sql += " WHERE ";
// sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
// sql += "HandID=" + boost::lexical_cast<string>(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) { if(SQLITE_LOG) {
@@ -398,53 +434,33 @@ void Log::logHandName(int seat, int cardsValueInt, PlayerList activePlayerList)
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
sql += "UPDATE Hand SET "; PlayerListConstIterator it_c;
sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\""; int myCards[2];
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_int=" + boost::lexical_cast<string>(cardsValueInt);
sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(curHandID);
sql += ";";
if(myConfig->readConfigInt("LogInterval") == 0) {
exec_transaction(&sql);
}
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<string>((*it_c)->getMyID()+1) + "_Hand_text=\"" + CardsValue::determineHandName((*it_c)->getMyCardsValueInt(),activePlayerList) + "\"";
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Hand_int=" + boost::lexical_cast<string>((*it_c)->getMyCardsValueInt());
if(!logHoleCardsDone) {
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast<string>(myCards[0]);
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_2=" + boost::lexical_cast<string>(myCards[1]);
}
sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(curHandID);
sql += ";";
if(myConfig->readConfigInt("LogInterval") == 0) {
exec_transaction(&sql);
}
void Log::logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, PlayerList activePlayerList) if(!logHoleCardsDone) {
{ logPlayerAction(bero,(*it_c)->getMyID()+1,LOG_ACTION_SHOW);
if(SQLITE_LOG) { } else {
logPlayerAction(bero,(*it_c)->getMyID()+1,LOG_ACTION_HAS);
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<string>(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\"";
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_int=" + boost::lexical_cast<string>(cardsValueInt);
if(!logHoleCardsDone) {
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_1=" + boost::lexical_cast<string>(cards[0]);
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_2=" + boost::lexical_cast<string>(cards[1]);
}
sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(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);
} }
} }
} }
+3 -3
View File
@@ -38,9 +38,9 @@ public:
void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList); 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 logPlayerAction(int bero, int seat, PlayerActionLog action, int amount = 0);
void logBoardCards(int bero, int boardCards[5]); void logBoardCards(int bero, int boardCards[5]);
void logHoleCards(int bero, int seat, int cards[2]); void logHoleCards(int bero, PlayerList activePlayerList);
void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList); // void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList);
void logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, PlayerList activePlayerList); void logHoleCardsHandName(int bero, PlayerList activePlayerList);
void exec_transaction(std::string *sql); void exec_transaction(std::string *sql);
// void closeLogDbAtExit(); // void closeLogDbAtExit();