From 377f6dde6e9c71322c220b1e10f117931359833f Mon Sep 17 00:00:00 2001 From: floty Date: Wed, 29 Sep 2010 17:43:49 +0000 Subject: [PATCH] active sqlite-log with symbol constant --- src/engine/local_engine/localplayer.cpp | 283 +++++++++--- src/game.cpp | 4 +- src/game_defs.h | 2 + src/gui/qt/gametable/gametableimpl.cpp | 2 +- src/gui/qt/gametable/log/log.cpp | 556 +++++++++++++----------- 5 files changed, 541 insertions(+), 306 deletions(-) diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 320177c0..9575e542 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -861,34 +861,34 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq switch(myUniqueID) { case 0: { - myCash=2588; + myCash=4140; } break; case 1: { - myCash=0; + myCash=4940; } break; case 2: { - myCash=404; + myCash=4660; } break; case 3: { - myCash=0; + myCash=4960; } break; case 4: { - myCash=0; + myCash=5680; } break; case 5: { - myCash=1133; + myCash=4960; } break; case 6: { - myCash=5275; + myCash=4960; } break; case 7: { - myCash=0; + myCash=5780; } break; case 8: { - myCash=0; + myCash=4960; } break; case 9: { - myCash=0; + myCash=4960; } break; default: { @@ -1356,8 +1356,8 @@ void LocalPlayer::preflopEngine() { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_RAISE; - raise = 20000; + myAction = PLAYER_ACTION_CALL; +// raise = 20000; // if(mySet >= 40) { // myAction = PLAYER_ACTION_CALL; // } @@ -1380,8 +1380,8 @@ void LocalPlayer::preflopEngine() { case 3: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_RAISE; - raise = 2000; + myAction = PLAYER_ACTION_CALL; +// raise = 2000; // if(mySet >= 40) { // myAction = PLAYER_ACTION_CALL; // } @@ -1403,8 +1403,8 @@ void LocalPlayer::preflopEngine() { case 4: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_RAISE; - raise = 2000; + myAction = PLAYER_ACTION_CALL; +// raise = 2000; // if(mySet > 0) { // myAction = PLAYER_ACTION_FOLD; // } @@ -1425,14 +1425,14 @@ void LocalPlayer::preflopEngine() { break; case 5: { // if(mySet == 0) { - myAction = PLAYER_ACTION_FOLD; + myAction = PLAYER_ACTION_CALL; // raise = 20; // } } break; case 6: { // if(mySet == 160) { - myAction = PLAYER_ACTION_CALL; + myAction = PLAYER_ACTION_CHECK; // } } break; @@ -1450,6 +1450,13 @@ void LocalPlayer::preflopEngine() { // } } break; + case 9: { + // if(mySet == 160) { + myAction = PLAYER_ACTION_CALL; + + // } + } + break; default: {} } @@ -1728,7 +1735,7 @@ void LocalPlayer::flopEngine() { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_CALL; + myAction = PLAYER_ACTION_CHECK; // bet = 20; // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // myAction = PLAYER_ACTION_CALL; @@ -1746,7 +1753,7 @@ void LocalPlayer::flopEngine() { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_CALL; + myAction = PLAYER_ACTION_CHECK; // bet = 20; // raise = 20; // if(mySet > 20) { @@ -1774,7 +1781,7 @@ void LocalPlayer::flopEngine() { case 3: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_CALL; + myAction = PLAYER_ACTION_CHECK; // raise = 400; // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // myAction = PLAYER_ACTION_CALL; @@ -1801,9 +1808,9 @@ void LocalPlayer::flopEngine() { case 1: { myAction = PLAYER_ACTION_CHECK; // raise = 140; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_CALL; - } +// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { +// myAction = PLAYER_ACTION_CALL; +// } } break; case 2: { @@ -1824,8 +1831,8 @@ void LocalPlayer::flopEngine() { case 5: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_BET; - bet = 20; + myAction = PLAYER_ACTION_CHECK; +// bet = 20; // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // myAction = PLAYER_ACTION_FOLD; // } @@ -1849,11 +1856,11 @@ void LocalPlayer::flopEngine() { case 6: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_RAISE; - raise = 40; - if(currentHand->getCurrentBeRo()->getHighestSet() > 60) { - myAction = PLAYER_ACTION_CALL; - } + myAction = PLAYER_ACTION_CHECK; +// raise = 40; +// if(currentHand->getCurrentBeRo()->getHighestSet() > 60) { +// myAction = PLAYER_ACTION_CALL; +// } } break; case 2: { @@ -1869,6 +1876,18 @@ void LocalPlayer::flopEngine() { } + } + break; + case 7: { + myAction = PLAYER_ACTION_CHECK; + } + break; + case 8: { + myAction = PLAYER_ACTION_CHECK; + } + break; + case 9: { + myAction = PLAYER_ACTION_CHECK; } break; default: {} @@ -2419,7 +2438,7 @@ void LocalPlayer::turnEngine() { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_CALL; + myAction = PLAYER_ACTION_FOLD; // bet = 20; // if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { // myAction = PLAYER_ACTION_CALL; @@ -2465,7 +2484,7 @@ void LocalPlayer::turnEngine() { case 3: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_CALL; + myAction = PLAYER_ACTION_FOLD; // bet = 10; // if(currentHand->getCurrentBeRo()->getHighestSet() > 500) { // myAction = PLAYER_ACTION_RAISE; @@ -2491,11 +2510,11 @@ void LocalPlayer::turnEngine() { case 4: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_BET; - bet = 120; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_CALL; - } + myAction = PLAYER_ACTION_FOLD; +// bet = 120; +// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { +// myAction = PLAYER_ACTION_CALL; +// } } break; case 2: { @@ -2516,11 +2535,11 @@ void LocalPlayer::turnEngine() { case 5: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_FOLD; - // bet = 10; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // myAction = PLAYER_ACTION_CALL; - // } + myAction = PLAYER_ACTION_BET; + bet = 20; + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; + } } break; case 2: { @@ -2541,11 +2560,89 @@ void LocalPlayer::turnEngine() { case 6: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_BET; - bet = 240; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_RAISE; - raise = 10000; + myAction = PLAYER_ACTION_RAISE; + bet = 20; + if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { + myAction = PLAYER_ACTION_CALL; +// raise = 10000; + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + + + } + break; + case 7: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; +// bet = 20; +// if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { +// myAction = PLAYER_ACTION_CALL; +// raise = 10000; +// } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + + + } + break; + case 8: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_FOLD; +// bet = 20; +// if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { +// myAction = PLAYER_ACTION_CALL; +// raise = 10000; +// } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + + + } + break; + case 9: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_RAISE; + bet = 60; + if(currentHand->getCurrentBeRo()->getHighestSet() > 40) { + myAction = PLAYER_ACTION_CALL; +// raise = 10000; } } break; @@ -2948,12 +3045,12 @@ void LocalPlayer::riverEngine() { case 5: { switch(currentHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_FOLD; + myAction = PLAYER_ACTION_CHECK; // bet = 120; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // myAction = PLAYER_ACTION_RAISE; - // raise = 10000; - // } + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_FOLD; +// raise = 10000; + } } break; case 2: { @@ -2975,8 +3072,86 @@ void LocalPlayer::riverEngine() { switch(currentHand->getMyID()) { case 1: { myAction = PLAYER_ACTION_BET; - bet = 240; + bet = 40; if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; +// raise = 10000; + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + + + } + break; + case 7: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; +// bet = 40; +// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { +// myAction = PLAYER_ACTION_CALL; +// raise = 10000; +// } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + + + } + break; + case 8: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 40; + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; +// raise = 10000; + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + + + } + break; + case 9: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_RAISE; + bet = 180; + if(currentHand->getCurrentBeRo()->getHighestSet() > 40) { myAction = PLAYER_ACTION_RAISE; raise = 10000; } diff --git a/src/game.cpp b/src/game.cpp index f8695214..fc2a49df 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -43,9 +43,9 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, dealerPosition = startData.startDealerPlayerId; if(DEBUG_MODE) { - startSmallBlind = 300; + startSmallBlind = 10; currentSmallBlind = startSmallBlind; - dealerPosition = 5; + dealerPosition = 4; } int i; diff --git a/src/game_defs.h b/src/game_defs.h index 1c1341f5..d451d090 100644 --- a/src/game_defs.h +++ b/src/game_defs.h @@ -27,6 +27,8 @@ #define MAX_GUI_SPEED 11 #define DEBUG_MODE 0 +#define SQLITE_LOG 0 +#define HTML_LOG 1 #define POKERTH_VERSION_MAJOR 0 #define POKERTH_VERSION_MINOR 80 diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 29cf1e79..3c990630 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -1132,7 +1132,7 @@ void gameTableImpl::dealHoleCards() { (*it_c)->getMyCards(tempCardsIntArray); for(j=0; j<2; j++) { if((*it_c)->getMyActiveStatus()) { - if (( (*it_c)->getMyID() == 0) || DEBUG_MODE) { + if (( (*it_c)->getMyID() == 0)/* || DEBUG_MODE*/) { tempCardsPixmapArray[j].load(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png"); if(myConfig->readConfigInt("AntiPeekMode")) { holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(flipside, TRUE); diff --git a/src/gui/qt/gametable/log/log.cpp b/src/gui/qt/gametable/log/log.cpp index 22889bff..643b7fae 100755 --- a/src/gui/qt/gametable/log/log.cpp +++ b/src/gui/qt/gametable/log/log.cpp @@ -60,110 +60,124 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my if(myConfig->readConfigString("LogDir") != "" && logDir.exists()) { - myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); - QDateTime currentTime = QDateTime::currentDateTime(); - myHtmlLogFile = new QFile(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".html"); -// mySqliteLogDb = new QSqlDatabase; - - //Logo-Pixmap extrahieren - QPixmap logoChipPixmapFile(":/gfx/logoChip3D.png"); - logoChipPixmapFile.save(myLogDir->absolutePath()+"/logo.png"); - -// myW->textBrowser_Log->append(myHtmlLogFile->fileName()); - - // erstelle html-Datei - myHtmlLogFile->open( QIODevice::WriteOnly ); - QTextStream stream( myHtmlLogFile ); - stream << "\n"; - stream << "\n"; - stream << ""; - stream << "\n"; - stream << "\n"; - stream << "\n"; - stream << QString("

Log-File for PokerTH %1 Session started on ").arg(POKERTH_BETA_RELEASE_STRING)+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"

\n"; - myHtmlLogFile->close(); - int i; -// // lege sqlite-Datenbank -// *mySqliteLogDb = QSqlDatabase::addDatabase("QSQLITE"); -// mySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb"); -// if(mySqliteLogDb->open()) { -// -// QSqlQuery query(*mySqliteLogDb); -// QString sql; -// -// // Session-Tabelle -// sql = "CREATE TABLE Session ("; -// sql += "PokerTH_Version TEXT,"; -// sql += "Date TEXT,"; -// sql += "Time TEXT,"; -// sql += "PRIMARY KEY(Date,Time))"; -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// sql = "INSERT INTO Session (PokerTH_Version,Date,Time) VALUES ("; -// sql += "'"+QString("%1").arg(POKERTH_BETA_RELEASE_STRING)+"',"; -// sql += "'"+currentTime.toString("yyyy-MM-dd")+"',"; -// sql += "'"+currentTime.toString("hh:mm:ss")+"')"; -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// -// // Game-Tabelle -// sql = "CREATE TABLE Game ("; -// sql += "GameID INTEGER NOT NULL PRIMARY KEY,"; -// sql += "Startmoney INTEGER NOT NULL,"; -// sql += "StartSb INTEGER NOT NULL,"; -// sql += "DealerPos INTEGER NOT NULL"; -// for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { -// sql += ",Seat_" + QString("%1").arg(i); -// } -// sql += ",Winner_Seat INTEGER)"; -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// -// // Hand-Tabelle -// sql = "CREATE TABLE Hand ("; -// sql += "HandID INTEGER NOT NULL,"; -// sql += "GameID INTEGER NOT NULL,"; -// sql += "Sb_Amount INTEGER,"; -// sql += "Sb_Seat INTEGER,"; -// sql += "Bb_Amount INTEGER,"; -// sql += "Bb_Seat INTEGER,"; -// sql += "Dealer_Seat INTEGER,"; -// for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { -// sql += "Seat_" + QString("%1").arg(i) + "_Cash INTEGER,"; -// sql += "Seat_" + QString("%1").arg(i) + "_Card_1 INTEGER,"; -// sql += "Seat_" + QString("%1").arg(i) + "_Card_2 INTEGER,"; -// sql += "Seat_" + QString("%1").arg(i) + "_Hand TEXT,"; -// } -// for(i=1; i<=5; i++) { -// sql += "BoardCard_" + QString("%1").arg(i) + " INTEGER,"; -// } -// sql += "PRIMARY KEY(HandID,GameID))"; -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// -// // Action-Tabelle -// sql = "CREATE TABLE Action ("; -// sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT,"; -// sql += "HandID INTEGER NOT NULL,"; -// sql += "GameID INTEGER NOT NULL,"; -// sql += "BeRo INTEGER NOT NULL,"; -// sql += "Player INTEGER NOT NULL,"; -// sql += "Action INTEGER NOT NULL,"; -// sql += "Amount INTEGER)"; -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// -// } else { -// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } - //Zu alte Dateien löschen!!! + if(HTML_LOG) { + + myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); + QDateTime currentTime = QDateTime::currentDateTime(); + myHtmlLogFile = new QFile(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".html"); + + //Logo-Pixmap extrahieren + QPixmap logoChipPixmapFile(":/gfx/logoChip3D.png"); + logoChipPixmapFile.save(myLogDir->absolutePath()+"/logo.png"); + +// myW->textBrowser_Log->append(myHtmlLogFile->fileName()); + + // erstelle html-Datei + myHtmlLogFile->open( QIODevice::WriteOnly ); + QTextStream stream( myHtmlLogFile ); + stream << "\n"; + stream << "\n"; + stream << ""; + stream << "\n"; + stream << "\n"; + stream << "\n"; + stream << QString("

Log-File for PokerTH %1 Session started on ").arg(POKERTH_BETA_RELEASE_STRING)+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"

\n"; + myHtmlLogFile->close(); + + } + + if(SQLITE_LOG) { + + myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); + QDateTime currentTime = QDateTime::currentDateTime(); + mySqliteLogDb = new QSqlDatabase; + + // create sqlite-db + *mySqliteLogDb = QSqlDatabase::addDatabase("QSQLITE"); + mySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb"); + + // open sqlite-db + if(mySqliteLogDb->open()) { + + QSqlQuery query(*mySqliteLogDb); + QString sql; + + // create session table + sql = "CREATE TABLE Session ("; + sql += "PokerTH_Version TEXT,"; + sql += "Date TEXT,"; + sql += "Time TEXT,"; + sql += "PRIMARY KEY(Date,Time))"; + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + sql = "INSERT INTO Session (PokerTH_Version,Date,Time) VALUES ("; + sql += "'"+QString("%1").arg(POKERTH_BETA_RELEASE_STRING)+"',"; + sql += "'"+currentTime.toString("yyyy-MM-dd")+"',"; + sql += "'"+currentTime.toString("hh:mm:ss")+"')"; + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + // create game table + sql = "CREATE TABLE Game ("; + sql += "GameID INTEGER NOT NULL PRIMARY KEY,"; + sql += "Startmoney INTEGER NOT NULL,"; + sql += "StartSb INTEGER NOT NULL,"; + sql += "DealerPos INTEGER NOT NULL"; + for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { + sql += ",Seat_" + QString("%1").arg(i); + } + sql += ",Winner_Seat INTEGER)"; + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + // create hand table + sql = "CREATE TABLE Hand ("; + sql += "HandID INTEGER NOT NULL,"; + sql += "GameID INTEGER NOT NULL,"; + sql += "Sb_Amount INTEGER,"; + sql += "Sb_Seat INTEGER,"; + sql += "Bb_Amount INTEGER,"; + sql += "Bb_Seat INTEGER,"; + sql += "Dealer_Seat INTEGER,"; + for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { + sql += "Seat_" + QString("%1").arg(i) + "_Cash INTEGER,"; + sql += "Seat_" + QString("%1").arg(i) + "_Card_1 INTEGER,"; + sql += "Seat_" + QString("%1").arg(i) + "_Card_2 INTEGER,"; + sql += "Seat_" + QString("%1").arg(i) + "_Hand TEXT,"; + } + for(i=1; i<=5; i++) { + sql += "BoardCard_" + QString("%1").arg(i) + " INTEGER,"; + } + sql += "PRIMARY KEY(HandID,GameID))"; + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + // create action table + sql = "CREATE TABLE Action ("; + sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT,"; + sql += "HandID INTEGER NOT NULL,"; + sql += "GameID INTEGER NOT NULL,"; + sql += "BeRo INTEGER NOT NULL,"; + sql += "Player INTEGER NOT NULL,"; + sql += "Action INTEGER NOT NULL,"; + sql += "Amount INTEGER)"; + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + } else { + QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + } + + // delete old log files int daysUntilWaste = myConfig->readConfigInt("LogStoreDuration"); QStringList filters("pokerth-log*"); @@ -180,7 +194,7 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my QDate dateOfFile(QDate::fromString(dateString, Qt::ISODate)); QDate today(QDate::currentDate()); - // cout << dateOfFile.daysTo(today) << endl; +// cout << dateOfFile.daysTo(today) << endl; if (dateOfFile.daysTo(today) > daysUntilWaste) { @@ -201,16 +215,19 @@ Log::~Log() { delete myLogDir; delete myHtmlLogFile; -// delete mySqliteLogDb; + if(SQLITE_LOG) delete mySqliteLogDb; } void Log::closeLogDbAtExit() { - // Datenbank schließen -// mySqliteLogDb->close(); -// delete mySqliteLogDb; -// mySqliteLogDb = NULL; + if(SQLITE_LOG) { + // close sqlite-db + mySqliteLogDb->close(); + delete mySqliteLogDb; + mySqliteLogDb = NULL; + } + } void Log::logPlayerActionMsg(QString msg, int playerID, int action, int setValue) { @@ -234,36 +251,50 @@ void Log::logPlayerActionMsg(QString msg, int playerID, int action, int setValue if (action >= 3) { msg += "$"+QString::number(setValue,10)+"."; } - myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+msg+""); + myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+msg+""); if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled - logFileStreamString += msg+"
\n"; - - if(myConfig->readConfigInt("LogInterval") == 0) { - writeLogFileStream(logFileStreamString); - logFileStreamString = ""; - } + //if write logfiles is enabled -// if(mySqliteLogDb->isOpen()) { -// -// QSqlQuery query(*mySqliteLogDb); -// QString sql; -// -// sql = "INSERT INTO Action (HandID,GameID,BeRo,Player,Action,Amount) VALUES ("; -// sql += QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10); -// sql += "," + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10); -// sql += "," + QString::number(myW->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->getMyBeRoID(),10); -// sql += "," + QString::number(playerID,10); -// sql += "," + QString::number(action,10); -// sql += "," + QString::number(setValue,10); -// sql += ")"; -// -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// -// } + if(HTML_LOG) { + + logFileStreamString += msg+"
\n"; + + if(myConfig->readConfigInt("LogInterval") == 0) { + writeLogFileStream(logFileStreamString); + logFileStreamString = ""; + } + + } + + if(SQLITE_LOG) { + + if(mySqliteLogDb->isOpen()) { + + QSqlQuery query(*mySqliteLogDb); + QString sql; + + sql = "INSERT INTO Action (HandID,GameID,BeRo,Player,Action,Amount) VALUES ("; + sql += QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10); + sql += "," + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10); + sql += "," + QString::number(myW->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->getMyBeRoID(),10); + sql += "," + QString::number(playerID,10); + sql += "," + QString::number(action,10); + sql += "," + QString::number(setValue,10); + sql += ")"; + + if(myConfig->readConfigInt("LogInterval") == 0) { + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + } + + + } else { + QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + } } } @@ -273,94 +304,98 @@ void Log::logNewGameHandMsg(int gameID, int handID) { PlayerListConstIterator it_c; HandInterface *currentHand = myW->getSession()->getCurrentGame()->getCurrentHand(); - myW->textBrowser_Log->append("getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##"); + myW->textBrowser_Log->append("getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##"); if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + //if write logfiles is enabled -// int i; + if(HTML_LOG) { - logFileStreamString += "

Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"
"; - logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"
"; + logFileStreamString += "

Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"
"; + logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"
"; -// if(!mySqliteLogDb->open()) { -// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } + //print cash only for active players + for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { -// -// if(mySqliteLogDb->isOpen()) { -// -// QSqlQuery query(*mySqliteLogDb); -// QString sql; -// -// // bei Beginn eines Games -// if(handID == 1) { -// sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos"; -// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { -// sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10); -// } -//// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) { -//// sql += ",Seat_" + QString::number(i,10); -//// } -// sql += ") VALUES ("; -// sql += QString::number(gameID,10) + ","; -// sql += QString::number(myW->getSession()->getCurrentGame()->getStartCash(),10) + ","; -// sql += QString::number(myW->getSession()->getCurrentGame()->getStartSmallBlind(),10) + ","; -// sql += QString::number(myW->getSession()->getCurrentGame()->getDealerPosition(),10); -// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { + logFileStreamString += "Seat " + QString::number((*it_c)->getMyID()+1,10) + ": " + QString::fromUtf8((*it_c)->getMyName().c_str()) + " ($" + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10)+")
"; + + } + + } + + if(SQLITE_LOG) { + + + if(mySqliteLogDb->isOpen()) { + + QSqlQuery query(*mySqliteLogDb); + QString sql; + + // beginning of a game + if(handID == 1) { + sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos"; + for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { + sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10); + } +// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) { +// sql += ",Seat_" + QString::number(i,10); +// } + sql += ") VALUES ("; + sql += QString::number(gameID,10) + ","; + sql += QString::number(myW->getSession()->getCurrentGame()->getStartCash(),10) + ","; + sql += QString::number(myW->getSession()->getCurrentGame()->getStartSmallBlind(),10) + ","; + sql += QString::number(myW->getSession()->getCurrentGame()->getDealerPosition(),10); + for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { + sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'"; + } +// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) { +// if((*it_c)->getMyActiveStatus()) { // sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'"; -// } -//// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) { -//// if((*it_c)->getMyActiveStatus()) { -//// sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'"; -//// } else { -//// sql += ",NULL"; -//// } -//// } -// sql += ")"; -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); +// } else { +// sql += ",NULL"; // } // } -// -// sql = "INSERT INTO Hand (HandID,GameID,Sb_Amount,Bb_Amount"; -// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { -// sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10) + "_Cash"; -// } -//// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) { -//// sql += ",Seat_" + QString("%1").arg(i) + "_Cash"; -//// } -// sql += ") VALUES ("; -// sql += QString::number(handID,10); -// sql += "," + QString::number(gameID,10); -// sql += "," + QString::number(currentHand->getSmallBlind(),10); -// sql += "," + QString::number(currentHand->getSmallBlind()*2,10); -// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { -// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10); -// } -//// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) { -//// if((*it_c)->getMyActiveStatus()) { -//// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10); -//// } else { -//// sql += ",NULL"; -//// } -//// } -// sql += ")"; -// -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// + sql += ")"; + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + } + + // beginning of a hand + sql = "INSERT INTO Hand (HandID,GameID,Sb_Amount,Bb_Amount"; + for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { + sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10) + "_Cash"; + } +// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) { +// sql += ",Seat_" + QString("%1").arg(i) + "_Cash"; // } -// + sql += ") VALUES ("; + sql += QString::number(handID,10); + sql += "," + QString::number(gameID,10); + sql += "," + QString::number(currentHand->getSmallBlind(),10); + sql += "," + QString::number(currentHand->getSmallBlind()*2,10); + for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { + sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10); + } +// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) { +// if((*it_c)->getMyActiveStatus()) { +// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10); +// } else { +// sql += ",NULL"; +// } +// } + sql += ")"; - //print cash only for active players - for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } - logFileStreamString += "Seat " + QString::number((*it_c)->getMyID()+1,10) + ": " + QString::fromUtf8((*it_c)->getMyName().c_str()) + " ($" + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10)+")
"; + } else { + QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); + } - } + } } @@ -459,49 +494,72 @@ void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int } if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + //if write logfiles is enabled + + if(HTML_LOG) { + + switch (roundID) { + + case 1: round = "Flop"; + logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+"]"+"
\n"; + break; + case 2: round = "Turn"; + logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+"]"+"
\n"; + break; + case 3: round = "River"; + logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+""+translateCardCode(card5).at(1)+"]"+"
\n"; + break; + default: round = "ERROR"; + } + + if(myConfig->readConfigInt("LogInterval") == 0) { + writeLogFileStream(logFileStreamString); + logFileStreamString = ""; + } + + } + + if(SQLITE_LOG) { + + if(mySqliteLogDb->isOpen()) { + + QSqlQuery query(*mySqliteLogDb); + QString sql; + sql = "UPDATE Hand SET "; -// QString sql; -// sql = "UPDATE Hand SET "; -// switch (roundID) { - - case 1: round = "Flop"; - logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+"]"+"
\n"; -// sql += "BoardCard_1 = " + QString::number(card1,10) + ","; -// sql += "BoardCard_2 = " + QString::number(card2,10) + ","; -// sql += "BoardCard_3 = " + QString::number(card3,10); - break; - case 2: round = "Turn"; - logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+"]"+"
\n"; -// sql += "BoardCard_4 = " + QString::number(card4,10); - break; - case 3: round = "River"; - logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+""+translateCardCode(card5).at(1)+"]"+"
\n"; -// sql += "BoardCard_5 = " + QString::number(card5,10); - break; - default: round = "ERROR"; + case 1: round = "Flop"; + sql += "BoardCard_1 = " + QString::number(card1,10) + ","; + sql += "BoardCard_2 = " + QString::number(card2,10) + ","; + sql += "BoardCard_3 = " + QString::number(card3,10); + break; + case 2: round = "Turn"; + sql += "BoardCard_4 = " + QString::number(card4,10); + break; + case 3: round = "River"; + sql += "BoardCard_5 = " + QString::number(card5,10); + break; + default: round = "ERROR"; } - if(myConfig->readConfigInt("LogInterval") == 0) { - writeLogFileStream(logFileStreamString); - logFileStreamString = ""; - } -// -// sql += " WHERE "; -// sql += "HandID = " + QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10) + " AND "; -// sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10); -// -// if(roundID <= 3) { -// if(mySqliteLogDb->isOpen()) { -// -// QSqlQuery query(*mySqliteLogDb); -// if(!query.exec(sql)) { -// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); -// } -// -// } -// -// } + sql += " WHERE "; + sql += "HandID = " + QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10) + " AND "; + sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10); + + + if(myConfig->readConfigInt("LogInterval") == 0) { + if(roundID <= 3) { + if(!query.exec(sql)) { + QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + } + } + + } else { + QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); + } + + } } }