From 7f3e3f6dfdbcfd20df9a7106bb33450c64539753 Mon Sep 17 00:00:00 2001 From: floty Date: Thu, 22 Jul 2010 21:17:22 +0000 Subject: [PATCH] delete some bug for determining the list of player who have to show their cards. additionally the lastActionPlayer is now determined correctly (especially in every betting roud) --- src/engine/berointerface.h | 3 -- src/engine/handinterface.h | 3 ++ src/engine/local_engine/localbero.cpp | 2 +- src/engine/local_engine/localbero.h | 5 ---- src/engine/local_engine/localboard.cpp | 36 +++++++++++++----------- src/engine/local_engine/localhand.cpp | 8 ++++-- src/engine/local_engine/localhand.h | 4 +++ src/engine/local_engine/localplayer.cpp | 12 ++++++-- src/engine/network_engine/clienthand.cpp | 12 ++++++++ src/engine/network_engine/clienthand.h | 4 +++ src/gui/qt/gametable/gametableimpl.cpp | 6 ++++ 11 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/engine/berointerface.h b/src/engine/berointerface.h index ebe3c967..70207f56 100644 --- a/src/engine/berointerface.h +++ b/src/engine/berointerface.h @@ -58,9 +58,6 @@ public: virtual void setHighestCardsValue(int theValue) =0; virtual int getHighestCardsValue() const =0; - virtual void setLastActionPlayer( unsigned theValue ) =0; - virtual unsigned getLastActionPlayer() const =0; - virtual void setMinimumRaise (int) =0; virtual int getMinimumRaise() const =0; diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index 9f850881..27ae1226 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -75,6 +75,9 @@ public: virtual void setLastPlayersTurn(int theValue) =0; virtual int getLastPlayersTurn() const =0; + virtual void setLastActionPlayer( unsigned theValue ) =0; + virtual unsigned getLastActionPlayer() const =0; + virtual void setCardsShown(bool theValue) =0; virtual bool getCardsShown() const =0; diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index 121025be..2c6a4acd 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -26,7 +26,7 @@ using namespace std; LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS) -: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false), lastActionPlayer(-1) +: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false) { currentPlayersTurnIt = myHand->getRunningPlayerList()->begin(); lastPlayersTurnIt = myHand->getRunningPlayerList()->begin(); diff --git a/src/engine/local_engine/localbero.h b/src/engine/local_engine/localbero.h index b2740c9a..8a6e9485 100644 --- a/src/engine/local_engine/localbero.h +++ b/src/engine/local_engine/localbero.h @@ -97,9 +97,6 @@ protected: void setSmallBlind(int theValue) { smallBlind = theValue; } int getSmallBlind() const { return smallBlind; } - - void setLastActionPlayer ( unsigned theValue ) { lastActionPlayer = theValue; } - unsigned getLastActionPlayer() const { return lastActionPlayer; } @@ -137,8 +134,6 @@ private: bool logBoardCardsDone; - int lastActionPlayer; - }; diff --git a/src/engine/local_engine/localboard.cpp b/src/engine/local_engine/localboard.cpp index 6d24b790..1d7d9f81 100755 --- a/src/engine/local_engine/localboard.cpp +++ b/src/engine/local_engine/localboard.cpp @@ -240,6 +240,7 @@ void LocalBoard::distributePot() { void LocalBoard::determinePlayerNeedToShowCards() { + playerNeedToShowCards.clear(); // all winners have to show their cards @@ -268,14 +269,15 @@ void LocalBoard::determinePlayerNeedToShowCards() { PlayerListConstIterator lastActionPlayerIt; PlayerListConstIterator it_c; +// cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl; // search lastActionPlayer for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); it_c++) { -// cout << (*it_c)->getMyUniqueID() << ','; - if((*it_c)->getMyUniqueID() == currentHand->getCurrentBeRo()->getLastActionPlayer() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + if((*it_c)->getMyUniqueID() == currentHand->getLastActionPlayer() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { lastActionPlayerIt = it_c; +// cout << (*it_c)->getMyUniqueID() << endl; + break; } } -// cout << endl; if(it_c == activePlayerList->end()) { for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); it_c++) { @@ -310,7 +312,7 @@ void LocalBoard::determinePlayerNeedToShowCards() { it_c = lastActionPlayerIt; it_c++; - for(int i = 0; i < activePlayerList->size(); i++) { + for(unsigned i = 0; i < activePlayerList->size(); i++) { if(it_c == activePlayerList->end()) it_c = activePlayerList->begin(); @@ -338,9 +340,9 @@ void LocalBoard::determinePlayerNeedToShowCards() { next_level_it = level_it; next_level_it++; - for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { - cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; - } +// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { +// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; +// } if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) { @@ -357,15 +359,15 @@ void LocalBoard::determinePlayerNeedToShowCards() { level_tmp[0] = (*it_c)->getMyCardsValueInt(); level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); - for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { - cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; - } +// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { +// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; +// } level.insert(level_it,level_tmp); - for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { - cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; - } +// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { +// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; +// } break; } @@ -407,9 +409,9 @@ void LocalBoard::determinePlayerNeedToShowCards() { std::_List_iterator playerNeedToShowCardsIt; - for(playerNeedToShowCardsIt = playerNeedToShowCards.begin(); playerNeedToShowCardsIt!=playerNeedToShowCards.end(); playerNeedToShowCardsIt++) { - cout << (*playerNeedToShowCardsIt) << '\t'; - } - cout << endl; +// for(playerNeedToShowCardsIt = playerNeedToShowCards.begin(); playerNeedToShowCardsIt!=playerNeedToShowCards.end(); playerNeedToShowCardsIt++) { +// cout << (*playerNeedToShowCardsIt) << '\t'; +// } +// cout << endl; } diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 563330a3..cfce771f 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -31,7 +31,7 @@ using namespace std; LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC) -: myFactory(f), myGui(g), myBoard(b), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(false), +: myFactory(f), myGui(g), myBoard(b), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false), cardsShown(false), bettingRoundsPlayed(0) { @@ -431,7 +431,7 @@ void LocalHand::assignButtons() { //big blind in heads up (*it)->setMyButton(3); // lastPlayerAction for showing cards -// getCurrentBeRo()->setLastActionPlayer((*it)->getMyUniqueID()); + lastActionPlayer = (*it)->getMyUniqueID(); } it++; @@ -441,7 +441,7 @@ void LocalHand::assignButtons() { //big blind normal (*it)->setMyButton(3); // lastPlayerAction for showing cards -// getCurrentBeRo()->setLastActionPlayer((*it)->getMyUniqueID()); + lastActionPlayer = (*it)->getMyUniqueID(); } else { //small blind in heads up (*it)->setMyButton(2); @@ -455,6 +455,8 @@ void LocalHand::assignButtons() { throw LocalException(__FILE__, __LINE__, ERR_NEXT_ACTIVE_PLAYER_NOT_FOUND); } +// cout << "lAP-Button: " << lastActionPlayer << endl; + //do sets --> TODO switch? for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); it_c++) { diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 34d63f48..ff7c5aa5 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -82,6 +82,9 @@ public: void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; } int getLastPlayersTurn() const { return lastPlayersTurn; } + void setLastActionPlayer ( unsigned theValue ) { lastActionPlayer = theValue; } + unsigned getLastActionPlayer() const { return lastActionPlayer; } + void setCardsShown(bool theValue) { cardsShown = theValue; } bool getCardsShown() const { return cardsShown; } @@ -110,6 +113,7 @@ private: int startCash; int lastPlayersTurn; + unsigned lastActionPlayer; bool allInCondition; bool cardsShown; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 4b4afc15..8a6f7940 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -3067,9 +3067,10 @@ void LocalPlayer::evaluation(int bet, int raise) { myCash = myCash - bet; mySet = bet; highestSet = mySet; + } // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->getCurrentBeRo()->setLastActionPlayer(myUniqueID); + currentHand->setLastActionPlayer(myUniqueID); } break; // raise @@ -3097,6 +3098,9 @@ void LocalPlayer::evaluation(int bet, int raise) { // -> full bet rule if(highestSet + currentHand->getCurrentBeRo()->getMinimumRaise() > myCash + mySet) { currentHand->getCurrentBeRo()->setFullBetRule(true); + } else { + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(myUniqueID); } mySet += myCash; currentHand->getCurrentBeRo()->setMinimumRaise(mySet-highestSet); @@ -3110,10 +3114,10 @@ void LocalPlayer::evaluation(int bet, int raise) { myCash = myCash + mySet - highestSet - raise; mySet = highestSet + raise; highestSet = mySet; + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(myUniqueID); } } - // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->getCurrentBeRo()->setLastActionPlayer(myUniqueID); } break; // all in @@ -3126,6 +3130,8 @@ void LocalPlayer::evaluation(int bet, int raise) { currentHand->getCurrentBeRo()->setHighestSet(highestSet); +// cout << "lAP: " << currentHand->getLastActionPlayer() << endl; + } diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index e2b11e59..5612d24d 100644 --- a/src/engine/network_engine/clienthand.cpp +++ b/src/engine/network_engine/clienthand.cpp @@ -296,6 +296,18 @@ ClientHand::getLastPlayersTurn() const return lastPlayersTurn; } +void +ClientHand::setLastActionPlayer (unsigned theValue) +{ + lastActionPlayer = theValue; +} + +unsigned +ClientHand::getLastActionPlayer() const +{ + return lastActionPlayer; +} + void ClientHand::setCardsShown(bool theValue) { diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index 376b7147..ee3b97c6 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -83,6 +83,9 @@ class ClientHand : public HandInterface void setLastPlayersTurn ( int theValue ); int getLastPlayersTurn() const; + void setLastActionPlayer ( unsigned theValue ); + unsigned getLastActionPlayer() const; + void setCardsShown ( bool theValue ); bool getCardsShown() const; @@ -110,6 +113,7 @@ class ClientHand : public HandInterface int startCash; int lastPlayersTurn; + unsigned lastActionPlayer; bool allInCondition; bool cardsShown; diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index f336c065..02a602b7 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -1760,6 +1760,9 @@ void gameTableImpl::mySet(){ //set that i was the last active player. need this for unhighlighting groupbox currentHand->setLastPlayersTurn(0); + + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(currentHand->getSeatsList()->front()->getMyUniqueID()); //Spiel läuft weiter myActionDone(); @@ -1786,6 +1789,9 @@ void gameTableImpl::myAllIn(){ currentHand->getCurrentBeRo()->setHighestSet(currentHand->getSeatsList()->front()->getMySet()); + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(currentHand->getSeatsList()->front()->getMyUniqueID()); + } currentHand->getSeatsList()->front()->setMyTurn(0);