- updating sqlite-log

- handID in bero is unnecessary; removing parameter value
This commit is contained in:
floty
2011-10-21 00:16:43 +00:00
parent d14d1b4787
commit 8ae7db3e96
28 changed files with 158 additions and 164 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ public:
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0; virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp) =0; virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp) =0;
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0; virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0;
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, int id, unsigned dP, int sB) =0; virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB) =0;
}; };
#endif #endif
+2 -2
View File
@@ -24,8 +24,8 @@
using namespace std; using namespace std;
LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS) LocalBeRo::LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false) : BeRoInterface(), myHand(hi), myBeRoID(gS), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false)
{ {
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin(); currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin(); lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
+1 -2
View File
@@ -28,7 +28,7 @@
class LocalBeRo : public BeRoInterface class LocalBeRo : public BeRoInterface
{ {
public: public:
LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS); LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS);
~LocalBeRo(); ~LocalBeRo();
GameState getMyBeRoID() const { GameState getMyBeRoID() const {
@@ -169,7 +169,6 @@ private:
HandInterface* myHand; HandInterface* myHand;
const GameState myBeRoID; const GameState myBeRoID;
int myID;
int dealerPosition; int dealerPosition;
int smallBlindPosition; int smallBlindPosition;
+1 -1
View File
@@ -23,7 +23,7 @@
using namespace std; using namespace std;
LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_FLOP) LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, unsigned dP, int sB) : LocalBeRo(hi, dP, sB, GAME_STATE_FLOP)
{ {
} }
+1 -1
View File
@@ -28,7 +28,7 @@ class LocalBeRoFlop : public LocalBeRo
{ {
public: public:
LocalBeRoFlop(HandInterface*, int, unsigned, int); LocalBeRoFlop(HandInterface*, unsigned, int);
~LocalBeRoFlop(); ~LocalBeRoFlop();
}; };
+10 -1
View File
@@ -24,7 +24,7 @@
using namespace std; using namespace std;
LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_POST_RIVER), highestCardsValue(0) LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* hi, int dP, int sB) : LocalBeRo(hi, dP, sB, GAME_STATE_POST_RIVER), highestCardsValue(0)
{ {
} }
@@ -83,6 +83,15 @@ void LocalBeRoPostRiver::postRiverRun()
//Pot auf 0 setzen //Pot auf 0 setzen
getMyHand()->getBoard()->setPot(0); getMyHand()->getBoard()->setPot(0);
// Logging hole Cards / Hands
int myCards[2];
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
(*it_c)->getMyCards(myCards);
getMyHand()->getLog()->logHoleCardsHandName((*it_c)->getMyID()+1,myCards,(*it_c)->getMyCardsValueInt(),getMyHand()->getActivePlayerList());
}
}
//starte die Animaionsreihe //starte die Animaionsreihe
getMyHand()->getGuiInterface()->postRiverRunAnimation1(); getMyHand()->getGuiInterface()->postRiverRunAnimation1();
} }
+1 -1
View File
@@ -28,7 +28,7 @@ class HandInterface;
class LocalBeRoPostRiver : public LocalBeRo class LocalBeRoPostRiver : public LocalBeRo
{ {
public: public:
LocalBeRoPostRiver(HandInterface*, int, int, int); LocalBeRoPostRiver(HandInterface*, int, int);
~LocalBeRoPostRiver(); ~LocalBeRoPostRiver();
void setHighestCardsValue(int theValue) { void setHighestCardsValue(int theValue) {
+1 -1
View File
@@ -26,7 +26,7 @@
using namespace std; using namespace std;
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP) LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, unsigned dP, int sB) : LocalBeRo(hi, dP, sB, GAME_STATE_PREFLOP)
{ {
setHighestSet(2*getSmallBlind()); setHighestSet(2*getSmallBlind());
} }
+1 -1
View File
@@ -28,7 +28,7 @@ class LocalBeRoPreflop : public LocalBeRo
{ {
public: public:
LocalBeRoPreflop(HandInterface*, int, unsigned, int); LocalBeRoPreflop(HandInterface*, unsigned, int);
~LocalBeRoPreflop(); ~LocalBeRoPreflop();
void run(); void run();
+1 -1
View File
@@ -24,7 +24,7 @@
using namespace std; using namespace std;
LocalBeRoRiver::LocalBeRoRiver(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_RIVER) LocalBeRoRiver::LocalBeRoRiver(HandInterface* hi, unsigned dP, int sB) : LocalBeRo(hi, dP, sB, GAME_STATE_RIVER)
{ {
} }
+1 -1
View File
@@ -28,7 +28,7 @@ class HandInterface;
class LocalBeRoRiver : public LocalBeRo class LocalBeRoRiver : public LocalBeRo
{ {
public: public:
LocalBeRoRiver(HandInterface*, int, unsigned, int); LocalBeRoRiver(HandInterface*, unsigned, int);
~LocalBeRoRiver(); ~LocalBeRoRiver();
}; };
+1 -1
View File
@@ -23,7 +23,7 @@
using namespace std; using namespace std;
LocalBeRoTurn::LocalBeRoTurn(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_TURN) LocalBeRoTurn::LocalBeRoTurn(HandInterface* hi, unsigned dP, int sB) : LocalBeRo(hi, dP, sB, GAME_STATE_TURN)
{ {
} }
+1 -1
View File
@@ -27,7 +27,7 @@ class HandInterface;
class LocalBeRoTurn : public LocalBeRo class LocalBeRoTurn : public LocalBeRo
{ {
public: public:
LocalBeRoTurn(HandInterface*, int, unsigned, int); LocalBeRoTurn(HandInterface*, unsigned, int);
~LocalBeRoTurn(); ~LocalBeRoTurn();
}; };
@@ -60,19 +60,19 @@ LocalEngineFactory::createPlayer(int id, unsigned uniqueId, PlayerType type, std
} }
std::vector<boost::shared_ptr<BeRoInterface> > std::vector<boost::shared_ptr<BeRoInterface> >
LocalEngineFactory::createBeRo(HandInterface *hi, int id, unsigned dP, int sB) LocalEngineFactory::createBeRo(HandInterface *hi, unsigned dP, int sB)
{ {
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPreflop(hi, id, dP, sB))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPreflop(hi, dP, sB)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoFlop(hi, id, dP, sB))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoFlop(hi, dP, sB)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoTurn(hi, id, dP, sB))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoTurn(hi, dP, sB)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoRiver(hi, id, dP, sB))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoRiver(hi, dP, sB)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPostRiver(hi, id, dP, sB))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPostRiver(hi, dP, sB)));
return myBeRo; return myBeRo;
+1 -1
View File
@@ -39,7 +39,7 @@ public:
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp); virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp);
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, int id, unsigned dP, int sB); virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB);
private: private:
ConfigFile *myConfig; ConfigFile *myConfig;
+9 -1
View File
@@ -367,7 +367,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
setBlinds(); setBlinds();
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind); myBeRo = myFactory->createBeRo(this, dealerPosition, smallBlind);
} }
@@ -626,6 +626,14 @@ void LocalHand::switchRounds()
myGui->refreshPot(); myGui->refreshPot();
myGui->refreshSet(); myGui->refreshSet();
myGui->flipHolecardsAllIn(); myGui->flipHolecardsAllIn();
// Logging HoleCards
int myCards[2];
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
(*it_c)->getMyCards(myCards);
myLog->logHoleCards(currentRound+1,(*it_c)->getMyID()+1,myCards);
}
}
if (currentRound < 4) // do not increment past 4 if (currentRound < 4) // do not increment past 4
currentRound++; currentRound++;
+3 -3
View File
@@ -166,15 +166,15 @@ public:
switch(state) { switch(state) {
case 1: case 1:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt); currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt);
currentHand->getLog()->logHoleCardsHandName(myID+1,myCards,myCardsValueInt,currentHand->getActivePlayerList()); // currentHand->getLog()->logHoleCardsHandName(myID+1,myCards,myCardsValueInt,currentHand->getActivePlayerList());
break; break;
case 2: case 2:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]); currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]);
currentHand->getLog()->logHoleCards(currentHand->getCurrentRound()+1,myID+1,myCards); // currentHand->getLog()->logHoleCards(currentHand->getCurrentRound()+1,myID+1,myCards);
break; break;
case 3: case 3:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has"); currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has");
currentHand->getLog()->logHandName(myID+1,myCardsValueInt,currentHand->getActivePlayerList()); // currentHand->getLog()->logHandName(myID+1,myCardsValueInt,currentHand->getActivePlayerList());
break; break;
default: default:
; ;
+88 -115
View File
@@ -23,32 +23,26 @@
#include "cardsvalue.h" #include "cardsvalue.h"
#include <sqlite3.h> #include <sqlite3.h>
#include <iostream>
#include <dirent.h> #include <dirent.h>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
using namespace std; using namespace std;
Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), logOnOff(false) Log::Log(ConfigFile *c) : myConfig(c), curGameID(0), curHandID(0), sql(""), logHoleCardsDone(false)
{ {
if(SQLITE_LOG) { if(SQLITE_LOG) {
// logging activated // logging activated
if(logOnOffInt) { if(myConfig->readConfigInt("LogOnOff")) {
logOnOff = true;
DIR *logDir; DIR *logDir;
logDir = opendir(logDirString.c_str()); logDir = opendir((myConfig->readConfigString("LogDir")).c_str());
bool dirExists = logDir != NULL; bool dirExists = logDir != NULL;
closedir(logDir); closedir(logDir);
// check if logging path exist // check if logging path exist
if(logDirString != "" && dirExists) { if(myConfig->readConfigString("LogDir") != "" && dirExists) {
string sql;
char *errmsg = NULL;
// detect current time // detect current time
char curDateTime[20]; char curDateTime[20];
@@ -60,7 +54,7 @@ Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), log
strftime(curDate,11,"%Y-%m-%d",z); strftime(curDate,11,"%Y-%m-%d",z);
strftime(curTime,9,"%H:%M:%S",z); strftime(curTime,9,"%H:%M:%S",z);
string mySqliteLogFileName = boost::lexical_cast<string>(logDirString.c_str()); string mySqliteLogFileName = boost::lexical_cast<string>((myConfig->readConfigString("LogDir")).c_str());
mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast<string>(curDateTime) + ".pdb"; mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast<string>(curDateTime) + ".pdb";
// open sqlite-db // open sqlite-db
@@ -69,33 +63,23 @@ Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), log
int i; int i;
// create session table // create session table
sql = "CREATE TABLE Session ("; sql += "CREATE TABLE Session (";
sql += "PokerTH_Version TEXT NOT NULL"; sql += "PokerTH_Version TEXT NOT NULL";
sql += ",Date TEXT NOT NULL"; sql += ",Date TEXT NOT NULL";
sql += ",Time TEXT NOT NULL"; sql += ",Time TEXT NOT NULL";
sql += ", PRIMARY KEY(Date,Time))"; sql += ", PRIMARY KEY(Date,Time));";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
errmsg = NULL;
}
sql = "INSERT INTO Session ("; sql += "INSERT INTO Session (";
sql += "PokerTH_Version"; sql += "PokerTH_Version";
sql += ",Date"; sql += ",Date";
sql += ",Time"; sql += ",Time";
sql += ") VALUES ("; sql += ") VALUES (";
sql += "\"" + boost::lexical_cast<string>(POKERTH_BETA_RELEASE_STRING) + "\","; sql += "\"" + boost::lexical_cast<string>(POKERTH_BETA_RELEASE_STRING) + "\",";
sql += "\"" + boost::lexical_cast<string>(curDate) + "\","; sql += "\"" + boost::lexical_cast<string>(curDate) + "\",";
sql += "\"" + boost::lexical_cast<string>(curTime) + "\")"; sql += "\"" + boost::lexical_cast<string>(curTime) + "\");";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
errmsg = NULL;
}
// create game table // create game table
sql = "CREATE TABLE Game ("; sql += "CREATE TABLE Game (";
sql += "GameID INTEGER NOT NULL PRIMARY KEY"; sql += "GameID INTEGER NOT NULL PRIMARY KEY";
sql += ",Startmoney INTEGER NOT NULL"; sql += ",Startmoney INTEGER NOT NULL";
sql += ",StartSb INTEGER NOT NULL"; sql += ",StartSb INTEGER NOT NULL";
@@ -104,15 +88,10 @@ Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), log
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + " TEXT"; sql += ",Seat_" + boost::lexical_cast<std::string>(i) + " TEXT";
} }
sql += ",Winner_Seat INTEGER"; sql += ",Winner_Seat INTEGER";
sql += ")"; sql += ");";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
errmsg = NULL;
}
// create hand table // create hand table
sql = "CREATE TABLE Hand ("; sql += "CREATE TABLE Hand (";
sql += "HandID INTEGER NOT NULL"; sql += "HandID INTEGER NOT NULL";
sql += ",GameID INTEGER NOT NULL"; sql += ",GameID INTEGER NOT NULL";
sql += ",Dealer_Seat INTEGER"; sql += ",Dealer_Seat INTEGER";
@@ -130,15 +109,10 @@ Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), log
for(i=1; i<=5; i++) { for(i=1; i<=5; i++) {
sql += ",BoardCard_" + boost::lexical_cast<std::string>(i) + " INTEGER"; sql += ",BoardCard_" + boost::lexical_cast<std::string>(i) + " INTEGER";
} }
sql += ",PRIMARY KEY(HandID,GameID))"; sql += ",PRIMARY KEY(HandID,GameID));";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
errmsg = NULL;
}
// create action table // create action table
sql = "CREATE TABLE Action ("; sql += "CREATE TABLE Action (";
sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT"; sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT";
sql += ",HandID INTEGER NOT NULL"; sql += ",HandID INTEGER NOT NULL";
sql += ",GameID INTEGER NOT NULL"; sql += ",GameID INTEGER NOT NULL";
@@ -146,12 +120,9 @@ Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), log
sql += ",Player INTEGER NOT NULL"; sql += ",Player INTEGER NOT NULL";
sql += ",Action TEXT NOT NULL"; sql += ",Action TEXT NOT NULL";
sql += ",Amount INTEGER"; sql += ",Amount INTEGER";
sql += ")"; sql += ");";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; exec_transaction(&sql);
sqlite3_free(errmsg);
errmsg = NULL;
}
} }
} }
} }
@@ -172,18 +143,16 @@ void Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned
if(SQLITE_LOG) { if(SQLITE_LOG) {
if(logOnOff) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
string sql;
char *errmsg = NULL;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
int i; int i;
sql = "INSERT INTO Game ("; sql += "INSERT INTO Game (";
sql += "GameID"; sql += "GameID";
sql += ",Startmoney"; sql += ",Startmoney";
sql += ",StartSb"; sql += ",StartSb";
@@ -203,12 +172,8 @@ void Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned
sql += ",NULL"; sql += ",NULL";
} }
} }
sql += ")"; sql += ");";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { exec_transaction(&sql);
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
errmsg = NULL;
}
} }
} }
} }
@@ -221,18 +186,16 @@ void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, uns
if(SQLITE_LOG) { if(SQLITE_LOG) {
if(logOnOff) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
string sql;
char *errmsg = NULL;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
int i; int i;
sql = "INSERT INTO Hand ("; sql += "INSERT INTO Hand (";
sql += "HandID"; sql += "HandID";
sql += ",GameID"; sql += ",GameID";
sql += ",Dealer_Seat"; sql += ",Dealer_Seat";
@@ -258,11 +221,9 @@ void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, uns
sql += ",NULL"; sql += ",NULL";
} }
} }
sql += ")"; sql += ");";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { if(myConfig->readConfigInt("LogInterval") == 0) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; exec_transaction(&sql);
sqlite3_free(errmsg);
errmsg = NULL;
} }
logPlayerAction(0,dealerPosition,LOG_ACTION_DEALER); logPlayerAction(0,dealerPosition,LOG_ACTION_DEALER);
@@ -276,16 +237,13 @@ void Log::logPlayerAction(int bero, int seat, PlayerActionLog action, int amount
if(SQLITE_LOG) { if(SQLITE_LOG) {
if(logOnOff) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
string sql;
char *errmsg = NULL;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
sql = "INSERT INTO Action ("; sql += "INSERT INTO Action (";
sql += "HandID"; sql += "HandID";
sql += ",GameID"; sql += ",GameID";
sql += ",BeRo"; sql += ",BeRo";
@@ -348,11 +306,9 @@ void Log::logPlayerAction(int bero, int seat, PlayerActionLog action, int amount
} else { } else {
sql += ",NULL"; sql += ",NULL";
} }
sql += ")"; sql += ");";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { if(myConfig->readConfigInt("LogInterval") == 0) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; exec_transaction(&sql);
sqlite3_free(errmsg);
errmsg = NULL;
} }
} }
} }
@@ -363,28 +319,27 @@ void Log::logBoardCards(int bero, int boardCards[5])
{ {
if(SQLITE_LOG) { if(SQLITE_LOG) {
if(logOnOff) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
string sql;
char *errmsg = NULL;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
sql = "UPDATE Hand SET ";
switch(bero) { switch(bero) {
case 2: { case 2: {
sql += "UPDATE Hand SET ";
sql += "BoardCard_1=" + boost::lexical_cast<string>(boardCards[0]) + ","; sql += "BoardCard_1=" + boost::lexical_cast<string>(boardCards[0]) + ",";
sql += "BoardCard_2=" + boost::lexical_cast<string>(boardCards[1]) + ","; sql += "BoardCard_2=" + boost::lexical_cast<string>(boardCards[1]) + ",";
sql += "BoardCard_3=" + boost::lexical_cast<string>(boardCards[2]); sql += "BoardCard_3=" + boost::lexical_cast<string>(boardCards[2]);
} }
break; break;
case 3: { case 3: {
sql += "UPDATE Hand SET ";
sql += "BoardCard_4=" + boost::lexical_cast<string>(boardCards[3]); sql += "BoardCard_4=" + boost::lexical_cast<string>(boardCards[3]);
} }
break; break;
case 4: { case 4: {
sql += "UPDATE Hand SET ";
sql += "BoardCard_5=" + boost::lexical_cast<string>(boardCards[4]); sql += "BoardCard_5=" + boost::lexical_cast<string>(boardCards[4]);
} }
break; break;
@@ -394,10 +349,9 @@ void Log::logBoardCards(int bero, int boardCards[5])
sql += " WHERE "; sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND "; sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(curHandID); sql += "HandID=" + boost::lexical_cast<string>(curHandID);
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { sql += ";";
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; if(myConfig->readConfigInt("LogInterval") == 0) {
sqlite3_free(errmsg); exec_transaction(&sql);
errmsg = NULL;
} }
} }
} }
@@ -406,27 +360,26 @@ void Log::logBoardCards(int bero, int boardCards[5])
void Log::logHoleCards(int bero, int seat, int cards[2]) void Log::logHoleCards(int bero, int seat, int cards[2])
{ {
logHoleCardsDone = false;
if(SQLITE_LOG) { if(SQLITE_LOG) {
if(logOnOff) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
string sql;
char *errmsg = NULL;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
sql = "UPDATE Hand SET "; sql += "UPDATE Hand SET ";
sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Card_1=" + boost::lexical_cast<string>(cards[0]); sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Card_1=" + boost::lexical_cast<string>(cards[0]);
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_2=" + boost::lexical_cast<string>(cards[1]); sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_2=" + boost::lexical_cast<string>(cards[1]);
sql += " WHERE "; sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND "; sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(curHandID); sql += "HandID=" + boost::lexical_cast<string>(curHandID);
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { sql += ";";
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; if(myConfig->readConfigInt("LogInterval") == 0) {
sqlite3_free(errmsg); exec_transaction(&sql);
errmsg = NULL;
} }
logPlayerAction(bero,seat,LOG_ACTION_SHOW); logPlayerAction(bero,seat,LOG_ACTION_SHOW);
@@ -439,28 +392,23 @@ void Log::logHandName(int seat, int cardsValueInt, PlayerList activePlayerList)
{ {
if(SQLITE_LOG) { if(SQLITE_LOG) {
if(logOnOff) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
string sql;
char *errmsg = NULL;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
sql = "UPDATE Hand SET "; sql += "UPDATE Hand SET ";
sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\""; sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\"";
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_int=" + boost::lexical_cast<string>(cardsValueInt); sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_int=" + boost::lexical_cast<string>(cardsValueInt);
sql += " WHERE "; sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND "; sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(curHandID); sql += "HandID=" + boost::lexical_cast<string>(curHandID);
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { sql += ";";
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; if(myConfig->readConfigInt("LogInterval") == 0) {
exec_transaction(&sql);
} }
sqlite3_free(errmsg);
errmsg = NULL;
logPlayerAction(5,seat,LOG_ACTION_HAS); logPlayerAction(5,seat,LOG_ACTION_HAS);
} }
} }
@@ -471,33 +419,50 @@ void Log::logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, Player
{ {
if(SQLITE_LOG) { if(SQLITE_LOG) {
if(logOnOff) { if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled //if write logfiles is enabled
string sql;
char *errmsg = NULL;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
sql = "UPDATE Hand SET "; sql += "UPDATE Hand SET ";
sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Card_1=" + boost::lexical_cast<string>(cards[0]); sql += "Seat_" + boost::lexical_cast<string>(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\"";
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_2=" + boost::lexical_cast<string>(cards[1]);
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_text=\"" + CardsValue::determineHandName(cardsValueInt,activePlayerList) + "\"";
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_int=" + boost::lexical_cast<string>(cardsValueInt); sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Hand_int=" + boost::lexical_cast<string>(cardsValueInt);
if(!logHoleCardsDone) {
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_1=" + boost::lexical_cast<string>(cards[0]);
sql += ",Seat_" + boost::lexical_cast<string>(seat) + "_Card_2=" + boost::lexical_cast<string>(cards[1]);
}
sql += " WHERE "; sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND "; sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(curHandID); sql += "HandID=" + boost::lexical_cast<string>(curHandID);
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { sql += ";";
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; if(myConfig->readConfigInt("LogInterval") == 0) {
sqlite3_free(errmsg); exec_transaction(&sql);
errmsg = NULL;
} }
logPlayerAction(5,seat,LOG_ACTION_SHOW); logPlayerAction(5,seat,LOG_ACTION_SHOW);
if(!logHoleCardsDone) {
logPlayerAction(5,seat,LOG_ACTION_SHOW);
} else {
logPlayerAction(5,seat,LOG_ACTION_HAS);
} }
} }
} }
}
}
void Log::exec_transaction(string *sql)
{
char *errmsg = NULL;
string sql_transaction = "BEGIN;" + *sql + "COMMIT;";
*sql = "";
if(sqlite3_exec(mySqliteLogDb, sql_transaction.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql_transaction.data() << "[" << errmsg << "]." << endl;
sqlite3_free(errmsg);
errmsg = NULL;
}
} }
//void //void
@@ -528,3 +493,11 @@ void Log::logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, Player
// 11 wins (side pot) // 11 wins (side pot)
// 11 sits out // 11 sits out
// 12 wins game // 12 wins game
// Bero-Code
// 0 Pre-Preflop
// 1 Preflop
// 2 Flop
// 3 Turn
// 4 River
// 5 Post-River
+7 -3
View File
@@ -24,11 +24,13 @@
struct sqlite3; struct sqlite3;
class ConfigFile;
class Log class Log
{ {
public: public:
Log(std::string logDirString, int logOnOffInt); Log(ConfigFile *c);
~Log(); ~Log();
@@ -39,15 +41,17 @@ public:
void logHoleCards(int bero, int seat, int cards[2]); void logHoleCards(int bero, int seat, int cards[2]);
void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList); void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList);
void logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, PlayerList activePlayerList); void logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, PlayerList activePlayerList);
void exec_transaction(std::string *sql);
// void closeLogDbAtExit(); // void closeLogDbAtExit();
private: private:
sqlite3 *mySqliteLogDb; sqlite3 *mySqliteLogDb;
ConfigFile *myConfig;
int curGameID; int curGameID;
int curHandID; int curHandID;
bool logOnOff; std::string sql;
bool logHoleCardsDone;
}; };
#endif // LOG_H #endif // LOG_H
+1 -1
View File
@@ -18,7 +18,7 @@
#include "clientbero.h" #include "clientbero.h"
ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, unsigned /*dP*/, int sB, GameState gS) ClientBeRo::ClientBeRo(HandInterface* hi, unsigned /*dP*/, int sB, GameState gS)
: BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), smallBlindPositionId(0), bigBlindPositionId(0), currentPlayersTurnId(0), : BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), smallBlindPositionId(0), bigBlindPositionId(0), currentPlayersTurnId(0),
firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false), firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false),
lastActionPlayer(0) lastActionPlayer(0)
+1 -1
View File
@@ -30,7 +30,7 @@ class HandInterface;
class ClientBeRo : public BeRoInterface class ClientBeRo : public BeRoInterface
{ {
public: public:
ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS); ClientBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS);
~ClientBeRo(); ~ClientBeRo();
GameState getMyBeRoID() const; GameState getMyBeRoID() const;
@@ -54,15 +54,15 @@ ClientEngineFactory::createPlayer(int id, unsigned uniqueId, PlayerType type, st
} }
std::vector<boost::shared_ptr<BeRoInterface> > std::vector<boost::shared_ptr<BeRoInterface> >
ClientEngineFactory::createBeRo(HandInterface *hi, int id, unsigned dP, int sB) ClientEngineFactory::createBeRo(HandInterface *hi, unsigned dP, int sB)
{ {
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, dP, sB, GAME_STATE_PREFLOP)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, id, dP, sB, GAME_STATE_FLOP))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, dP, sB, GAME_STATE_FLOP)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, id, dP, sB, GAME_STATE_TURN))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, dP, sB, GAME_STATE_TURN)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, id, dP, sB, GAME_STATE_RIVER))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, dP, sB, GAME_STATE_RIVER)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, id, dP, sB, GAME_STATE_POST_RIVER))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, dP, sB, GAME_STATE_POST_RIVER)));
return myBeRo; return myBeRo;
@@ -41,7 +41,7 @@ public:
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp); virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp);
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, int id, unsigned dP, int sB); virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB);
}; };
#endif #endif
+1 -1
View File
@@ -51,7 +51,7 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boos
// the rest of the buttons are assigned later as received from the server. // the rest of the buttons are assigned later as received from the server.
// Preflop, Flop, Turn und River erstellen // Preflop, Flop, Turn und River erstellen
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind); myBeRo = myFactory->createBeRo(this, dealerPosition, smallBlind);
} }
+1
View File
@@ -2512,6 +2512,7 @@ void gameTableImpl::postRiverRunAnimation3()
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
if((*it_c)->getMyCash() == 0) { if((*it_c)->getMyCash() == 0) {
currentHand->getGuiInterface()->logPlayerSitsOut((*it_c)->getMyName()); currentHand->getGuiInterface()->logPlayerSitsOut((*it_c)->getMyName());
currentHand->getLog()->logPlayerAction(5, (*it_c)->getMyID()+1, LOG_ACTION_SIT_OUT);
} }
} }
+1 -1
View File
@@ -55,7 +55,7 @@ ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager, Conf
m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false), m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false),
m_stateTimer(*m_ioService), m_avatarTimer(*m_ioService) m_stateTimer(*m_ioService), m_avatarTimer(*m_ioService)
{ {
m_clientLog.reset(new Log("", 0)); m_clientLog.reset(new Log(config));
m_context.reset(new ClientContext); m_context.reset(new ClientContext);
myQtToolsInterface.reset(CreateQtToolsWrapper()); myQtToolsInterface.reset(CreateQtToolsWrapper());
m_senderHelper.reset(new SenderHelper(m_ioService)); m_senderHelper.reset(new SenderHelper(m_ioService));
+1 -1
View File
@@ -214,7 +214,7 @@ ServerLobbyThread::Init(const string &logDir)
m_serverConfig.readConfigString("DBServerEncryptionKey")); m_serverConfig.readConfigString("DBServerEncryptionKey"));
GetBanManager().InitGameNameBadWordList(m_serverConfig.readConfigStringList("GameNameBadWordList")); GetBanManager().InitGameNameBadWordList(m_serverConfig.readConfigStringList("GameNameBadWordList"));
m_serverLog.reset(new Log(logDir, 0)); m_serverLog.reset(new Log(&m_serverConfig));
} }
void void
+1 -1
View File
@@ -43,7 +43,7 @@ Session::Session(GuiInterface *g, ConfigFile *c)
: currentGameNum(0), myGui(g), myConfig(c), myLog(0), myGameType(GAME_TYPE_NONE) : currentGameNum(0), myGui(g), myConfig(c), myLog(0), myGameType(GAME_TYPE_NONE)
{ {
myQtToolsInterface = CreateQtToolsWrapper(); myQtToolsInterface = CreateQtToolsWrapper();
myLog = new Log(myConfig->readConfigString("LogDir"),myConfig->readConfigInt("LogOnOff")); myLog = new Log(myConfig);
} }