create log in session; put some include from header to cpp

This commit is contained in:
floty
2010-12-20 20:30:12 +00:00
parent c88fe3220d
commit 29e16e3489
6 changed files with 27 additions and 22 deletions
+11 -5
View File
@@ -18,6 +18,12 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <sqlite3.h>
#include <iostream>
#include <dirent.h>
#include <boost/lexical_cast.hpp>
#include "configfile.h"
#include "game_defs.h"
#include "log.h" #include "log.h"
using namespace std; using namespace std;
@@ -150,7 +156,7 @@ Log::~Log()
} }
void void
Log::logNewGameMsg(int gameID, Game *currentGame) { Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList) {
if(SQLITE_LOG) { if(SQLITE_LOG) {
@@ -175,11 +181,11 @@ Log::logNewGameMsg(int gameID, Game *currentGame) {
} }
sql += ") VALUES ("; sql += ") VALUES (";
sql += boost::lexical_cast<string>(gameID); sql += boost::lexical_cast<string>(gameID);
sql += "," + boost::lexical_cast<string>(currentGame->getStartCash()); sql += "," + boost::lexical_cast<string>(startCash);
sql += "," + boost::lexical_cast<string>(currentGame->getStartSmallBlind()); sql += "," + boost::lexical_cast<string>(startSmallBlind);
sql += "," + boost::lexical_cast<string>(currentGame->getDealerPosition()); sql += "," + boost::lexical_cast<string>(dealerPosition);
for(it_c = currentGame->getCurrentHand()->getSeatsList()->begin();it_c!=currentGame->getCurrentHand()->getSeatsList()->end();it_c++) { for(it_c = seatsList->begin();it_c!=seatsList->end();it_c++) {
if((*it_c)->getMyActiveStatus()) { if((*it_c)->getMyActiveStatus()) {
sql += ",\"" + (*it_c)->getMyName() +"\""; sql += ",\"" + (*it_c)->getMyName() +"\"";
} else { } else {
+4 -11
View File
@@ -20,17 +20,10 @@
#ifndef LOG_H #ifndef LOG_H
#define LOG_H #define LOG_H
#include <sqlite3.h> #include "playerinterface.h"
#include <dirent.h>
#include <iostream>
#include <boost/lexical_cast.hpp>
#include "game.h" struct sqlite3;
#include "handinterface.h" class ConfigFile;
#include "configfile.h"
#include "game_defs.h"
//class Game;
class Log class Log
{ {
@@ -40,7 +33,7 @@ public:
~Log(); ~Log();
void logNewGameMsg(int, Game*); void logNewGameMsg(int, int, int, unsigned, PlayerList);
// void closeLogDbAtExit(); // void closeLogDbAtExit();
+5 -2
View File
@@ -31,8 +31,8 @@ using namespace std;
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory, Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
const PlayerDataList &playerDataList, const GameData &gameData, const PlayerDataList &playerDataList, const GameData &gameData,
const StartData &startData, int gameId) const StartData &startData, int gameId, Log* log)
: myFactory(factory), myGui(gui), currentHand(0), currentBoard(0), : myFactory(factory), myGui(gui), myLog(log), currentHand(0), currentBoard(0),
startQuantityPlayers(startData.numberOfPlayers), startQuantityPlayers(startData.numberOfPlayers),
startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind), startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind),
myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0), lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData) myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0), lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData)
@@ -108,6 +108,9 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
currentBoard->setPlayerLists(seatsList, activePlayerList, runningPlayerList); currentBoard->setPlayerLists(seatsList, activePlayerList, runningPlayerList);
// log game data
// myLog->logNewGameMsg(myGameID, startCash, startSmallBlind, dealerPosition, seatsList);
//start timer //start timer
blindsTimer.reset(); blindsTimer.reset();
blindsTimer.start(); blindsTimer.start();
+5 -2
View File
@@ -23,10 +23,12 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "gamedata.h" #include "gamedata.h"
#include "playerdata.h" #include "playerdata.h"
#include "log.h"
#include <third_party/boost/timers.hpp> #include <third_party/boost/timers.hpp>
class GuiInterface; class GuiInterface;
class Log;
class HandInterface; class HandInterface;
class PlayerInterface; class PlayerInterface;
class BoardInterface; class BoardInterface;
@@ -41,9 +43,9 @@ typedef std::list<boost::shared_ptr<PlayerInterface> >::const_iterator PlayerLis
class Game { class Game {
public: public:
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory, Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
const PlayerDataList &playerDataList, const GameData &gameData, const PlayerDataList &playerDataList, const GameData &gameData,
const StartData &startData, int gameId); const StartData &startData, int gameId, Log *myLog = 0);
~Game(); ~Game();
@@ -85,6 +87,7 @@ private:
boost::shared_ptr<EngineFactory> myFactory; boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui; GuiInterface *myGui;
Log *myLog;
HandInterface *currentHand; HandInterface *currentHand;
BoardInterface *currentBoard; BoardInterface *currentBoard;
+2 -1
View File
@@ -21,6 +21,7 @@
#include <net/socket_helper.h> #include <net/socket_helper.h>
#include "session.h" #include "session.h"
#include "game.h" #include "game.h"
#include "log.h"
#include "guiinterface.h" #include "guiinterface.h"
#include "configfile.h" #include "configfile.h"
#include <qttoolsinterface.h> #include <qttoolsinterface.h>
@@ -116,7 +117,7 @@ void Session::startLocalGame(const GameData &gameData, const StartData &startDat
// EngineFactory erstellen // EngineFactory erstellen
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen
currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum)); currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum, myLog));
//// SPIEL-SCHLEIFE //// SPIEL-SCHLEIFE
currentGame->initHand(); currentGame->initHand();
-1
View File
@@ -23,7 +23,6 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <string> #include <string>
#include "log.h"
#include "serverdata.h" #include "serverdata.h"
#include "gamedata.h" #include "gamedata.h"
#include "playerdata.h" #include "playerdata.h"