1 /***************************************************************************** 2 * PokerTH - The open source texas holdem engine * 3 * Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May * 4 * * 5 * This program is free software: you can redistribute it and/or modify * 6 * it under the terms of the GNU Affero General Public License as * 7 * published by the Free Software Foundation, either version 3 of the * 8 * License, or (at your option) any later version. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU Affero General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU Affero General Public License * 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 17 * * 18 * * 19 * Additional permission under GNU AGPL version 3 section 7 * 20 * * 21 * If you modify this program, or any covered work, by linking or * 22 * combining it with the OpenSSL project's OpenSSL library (or a * 23 * modified version of that library), containing parts covered by the * 24 * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH * 25 * (Felix Hammer, Florian Thauer, Lothar May) grant you additional * 26 * permission to convey the resulting work. * 27 * Corresponding Source for a non-source form of such a combination * 28 * shall include the source code for the parts of OpenSSL used as well * 29 * as that of the covered work. * 30 *****************************************************************************/ 31 32 #ifndef LOG_H 33 #define LOG_H 34 35 #include <string> 36 #include <boost/filesystem.hpp> 37 38 #include "engine_defs.h" 39 #include "game_defs.h" 40 #include <string> 41 42 struct sqlite3; 43 44 class ConfigFile; 45 46 class Log 47 { 48 49 public: 50 Log(ConfigFile *c); 51 52 ~Log(); 53 54 void init(); 55 void logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList); 56 void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList); 57 void logPlayerAction(std::string playerName, PlayerActionLog action, int amount = 0); 58 void logPlayerAction(int seat, PlayerActionLog action, int amount = 0); 59 PlayerActionLog transformPlayerActionLog(PlayerAction action); 60 void logBoardCards(int boardCards[5]); 61 void logHoleCardsHandName(PlayerList activePlayerList); 62 void logHoleCardsHandName(PlayerList activePlayerList, boost::shared_ptr<PlayerInterface> player, bool forceExecLog = 0); 63 void logHandWinner(PlayerList activePlayerList, int highestCardsValue, std::list<unsigned> winners); 64 void logGameWinner(PlayerList activePlayerList); 65 void logPlayerSitsOut(PlayerList activePlayerList); 66 void logAfterHand(); 67 void logAfterGame(); 68 // void closeLogDbAtExit(); 69 setCurrentRound(GameState theValue)70 void setCurrentRound(GameState theValue) 71 { 72 currentRound = theValue; 73 } 74 getMySqliteLogFileName()75 std::string getMySqliteLogFileName() 76 { 77 return mySqliteLogFileName.directory_string(); 78 } 79 80 private: 81 82 void exec_transaction(); 83 84 sqlite3 *mySqliteLogDb; 85 boost::filesystem::path mySqliteLogFileName; 86 ConfigFile *myConfig; 87 int uniqueGameID; 88 int currentHandID; 89 GameState currentRound; 90 std::string sql; 91 }; 92 93 #endif // LOG_H 94