changes in logging with sqlite-db

This commit is contained in:
floty
2010-07-02 23:29:30 +00:00
parent fdabcfcdda
commit 51126fad7c
4 changed files with 212 additions and 218 deletions
+13 -13
View File
@@ -118,11 +118,11 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
case 1: {
tempBoardArray[0] = 36;
tempBoardArray[1] = 21;
tempBoardArray[2] = 50;
tempBoardArray[3] = 15;
tempBoardArray[4] = -1;
tempBoardArray[0] = 32;
tempBoardArray[1] = 8;
tempBoardArray[2] = 7;
tempBoardArray[3] = 48;
tempBoardArray[4] = 21;
myBoard->setMyCards(tempBoardArray);
@@ -135,8 +135,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player0
it = seatsList->begin();
tempPlayerArray[0] = 0;
tempPlayerArray[1] = 1;
tempPlayerArray[0] = 44;
tempPlayerArray[1] = 10;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -148,8 +148,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player1
it++;
tempPlayerArray[0] = 47;
tempPlayerArray[1] = 51;
tempPlayerArray[0] = 31;
tempPlayerArray[1] = 22;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -174,8 +174,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player3
it++;
tempPlayerArray[0] = 36;
tempPlayerArray[1] = 47;
tempPlayerArray[0] = 23;
tempPlayerArray[1] = 1;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -187,8 +187,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player4
it++;
tempPlayerArray[0] = 48;
tempPlayerArray[1] = 2;
tempPlayerArray[0] = 36;
tempPlayerArray[1] = 45;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
+56 -55
View File
@@ -861,22 +861,22 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
switch(myUniqueID) {
case 0: {
myCash=19855;
myCash=2980;
} break;
case 1: {
myCash=20750;
myCash=2980;
} break;
case 2: {
myCash=0;
myCash=2980;
} break;
case 3: {
myCash=0;
myCash=2980;
} break;
case 4: {
myCash=9395;
myCash=2980;
} break;
case 5: {
myCash=100;
myCash=2980;
} break;
case 6: {
myCash=0;
@@ -1336,7 +1336,7 @@ void LocalPlayer::preflopEngine() {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_CHECK;
myAction = PLAYER_ACTION_CALL;
// raise = 20;
}
break;
@@ -1356,8 +1356,8 @@ void LocalPlayer::preflopEngine() {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_RAISE;
raise = 20;
myAction = PLAYER_ACTION_CALL;
// raise = 20;
// if(mySet >= 40) {
// myAction = PLAYER_ACTION_CALL;
// }
@@ -1425,7 +1425,8 @@ void LocalPlayer::preflopEngine() {
break;
case 5: {
// if(mySet == 0) {
myAction = PLAYER_ACTION_CHECK;
myAction = PLAYER_ACTION_RAISE;
raise = 20;
// }
}
break;
@@ -1713,11 +1714,11 @@ void LocalPlayer::flopEngine() {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_BET;
bet = 20;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
myAction = PLAYER_ACTION_CALL;
}
// bet = 20;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL;
// }
} break;
case 2: {
// myAction = PLAYER_ACTION_BET;
@@ -1731,12 +1732,12 @@ void LocalPlayer::flopEngine() {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_BET;
bet = 20;
// raise = 20;
if(mySet > 20) {
myAction = PLAYER_ACTION_CALL;
}
// bet = 20;
// raise = 20;
// if(mySet > 20) {
// myAction = PLAYER_ACTION_CALL;
// }
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL;
// }
@@ -1759,8 +1760,8 @@ void LocalPlayer::flopEngine() {
case 3: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_RAISE;
raise = 400;
myAction = PLAYER_ACTION_CALL;
// raise = 400;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL;
// }
@@ -1784,11 +1785,11 @@ void LocalPlayer::flopEngine() {
case 4: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_RAISE;
raise = 140;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_FOLD;
// }
myAction = PLAYER_ACTION_CHECK;
// raise = 140;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
myAction = PLAYER_ACTION_CALL;
}
}
break;
case 2: {
@@ -1809,8 +1810,8 @@ void LocalPlayer::flopEngine() {
case 5: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_FOLD;
// bet = 80;
myAction = PLAYER_ACTION_BET;
bet = 20;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_FOLD;
// }
@@ -2404,11 +2405,11 @@ void LocalPlayer::turnEngine() {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_BET;
bet = 20;
if(currentHand->getCurrentBeRo()->getHighestSet() > 20) {
myAction = PLAYER_ACTION_CALL;
}
// bet = 20;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 20) {
// myAction = PLAYER_ACTION_CALL;
// }
}
break;
case 2: {
@@ -2425,9 +2426,9 @@ void LocalPlayer::turnEngine() {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_BET;
myAction = PLAYER_ACTION_FOLD;
// raise = 40;
bet = 40;
// bet = 40;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 100) {
// myAction = PLAYER_ACTION_CALL;
// }
@@ -2452,10 +2453,10 @@ void LocalPlayer::turnEngine() {
case 1: {
myAction = PLAYER_ACTION_CALL;
// bet = 10;
if(currentHand->getCurrentBeRo()->getHighestSet() > 500) {
myAction = PLAYER_ACTION_RAISE;
raise = 10000;
}
// if(currentHand->getCurrentBeRo()->getHighestSet() > 500) {
// myAction = PLAYER_ACTION_RAISE;
// raise = 10000;
// }
}
break;
case 2: {
@@ -2476,11 +2477,11 @@ void LocalPlayer::turnEngine() {
case 4: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_RAISE;
raise = 120;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL;
// }
myAction = PLAYER_ACTION_BET;
bet = 120;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
myAction = PLAYER_ACTION_CALL;
}
}
break;
case 2: {
@@ -2501,7 +2502,7 @@ void LocalPlayer::turnEngine() {
case 5: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_CALL;
myAction = PLAYER_ACTION_FOLD;
// bet = 10;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_CALL;
@@ -2837,11 +2838,11 @@ void LocalPlayer::riverEngine() {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_RAISE;
raise = 40;
if(currentHand->getCurrentBeRo()->getHighestSet() > 60) {
myAction = PLAYER_ACTION_CALL;
}
// raise = 40;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 60) {
// myAction = PLAYER_ACTION_CALL;
// }
} break;
case 2: {
// myAction = PLAYER_ACTION_BET;
@@ -2880,7 +2881,7 @@ void LocalPlayer::riverEngine() {
case 3: {
switch(currentHand->getMyID()) {
case 1: {
// myAction = PLAYER_ACTION_BET;
myAction = PLAYER_ACTION_CALL;
// bet = 120;
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
// myAction = PLAYER_ACTION_RAISE;
@@ -2906,12 +2907,12 @@ void LocalPlayer::riverEngine() {
case 4: {
switch(currentHand->getMyID()) {
case 1: {
myAction = PLAYER_ACTION_RAISE;
raise = 300;
// bet = 120;
if(currentHand->getCurrentBeRo()->getHighestSet() > 360) {
myAction = PLAYER_ACTION_RAISE;
raise = 10000;
myAction = PLAYER_ACTION_BET;
// raise = 300;
bet = 220;
if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
myAction = PLAYER_ACTION_CALL;
// raise = 10000;
}
}
break;
+1 -1
View File
@@ -45,7 +45,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
if(DEBUG_MODE) {
startSmallBlind = 10;
currentSmallBlind = startSmallBlind;
dealerPosition = 4;
dealerPosition = 3;
}
int i;
+30 -37
View File
@@ -60,7 +60,7 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
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();
mySqliteLogDb = new QSqlDatabase;
//Logo-Pixmap extrahieren
QPixmap logoChipPixmapFile(":/gfx/logoChip3D.png");
@@ -84,15 +84,17 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
// 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()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
if(mySqliteLogDb->open()) {
QSqlQuery query(*mySqliteLogDb);
QString sql;
QSqlQuery query;
// Session-Tabelle
sql = "CREATE TABLE Session (Version TEXT,Date TEXT,Time TEXT, PRIMARY KEY(Date,Time))";
sql = "CREATE TABLE Session (";
sql += "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);
}
@@ -148,10 +150,11 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
query.clear();
} else {
// Datenbank schließen
mySqliteLogDb->close();
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
//Zu alte Dateien löschen!!!
int daysUntilWaste = myConfig->readConfigInt("LogStoreDuration");
@@ -189,7 +192,8 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
Log::~Log()
{
// Datenbank schließen
mySqliteLogDb->close();
delete myConfig;
delete myLogDir;
@@ -230,12 +234,10 @@ void Log::logPlayerActionMsg(QString msg, int playerID, int action, int setValue
logFileStreamString = "";
}
if(!mySqliteLogDb->open()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
if(mySqliteLogDb->isOpen()) {
QSqlQuery query(*mySqliteLogDb);
QString sql;
QSqlQuery query;
sql = "INSERT INTO Action (HandID,GameID,BeRo,Player,Action,Amount) VALUES (";
sql += QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10);
@@ -250,10 +252,7 @@ void Log::logPlayerActionMsg(QString msg, int playerID, int action, int setValue
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
query.clear();
mySqliteLogDb->close();
}
}
}
@@ -277,9 +276,13 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
// bei Beginn eines Games
if(mySqliteLogDb->isOpen()) {
QSqlQuery query(*mySqliteLogDb);
QString sql;
QSqlQuery query;
// bei Beginn eines Games
if(handID == 1) {
sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
@@ -323,9 +326,7 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
query.clear();
mySqliteLogDb->close();
}
//print cash only for active players
@@ -466,18 +467,15 @@ void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int
sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10);
if(roundID <= 3) {
if(!mySqliteLogDb->open()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
if(mySqliteLogDb->isOpen()) {
QSqlQuery query;
QSqlQuery query(*mySqliteLogDb);
if(!query.exec(sql)) {
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
query.clear();
}
mySqliteLogDb->close();
}
}
@@ -524,19 +522,14 @@ void Log::logFlipHoleCardsMsg(QString playerName, int playerID, int card1, int c
sql += "HandID = " + QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10) + " AND ";
sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10);
if(!mySqliteLogDb->open()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
if(mySqliteLogDb->isOpen()) {
QSqlQuery query;
QSqlQuery query(*mySqliteLogDb);
if(!query.exec(sql)) {
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
query.clear();
mySqliteLogDb->close();
}
}