From 4efd19c7582c9b4bb6c1ed82193036cfed96f80e Mon Sep 17 00:00:00 2001 From: doitux Date: Tue, 25 Sep 2007 12:43:58 +0000 Subject: [PATCH] adds activePlayerList and runningPlayerList (VIII) - BUGGY!!! - last sable rev856 --- src/engine/local_engine/localberopreflop.cpp | 16 ++++--- src/engine/local_engine/localberopreflop.h | 2 +- src/engine/local_engine/localhand.cpp | 50 ++++++++++++-------- src/game.cpp | 11 ++--- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/engine/local_engine/localberopreflop.cpp b/src/engine/local_engine/localberopreflop.cpp index f4c69372..07206c9a 100644 --- a/src/engine/local_engine/localberopreflop.cpp +++ b/src/engine/local_engine/localberopreflop.cpp @@ -32,16 +32,17 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : // // BigBlind ermitteln PlayerListIterator it; - bigBlindPosition = getMyHand()->getActivePlayerList()->begin(); + bigBlindPositionIt = getMyHand()->getActivePlayerList()->begin(); - for(it=getMyHand()->getActivePlayerList()->begin(); it!=getMyHand()->getActivePlayerList()->end(); it++) { - if((*it)->getMyButton() == BUTTON_BIG_BLIND) { - bigBlindPosition = it; - } + for(bigBlindPositionIt=getMyHand()->getActivePlayerList()->begin(); bigBlindPositionIt!=getMyHand()->getActivePlayerList()->end(); bigBlindPositionIt++) { + cout << "playerID: " << (*bigBlindPositionIt)->getMyID() << " Button: " << (*bigBlindPositionIt)->getMyButton() << endl; + if((*bigBlindPositionIt)->getMyButton() == BUTTON_BIG_BLIND) break; } + if(bigBlindPositionIt == getMyHand()->getActivePlayerList()->end()) cout << "!!!" << endl; + // // erste Spielernummer fr preflopRun() setzen - setPlayersTurn((*bigBlindPosition)->getMyID()); + setPlayersTurn((*bigBlindPositionIt)->getMyID()); } @@ -72,7 +73,8 @@ void LocalBeRoPreflop::run() { setPlayersTurn((getPlayersTurn()+1)%(MAX_NUMBER_OF_PLAYERS)); // falls BigBlind, dann PreflopFirstRound zuende - if(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyButton() == BUTTON_BIG_BLIND && (*bigBlindPosition)->getMySet() < 2*getSmallBlind()) setFirstRound(0); + if(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyButton() == BUTTON_BIG_BLIND && (*bigBlindPositionIt)->getMySet() < 2*getSmallBlind()) setFirstRound(0); + // if next player is small blind and only all-in-big-blind with <= 2*smallblind is nonfold too } diff --git a/src/engine/local_engine/localberopreflop.h b/src/engine/local_engine/localberopreflop.h index 122c19d6..2fbaa8aa 100644 --- a/src/engine/local_engine/localberopreflop.h +++ b/src/engine/local_engine/localberopreflop.h @@ -34,7 +34,7 @@ public: void run(); private: - PlayerListIterator bigBlindPosition; + PlayerListIterator bigBlindPositionIt; }; #endif diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 00b866a1..4360cce7 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -316,8 +316,8 @@ void LocalHand::assignButtons() { } } - //do sets - for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { + //do sets --> TODO switch? + for (it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) { //small blind if((*it)->getMyButton() == 2) { @@ -332,23 +332,33 @@ void LocalHand::assignButtons() { it = runningPlayerList->erase(it); } - else { (*it)->setMySet(smallBlind); } - } - - //big blind - if((*it)->getMyButton() == 3) { - - // all in ? - if((*it)->getMyCash() <= 2*smallBlind) { - - (*it)->setMySet((*it)->getMyCash()); - // 1 to do not log this - (*it)->setMyAction(6,1); - // delete this player from runningPlayerList - it = runningPlayerList->erase(it); - + else { + (*it)->setMySet(smallBlind); + it++; } - else { (*it)->setMySet(2*smallBlind); } + } else { + + //big blind + if((*it)->getMyButton() == 3) { + + // all in ? + if((*it)->getMyCash() <= 2*smallBlind) { + + (*it)->setMySet((*it)->getMyCash()); + // 1 to do not log this + (*it)->setMyAction(6,1); + // delete this player from runningPlayerList + it = runningPlayerList->erase(it); + + } + else { + (*it)->setMySet(2*smallBlind); + it++; + } + } else { + it++; + } + } } @@ -361,9 +371,11 @@ void LocalHand::switchRounds() { PlayerListIterator it; // refresh runningPlayerList - for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); it++) { + for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) { if((*it)->getMyAction() == 1 || (*it)->getMyAction() == 6) { it = runningPlayerList->erase(it); + } else { + it++; } } diff --git a/src/game.cpp b/src/game.cpp index 2fb95ad7..ca2e8c76 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -150,20 +150,17 @@ void Game::initHand() // Spieler mit leerem Cash auf inactive setzen PlayerListIterator it; -// cout << "id: " << actualHandID << endl; - - for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { - -// cout << "player" << (*it)->getMyID() << ": " << (*it)->getMyCash() << endl; + for(it=activePlayerList->begin(); it!=activePlayerList->end(); ) { if((*it)->getMyCash() == 0) { +// cout << "playerID: " << (*it)->getMyID() << endl; (*it)->setMyActiveStatus(0); it = activePlayerList->erase(it); + } else { + it++; } } -// cout << activePlayerList->size() << endl; - //Spieler Action auf 0 setzen for(i=0; isetMyAction(0);