sqlite-log: complete new hand log
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "boardinterface.h"
|
#include "boardinterface.h"
|
||||||
#include "playerinterface.h"
|
#include "playerinterface.h"
|
||||||
#include "berointerface.h"
|
#include "berointerface.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
class HandInterface
|
class HandInterface
|
||||||
{
|
{
|
||||||
@@ -44,6 +45,7 @@ public:
|
|||||||
virtual boost::shared_ptr<BeRoInterface> getRiver() const =0;
|
virtual boost::shared_ptr<BeRoInterface> getRiver() const =0;
|
||||||
virtual GuiInterface* getGuiInterface() const =0;
|
virtual GuiInterface* getGuiInterface() const =0;
|
||||||
virtual boost::shared_ptr<BeRoInterface> getCurrentBeRo() const =0;
|
virtual boost::shared_ptr<BeRoInterface> getCurrentBeRo() const =0;
|
||||||
|
virtual Log* getLog() const =0;
|
||||||
|
|
||||||
virtual void setMyID(int theValue) =0;
|
virtual void setMyID(int theValue) =0;
|
||||||
virtual int getMyID() const =0;
|
virtual int getMyID() const =0;
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ void LocalBeRo::run()
|
|||||||
switch(myBeRoID) {
|
switch(myBeRoID) {
|
||||||
case GAME_STATE_FLOP:
|
case GAME_STATE_FLOP:
|
||||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
|
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
|
||||||
|
myHand->getLog()->logBoardCards(myBeRoID, tempBoardCardsArray);
|
||||||
break;
|
break;
|
||||||
case GAME_STATE_TURN:
|
case GAME_STATE_TURN:
|
||||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
|
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
|
||||||
|
|||||||
@@ -357,10 +357,13 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
|||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
// determine dealer, SB, BB
|
// determine dealer, SB, BB
|
||||||
|
|
||||||
assignButtons();
|
assignButtons();
|
||||||
|
|
||||||
myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList);
|
myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList);
|
||||||
|
|
||||||
|
setBlinds();
|
||||||
|
|
||||||
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind);
|
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,40 +470,46 @@ void LocalHand::assignButtons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cout << "lAP-Button: " << lastActionPlayer << endl;
|
// cout << "lAP-Button: " << lastActionPlayer << endl;
|
||||||
|
}
|
||||||
|
|
||||||
//do sets --> TODO switch?
|
void LocalHand::setBlinds()
|
||||||
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) {
|
{
|
||||||
|
|
||||||
//small blind
|
PlayerListConstIterator it_c;
|
||||||
if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) {
|
|
||||||
|
|
||||||
// All in ?
|
//do sets --> TODO switch?
|
||||||
if((*it_c)->getMyCash() <= smallBlind) {
|
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) {
|
||||||
|
|
||||||
(*it_c)->setMySet((*it_c)->getMyCash());
|
//small blind
|
||||||
// 1 to do not log this
|
if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) {
|
||||||
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
|
|
||||||
|
|
||||||
} else {
|
// All in ?
|
||||||
(*it_c)->setMySet(smallBlind);
|
if((*it_c)->getMyCash() <= smallBlind) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//big blind
|
(*it_c)->setMySet((*it_c)->getMyCash());
|
||||||
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
|
// 1 to do not log this
|
||||||
|
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
|
||||||
|
|
||||||
// all in ?
|
} else {
|
||||||
if((*it_c)->getMyCash() <= 2*smallBlind) {
|
(*it_c)->setMySet(smallBlind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(*it_c)->setMySet((*it_c)->getMyCash());
|
//big blind
|
||||||
// 1 to do not log this
|
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
|
||||||
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
|
|
||||||
|
|
||||||
} else {
|
// all in ?
|
||||||
(*it_c)->setMySet(2*smallBlind);
|
if((*it_c)->getMyCash() <= 2*smallBlind) {
|
||||||
}
|
|
||||||
}
|
(*it_c)->setMySet((*it_c)->getMyCash());
|
||||||
}
|
// 1 to do not log this
|
||||||
|
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
(*it_c)->setMySet(2*smallBlind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ public:
|
|||||||
return myBeRo[currentRound];
|
return myBeRo[currentRound];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log* getLog() const {
|
||||||
|
return myLog;
|
||||||
|
}
|
||||||
|
|
||||||
void setMyID(int theValue) {
|
void setMyID(int theValue) {
|
||||||
myID = theValue;
|
myID = theValue;
|
||||||
}
|
}
|
||||||
@@ -147,6 +151,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void assignButtons();
|
void assignButtons();
|
||||||
|
void setBlinds();
|
||||||
|
|
||||||
void switchRounds();
|
void switchRounds();
|
||||||
|
|
||||||
|
|||||||
+111
-47
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Log::Log(string logDirString, int logOnOffInt) : curGameID(0), logOnOff(false)
|
Log::Log(string logDirString, int logOnOffInt) : curGameID(0), curHandID(0), logOnOff(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(SQLITE_LOG) {
|
if(SQLITE_LOG) {
|
||||||
@@ -165,8 +165,7 @@ Log::~Log()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList)
|
||||||
Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
curGameID = gameID;
|
curGameID = gameID;
|
||||||
@@ -213,59 +212,124 @@ Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned deal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList)
|
||||||
Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if(SQLITE_LOG) {
|
curHandID = handID;
|
||||||
|
|
||||||
if(logOnOff) {
|
if(SQLITE_LOG) {
|
||||||
//if write logfiles is enabled
|
|
||||||
|
|
||||||
PlayerListConstIterator it_c;
|
if(logOnOff) {
|
||||||
string sql;
|
//if write logfiles is enabled
|
||||||
char *errmsg;
|
|
||||||
|
|
||||||
if( mySqliteLogDb != 0 ) {
|
PlayerListConstIterator it_c;
|
||||||
// sqlite-db is open
|
string sql;
|
||||||
int i;
|
char *errmsg;
|
||||||
|
|
||||||
sql = "INSERT INTO Hand (";
|
if( mySqliteLogDb != 0 ) {
|
||||||
sql += "HandID";
|
// sqlite-db is open
|
||||||
sql += ",GameID";
|
int i;
|
||||||
sql += ",Dealer_Seat";
|
|
||||||
sql += ",Sb_Amount";
|
|
||||||
sql += ",Sb_Seat";
|
|
||||||
sql += ",Bb_Amount";
|
|
||||||
sql += ",Bb_Seat";
|
|
||||||
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
|
||||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash";
|
|
||||||
}
|
|
||||||
sql += ") VALUES (";
|
|
||||||
sql += boost::lexical_cast<string>(handID);
|
|
||||||
sql += "," + boost::lexical_cast<string>(curGameID);
|
|
||||||
sql += "," + boost::lexical_cast<string>(dealerPosition+1);
|
|
||||||
sql += "," + boost::lexical_cast<string>(smallBlind);
|
|
||||||
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
|
|
||||||
sql += "," + boost::lexical_cast<string>(bigBlind);
|
|
||||||
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
|
|
||||||
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
|
|
||||||
if((*it_c)->getMyActiveStatus()) {
|
|
||||||
sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash());
|
|
||||||
} else {
|
|
||||||
sql += ",NULL";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sql += ")";
|
|
||||||
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
|
|
||||||
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
sql = "INSERT INTO Hand (";
|
||||||
|
sql += "HandID";
|
||||||
|
sql += ",GameID";
|
||||||
|
sql += ",Dealer_Seat";
|
||||||
|
sql += ",Sb_Amount";
|
||||||
|
sql += ",Sb_Seat";
|
||||||
|
sql += ",Bb_Amount";
|
||||||
|
sql += ",Bb_Seat";
|
||||||
|
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash";
|
||||||
|
}
|
||||||
|
sql += ") VALUES (";
|
||||||
|
sql += boost::lexical_cast<string>(handID);
|
||||||
|
sql += "," + boost::lexical_cast<string>(curGameID);
|
||||||
|
sql += "," + boost::lexical_cast<string>(dealerPosition+1);
|
||||||
|
sql += "," + boost::lexical_cast<string>(smallBlind);
|
||||||
|
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
|
||||||
|
sql += "," + boost::lexical_cast<string>(bigBlind);
|
||||||
|
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
|
||||||
|
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
|
||||||
|
if((*it_c)->getMyActiveStatus()) {
|
||||||
|
sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash());
|
||||||
|
} else {
|
||||||
|
sql += ",NULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sql += ")";
|
||||||
|
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
|
||||||
|
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// Action 'starts as dealer'
|
||||||
|
sql = "INSERT INTO Action (";
|
||||||
|
sql += "HandID";
|
||||||
|
sql += ",GameID";
|
||||||
|
sql += ",BeRo";
|
||||||
|
sql += ",Player";
|
||||||
|
sql += ",Action";
|
||||||
|
sql += ",Amount";
|
||||||
|
sql += ") VALUES (";
|
||||||
|
sql += boost::lexical_cast<string>(handID);
|
||||||
|
sql += "," + boost::lexical_cast<string>(curGameID);
|
||||||
|
sql += ",0";
|
||||||
|
sql += "," + boost::lexical_cast<string>(dealerPosition+1);
|
||||||
|
sql += ",'starts as dealer'";
|
||||||
|
sql += ",NULL";
|
||||||
|
sql += ")";
|
||||||
|
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
|
||||||
|
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// Action 'posts small blind'
|
||||||
|
sql = "INSERT INTO Action (";
|
||||||
|
sql += "HandID";
|
||||||
|
sql += ",GameID";
|
||||||
|
sql += ",BeRo";
|
||||||
|
sql += ",Player";
|
||||||
|
sql += ",Action";
|
||||||
|
sql += ",Amount";
|
||||||
|
sql += ") VALUES (";
|
||||||
|
sql += boost::lexical_cast<string>(handID);
|
||||||
|
sql += "," + boost::lexical_cast<string>(curGameID);
|
||||||
|
sql += ",0";
|
||||||
|
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
|
||||||
|
sql += ",'posts small blind'";
|
||||||
|
sql += "," + boost::lexical_cast<string>(smallBlind);
|
||||||
|
sql += ")";
|
||||||
|
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
|
||||||
|
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Action 'posts big blind'
|
||||||
|
sql = "INSERT INTO Action (";
|
||||||
|
sql += "HandID";
|
||||||
|
sql += ",GameID";
|
||||||
|
sql += ",BeRo";
|
||||||
|
sql += ",Player";
|
||||||
|
sql += ",Action";
|
||||||
|
sql += ",Amount";
|
||||||
|
sql += ") VALUES (";
|
||||||
|
sql += boost::lexical_cast<string>(handID);
|
||||||
|
sql += "," + boost::lexical_cast<string>(curGameID);
|
||||||
|
sql += ",0";
|
||||||
|
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
|
||||||
|
sql += ",\'posts big blind'";
|
||||||
|
sql += "," + boost::lexical_cast<string>(bigBlind);
|
||||||
|
sql += ")";
|
||||||
|
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
|
||||||
|
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log::logBoardCards(GameState beroID, int boardCards[5])
|
||||||
|
{
|
||||||
|
if(SQLITE_LOG) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void
|
//void
|
||||||
|
|||||||
@@ -34,12 +34,14 @@ public:
|
|||||||
|
|
||||||
void logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList);
|
void logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList);
|
||||||
void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList);
|
void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList);
|
||||||
|
void logBoardCards(GameState beroID, int boardCards[5]);
|
||||||
// void closeLogDbAtExit();
|
// void closeLogDbAtExit();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sqlite3 *mySqliteLogDb;
|
sqlite3 *mySqliteLogDb;
|
||||||
int curGameID;
|
int curGameID;
|
||||||
|
int curHandID;
|
||||||
bool logOnOff;
|
bool logOnOff;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ public:
|
|||||||
GuiInterface* getGuiInterface() const;
|
GuiInterface* getGuiInterface() const;
|
||||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
|
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
|
||||||
|
|
||||||
|
Log* getLog() const {
|
||||||
|
return myLog;
|
||||||
|
}
|
||||||
|
|
||||||
void setMyID ( int theValue );
|
void setMyID ( int theValue );
|
||||||
int getMyID() const;
|
int getMyID() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user