adds activePlayerList and runningPlayerList (XVII) - !!! network-BROKEN !!!

This commit is contained in:
doitux
2007-09-27 00:37:01 +00:00
parent 3c7aa802db
commit aab3ac6b2c
17 changed files with 272 additions and 78 deletions
+83 -21
View File
@@ -33,8 +33,9 @@ LocalBoard::~LocalBoard()
{
}
void LocalBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl) {
playerArray = sl;
void LocalBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl) {
playerArray = sl_old; // delete
seatsList = sl;
activePlayerList = apl;
runningPlayerList = rpl;
}
@@ -44,32 +45,57 @@ void LocalBoard::setHand(HandInterface* br) { currentHand = br; }
void LocalBoard::collectSets() {
sets = 0;
int i;
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) sets += playerArray[i]->getMySet();
// int i;
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) sets += playerArray[i]->getMySet(); //delete
PlayerListConstIterator it_c;
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
sets += (*it_c)->getMySet();
}
}
void LocalBoard::collectPot() {
int i;
// int i;
pot += sets;
sets = 0;
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++){ playerArray[i]->setMySetNull(); }
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++){ playerArray[i]->setMySetNull(); }
PlayerListIterator it;
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
(*it)->setMySetNull();
}
}
void LocalBoard::distributePot() {
size_t i,j,k,l;
PlayerListIterator it;
PlayerListConstIterator it_c;
// filling player sets vector
// vector<int> playerSets;
// for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
// if(playerArray[i]->getMyActiveStatus()) {
// playerSets.push_back(((playerArray[i]->getMyRoundStartCash())-(playerArray[i]->getMyCash())));
// } else {
// playerSets.push_back(0);
// }
// }
// filling player sets vector
vector<int> playerSets;
for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
if(playerArray[i]->getMyActiveStatus()) {
playerSets.push_back(((playerArray[i]->getMyRoundStartCash())-(playerArray[i]->getMyCash())));
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
playerSets.push_back( ( ((*it_c)->getMyRoundStartCash()) - ((*it_c)->getMyCash()) ) );
} else {
playerSets.push_back(0);
}
}
// sort player sets asc
vector<int> playerSetsSort = playerSets;
sort(playerSetsSort.begin(), playerSetsSort.end());
@@ -100,29 +126,51 @@ void LocalBoard::distributePot() {
potLevel.push_back((playerSetsSort.size()-i)*potLevel[0]);
// determine level highestCardsValue
for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
// for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
// if(playerArray[j]->getMyCardsValueInt() > highestCardsValue && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
// highestCardsValue = playerArray[j]->getMyCardsValueInt();
// }
// }
if(playerArray[j]->getMyCardsValueInt() > highestCardsValue && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
highestCardsValue = playerArray[j]->getMyCardsValueInt();
// determine level highestCardsValue
j=0;
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++,j++) {
if((*it_c)->getMyActiveStatus() && (*it_c)->getMyCardsValueInt() > highestCardsValue && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
highestCardsValue = (*it_c)->getMyCardsValueInt();
}
}
// level winners
for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
if(highestCardsValue == playerArray[j]->getMyCardsValueInt() && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
potLevel.push_back(playerArray[j]->getMyID());
// for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
// if(highestCardsValue == playerArray[j]->getMyCardsValueInt() && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
// potLevel.push_back(playerArray[j]->getMyID());
// }
// }
// level winners
j=0;
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++,j++) {
if((*it_c)->getMyActiveStatus() && highestCardsValue == (*it_c)->getMyCardsValueInt() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
potLevel.push_back((*it_c)->getMyUniqueID());
}
}
// determine the number of level winners
winnerCount = potLevel.size()-2;
assert(winnerCount);
// distribute the pot level sum to level winners
mod = (potLevel[1])%winnerCount;
// pot level sum divisible by winnerCount
if(mod == 0) {
// for(j=2; j<potLevel.size(); j++) {
// playerArray[potLevel[j]]->setMyCash(playerArray[potLevel[j]]->getMyCash() + ((potLevel[1])/winnerCount));
// }
for(j=2; j<potLevel.size(); j++) {
playerArray[potLevel[j]]->setMyCash(playerArray[potLevel[j]]->getMyCash() + ((potLevel[1])/winnerCount));
it = currentHand->getSeatIt(potLevel[j]);
assert(it != seatsList->end());
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
}
}
@@ -148,10 +196,19 @@ void LocalBoard::distributePot() {
}
// if(j<mod) {
// playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
// } else {
// playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount));
// }
it = currentHand->getSeatIt(winnerPointer);
assert(it != seatsList->end());
if(j<mod) {
playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
} else {
playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount));
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount));
}
}
}
@@ -181,11 +238,16 @@ void LocalBoard::distributePot() {
if(pot!=0) cout << "distributePot-ERROR: Pot = " << pot << endl;
int sum = 0;
for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
if(playerArray[i]->getMyActiveStatus())
sum += playerArray[i]->getMyCash();
// for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
// if(playerArray[i]->getMyActiveStatus())
// sum += playerArray[i]->getMyCash();
// }
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
sum += (*it_c)->getMyCash();
}
if(sum != (currentHand->getStartQuantityPlayers() * currentHand->getStartCash()))
cout << "distributePot-ERROR: PlayersSumCash = " << sum << endl;