- some changes in sqlite logging

- replace beroID-int by GameState in hand
This commit is contained in:
floty
2011-10-22 23:57:02 +00:00
parent a958c4916e
commit ad4aace71d
11 changed files with 54 additions and 97 deletions
+2 -2
View File
@@ -52,8 +52,8 @@ public:
virtual void setStartQuantityPlayers(int theValue) =0;
virtual int getStartQuantityPlayers() const =0;
virtual void setCurrentRound(int theValue) =0;
virtual int getCurrentRound() const =0;
virtual void setCurrentRound(GameState theValue) =0;
virtual GameState getCurrentRound() const =0;
virtual void setDealerPosition(int theValue) =0;
virtual int getDealerPosition() const =0;
+1 -1
View File
@@ -176,7 +176,7 @@ void LocalBeRo::run()
// aktuelle bero nicht dran, weil alle Sets gleich sind
//also gehe in naechste bero
myHand->setCurrentRound(myBeRoID+1);
myHand->setCurrentRound(GameState(myBeRoID+1));
//Action loeschen und ActionButtons refresh
for(it_c=myHand->getRunningPlayerList()->begin(); it_c!=myHand->getRunningPlayerList()->end(); ++it_c) {
+15 -1
View File
@@ -83,7 +83,7 @@ void LocalBeRoPostRiver::postRiverRun()
//Pot auf 0 setzen
getMyHand()->getBoard()->setPot(0);
// Logging hole Cards / Hands
// logging hole Cards / Hands
int nonfoldPlayersCounter = 0;
for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++;
@@ -92,6 +92,20 @@ void LocalBeRoPostRiver::postRiverRun()
getMyHand()->getLog()->logHoleCardsHandName(5,getMyHand()->getActivePlayerList());
}
// logging winner if game is over
// wenn nur noch ein Spieler aktive "neues Spiel"-Dialog anzeigen
int playersPositiveCashCounter = 0;
for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if ((*it_c)->getMyCash() > 0) playersPositiveCashCounter++;
}
if (playersPositiveCashCounter==1) {
for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if ((*it_c)->getMyCash() > 0) {
getMyHand()->getLog()->logPlayerAction(5,(*it_c)->getMyID()+1,LOG_ACTION_WIN_GAME);
}
}
}
//starte die Animaionsreihe
getMyHand()->getGuiInterface()->postRiverRunAnimation1();
}
+8 -6
View File
@@ -30,7 +30,7 @@
using namespace std;
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false),
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(GAME_STATE_PREFLOP), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false),
cardsShown(false), bettingRoundsPlayed(0)
{
@@ -566,7 +566,7 @@ void LocalHand::switchRounds()
myBoard->collectPot();
myGui->refreshPot();
myGui->refreshSet();
currentRound = 4;
currentRound = GAME_STATE_POST_RIVER;
}
// check for all in condition
@@ -627,13 +627,15 @@ void LocalHand::switchRounds()
myGui->refreshSet();
myGui->flipHolecardsAllIn();
// Logging HoleCards
myLog->logHoleCards(currentRound+1,activePlayerList);
if(currentRound<GAME_STATE_RIVER) {
myLog->logHoleCardsHandName(currentRound+1,activePlayerList);
}
if (currentRound < 4) // do not increment past 4
currentRound++;
if (currentRound < GAME_STATE_POST_RIVER) // do not increment past 4
currentRound = GameState(currentRound + 1);
//log board cards for allin
if(currentRound >= 1) {
if(currentRound >= GAME_STATE_FLOP) {
int tempBoardCardsArray[5];
myBoard->getMyCards(tempBoardCardsArray);
+3 -3
View File
@@ -88,10 +88,10 @@ public:
return startQuantityPlayers;
}
void setCurrentRound(int theValue) {
void setCurrentRound(GameState theValue) {
currentRound = theValue;
}
int getCurrentRound() const {
GameState getCurrentRound() const {
return currentRound;
}
@@ -177,7 +177,7 @@ private:
unsigned dealerPosition;
unsigned smallBlindPosition;
unsigned bigBlindPosition;
int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
GameState currentRound;
int smallBlind;
int startCash;
+10 -68
View File
@@ -359,71 +359,6 @@ void Log::logBoardCards(int bero, int boardCards[5])
}
}
void Log::logHoleCards(int bero, PlayerList activePlayerList)
{
if(SQLITE_LOG) {
if(myConfig->readConfigInt("LogOnOff") & !logHoleCardsDone) {
//if write logfiles is enabled
if( mySqliteLogDb != 0 ) {
// sqlite-db is open
PlayerListConstIterator it_c;
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);
sql += "UPDATE Hand SET ";
sql += "Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast<string>(myCards[0]);
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_2=" + boost::lexical_cast<string>(myCards[1]);
sql += " WHERE ";
sql += "GameID=" + boost::lexical_cast<string>(curGameID) + " AND ";
sql += "HandID=" + boost::lexical_cast<string>(curHandID);
sql += ";";
if(myConfig->readConfigInt("LogInterval") == 0) {
exec_transaction(&sql);
}
logPlayerAction(bero,(*it_c)->getMyID()+1,LOG_ACTION_SHOW);
}
}
logHoleCardsDone = true;
}
}
}
}
//void Log::logHandName(int seat, int cardsValueInt, PlayerList activePlayerList)
//{
// if(SQLITE_LOG) {
// if(myConfig->readConfigInt("LogOnOff")) {
// //if write logfiles is enabled
// if( mySqliteLogDb != 0 ) {
// // sqlite-db is open
// 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);
// sql += ";";
// if(myConfig->readConfigInt("LogInterval") == 0) {
// exec_transaction(&sql);
// }
// logPlayerAction(5,seat,LOG_ACTION_HAS);
// }
// }
// }
//}
void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList)
{
if(SQLITE_LOG) {
@@ -431,8 +366,8 @@ void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList)
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
if( mySqliteLogDb != 0 ) {
// sqlite-db is open
if( mySqliteLogDb != 0 && (bero==5 || !logHoleCardsDone)) {
// sqlite-db is open and we are in postriver or before postriver doesn't log hole cards til now
PlayerListConstIterator it_c;
int myCards[2];
@@ -441,10 +376,15 @@ void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList)
if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
(*it_c)->getMyCards(myCards);
sql += "UPDATE Hand SET ";
if(bero==5) {
sql += "Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Hand_text=\"" + CardsValue::determineHandName((*it_c)->getMyCardsValueInt(),activePlayerList) + "\"";
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Hand_int=" + boost::lexical_cast<string>((*it_c)->getMyCardsValueInt());
}
if(bero==5 && !logHoleCardsDone) {
sql+= ",";
}
if(!logHoleCardsDone) {
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast<string>(myCards[0]);
sql += "Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_1=" + boost::lexical_cast<string>(myCards[0]);
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Card_2=" + boost::lexical_cast<string>(myCards[1]);
}
sql += " WHERE ";
@@ -462,6 +402,8 @@ void Log::logHoleCardsHandName(int bero, PlayerList activePlayerList)
}
}
}
logHoleCardsDone = true;
}
}
}
-2
View File
@@ -38,8 +38,6 @@ public:
void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList);
void logPlayerAction(int bero, int seat, PlayerActionLog action, int amount = 0);
void logBoardCards(int bero, int boardCards[5]);
void logHoleCards(int bero, PlayerList activePlayerList);
// void logHandName(int seat, int cardsValueInt, PlayerList activePlayerList);
void logHoleCardsHandName(int bero, PlayerList activePlayerList);
void exec_transaction(std::string *sql);
// void closeLogDbAtExit();
+3 -3
View File
@@ -22,7 +22,7 @@
using namespace std;
ClientHand::ClientHand(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)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0),
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(GAME_STATE_PREFLOP),
smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0)
{
@@ -203,13 +203,13 @@ ClientHand::getStartQuantityPlayers() const
}
void
ClientHand::setCurrentRound(int theValue)
ClientHand::setCurrentRound(GameState theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
currentRound = theValue;
}
int
GameState
ClientHand::getCurrentRound() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
+3 -3
View File
@@ -63,8 +63,8 @@ public:
void setStartQuantityPlayers ( int theValue );
int getStartQuantityPlayers() const;
void setCurrentRound ( int theValue );
int getCurrentRound() const;
void setCurrentRound ( GameState theValue );
GameState getCurrentRound() const;
void setDealerPosition ( int theValue );
int getDealerPosition() const;
@@ -115,7 +115,7 @@ private:
int myID;
int startQuantityPlayers;
unsigned dealerPosition;
int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
GameState currentRound;
int smallBlind;
int startCash;
+4 -3
View File
@@ -2651,9 +2651,10 @@ void gameTableImpl::showHoleCards(unsigned playerId, bool allIn)
}
}
//set Player value (logging)
if(currentHand->getCurrentRound() < 3 || allIn) {
if(currentHand->getCurrentRound() < GAME_STATE_RIVER || allIn) {
(*it_c)->setMyCardsFlip(1,2); //for bero before postriver or allin just log the hole cards
} else {
}
else {
(*it_c)->setMyCardsFlip(1,1); //for postriver log the value
}
}
@@ -2665,7 +2666,7 @@ void gameTableImpl::flipHolecardsAllIn()
boost::shared_ptr<Game> currentGame = myStartWindow->getSession()->getCurrentGame();
if(!flipHolecardsAllInAlreadyDone) {
if(!flipHolecardsAllInAlreadyDone && currentGame->getCurrentHand()->getCurrentRound() < GAME_STATE_RIVER) {
//Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen
int nonfoldPlayersCounter = 0;
PlayerListConstIterator it_c;
+1 -1
View File
@@ -1799,7 +1799,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
// Set round.
if (curGame->getCurrentHand()->getCurrentRound() != netPlayersTurn->gameState) {
ResetPlayerActions(*curGame);
curGame->getCurrentHand()->setCurrentRound(netPlayersTurn->gameState);
curGame->getCurrentHand()->setCurrentRound(GameState(netPlayersTurn->gameState));
// Refresh actions.
client->GetGui().refreshSet();
client->GetGui().refreshAction();