From e74d0fbf478e9ad509cc737180d6bec54e40afad Mon Sep 17 00:00:00 2001 From: floty Date: Sun, 6 Mar 2011 15:22:13 +0000 Subject: [PATCH] implementing pair for level-list --- src/engine/local_engine/localboard.cpp | 45 +++++++++++++------------ src/engine/local_engine/localhand.cpp | 36 ++++++++++---------- src/engine/local_engine/localplayer.cpp | 7 ++-- 3 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/engine/local_engine/localboard.cpp b/src/engine/local_engine/localboard.cpp index 5845fdb8..0ecca930 100755 --- a/src/engine/local_engine/localboard.cpp +++ b/src/engine/local_engine/localboard.cpp @@ -278,7 +278,7 @@ void LocalBoard::determinePlayerNeedToShowCards() // std::_List_const_iterator it_c; - std::list level; + std::list > level; // for(it_c=winners.begin(); it_c != winners.end(); it_c++) { // cout << (*it_c) << endl; @@ -323,10 +323,11 @@ void LocalBoard::determinePlayerNeedToShowCards() // cout << (*lastActionPlayerIt)->getMyUniqueID() << " - " << (*lastActionPlayerIt)->getMyName() << endl; - int *level_tmp = new int[2]; +// int *level_tmp = new int[2]; + std::pair level_tmp; // get position und cardsValue of the player who show his cards first - level_tmp[0] = (*lastActionPlayerIt)->getMyCardsValueInt(); - level_tmp[1] = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash(); + level_tmp.first = (*lastActionPlayerIt)->getMyCardsValueInt(); + level_tmp.second = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash(); // level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()}; @@ -334,9 +335,9 @@ void LocalBoard::determinePlayerNeedToShowCards() level.push_back(level_tmp); - std::list::iterator level_it; - std::list::iterator level_it_tmp; - std::list::iterator next_level_it; + std::list >::iterator level_it; +// std::list >::iterator level_it_tmp; + std::list >::iterator next_level_it; // PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt; // firstAfterLastActionPlayerIt++; @@ -356,19 +357,19 @@ void LocalBoard::determinePlayerNeedToShowCards() // } // } for(level_it = level.begin(); level_it != level.end(); ++level_it) { - if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) { + if((*it_c)->getMyCardsValueInt() > (*level_it).first) { next_level_it = level_it; ++next_level_it; if(next_level_it == level.end()) { playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - level_tmp = new int[2]; - level_tmp[0] = (*it_c)->getMyCardsValueInt(); - level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); +// level_tmp = new int[2]; + level_tmp.first = (*it_c)->getMyCardsValueInt(); + level_tmp.second = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); level.push_back(level_tmp); break; } } else { - if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) { + if((*it_c)->getMyCardsValueInt() == (*level_it).first) { next_level_it = level_it; ++next_level_it; // @@ -377,19 +378,19 @@ void LocalBoard::determinePlayerNeedToShowCards() // } - if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) { + if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it).second) { playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) { - (*level_it)[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); + if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it).second) { + (*level_it).second = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); } } break; } else { - if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) { + if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it).second) { playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - level_tmp = new int(2); - level_tmp[0] = (*it_c)->getMyCardsValueInt(); - level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); +// level_tmp = new int(2); + level_tmp.first = (*it_c)->getMyCardsValueInt(); + level_tmp.second = (*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; @@ -413,9 +414,9 @@ void LocalBoard::determinePlayerNeedToShowCards() } - for(level_it = level.begin(); level_it != level.end(); ++level_it) { - delete[] *level_it; - } +// for(level_it = level.begin(); level_it != level.end(); ++level_it) { +// delete[] *level_it; +// } level.clear(); // bool showCards; diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 92b01cd7..58a94cec 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -38,8 +38,6 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: int i, j, k; PlayerListIterator it; - CardsValue myCardsValue; - for(it=seatsList->begin(); it!=seatsList->end(); ++it) { (*it)->setHand(this); // set myFlipCards 0 @@ -71,7 +69,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: } (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray, bestHandPos)); (*it)->setMyBestHandPosition(bestHandPos); (*it)->setMyRoundStartCash((*it)->getMyCash()); @@ -139,7 +137,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -152,7 +150,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -165,7 +163,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -178,7 +176,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -191,7 +189,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -204,7 +202,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -217,7 +215,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -230,7 +228,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -243,7 +241,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: tempPlayerAndBoardArray[1] = tempPlayerArray[1]; (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); (*it)->setMyBestHandPosition(temp5Array); @@ -275,7 +273,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; // // (*it)->setMyCards(tempPlayerArray); -// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); // // (*it)->setMyBestHandPosition(temp5Array); @@ -288,7 +286,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; // // (*it)->setMyCards(tempPlayerArray); -// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); // // (*it)->setMyBestHandPosition(temp5Array); @@ -301,7 +299,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; // // (*it)->setMyCards(tempPlayerArray); -// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); // // (*it)->setMyBestHandPosition(temp5Array); @@ -314,7 +312,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; // // (*it)->setMyCards(tempPlayerArray); -// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); // // (*it)->setMyBestHandPosition(temp5Array); @@ -327,7 +325,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; // // (*it)->setMyCards(tempPlayerArray); -// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); // // (*it)->setMyBestHandPosition(temp5Array); @@ -340,7 +338,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; // // (*it)->setMyCards(tempPlayerArray); -// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array)); // // (*it)->setMyBestHandPosition(temp5Array); @@ -360,7 +358,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: assignButtons(); - myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList); + myLog->logNewHandMsg(myID, dealerPosition+1, smallBlind, smallBlindPosition+1, 2*smallBlind, bigBlindPosition+1, seatsList); setBlinds(); diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index c99eb9cc..07a10ee0 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -3210,10 +3210,7 @@ void LocalPlayer::evaluation(int bet, int raise) { - int highestSet = 0; - - highestSet = currentHand->getCurrentBeRo()->getHighestSet(); - + int highestSet = currentHand->getCurrentBeRo()->getHighestSet(); // cout << "myAction(evaluation): " << myAction << endl; switch(myAction) { @@ -3254,8 +3251,8 @@ void LocalPlayer::evaluation(int bet, int raise) case 4: { // all in if(bet >= myCash) { - // -> full bet rule if(myCash < 2*currentHand->getSmallBlind()) { + // -> full bet rule currentHand->getCurrentBeRo()->setFullBetRule(true); } currentHand->getCurrentBeRo()->setMinimumRaise(myCash);