create log in session; put some include from header to cpp
This commit is contained in:
@@ -18,6 +18,12 @@
|
||||
* 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"
|
||||
|
||||
using namespace std;
|
||||
@@ -150,7 +156,7 @@ Log::~Log()
|
||||
}
|
||||
|
||||
void
|
||||
Log::logNewGameMsg(int gameID, Game *currentGame) {
|
||||
Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList) {
|
||||
|
||||
if(SQLITE_LOG) {
|
||||
|
||||
@@ -175,11 +181,11 @@ Log::logNewGameMsg(int gameID, Game *currentGame) {
|
||||
}
|
||||
sql += ") VALUES (";
|
||||
sql += boost::lexical_cast<string>(gameID);
|
||||
sql += "," + boost::lexical_cast<string>(currentGame->getStartCash());
|
||||
sql += "," + boost::lexical_cast<string>(currentGame->getStartSmallBlind());
|
||||
sql += "," + boost::lexical_cast<string>(currentGame->getDealerPosition());
|
||||
sql += "," + boost::lexical_cast<string>(startCash);
|
||||
sql += "," + boost::lexical_cast<string>(startSmallBlind);
|
||||
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()) {
|
||||
sql += ",\"" + (*it_c)->getMyName() +"\"";
|
||||
} else {
|
||||
|
||||
@@ -20,17 +20,10 @@
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <dirent.h>
|
||||
#include <iostream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "playerinterface.h"
|
||||
|
||||
#include "game.h"
|
||||
#include "handinterface.h"
|
||||
#include "configfile.h"
|
||||
#include "game_defs.h"
|
||||
|
||||
//class Game;
|
||||
struct sqlite3;
|
||||
class ConfigFile;
|
||||
|
||||
class Log
|
||||
{
|
||||
@@ -40,7 +33,7 @@ public:
|
||||
|
||||
~Log();
|
||||
|
||||
void logNewGameMsg(int, Game*);
|
||||
void logNewGameMsg(int, int, int, unsigned, PlayerList);
|
||||
// void closeLogDbAtExit();
|
||||
|
||||
|
||||
|
||||
+5
-2
@@ -31,8 +31,8 @@ using namespace std;
|
||||
|
||||
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||
const StartData &startData, int gameId)
|
||||
: myFactory(factory), myGui(gui), currentHand(0), currentBoard(0),
|
||||
const StartData &startData, int gameId, Log* log)
|
||||
: myFactory(factory), myGui(gui), myLog(log), currentHand(0), currentBoard(0),
|
||||
startQuantityPlayers(startData.numberOfPlayers),
|
||||
startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind),
|
||||
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);
|
||||
|
||||
// log game data
|
||||
// myLog->logNewGameMsg(myGameID, startCash, startSmallBlind, dealerPosition, seatsList);
|
||||
|
||||
//start timer
|
||||
blindsTimer.reset();
|
||||
blindsTimer.start();
|
||||
|
||||
+5
-2
@@ -23,10 +23,12 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "gamedata.h"
|
||||
#include "playerdata.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <third_party/boost/timers.hpp>
|
||||
|
||||
class GuiInterface;
|
||||
class Log;
|
||||
class HandInterface;
|
||||
class PlayerInterface;
|
||||
class BoardInterface;
|
||||
@@ -41,9 +43,9 @@ typedef std::list<boost::shared_ptr<PlayerInterface> >::const_iterator PlayerLis
|
||||
class Game {
|
||||
|
||||
public:
|
||||
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
|
||||
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
|
||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||
const StartData &startData, int gameId);
|
||||
const StartData &startData, int gameId, Log *myLog = 0);
|
||||
|
||||
~Game();
|
||||
|
||||
@@ -85,6 +87,7 @@ private:
|
||||
boost::shared_ptr<EngineFactory> myFactory;
|
||||
|
||||
GuiInterface *myGui;
|
||||
Log *myLog;
|
||||
HandInterface *currentHand;
|
||||
BoardInterface *currentBoard;
|
||||
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
#include <net/socket_helper.h>
|
||||
#include "session.h"
|
||||
#include "game.h"
|
||||
#include "log.h"
|
||||
#include "guiinterface.h"
|
||||
#include "configfile.h"
|
||||
#include <qttoolsinterface.h>
|
||||
@@ -116,7 +117,7 @@ void Session::startLocalGame(const GameData &gameData, const StartData &startDat
|
||||
// EngineFactory 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
|
||||
currentGame->initHand();
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "log.h"
|
||||
#include "serverdata.h"
|
||||
#include "gamedata.h"
|
||||
#include "playerdata.h"
|
||||
|
||||
Reference in New Issue
Block a user