2007-01-13 02:40:33 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2006 by FThauer FHammer *
|
|
|
|
|
* f.thauer@web.de *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
#include "localboard.h"
|
|
|
|
|
|
2007-05-18 17:13:27 +00:00
|
|
|
#include "handinterface.h"
|
2007-04-17 07:28:32 +00:00
|
|
|
#include <game_defs.h>
|
2007-10-23 21:26:07 +00:00
|
|
|
#include <core/loghelper.h>
|
2007-09-29 00:08:19 +00:00
|
|
|
#include "localexception.h"
|
2007-10-14 11:01:44 +00:00
|
|
|
#include "engine_msg.h"
|
2007-01-13 02:40:33 +00:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
2011-02-08 12:10:39 +00:00
|
|
|
LocalBoard::LocalBoard(unsigned dp) : BoardInterface(), pot(0), sets(0), dealerPosition(dp), allInCondition(false), lastActionPlayer(0)
|
2007-01-13 02:40:33 +00:00
|
|
|
{
|
2010-10-28 08:04:36 +00:00
|
|
|
myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalBoard::~LocalBoard()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl)
|
|
|
|
|
{
|
2007-09-27 00:37:01 +00:00
|
|
|
seatsList = sl;
|
2007-09-23 21:30:51 +00:00
|
|
|
activePlayerList = apl;
|
|
|
|
|
runningPlayerList = rpl;
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void LocalBoard::collectSets()
|
|
|
|
|
{
|
2007-01-13 02:40:33 +00:00
|
|
|
|
|
|
|
|
sets = 0;
|
2007-09-27 00:37:01 +00:00
|
|
|
|
|
|
|
|
PlayerListConstIterator it_c;
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) {
|
2007-09-27 00:37:01 +00:00
|
|
|
sets += (*it_c)->getMySet();
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void LocalBoard::collectPot()
|
|
|
|
|
{
|
2007-10-19 14:03:12 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
pot += sets;
|
2007-01-13 02:40:33 +00:00
|
|
|
sets = 0;
|
2007-09-27 00:37:01 +00:00
|
|
|
|
|
|
|
|
PlayerListIterator it;
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
|
2007-09-27 00:37:01 +00:00
|
|
|
(*it)->setMySetNull();
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void LocalBoard::distributePot()
|
|
|
|
|
{
|
2007-08-09 18:02:58 +00:00
|
|
|
|
2007-10-17 14:46:20 +00:00
|
|
|
winners.clear();
|
|
|
|
|
|
2007-08-10 18:44:41 +00:00
|
|
|
size_t i,j,k,l;
|
2007-09-27 00:37:01 +00:00
|
|
|
PlayerListIterator it;
|
|
|
|
|
PlayerListConstIterator it_c;
|
|
|
|
|
|
2007-08-10 00:17:46 +00:00
|
|
|
// filling player sets vector
|
2007-10-29 13:44:58 +00:00
|
|
|
vector<unsigned> playerSets;
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
|
2007-10-29 22:26:50 +00:00
|
|
|
if((*it)->getMyActiveStatus()) {
|
|
|
|
|
playerSets.push_back( ( ((*it)->getMyRoundStartCash()) - ((*it)->getMyCash()) ) );
|
2007-08-10 00:15:51 +00:00
|
|
|
} else {
|
|
|
|
|
playerSets.push_back(0);
|
|
|
|
|
}
|
2007-10-29 22:26:50 +00:00
|
|
|
(*it)->setLastMoneyWon(0);
|
2007-08-10 00:15:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// sort player sets asc
|
2007-10-29 13:44:58 +00:00
|
|
|
vector<unsigned> playerSetsSort = playerSets;
|
2007-08-10 00:15:51 +00:00
|
|
|
sort(playerSetsSort.begin(), playerSetsSort.end());
|
|
|
|
|
|
|
|
|
|
// potLevel[0] = amount, potLevel[1] = sum, potLevel[2..n] = winner
|
2007-10-29 13:44:58 +00:00
|
|
|
vector<unsigned> potLevel;
|
2007-08-10 00:15:51 +00:00
|
|
|
|
|
|
|
|
// temp var
|
|
|
|
|
int highestCardsValue;
|
|
|
|
|
size_t winnerCount;
|
|
|
|
|
size_t mod;
|
2007-10-29 19:57:46 +00:00
|
|
|
// int winnerPointer;
|
2007-08-10 00:15:51 +00:00
|
|
|
bool winnerHit;
|
|
|
|
|
|
|
|
|
|
// level loop
|
|
|
|
|
for(i=0; i<playerSetsSort.size(); i++) {
|
|
|
|
|
|
|
|
|
|
// restart levelHighestCardsValue
|
|
|
|
|
highestCardsValue = 0;
|
|
|
|
|
|
|
|
|
|
// level detection
|
|
|
|
|
if(playerSetsSort[i] > 0) {
|
|
|
|
|
|
|
|
|
|
// level amount
|
|
|
|
|
potLevel.push_back(playerSetsSort[i]);
|
|
|
|
|
|
|
|
|
|
// level sum
|
|
|
|
|
potLevel.push_back((playerSetsSort.size()-i)*potLevel[0]);
|
|
|
|
|
|
|
|
|
|
// determine level highestCardsValue
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it_c=seatsList->begin(), j=0; it_c!=seatsList->end(); ++it_c,j++) {
|
2011-02-11 20:02:08 +00:00
|
|
|
if((*it_c)->getMyActiveStatus() && (*it_c)->getMyCardsValueInt() > highestCardsValue && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
|
|
|
|
highestCardsValue = (*it_c)->getMyCardsValueInt();
|
2007-08-10 00:15:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// level winners
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it_c=seatsList->begin(), j=0; it_c!=seatsList->end(); ++it_c,j++) {
|
2007-09-27 00:37:01 +00:00
|
|
|
if((*it_c)->getMyActiveStatus() && highestCardsValue == (*it_c)->getMyCardsValueInt() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
|
|
|
|
potLevel.push_back((*it_c)->getMyUniqueID());
|
2007-08-10 00:15:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// determine the number of level winners
|
|
|
|
|
winnerCount = potLevel.size()-2;
|
2007-10-14 11:01:44 +00:00
|
|
|
if (!winnerCount) {
|
2007-10-18 20:36:49 +00:00
|
|
|
throw LocalException(__FILE__, __LINE__, ERR_NO_WINNER);
|
2007-10-14 11:01:44 +00:00
|
|
|
}
|
2007-08-10 00:15:51 +00:00
|
|
|
|
|
|
|
|
// distribute the pot level sum to level winners
|
|
|
|
|
mod = (potLevel[1])%winnerCount;
|
|
|
|
|
// pot level sum divisible by winnerCount
|
|
|
|
|
if(mod == 0) {
|
2007-09-27 00:37:01 +00:00
|
|
|
|
2007-08-10 00:15:51 +00:00
|
|
|
for(j=2; j<potLevel.size(); j++) {
|
2011-02-11 20:02:08 +00:00
|
|
|
// find seat with potLevel[j]-ID
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
|
2011-02-11 20:02:08 +00:00
|
|
|
if((*it)->getMyUniqueID() == potLevel[j]) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-10-14 11:01:44 +00:00
|
|
|
if(it == seatsList->end()) {
|
2007-10-18 20:36:49 +00:00
|
|
|
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
2007-10-14 11:01:44 +00:00
|
|
|
}
|
2007-09-27 00:37:01 +00:00
|
|
|
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
|
2007-10-17 14:46:20 +00:00
|
|
|
|
|
|
|
|
// filling winners vector
|
2007-10-29 19:23:52 +00:00
|
|
|
winners.push_back((*it)->getMyUniqueID());
|
2007-10-29 22:26:50 +00:00
|
|
|
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
|
2007-08-10 00:15:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// pot level sum not divisible by winnerCount
|
2007-10-17 14:46:20 +00:00
|
|
|
// --> distribution after smallBlind
|
2007-08-10 00:15:51 +00:00
|
|
|
else {
|
|
|
|
|
|
2007-10-29 13:44:58 +00:00
|
|
|
// winnerPointer = currentHand->getDealerPosition();
|
2011-01-06 22:00:52 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// find Seat with dealerPosition
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
|
2011-02-11 20:02:08 +00:00
|
|
|
if((*it)->getMyUniqueID() == dealerPosition) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(it == seatsList->end()) {
|
2007-10-29 13:44:58 +00:00
|
|
|
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
|
|
|
|
}
|
2007-08-10 00:15:51 +00:00
|
|
|
|
|
|
|
|
for(j=0; j<winnerCount; j++) {
|
|
|
|
|
|
2007-08-10 18:44:41 +00:00
|
|
|
winnerHit = false;
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
for(k=0; k<MAX_NUMBER_OF_PLAYERS && !winnerHit; k++) {
|
2007-08-10 00:15:51 +00:00
|
|
|
|
2007-10-29 13:44:58 +00:00
|
|
|
// winnerPointer = (winnerPointer+1)%(MAX_NUMBER_OF_PLAYERS);
|
2007-08-10 00:15:51 +00:00
|
|
|
|
2007-10-29 13:44:58 +00:00
|
|
|
// winnerHit = false;
|
|
|
|
|
|
2011-02-09 14:33:39 +00:00
|
|
|
++it;
|
2007-10-29 13:44:58 +00:00
|
|
|
if(it == seatsList->end())
|
|
|
|
|
it = seatsList->begin();
|
2007-08-10 00:15:51 +00:00
|
|
|
|
2007-08-10 18:44:41 +00:00
|
|
|
for(l=2; l<potLevel.size(); l++) {
|
2007-10-29 13:44:58 +00:00
|
|
|
// if(winnerPointer == potLevel[l]) winnerHit = true;
|
|
|
|
|
if((*it)->getMyUniqueID() == potLevel[l]) winnerHit = true;
|
2007-08-10 00:15:51 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-10 18:44:41 +00:00
|
|
|
}
|
2007-08-10 00:15:51 +00:00
|
|
|
|
2007-10-29 13:44:58 +00:00
|
|
|
// it = currentHand->getSeatIt(winnerPointer);
|
|
|
|
|
// if(it == seatsList->end()) {
|
|
|
|
|
// throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
|
|
|
|
// }
|
2007-08-10 00:15:51 +00:00
|
|
|
if(j<mod) {
|
2007-09-27 00:37:01 +00:00
|
|
|
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
2007-10-17 14:46:20 +00:00
|
|
|
// filling winners vector
|
2007-10-29 19:23:52 +00:00
|
|
|
winners.push_back((*it)->getMyUniqueID());
|
2007-10-29 22:26:50 +00:00
|
|
|
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + ((potLevel[1])/winnerCount) + 1 );
|
2007-08-10 00:15:51 +00:00
|
|
|
} else {
|
2007-09-27 00:37:01 +00:00
|
|
|
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount));
|
2007-10-17 14:46:20 +00:00
|
|
|
// filling winners vector
|
2007-10-29 19:23:52 +00:00
|
|
|
winners.push_back((*it)->getMyUniqueID());
|
2007-10-29 22:26:50 +00:00
|
|
|
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
|
2007-08-10 00:15:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// reevaluate the player sets
|
|
|
|
|
for(j=0; j<playerSets.size(); j++) {
|
|
|
|
|
if(playerSets[j]>0) {
|
|
|
|
|
playerSets[j] -= potLevel[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// sort player sets asc
|
|
|
|
|
playerSetsSort = playerSets;
|
|
|
|
|
sort(playerSetsSort.begin(), playerSetsSort.end());
|
|
|
|
|
|
|
|
|
|
// pot refresh
|
|
|
|
|
pot -= potLevel[1];
|
|
|
|
|
|
|
|
|
|
// clear potLevel
|
|
|
|
|
potLevel.clear();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// winners sort and unique
|
2007-10-17 14:46:20 +00:00
|
|
|
winners.sort();
|
|
|
|
|
winners.unique();
|
|
|
|
|
|
|
|
|
|
|
2007-08-10 00:15:51 +00:00
|
|
|
// ERROR-Outputs
|
|
|
|
|
|
2007-10-23 21:26:07 +00:00
|
|
|
if(pot!=0) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): distributePot-ERROR: Pot = " << pot);
|
2007-08-10 00:15:51 +00:00
|
|
|
|
2010-10-28 08:04:36 +00:00
|
|
|
/*int sum = 0;
|
2007-09-27 00:37:01 +00:00
|
|
|
|
|
|
|
|
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
|
|
|
|
|
sum += (*it_c)->getMyCash();
|
2010-10-28 08:04:36 +00:00
|
|
|
}*/
|
2007-08-09 18:02:58 +00:00
|
|
|
}
|
2010-07-15 22:37:46 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void LocalBoard::determinePlayerNeedToShowCards()
|
|
|
|
|
{
|
2010-07-15 22:37:46 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
playerNeedToShowCards.clear();
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// in All In Condition everybody have to show the cards
|
|
|
|
|
if(allInCondition) {
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
PlayerListConstIterator it_c;
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-09 14:33:39 +00:00
|
|
|
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
|
2011-02-11 20:02:08 +00:00
|
|
|
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
|
|
|
|
|
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
else {
|
2010-07-22 06:03:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// all winners have to show their cards
|
|
|
|
|
// playerNeedToShowCards = winners;
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// std::_List_const_iterator<unsigned> it_c;
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
std::list<int*> level;
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// for(it_c=winners.begin(); it_c != winners.end(); it_c++) {
|
|
|
|
|
// cout << (*it_c) << endl;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// cout << "lastActionPlayer" << currentHand->getCurrentBeRo()->getLastActionPlayer() << endl;
|
|
|
|
|
//
|
|
|
|
|
// int lastActionPlayer = ;
|
|
|
|
|
//
|
|
|
|
|
// if(lastActionPlayer == -1) {
|
|
|
|
|
// lastActionPlayer = 0;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
2010-07-22 06:03:11 +00:00
|
|
|
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
PlayerListConstIterator lastActionPlayerIt;
|
|
|
|
|
PlayerListConstIterator it_c;
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl;
|
|
|
|
|
// search lastActionPlayer
|
|
|
|
|
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
|
|
|
|
|
if((*it_c)->getMyUniqueID() == lastActionPlayer && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
|
|
|
|
|
lastActionPlayerIt = it_c;
|
2010-09-04 23:41:13 +00:00
|
|
|
// cout << (*it_c)->getMyUniqueID() << endl;
|
2011-02-11 20:02:08 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(it_c == activePlayerList->end()) {
|
|
|
|
|
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) {
|
|
|
|
|
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
|
|
|
|
|
lastActionPlayerIt = it_c;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// the player who has done the last action has to show his cards first
|
|
|
|
|
playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID());
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2010-09-04 23:41:13 +00:00
|
|
|
// cout << (*lastActionPlayerIt)->getMyUniqueID() << " - " << (*lastActionPlayerIt)->getMyName() << endl;
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
int *level_tmp = new int[2];
|
|
|
|
|
// get position und cardsValue of the player who show his cards first
|
|
|
|
|
level_tmp[0] = (*lastActionPlayerIt)->getMyCardsValueInt();
|
|
|
|
|
level_tmp[1] = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash();
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()};
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2010-09-04 23:41:13 +00:00
|
|
|
// cout << level_tmp[0] << "," << level_tmp[1] << endl;
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
level.push_back(level_tmp);
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-28 17:12:55 +00:00
|
|
|
std::list<int*>::iterator level_it;
|
|
|
|
|
std::list<int*>::iterator level_it_tmp;
|
|
|
|
|
std::list<int*>::iterator next_level_it;
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt;
|
|
|
|
|
// firstAfterLastActionPlayerIt++;
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
it_c = lastActionPlayerIt;
|
|
|
|
|
++it_c;
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
for(unsigned i = 0; i < activePlayerList->size(); i++) {
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(it_c == activePlayerList->end()) it_c = activePlayerList->begin();
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
|
|
|
|
|
// for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) {
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// if(it_c == lastActionPlayerIt) {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2011-02-28 18:29:57 +00:00
|
|
|
for(level_it = level.begin(); level_it != level.end(); ++level_it) {
|
2011-02-11 20:02:08 +00:00
|
|
|
if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) {
|
|
|
|
|
next_level_it = level_it;
|
2011-02-28 18:29:57 +00:00
|
|
|
++next_level_it;
|
2011-02-11 20:02:08 +00:00
|
|
|
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.push_back(level_tmp);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) {
|
|
|
|
|
next_level_it = level_it;
|
2011-02-28 18:29:57 +00:00
|
|
|
++next_level_it;
|
2010-09-04 23:41:13 +00:00
|
|
|
//
|
|
|
|
|
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
|
|
|
|
|
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
|
|
|
|
|
// }
|
2010-09-04 23:30:55 +00:00
|
|
|
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) {
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) {
|
|
|
|
|
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();
|
2010-09-04 23:41:13 +00:00
|
|
|
//
|
|
|
|
|
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
|
|
|
|
|
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
|
|
|
|
|
// }
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
level.insert(level_it,level_tmp);
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2010-09-04 23:41:13 +00:00
|
|
|
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
|
|
|
|
|
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
|
|
|
|
|
// }
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
++it_c;
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-03-01 09:07:39 +00:00
|
|
|
for(level_it = level.begin(); level_it != level.end(); ++level_it) {
|
|
|
|
|
delete[] *level_it;
|
|
|
|
|
}
|
|
|
|
|
level.clear();
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// bool showCards;
|
2010-09-04 23:30:55 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// search for more player who have to show their cards (perhaps not all situation are considered yet)
|
|
|
|
|
// for(it_c = ++lastActionPlayerIt; it_c!=activePlayerList->end(); it_c++) {
|
|
|
|
|
//
|
|
|
|
|
// showCards = false;
|
|
|
|
|
//
|
|
|
|
|
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
|
|
|
|
|
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
|
|
|
|
|
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
|
|
|
|
|
//// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// for(it_c = activePlayerList->begin(); it_c!=lastActionPlayerIt; it_c++) {
|
|
|
|
|
//// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) {
|
|
|
|
|
//// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
|
|
|
|
|
//// highestCardsValueInt = (*it_c)->getMyCardsValueInt();
|
|
|
|
|
//// }
|
|
|
|
|
// }
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
2010-07-22 06:03:11 +00:00
|
|
|
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
// sort and unique the list
|
|
|
|
|
playerNeedToShowCards.sort();
|
|
|
|
|
playerNeedToShowCards.unique();
|
2010-07-22 06:03:11 +00:00
|
|
|
|
2010-09-04 23:41:13 +00:00
|
|
|
// std::_List_iterator<unsigned> playerNeedToShowCardsIt;
|
|
|
|
|
//
|
|
|
|
|
// for(playerNeedToShowCardsIt = playerNeedToShowCards.begin(); playerNeedToShowCardsIt!=playerNeedToShowCards.end(); playerNeedToShowCardsIt++) {
|
|
|
|
|
// cout << (*playerNeedToShowCardsIt) << '\t';
|
|
|
|
|
// }
|
|
|
|
|
// cout << endl;
|
2010-07-15 22:37:46 +00:00
|
|
|
|
|
|
|
|
}
|