active sqlite-log with symbol constant

This commit is contained in:
floty
2010-09-29 17:43:49 +00:00
parent 76ce0afe4c
commit 377f6dde6e
5 changed files with 541 additions and 306 deletions
+229 -54
View File
@@ -861,34 +861,34 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
switch(myUniqueID) { switch(myUniqueID) {
case 0: { case 0: {
myCash=2588; myCash=4140;
} break; } break;
case 1: { case 1: {
myCash=0; myCash=4940;
} break; } break;
case 2: { case 2: {
myCash=404; myCash=4660;
} break; } break;
case 3: { case 3: {
myCash=0; myCash=4960;
} break; } break;
case 4: { case 4: {
myCash=0; myCash=5680;
} break; } break;
case 5: { case 5: {
myCash=1133; myCash=4960;
} break; } break;
case 6: { case 6: {
myCash=5275; myCash=4960;
} break; } break;
case 7: { case 7: {
myCash=0; myCash=5780;
} break; } break;
case 8: { case 8: {
myCash=0; myCash=4960;
} break; } break;
case 9: { case 9: {
myCash=0; myCash=4960;
} break; } break;
default: { default: {
@@ -1356,8 +1356,8 @@ void LocalPlayer::preflopEngine() {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_RAISE; myAction = PLAYER_ACTION_CALL;
raise = 20000; // raise = 20000;
// if(mySet >= 40) { // if(mySet >= 40) {
// myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
// } // }
@@ -1380,8 +1380,8 @@ void LocalPlayer::preflopEngine() {
case 3: { case 3: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_RAISE; myAction = PLAYER_ACTION_CALL;
raise = 2000; // raise = 2000;
// if(mySet >= 40) { // if(mySet >= 40) {
// myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
// } // }
@@ -1403,8 +1403,8 @@ void LocalPlayer::preflopEngine() {
case 4: { case 4: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_RAISE; myAction = PLAYER_ACTION_CALL;
raise = 2000; // raise = 2000;
// if(mySet > 0) { // if(mySet > 0) {
// myAction = PLAYER_ACTION_FOLD; // myAction = PLAYER_ACTION_FOLD;
// } // }
@@ -1425,14 +1425,14 @@ void LocalPlayer::preflopEngine() {
break; break;
case 5: { case 5: {
// if(mySet == 0) { // if(mySet == 0) {
myAction = PLAYER_ACTION_FOLD; myAction = PLAYER_ACTION_CALL;
// raise = 20; // raise = 20;
// } // }
} }
break; break;
case 6: { case 6: {
// if(mySet == 160) { // if(mySet == 160) {
myAction = PLAYER_ACTION_CALL; myAction = PLAYER_ACTION_CHECK;
// } // }
} }
break; break;
@@ -1450,6 +1450,13 @@ void LocalPlayer::preflopEngine() {
// } // }
} }
break; break;
case 9: {
// if(mySet == 160) {
myAction = PLAYER_ACTION_CALL;
// }
}
break;
default: {} default: {}
} }
@@ -1728,7 +1735,7 @@ void LocalPlayer::flopEngine() {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_CALL; myAction = PLAYER_ACTION_CHECK;
// bet = 20; // bet = 20;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
@@ -1746,7 +1753,7 @@ void LocalPlayer::flopEngine() {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_CALL; myAction = PLAYER_ACTION_CHECK;
// bet = 20; // bet = 20;
// raise = 20; // raise = 20;
// if(mySet > 20) { // if(mySet > 20) {
@@ -1774,7 +1781,7 @@ void LocalPlayer::flopEngine() {
case 3: { case 3: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_CALL; myAction = PLAYER_ACTION_CHECK;
// raise = 400; // raise = 400;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
@@ -1801,9 +1808,9 @@ void LocalPlayer::flopEngine() {
case 1: { case 1: {
myAction = PLAYER_ACTION_CHECK; myAction = PLAYER_ACTION_CHECK;
// raise = 140; // raise = 140;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
} // }
} }
break; break;
case 2: { case 2: {
@@ -1824,8 +1831,8 @@ void LocalPlayer::flopEngine() {
case 5: { case 5: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_BET; myAction = PLAYER_ACTION_CHECK;
bet = 20; // bet = 20;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_FOLD; // myAction = PLAYER_ACTION_FOLD;
// } // }
@@ -1849,11 +1856,11 @@ void LocalPlayer::flopEngine() {
case 6: { case 6: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_RAISE; myAction = PLAYER_ACTION_CHECK;
raise = 40; // raise = 40;
if(currentHand->getCurrentBeRo()->getHighestSet() > 60) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 60) {
myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
} // }
} }
break; break;
case 2: { 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; break;
default: {} default: {}
@@ -2419,7 +2438,7 @@ void LocalPlayer::turnEngine() {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_CALL; myAction = PLAYER_ACTION_FOLD;
// bet = 20; // bet = 20;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 20) {
// myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
@@ -2465,7 +2484,7 @@ void LocalPlayer::turnEngine() {
case 3: { case 3: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_CALL; myAction = PLAYER_ACTION_FOLD;
// bet = 10; // bet = 10;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 500) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 500) {
// myAction = PLAYER_ACTION_RAISE; // myAction = PLAYER_ACTION_RAISE;
@@ -2491,11 +2510,11 @@ void LocalPlayer::turnEngine() {
case 4: { case 4: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_BET; myAction = PLAYER_ACTION_FOLD;
bet = 120; // bet = 120;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
myAction = PLAYER_ACTION_CALL; // myAction = PLAYER_ACTION_CALL;
} // }
} }
break; break;
case 2: { case 2: {
@@ -2516,11 +2535,11 @@ void LocalPlayer::turnEngine() {
case 5: { case 5: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_FOLD; myAction = PLAYER_ACTION_BET;
// bet = 10; bet = 20;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL; myAction = PLAYER_ACTION_CALL;
// } }
} }
break; break;
case 2: { case 2: {
@@ -2541,11 +2560,89 @@ void LocalPlayer::turnEngine() {
case 6: { case 6: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_BET; myAction = PLAYER_ACTION_RAISE;
bet = 240; bet = 20;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { if(currentHand->getCurrentBeRo()->getHighestSet() > 20) {
myAction = PLAYER_ACTION_RAISE; myAction = PLAYER_ACTION_CALL;
raise = 10000; // 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; break;
@@ -2948,12 +3045,12 @@ void LocalPlayer::riverEngine() {
case 5: { case 5: {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_FOLD; myAction = PLAYER_ACTION_CHECK;
// bet = 120; // bet = 120;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_RAISE; myAction = PLAYER_ACTION_FOLD;
// raise = 10000; // raise = 10000;
// } }
} }
break; break;
case 2: { case 2: {
@@ -2975,8 +3072,86 @@ void LocalPlayer::riverEngine() {
switch(currentHand->getMyID()) { switch(currentHand->getMyID()) {
case 1: { case 1: {
myAction = PLAYER_ACTION_BET; myAction = PLAYER_ACTION_BET;
bet = 240; bet = 40;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { 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; myAction = PLAYER_ACTION_RAISE;
raise = 10000; raise = 10000;
} }
+2 -2
View File
@@ -43,9 +43,9 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
dealerPosition = startData.startDealerPlayerId; dealerPosition = startData.startDealerPlayerId;
if(DEBUG_MODE) { if(DEBUG_MODE) {
startSmallBlind = 300; startSmallBlind = 10;
currentSmallBlind = startSmallBlind; currentSmallBlind = startSmallBlind;
dealerPosition = 5; dealerPosition = 4;
} }
int i; int i;
+2
View File
@@ -27,6 +27,8 @@
#define MAX_GUI_SPEED 11 #define MAX_GUI_SPEED 11
#define DEBUG_MODE 0 #define DEBUG_MODE 0
#define SQLITE_LOG 0
#define HTML_LOG 1
#define POKERTH_VERSION_MAJOR 0 #define POKERTH_VERSION_MAJOR 0
#define POKERTH_VERSION_MINOR 80 #define POKERTH_VERSION_MINOR 80
+1 -1
View File
@@ -1132,7 +1132,7 @@ void gameTableImpl::dealHoleCards() {
(*it_c)->getMyCards(tempCardsIntArray); (*it_c)->getMyCards(tempCardsIntArray);
for(j=0; j<2; j++) { for(j=0; j<2; j++) {
if((*it_c)->getMyActiveStatus()) { 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"); tempCardsPixmapArray[j].load(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png");
if(myConfig->readConfigInt("AntiPeekMode")) { if(myConfig->readConfigInt("AntiPeekMode")) {
holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(flipside, TRUE); holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(flipside, TRUE);
+306 -248
View File
@@ -60,110 +60,124 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
if(myConfig->readConfigString("LogDir") != "" && logDir.exists()) { 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 << "<html>\n";
stream << "<head>\n";
stream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\">";
stream << "</head>\n";
stream << "<body style=\"font-size:smaller\">\n";
stream << "<img src='logo.png'>\n";
stream << QString("<h3><b>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")+"</b></h3>\n";
myHtmlLogFile->close();
int i; 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 << "<html>\n";
stream << "<head>\n";
stream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\">";
stream << "</head>\n";
stream << "<body style=\"font-size:smaller\">\n";
stream << "<img src='logo.png'>\n";
stream << QString("<h3><b>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")+"</b></h3>\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"); int daysUntilWaste = myConfig->readConfigInt("LogStoreDuration");
QStringList filters("pokerth-log*"); 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 dateOfFile(QDate::fromString(dateString, Qt::ISODate));
QDate today(QDate::currentDate()); QDate today(QDate::currentDate());
// cout << dateOfFile.daysTo(today) << endl; // cout << dateOfFile.daysTo(today) << endl;
if (dateOfFile.daysTo(today) > daysUntilWaste) { if (dateOfFile.daysTo(today) > daysUntilWaste) {
@@ -201,16 +215,19 @@ Log::~Log()
{ {
delete myLogDir; delete myLogDir;
delete myHtmlLogFile; delete myHtmlLogFile;
// delete mySqliteLogDb; if(SQLITE_LOG) delete mySqliteLogDb;
} }
void Log::closeLogDbAtExit() void Log::closeLogDbAtExit()
{ {
// Datenbank schließen if(SQLITE_LOG) {
// mySqliteLogDb->close(); // close sqlite-db
// delete mySqliteLogDb; mySqliteLogDb->close();
// mySqliteLogDb = NULL; delete mySqliteLogDb;
mySqliteLogDb = NULL;
}
} }
void Log::logPlayerActionMsg(QString msg, int playerID, int action, int setValue) { 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)+"."; } if (action >= 3) { msg += "$"+QString::number(setValue,10)+"."; }
myW->textBrowser_Log->append("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+msg+"</span>"); myW->textBrowser_Log->append("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+msg+"</span>");
if(myConfig->readConfigInt("LogOnOff")) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
logFileStreamString += msg+"</br>\n";
if(myConfig->readConfigInt("LogInterval") == 0) { if(HTML_LOG) {
writeLogFileStream(logFileStreamString);
logFileStreamString = "";
}
// if(mySqliteLogDb->isOpen()) { logFileStreamString += msg+"</br>\n";
//
// QSqlQuery query(*mySqliteLogDb); if(myConfig->readConfigInt("LogInterval") == 0) {
// QString sql; writeLogFileStream(logFileStreamString);
// logFileStreamString = "";
// 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); if(SQLITE_LOG) {
// sql += "," + QString::number(action,10);
// sql += "," + QString::number(setValue,10); if(mySqliteLogDb->isOpen()) {
// sql += ")";
// QSqlQuery query(*mySqliteLogDb);
// if(!query.exec(sql)) { QString sql;
// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// } 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; PlayerListConstIterator it_c;
HandInterface *currentHand = myW->getSession()->getCurrentGame()->getCurrentHand(); HandInterface *currentHand = myW->getSession()->getCurrentGame()->getCurrentHand();
myW->textBrowser_Log->append("<span style=\"color:#"+myStyle->getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##</span>"); myW->textBrowser_Log->append("<span style=\"color:#"+myStyle->getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##</span>");
if(myConfig->readConfigInt("LogOnOff")) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
// int i; if(HTML_LOG) {
logFileStreamString += "<table><tr><td width=\"600\" align=\"center\"><hr noshade size=\"3\"><b>Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"</b></td><td></td></tr></table>"; logFileStreamString += "<table><tr><td width=\"600\" align=\"center\"><hr noshade size=\"3\"><b>Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"</b></td><td></td></tr></table>";
logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"</br>"; logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"</br>";
// if(!mySqliteLogDb->open()) { //print cash only for active players
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
// }
// logFileStreamString += "Seat " + QString::number((*it_c)->getMyID()+1,10) + ": <b>" + QString::fromUtf8((*it_c)->getMyName().c_str()) + "</b> ($" + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10)+")</br>";
// if(mySqliteLogDb->isOpen()) {
// }
// QSqlQuery query(*mySqliteLogDb);
// QString sql; }
//
// // bei Beginn eines Games if(SQLITE_LOG) {
// if(handID == 1) {
// sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { if(mySqliteLogDb->isOpen()) {
// sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10);
// } QSqlQuery query(*mySqliteLogDb);
//// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) { QString sql;
//// sql += ",Seat_" + QString::number(i,10);
//// } // beginning of a game
// sql += ") VALUES ("; if(handID == 1) {
// sql += QString::number(gameID,10) + ","; sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
// sql += QString::number(myW->getSession()->getCurrentGame()->getStartCash(),10) + ","; for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
// sql += QString::number(myW->getSession()->getCurrentGame()->getStartSmallBlind(),10) + ","; sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10);
// sql += QString::number(myW->getSession()->getCurrentGame()->getDealerPosition(),10); }
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { // 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()) +"'"; // sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'";
// } // } else {
//// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) { // sql += ",NULL";
//// 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);
// } // }
// } // }
// sql += ")";
// sql = "INSERT INTO Hand (HandID,GameID,Sb_Amount,Bb_Amount"; if(!query.exec(sql)) {
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// 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"; // beginning of a hand
//// } sql = "INSERT INTO Hand (HandID,GameID,Sb_Amount,Bb_Amount";
// sql += ") VALUES ("; for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
// sql += QString::number(handID,10); sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10) + "_Cash";
// sql += "," + QString::number(gameID,10); }
// sql += "," + QString::number(currentHand->getSmallBlind(),10); // for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
// sql += "," + QString::number(currentHand->getSmallBlind()*2,10); // sql += ",Seat_" + QString("%1").arg(i) + "_Cash";
// 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 += ") 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 if(!query.exec(sql)) {
for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
logFileStreamString += "Seat " + QString::number((*it_c)->getMyID()+1,10) + ": <b>" + QString::fromUtf8((*it_c)->getMyName().c_str()) + "</b> ($" + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10)+")</br>"; } 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(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
if(HTML_LOG) {
switch (roundID) {
case 1: round = "Flop";
logFileStreamString += "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+"]"+"</br>\n";
break;
case 2: round = "Turn";
logFileStreamString += "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+"]"+"</br>\n";
break;
case 3: round = "River";
logFileStreamString += "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+",<b>"+translateCardCode(card5).at(0)+"</b>"+translateCardCode(card5).at(1)+"]"+"</br>\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) { switch (roundID) {
case 1: round = "Flop";
case 1: round = "Flop"; sql += "BoardCard_1 = " + QString::number(card1,10) + ",";
logFileStreamString += "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+"]"+"</br>\n"; sql += "BoardCard_2 = " + QString::number(card2,10) + ",";
// sql += "BoardCard_1 = " + QString::number(card1,10) + ","; sql += "BoardCard_3 = " + QString::number(card3,10);
// sql += "BoardCard_2 = " + QString::number(card2,10) + ","; break;
// sql += "BoardCard_3 = " + QString::number(card3,10); case 2: round = "Turn";
break; sql += "BoardCard_4 = " + QString::number(card4,10);
case 2: round = "Turn"; break;
logFileStreamString += "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+"]"+"</br>\n"; case 3: round = "River";
// sql += "BoardCard_4 = " + QString::number(card4,10); sql += "BoardCard_5 = " + QString::number(card5,10);
break; break;
case 3: round = "River"; default: round = "ERROR";
logFileStreamString += "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+",<b>"+translateCardCode(card5).at(0)+"</b>"+translateCardCode(card5).at(1)+"]"+"</br>\n";
// sql += "BoardCard_5 = " + QString::number(card5,10);
break;
default: round = "ERROR";
} }
if(myConfig->readConfigInt("LogInterval") == 0) { sql += " WHERE ";
writeLogFileStream(logFileStreamString); sql += "HandID = " + QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10) + " AND ";
logFileStreamString = ""; sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10);
}
//
// sql += " WHERE "; if(myConfig->readConfigInt("LogInterval") == 0) {
// sql += "HandID = " + QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10) + " AND "; if(roundID <= 3) {
// sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10); if(!query.exec(sql)) {
// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// 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); } else {
// } QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
// }
// }
// }
} }
} }