- updating sqlite-log
- handID in bero is unnecessary; removing parameter value
This commit is contained in:
@@ -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<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 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
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
LocalBeRo::LocalBeRo(HandInterface* hi, int id, 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)
|
||||
LocalBeRo::LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS)
|
||||
: 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();
|
||||
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
class LocalBeRo : public BeRoInterface
|
||||
{
|
||||
public:
|
||||
LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
|
||||
LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS);
|
||||
~LocalBeRo();
|
||||
|
||||
GameState getMyBeRoID() const {
|
||||
@@ -169,7 +169,6 @@ private:
|
||||
HandInterface* myHand;
|
||||
|
||||
const GameState myBeRoID;
|
||||
int myID;
|
||||
int dealerPosition;
|
||||
int smallBlindPosition;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class LocalBeRoFlop : public LocalBeRo
|
||||
{
|
||||
|
||||
public:
|
||||
LocalBeRoFlop(HandInterface*, int, unsigned, int);
|
||||
LocalBeRoFlop(HandInterface*, unsigned, int);
|
||||
~LocalBeRoFlop();
|
||||
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
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
|
||||
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
|
||||
getMyHand()->getGuiInterface()->postRiverRunAnimation1();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class HandInterface;
|
||||
class LocalBeRoPostRiver : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoPostRiver(HandInterface*, int, int, int);
|
||||
LocalBeRoPostRiver(HandInterface*, int, int);
|
||||
~LocalBeRoPostRiver();
|
||||
|
||||
void setHighestCardsValue(int theValue) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class LocalBeRoPreflop : public LocalBeRo
|
||||
{
|
||||
|
||||
public:
|
||||
LocalBeRoPreflop(HandInterface*, int, unsigned, int);
|
||||
LocalBeRoPreflop(HandInterface*, unsigned, int);
|
||||
~LocalBeRoPreflop();
|
||||
|
||||
void run();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class HandInterface;
|
||||
class LocalBeRoRiver : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoRiver(HandInterface*, int, unsigned, int);
|
||||
LocalBeRoRiver(HandInterface*, unsigned, int);
|
||||
~LocalBeRoRiver();
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class HandInterface;
|
||||
class LocalBeRoTurn : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoTurn(HandInterface*, int, unsigned, int);
|
||||
LocalBeRoTurn(HandInterface*, unsigned, int);
|
||||
~LocalBeRoTurn();
|
||||
|
||||
};
|
||||
|
||||
@@ -60,19 +60,19 @@ LocalEngineFactory::createPlayer(int id, unsigned uniqueId, PlayerType type, std
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -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<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 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:
|
||||
ConfigFile *myConfig;
|
||||
|
||||
@@ -367,7 +367,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
|
||||
setBlinds();
|
||||
|
||||
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind);
|
||||
myBeRo = myFactory->createBeRo(this, dealerPosition, smallBlind);
|
||||
}
|
||||
|
||||
|
||||
@@ -626,6 +626,14 @@ void LocalHand::switchRounds()
|
||||
myGui->refreshPot();
|
||||
myGui->refreshSet();
|
||||
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
|
||||
currentRound++;
|
||||
|
||||
@@ -166,15 +166,15 @@ public:
|
||||
switch(state) {
|
||||
case 1:
|
||||
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;
|
||||
case 2:
|
||||
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;
|
||||
case 3:
|
||||
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;
|
||||
default:
|
||||
;
|
||||
|
||||
+95
-122
@@ -23,32 +23,26 @@
|
||||
#include "cardsvalue.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <iostream>
|
||||
#include <dirent.h>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
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) {
|
||||
|
||||
// logging activated
|
||||
if(logOnOffInt) {
|
||||
|
||||
logOnOff = true;
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
|
||||
DIR *logDir;
|
||||
logDir = opendir(logDirString.c_str());
|
||||
logDir = opendir((myConfig->readConfigString("LogDir")).c_str());
|
||||
bool dirExists = logDir != NULL;
|
||||
closedir(logDir);
|
||||
|
||||
// check if logging path exist
|
||||
if(logDirString != "" && dirExists) {
|
||||
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
if(myConfig->readConfigString("LogDir") != "" && dirExists) {
|
||||
|
||||
// detect current time
|
||||
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(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";
|
||||
|
||||
// open sqlite-db
|
||||
@@ -69,33 +63,23 @@ Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), log
|
||||
|
||||
int i;
|
||||
// create session table
|
||||
sql = "CREATE TABLE Session (";
|
||||
sql += "CREATE TABLE Session (";
|
||||
sql += "PokerTH_Version TEXT NOT NULL";
|
||||
sql += ",Date TEXT NOT NULL";
|
||||
sql += ",Time TEXT NOT NULL";
|
||||
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 += ", PRIMARY KEY(Date,Time));";
|
||||
|
||||
sql = "INSERT INTO Session (";
|
||||
sql += "INSERT INTO Session (";
|
||||
sql += "PokerTH_Version";
|
||||
sql += ",Date";
|
||||
sql += ",Time";
|
||||
sql += ") VALUES (";
|
||||
sql += "\"" + boost::lexical_cast<string>(POKERTH_BETA_RELEASE_STRING) + "\",";
|
||||
sql += "\"" + boost::lexical_cast<string>(curDate) + "\",";
|
||||
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;
|
||||
}
|
||||
sql += "\"" + boost::lexical_cast<string>(curTime) + "\");";
|
||||
|
||||
// create game table
|
||||
sql = "CREATE TABLE Game (";
|
||||
sql += "CREATE TABLE Game (";
|
||||
sql += "GameID INTEGER NOT NULL PRIMARY KEY";
|
||||
sql += ",Startmoney 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 += ",Winner_Seat INTEGER";
|
||||
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;
|
||||
}
|
||||
sql += ");";
|
||||
|
||||
// create hand table
|
||||
sql = "CREATE TABLE Hand (";
|
||||
sql += "CREATE TABLE Hand (";
|
||||
sql += "HandID INTEGER NOT NULL";
|
||||
sql += ",GameID INTEGER NOT NULL";
|
||||
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++) {
|
||||
sql += ",BoardCard_" + boost::lexical_cast<std::string>(i) + " INTEGER";
|
||||
}
|
||||
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;
|
||||
}
|
||||
sql += ",PRIMARY KEY(HandID,GameID));";
|
||||
|
||||
// create action table
|
||||
sql = "CREATE TABLE Action (";
|
||||
sql += "CREATE TABLE Action (";
|
||||
sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT";
|
||||
sql += ",HandID 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 += ",Action TEXT NOT NULL";
|
||||
sql += ",Amount INTEGER";
|
||||
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;
|
||||
}
|
||||
sql += ");";
|
||||
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,18 +143,16 @@ void Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned
|
||||
|
||||
if(SQLITE_LOG) {
|
||||
|
||||
if(logOnOff) {
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
PlayerListConstIterator it_c;
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if( mySqliteLogDb != 0 ) {
|
||||
// sqlite-db is open
|
||||
int i;
|
||||
|
||||
sql = "INSERT INTO Game (";
|
||||
sql += "INSERT INTO Game (";
|
||||
sql += "GameID";
|
||||
sql += ",Startmoney";
|
||||
sql += ",StartSb";
|
||||
@@ -203,12 +172,8 @@ void Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned
|
||||
sql += ",NULL";
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
sql += ");";
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,18 +186,16 @@ void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, uns
|
||||
|
||||
if(SQLITE_LOG) {
|
||||
|
||||
if(logOnOff) {
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
PlayerListConstIterator it_c;
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if( mySqliteLogDb != 0 ) {
|
||||
// sqlite-db is open
|
||||
int i;
|
||||
|
||||
sql = "INSERT INTO Hand (";
|
||||
sql += "INSERT INTO Hand (";
|
||||
sql += "HandID";
|
||||
sql += ",GameID";
|
||||
sql += ",Dealer_Seat";
|
||||
@@ -258,12 +221,10 @@ void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, uns
|
||||
sql += ",NULL";
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
sql += ");";
|
||||
if(myConfig->readConfigInt("LogInterval") == 0) {
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
|
||||
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(logOnOff) {
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if( mySqliteLogDb != 0 ) {
|
||||
// sqlite-db is open
|
||||
|
||||
sql = "INSERT INTO Action (";
|
||||
sql += "INSERT INTO Action (";
|
||||
sql += "HandID";
|
||||
sql += ",GameID";
|
||||
sql += ",BeRo";
|
||||
@@ -348,12 +306,10 @@ void Log::logPlayerAction(int bero, int seat, PlayerActionLog action, int amount
|
||||
} else {
|
||||
sql += ",NULL";
|
||||
}
|
||||
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;
|
||||
}
|
||||
sql += ");";
|
||||
if(myConfig->readConfigInt("LogInterval") == 0) {
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,28 +319,27 @@ void Log::logBoardCards(int bero, int boardCards[5])
|
||||
{
|
||||
if(SQLITE_LOG) {
|
||||
|
||||
if(logOnOff) {
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if( mySqliteLogDb != 0 ) {
|
||||
// sqlite-db is open
|
||||
|
||||
sql = "UPDATE Hand SET ";
|
||||
switch(bero) {
|
||||
case 2: {
|
||||
sql += "UPDATE Hand SET ";
|
||||
sql += "BoardCard_1=" + boost::lexical_cast<string>(boardCards[0]) + ",";
|
||||
sql += "BoardCard_2=" + boost::lexical_cast<string>(boardCards[1]) + ",";
|
||||
sql += "BoardCard_3=" + boost::lexical_cast<string>(boardCards[2]);
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
sql += "UPDATE Hand SET ";
|
||||
sql += "BoardCard_4=" + boost::lexical_cast<string>(boardCards[3]);
|
||||
}
|
||||
break;
|
||||
case 4: {
|
||||
sql += "UPDATE Hand SET ";
|
||||
sql += "BoardCard_5=" + boost::lexical_cast<string>(boardCards[4]);
|
||||
}
|
||||
break;
|
||||
@@ -394,11 +349,10 @@ void Log::logBoardCards(int bero, int boardCards[5])
|
||||
sql += " WHERE ";
|
||||
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
|
||||
sql += "HandID=" + boost::lexical_cast<string>(curHandID);
|
||||
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 += ";";
|
||||
if(myConfig->readConfigInt("LogInterval") == 0) {
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,28 +360,27 @@ void Log::logBoardCards(int bero, int boardCards[5])
|
||||
|
||||
void Log::logHoleCards(int bero, int seat, int cards[2])
|
||||
{
|
||||
|
||||
logHoleCardsDone = false;
|
||||
|
||||
if(SQLITE_LOG) {
|
||||
|
||||
if(logOnOff) {
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if( mySqliteLogDb != 0 ) {
|
||||
// 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_2=" + boost::lexical_cast<string>(cards[1]);
|
||||
sql += " WHERE ";
|
||||
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
|
||||
sql += "HandID=" + boost::lexical_cast<string>(curHandID);
|
||||
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 += ";";
|
||||
if(myConfig->readConfigInt("LogInterval") == 0) {
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
|
||||
logPlayerAction(bero,seat,LOG_ACTION_SHOW);
|
||||
}
|
||||
@@ -439,27 +392,22 @@ void Log::logHandName(int seat, int cardsValueInt, PlayerList activePlayerList)
|
||||
{
|
||||
if(SQLITE_LOG) {
|
||||
|
||||
if(logOnOff) {
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if( mySqliteLogDb != 0 ) {
|
||||
// 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_int=" + boost::lexical_cast<string>(cardsValueInt);
|
||||
sql += " WHERE ";
|
||||
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
|
||||
sql += "HandID=" + boost::lexical_cast<string>(curHandID);
|
||||
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 += ";";
|
||||
if(myConfig->readConfigInt("LogInterval") == 0) {
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
|
||||
logPlayerAction(5,seat,LOG_ACTION_HAS);
|
||||
}
|
||||
@@ -471,35 +419,52 @@ void Log::logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, Player
|
||||
{
|
||||
if(SQLITE_LOG) {
|
||||
|
||||
if(logOnOff) {
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
string sql;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if( mySqliteLogDb != 0 ) {
|
||||
// sqlite-db is open
|
||||
|
||||
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_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 += "UPDATE Hand SET ";
|
||||
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);
|
||||
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 += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
|
||||
sql += "HandID=" + boost::lexical_cast<string>(curHandID);
|
||||
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 += ";";
|
||||
if(myConfig->readConfigInt("LogInterval") == 0) {
|
||||
exec_transaction(&sql);
|
||||
}
|
||||
|
||||
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
|
||||
//Log::closeLogDbAtExit()
|
||||
//{
|
||||
@@ -528,3 +493,11 @@ void Log::logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, Player
|
||||
// 11 wins (side pot)
|
||||
// 11 sits out
|
||||
// 12 wins game
|
||||
|
||||
// Bero-Code
|
||||
// 0 Pre-Preflop
|
||||
// 1 Preflop
|
||||
// 2 Flop
|
||||
// 3 Turn
|
||||
// 4 River
|
||||
// 5 Post-River
|
||||
|
||||
+7
-3
@@ -24,11 +24,13 @@
|
||||
|
||||
struct sqlite3;
|
||||
|
||||
class ConfigFile;
|
||||
|
||||
class Log
|
||||
{
|
||||
|
||||
public:
|
||||
Log(std::string logDirString, int logOnOffInt);
|
||||
Log(ConfigFile *c);
|
||||
|
||||
~Log();
|
||||
|
||||
@@ -39,15 +41,17 @@ public:
|
||||
void logHoleCards(int bero, int seat, int cards[2]);
|
||||
void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList);
|
||||
void logHoleCardsHandName(int seat, int cards[2], int cardsValueInt, PlayerList activePlayerList);
|
||||
void exec_transaction(std::string *sql);
|
||||
// void closeLogDbAtExit();
|
||||
|
||||
|
||||
private:
|
||||
sqlite3 *mySqliteLogDb;
|
||||
ConfigFile *myConfig;
|
||||
int curGameID;
|
||||
int curHandID;
|
||||
bool logOnOff;
|
||||
|
||||
std::string sql;
|
||||
bool logHoleCardsDone;
|
||||
};
|
||||
|
||||
#endif // LOG_H
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#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),
|
||||
firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false),
|
||||
lastActionPlayer(0)
|
||||
|
||||
@@ -30,7 +30,7 @@ class HandInterface;
|
||||
class ClientBeRo : public BeRoInterface
|
||||
{
|
||||
public:
|
||||
ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
|
||||
ClientBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS);
|
||||
~ClientBeRo();
|
||||
|
||||
GameState getMyBeRoID() const;
|
||||
|
||||
@@ -54,15 +54,15 @@ ClientEngineFactory::createPlayer(int id, unsigned uniqueId, PlayerType type, st
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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, id, 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, id, 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_PREFLOP)));
|
||||
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, dP, sB, GAME_STATE_TURN)));
|
||||
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, dP, sB, GAME_STATE_POST_RIVER)));
|
||||
|
||||
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<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 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
|
||||
|
||||
@@ -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.
|
||||
|
||||
// Preflop, Flop, Turn und River erstellen
|
||||
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind);
|
||||
myBeRo = myFactory->createBeRo(this, dealerPosition, smallBlind);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2512,6 +2512,7 @@ void gameTableImpl::postRiverRunAnimation3()
|
||||
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
|
||||
if((*it_c)->getMyCash() == 0) {
|
||||
currentHand->getGuiInterface()->logPlayerSitsOut((*it_c)->getMyName());
|
||||
currentHand->getLog()->logPlayerAction(5, (*it_c)->getMyID()+1, LOG_ACTION_SIT_OUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager, Conf
|
||||
m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false),
|
||||
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);
|
||||
myQtToolsInterface.reset(CreateQtToolsWrapper());
|
||||
m_senderHelper.reset(new SenderHelper(m_ioService));
|
||||
|
||||
@@ -214,7 +214,7 @@ ServerLobbyThread::Init(const string &logDir)
|
||||
m_serverConfig.readConfigString("DBServerEncryptionKey"));
|
||||
|
||||
GetBanManager().InitGameNameBadWordList(m_serverConfig.readConfigStringList("GameNameBadWordList"));
|
||||
m_serverLog.reset(new Log(logDir, 0));
|
||||
m_serverLog.reset(new Log(&m_serverConfig));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ Session::Session(GuiInterface *g, ConfigFile *c)
|
||||
: currentGameNum(0), myGui(g), myConfig(c), myLog(0), myGameType(GAME_TYPE_NONE)
|
||||
{
|
||||
myQtToolsInterface = CreateQtToolsWrapper();
|
||||
myLog = new Log(myConfig->readConfigString("LogDir"),myConfig->readConfigInt("LogOnOff"));
|
||||
myLog = new Log(myConfig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user