additional log in sqlite-db + preparation for replay mode

This commit is contained in:
floty
2010-05-29 14:05:41 +00:00
parent 4e3d885bc3
commit 4643e7ff89
19 changed files with 372 additions and 61 deletions
+6 -3
View File
@@ -10,6 +10,7 @@ CONFIG += qt \
stl \
warn_on
include(src/third_party/qtsingleapplication/qtsingleapplication.pri)
QT += sql
# ####Uncomment this for RELEASE on Linux/Unix/BSD (only for static Qt)
# QTPLUGIN += qjpeg qgif
@@ -193,7 +194,8 @@ HEADERS += src/game.h \
src/gui/qt/gametable/mynamelabel.h \
src/gui/qt/settingsdialog/mystylelistitem.h \
src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.h \
src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h
src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h \
src/engine/local_engine/replay.h
FORMS += src/gui/qt/gametable.ui \
src/gui/qt/aboutpokerth.ui \
src/gui/qt/connecttoserverdialog.ui \
@@ -259,7 +261,8 @@ SOURCES += src/pokerth.cpp \
src/gui/qt/gametable/mynamelabel.cpp \
src/gui/qt/settingsdialog/mystylelistitem.cpp \
src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp \
src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp
src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp \
src/engine/local_engine/replay.cpp
TRANSLATIONS = ts/pokerth_bg.ts \
ts/pokerth_ca.ts \
ts/pokerth_cz.ts \
@@ -408,7 +411,7 @@ unix:!mac {
LIBS += -lSDL_mixer \
-lcurl \
-lgsasl
!isEmpty( BSD ): isEmpty( kFreeBSD ):LIBS += -lcrypto
!isEmpty( BSD ):isEmpty( kFreeBSD ):LIBS += -lcrypto
else:LIBS += -lgnutls-openssl \
-lgcrypt
TARGETDEPS += ./lib/libpokerth_lib.a \
+19 -5
View File
@@ -98,6 +98,20 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
if(DEBUG_MODE) {
//QSqlDatabase *mySqliteLogDb;
// myGui->getMyW()->getSession();
//QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb();
// if(!mySqliteLogDb->open()) {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
int temp5Array[5];
switch(myID) {
@@ -108,7 +122,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
tempBoardArray[1] = 21;
tempBoardArray[2] = 50;
tempBoardArray[3] = 15;
tempBoardArray[4] = 12;
tempBoardArray[4] = -1;
myBoard->setMyCards(tempBoardArray);
@@ -121,8 +135,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// player0
it = seatsList->begin();
tempPlayerArray[0] = 13;
tempPlayerArray[1] = 22;
tempPlayerArray[0] = 0;
tempPlayerArray[1] = 1;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -174,7 +188,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
it++;
tempPlayerArray[0] = 48;
tempPlayerArray[1] = 7;
tempPlayerArray[1] = 2;
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
@@ -347,7 +361,7 @@ void LocalHand::start() {
it_sB = getActivePlayerIt(getCurrentBeRo()->getSmallBlindPositionId());
it_bB = getActivePlayerIt(getCurrentBeRo()->getBigBlindPositionId());
if(it_sB != getActivePlayerList()->end() && it_bB != getActivePlayerList()->end()) {
myGui->logNewBlindsSetsMsg((*it_sB)->getMySet(), (*it_bB)->getMySet(), (*it_sB)->getMyName().c_str(), (*it_bB)->getMyName().c_str());
myGui->logNewBlindsSetsMsg((*it_sB)->getMySet(), (*it_bB)->getMySet(), (*it_sB)->getMyName().c_str(), (*it_bB)->getMyName().c_str());
}
else { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID"); }
myGui->flushLogAtHand();
+7 -5
View File
@@ -856,6 +856,8 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
// !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!
if(DEBUG_MODE) {
//cout << myConfig->readConfigString("LogDir").c_str() << endl;
switch(myUniqueID) {
case 0: {
@@ -874,19 +876,19 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq
myCash=9395;
} break;
case 5: {
myCash=0;
myCash=100;
} break;
case 6: {
myCash=0;
} break;
case 7: {
myCash=0;
myCash=0;
} break;
case 8: {
myCash=0;
myCash=0;
} break;
case 9: {
myCash=0;
myCash=0;
} break;
default: {
@@ -1048,7 +1050,7 @@ void LocalPlayer::action() {
//set that i was the last active player. need this for unhighlighting groupbox
currentHand->setLastPlayersTurn(myID);
currentHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, mySet);
currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet);
currentHand->getGuiInterface()->nextPlayerAnimation();
// cout << "playerID in action(): " << (*(currentHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl;
+4 -4
View File
@@ -67,7 +67,7 @@ public:
void setMyAction(int theValue, bool blind = 0) {
myAction = theValue;
// logging for human player
if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, mySet);
if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet);
}
int getMyAction() const { return myAction; }
@@ -91,11 +91,11 @@ public:
// log flipping cards
if(myCardsFlip) {
switch(state) {
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt);
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
break;
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]);
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
break;
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has");
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
break;
default: ;
}
+39
View File
@@ -0,0 +1,39 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "replay.h"
Replay::Replay() : replaySqliteLogDb(0)
{
replaySqliteLogDb = new QSqlDatabase();
*replaySqliteLogDb = QSqlDatabase::addDatabase("QSQLITE");
//replaySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".db");
//if(!mySqliteLogDb->open()) {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
//}
}
Replay::~Replay()
{
delete replaySqliteLogDb;
}
+36
View File
@@ -0,0 +1,36 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef REPLAY_H
#define REPLAY_H
#include <QtSql>
class Replay
{
public:
Replay();
~Replay();
private:
QSqlDatabase *replaySqliteLogDb;
};
#endif // REPLAY_H
+3 -3
View File
@@ -258,11 +258,11 @@ ClientPlayer::setMyCardsFlip(bool theValue, int state)
// log flipping cards
if (myCardsFlip) {
switch(state) {
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt);
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
break;
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]);
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
break;
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has");
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
break;
default: ;
}
+4 -3
View File
@@ -40,9 +40,12 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
blindsList = myGameData.manualBlindsList;
dealerPosition = startData.startDealerPlayerId;
if(DEBUG_MODE) {
startSmallBlind = 10;
currentSmallBlind = startSmallBlind;
dealerPosition = 4;
}
int i;
@@ -53,15 +56,13 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
while (player_i != player_end)
{
if ((*player_i)->GetUniqueId() == startData.startDealerPlayerId)
if ((*player_i)->GetUniqueId() == dealerPosition)
break;
++player_i;
}
if (player_i == player_end)
throw LocalException(__FILE__, __LINE__, ERR_DEALER_NOT_FOUND);
dealerPosition = startData.startDealerPlayerId;
// create board
currentBoard = myFactory->createBoard();
+2
View File
@@ -74,6 +74,8 @@ public:
void setCurrentHandID(int theValue) { currentHandID = theValue; }
int getCurrentHandID() const { return currentHandID; }
unsigned getDealerPosition() const { return dealerPosition; }
boost::shared_ptr<PlayerInterface> getPlayerByUniqueId(unsigned id);
boost::shared_ptr<PlayerInterface> getCurrentPlayer();
+2 -2
View File
@@ -106,14 +106,14 @@ void ServerGuiWrapper::changeVoteOnKickButtonsState(bool /*showHide*/) {}
void ServerGuiWrapper::refreshVotesMonitor(int /*currentVotes*/, int /*numVotesNeededToKick*/) {}
void ServerGuiWrapper::endVoteOnKick() {}
void ServerGuiWrapper::logPlayerActionMsg(string /*playerName*/, int /*action*/, int /*setValue*/) {}
void ServerGuiWrapper::logPlayerActionMsg(string /*playerName*/, int /*playerID*/, int /*action*/, int /*setValue*/) {}
void ServerGuiWrapper::logNewGameHandMsg(int /*gameID*/, int /*handID*/) {}
void ServerGuiWrapper::logPlayerWinsMsg(std::string /*playerName*/, int /*pot*/, bool /*main*/) {}
void ServerGuiWrapper::logPlayerSitsOut(std::string /*playerName*/) {}
void ServerGuiWrapper::logNewBlindsSetsMsg(int /*sbSet*/, int /*bbSet*/, std::string /*sbName*/, std::string /*bbName*/) {}
void ServerGuiWrapper::logDealBoardCardsMsg(int /*roundID*/, int /*card1*/, int /*card2*/, int /*card3*/, int /*card4*/, int /*card5*/) {}
void ServerGuiWrapper::logFlipHoleCardsMsg(std::string /*playerName*/, int /*card1*/, int /*card2*/, int /*cardsValueInt*/, std::string /*showHas*/) {}
void ServerGuiWrapper::logFlipHoleCardsMsg(std::string /*playerName*/, int /*playerID*/, int /*card1*/, int /*card2*/, int /*cardsValueInt*/, std::string /*showHas*/) {}
void ServerGuiWrapper::logPlayerWinGame(std::string /*playerName*/, int /*gameID*/) {}
void ServerGuiWrapper::flushLogAtGame(int /*gameID*/) {}
void ServerGuiWrapper::flushLogAtHand() {}
+2 -2
View File
@@ -93,13 +93,13 @@ public:
void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick);
void endVoteOnKick();
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logPlayerActionMsg(std::string playerName, int playerID, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ;
void logPlayerWinsMsg(std::string playerName, int pot, bool main);
void logPlayerSitsOut(std::string playerName);
void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName);
void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) ;
void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ;
void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ;
void logPlayerWinGame(std::string playerName, int gameID);
void flushLogAtGame(int gameID);
void flushLogAtHand();
+2 -2
View File
@@ -97,13 +97,13 @@ public:
virtual void endVoteOnKick() =0;
//log.cpp
virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0;
virtual void logPlayerActionMsg(std::string playName, int playerID, int action, int setValue) =0;
virtual void logNewGameHandMsg(int gameID, int HandID) =0;
virtual void logPlayerWinsMsg(std::string playerName, int pot, bool main) = 0;
virtual void logPlayerSitsOut(std::string playerName) = 0;
virtual void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) =0;
virtual void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) = 0;
virtual void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") = 0;
virtual void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") = 0;
virtual void logPlayerWinGame(std::string playerName, int gameID) =0;
virtual void flushLogAtGame(int gameID) =0;
virtual void flushLogAtHand() =0;
+227 -16
View File
@@ -28,20 +28,20 @@
using namespace std;
Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myLogFile(0)
Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myHtmlLogFile(0), mySqliteLogDb(0)
{
myW->setLog(this);
myStyle = myW->getMyGameTableStyle();
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
connect(this, SIGNAL(signalLogPlayerActionMsg(QString, int, int)), this, SLOT(logPlayerActionMsg(QString, int, int)));
connect(this, SIGNAL(signalLogPlayerActionMsg(QString, int, int, int)), this, SLOT(logPlayerActionMsg(QString, int, int, int)));
connect(this, SIGNAL(signalLogNewGameHandMsg(int, int)), this, SLOT(logNewGameHandMsg(int, int)));
connect(this, SIGNAL(signalLogNewBlindsSetsMsg(int, int, QString, QString)), this, SLOT(logNewBlindsSetsMsg(int, int, QString, QString)));
connect(this, SIGNAL(signalLogPlayerWinsMsg(QString, int, bool)), this, SLOT(logPlayerWinsMsg(QString, int, bool)));
connect(this, SIGNAL(signalLogPlayerSitsOut(QString)), this, SLOT(logPlayerSitsOut(QString)));
connect(this, SIGNAL(signalLogDealBoardCardsMsg(int, int, int, int, int, int)), this, SLOT(logDealBoardCardsMsg(int, int, int, int, int, int)));
connect(this, SIGNAL(signalLogFlipHoleCardsMsg(QString, int, int, int, QString)), this, SLOT(logFlipHoleCardsMsg(QString, int, int, int, QString)));
connect(this, SIGNAL(signalLogFlipHoleCardsMsg(QString, int, int, int, int, QString)), this, SLOT(logFlipHoleCardsMsg(QString, int, int, int, int, QString)));
connect(this, SIGNAL(signalLogPlayerLeftMsg(QString, int)), this, SLOT(logPlayerLeftMsg(QString, int)));
connect(this, SIGNAL(signalLogNewGameAdminMsg(QString)), this, SLOT(logNewGameAdminMsg(QString)));
connect(this, SIGNAL(signalLogPlayerWinGame(QString, int)), this, SLOT(logPlayerWinGame(QString, int)));
@@ -58,16 +58,19 @@ 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()));
myLogFile = new QFile(myLogDir->absolutePath()+"/pokerth-log-"+QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss")+".html");
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(myLogFile->fileName());
// myW->textBrowser_Log->append(myHtmlLogFile->fileName());
myLogFile->open( QIODevice::WriteOnly );
QTextStream stream( myLogFile );
// 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\">";
@@ -75,11 +78,83 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
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";
myLogFile->close();
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")+".db");
if(!mySqliteLogDb->open()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
QString sql;
QSqlQuery query;
// Session-Tabelle
sql = "CREATE TABLE Session (Version TEXT,Date TEXT,Time TEXT, PRIMARY KEY(Date,Time))";
if(!query.exec(sql)) {
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
sql = "INSERT INTO Session (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 += ")";
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,";
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,";
}
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);
}
query.clear();
// Datenbank schließen
mySqliteLogDb->close();
//Zu alte Dateien löschen!!!
int daysUntilWaste = myConfig->readConfigInt("LogStoreDuration");
int i;
QStringList filters("pokerth-log*");
QStringList logFileList = myLogDir->entryList(filters, QDir::Files);
@@ -113,13 +188,17 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
Log::~Log()
{
delete myConfig;
delete myLogDir;
delete myLogFile;
delete myHtmlLogFile;
delete mySqliteLogDb;
myConfig = 0;
}
void Log::logPlayerActionMsg(QString msg, int action, int setValue) {
void Log::logPlayerActionMsg(QString msg, int playerID, int action, int setValue) {
switch (action) {
@@ -151,6 +230,31 @@ void Log::logPlayerActionMsg(QString msg, int action, int setValue) {
logFileStreamString = "";
}
if(!mySqliteLogDb->open()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
QString sql;
QSqlQuery query;
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);
}
query.clear();
mySqliteLogDb->close();
}
}
@@ -164,15 +268,74 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
int i;
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>";
if(!mySqliteLogDb->open()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
// bei Beginn eines Games
QString sql;
QSqlQuery query;
if(handID == 1) {
sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
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->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);
}
}
sql = "INSERT INTO Hand (HandID,GameID";
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);
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);
}
query.clear();
mySqliteLogDb->close();
//print cash only for active players
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>";
}
}
}
@@ -272,16 +435,24 @@ void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
QString sql;
sql = "UPDATE Hand SET ";
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";
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 += "</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";
sql += "BoardCard_4 = " + QString::number(card4,10);
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";
sql += "BoardCard_5 = " + QString::number(card5,10);
break;
default: round = "ERROR";
}
@@ -290,10 +461,29 @@ void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int
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->open()) {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
QSqlQuery query;
if(!query.exec(sql)) {
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
query.clear();
mySqliteLogDb->close();
}
}
}
void Log::logFlipHoleCardsMsg(QString playerName, int card1, int card2, int cardsValueInt, QString showHas) {
void Log::logFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt, QString showHas) {
if (cardsValueInt != -1) {
@@ -327,6 +517,27 @@ void Log::logFlipHoleCardsMsg(QString playerName, int card1, int card2, int card
}
}
QString sql = "UPDATE Hand SET ";
sql += "Seat_" + QString::number(playerID+1,10) + "_Card_1 = " + QString::number(card1,10) + ",";
sql += "Seat_" + QString::number(playerID+1,10) + "_Card_2 = " + QString::number(card2,10);
sql += " WHERE ";
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);
}
QSqlQuery query;
if(!query.exec(sql)) {
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
query.clear();
mySqliteLogDb->close();
}
void Log::logPlayerLeftMsg(QString playerName, int wasKicked) {
@@ -1647,12 +1858,12 @@ QString Log::determineHandName(int myCardsValueInt) {
void Log::writeLogFileStream(QString streamString) {
if(myLogFile) {
if(myLogFile->open( QIODevice::ReadWrite )) {
QTextStream stream( myLogFile );
if(myHtmlLogFile) {
if(myHtmlLogFile->open( QIODevice::ReadWrite )) {
QTextStream stream( myHtmlLogFile );
stream.readAll();
stream << streamString;
myLogFile->close();
myHtmlLogFile->close();
}
else { cout << "Could not open log-file to write log-messages!" << endl; }
}
+7 -6
View File
@@ -24,8 +24,8 @@
#include "configfile.h"
#include <QtCore>
#include <QtSql>
class gameTableImpl;
class GameTableStyleReader;
@@ -40,13 +40,13 @@ public:
~Log();
public slots:
void logPlayerActionMsg(QString playerName, int action, int setValue);
void logPlayerActionMsg(QString playerName, int playerID, int action, int setValue);
void logNewGameHandMsg(int gameID, int handID);
void logNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString bbName);
void logPlayerWinsMsg(QString playerName, int pot, bool main);
void logPlayerSitsOut(QString playerName);
void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1);
void logFlipHoleCardsMsg(QString playerName, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows");
void logFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows");
void logPlayerLeftMsg(QString playerName, int wasKicked);
void logNewGameAdminMsg(QString playerName);
void logPlayerWinGame(QString playerName, int gameID);
@@ -62,13 +62,13 @@ public:
void writeLogFileStream(QString string);
signals:
void signalLogPlayerActionMsg(QString playerName, int action, int setValue);
void signalLogPlayerActionMsg(QString playerName, int playerID, int action, int setValue);
void signalLogNewGameHandMsg(int gameID, int handID);
void signalLogNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString bbName);
void signalLogPlayerWinsMsg(QString playerName, int pot, bool main);
void signalLogPlayerSitsOut(QString playerName);
void signalLogDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1);
void signalLogFlipHoleCardsMsg(QString playerName, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows");
void signalLogFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows");
void signalLogPlayerLeftMsg(QString playerName, int wasKicked);
void signalLogNewGameAdminMsg(QString playerName);
void signalLogPlayerWinGame(QString playerName, int gameID);
@@ -83,7 +83,8 @@ private:
ConfigFile *myConfig;
QTextStream stream;
QDir *myLogDir;
QFile *myLogFile;
QFile *myHtmlLogFile;
QSqlDatabase *mySqliteLogDb;
QString logFileStreamString;
QString myAppDataPath;
+2 -2
View File
@@ -111,13 +111,13 @@ void GuiWrapper::changeVoteOnKickButtonsState(bool showHide) { myW->signalChange
void GuiWrapper::refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) { myW->refreshVotesMonitor(currentVotes, numVotesNeededToKick); }
void GuiWrapper::endVoteOnKick() { myW->signalEndVoteOnKick(); }
void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), action, setValue); }
void GuiWrapper::logPlayerActionMsg(string playerName, int playerID, int action, int setValue) { myLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), playerID, action, setValue); }
void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->signalLogNewGameHandMsg(gameID, handID); }
void GuiWrapper::logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) { myLog->signalLogNewBlindsSetsMsg(sbSet, bbSet, QString::fromUtf8(sbName.c_str()), QString::fromUtf8(bbName.c_str())); }
void GuiWrapper::logPlayerWinsMsg(std::string playerName, int pot, bool main) { myLog->signalLogPlayerWinsMsg(QString::fromUtf8(playerName.c_str()), pot, main); }
void GuiWrapper::logPlayerSitsOut(std::string playerName) { myLog->signalLogPlayerSitsOut(QString::fromUtf8(playerName.c_str())); }
void GuiWrapper::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) { myLog->signalLogDealBoardCardsMsg(roundID, card1, card2, card3, card4, card5); }
void GuiWrapper::logFlipHoleCardsMsg(string playerName, int card1, int card2, int cardsValueInt, string showHas) { myLog->signalLogFlipHoleCardsMsg(QString::fromUtf8(playerName.c_str()), card1, card2, cardsValueInt, QString::fromUtf8(showHas.c_str())); }
void GuiWrapper::logFlipHoleCardsMsg(string playerName, int playerID, int card1, int card2, int cardsValueInt, string showHas) { myLog->signalLogFlipHoleCardsMsg(QString::fromUtf8(playerName.c_str()), playerID, card1, card2, cardsValueInt, QString::fromUtf8(showHas.c_str())); }
void GuiWrapper::logPlayerWinGame(std::string playerName, int gameID) { myLog->signalLogPlayerWinGame(QString::fromUtf8(playerName.c_str()), gameID); }
void GuiWrapper::flushLogAtGame(int gameID) { myLog->signalFlushLogAtGame(gameID); }
void GuiWrapper::flushLogAtHand() { myLog->signalFlushLogAtHand(); }
+2 -2
View File
@@ -100,13 +100,13 @@ public:
void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick);
void endVoteOnKick();
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logPlayerActionMsg(std::string playerName, int playerID, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ;
void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName);
void logPlayerWinsMsg(std::string playerName, int pot, bool main);
void logPlayerSitsOut(std::string playerName);
void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1);
void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows");
void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows");
void logPlayerWinGame(std::string playerName, int gameID);
void flushLogAtGame(int gameID);
void flushLogAtHand();
+3 -3
View File
@@ -273,9 +273,9 @@ void startWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
int tmpDealerPos = 0;
startData.numberOfPlayers = gameData.maxNumberOfPlayers;
Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0);
if(DEBUG_MODE) {
tmpDealerPos = 4;
}
//if(DEBUG_MODE) {
// tmpDealerPos = 4;
//}
startData.startDealerPlayerId = static_cast<unsigned>(tmpDealerPos);
//some gui modifications
+1
View File
@@ -1776,6 +1776,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
assert(netActionDone->totalPlayerBet >= (long)tmpPlayer->getMySet());
client->GetGui().logPlayerActionMsg(
tmpPlayer->getMyName(),
tmpPlayer->getMyID(),
netActionDone->playerAction,
netActionDone->totalPlayerBet - tmpPlayer->getMySet());
}
+1
View File
@@ -63,6 +63,7 @@
//Q_IMPORT_PLUGIN(qjpeg)
//Q_IMPORT_PLUGIN(qgif)
#ifdef _WIN32 // Always use static Qt on Windows.
#include <QtPlugin>
Q_IMPORT_PLUGIN(qjpeg)