Merge remote-tracking branch 'origin/master'

This commit is contained in:
doitux
2012-12-09 19:44:36 +01:00
+72 -51
View File
@@ -95,6 +95,8 @@ void LocalBoard::distributePot()
// temp var // temp var
int highestCardsValue; int highestCardsValue;
size_t winnerCount; size_t winnerCount;
bool finalPot;
int potCarryOver = 0;
size_t mod; size_t mod;
bool winnerHit; bool winnerHit;
@@ -111,7 +113,7 @@ void LocalBoard::distributePot()
potLevel.push_back(playerSetsSort[i]); potLevel.push_back(playerSetsSort[i]);
// level sum // level sum
potLevel.push_back((playerSetsSort.size()-i)*potLevel[0]); potLevel.push_back((playerSetsSort.size()-i)*potLevel[0] + potCarryOver);
// determine level highestCardsValue // determine level highestCardsValue
for(it_c=seatsList->begin(), j=0; it_c!=seatsList->end(); ++it_c,j++) { for(it_c=seatsList->begin(), j=0; it_c!=seatsList->end(); ++it_c,j++) {
@@ -133,71 +135,93 @@ void LocalBoard::distributePot()
throw LocalException(__FILE__, __LINE__, ERR_NO_WINNER); throw LocalException(__FILE__, __LINE__, ERR_NO_WINNER);
} }
// distribute the pot level sum to level winners // check if this is the final pot level for at least one winner
mod = (potLevel[1])%winnerCount; finalPot = false;
// pot level sum divisible by winnerCount for(j=2; j<potLevel.size(); j++) {
if(mod == 0) { // find seat with potLevel[j]-ID
for(it=seatsList->begin(), k=0; it!=seatsList->end(); ++it, k++) {
if((*it)->getMyUniqueID() == potLevel[j] && potLevel[0] == playerSets[k]) {
finalPot = true;
break;
}
}
if(finalPot) break;
}
for(j=2; j<potLevel.size(); j++) { if(finalPot) {
// find seat with potLevel[j]-ID // 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++) {
// find seat with potLevel[j]-ID
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
if((*it)->getMyUniqueID() == potLevel[j]) {
break;
}
}
if(it == seatsList->end()) {
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
}
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
// filling winners vector
winners.push_back((*it)->getMyUniqueID());
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
}
}
// pot level sum not divisible by winnerCount
// --> distribution after smallBlind
else {
// find Seat with dealerPosition
for(it=seatsList->begin(); it!=seatsList->end(); ++it) { for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
if((*it)->getMyUniqueID() == potLevel[j]) { if((*it)->getMyUniqueID() == dealerPosition) {
break; break;
} }
} }
if(it == seatsList->end()) { if(it == seatsList->end()) {
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND); throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
} }
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
// filling winners vector for(j=0; j<winnerCount; j++) {
winners.push_back((*it)->getMyUniqueID());
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
}
} winnerHit = false;
// pot level sum not divisible by winnerCount
// --> distribution after smallBlind
else {
// find Seat with dealerPosition for(k=0; k<MAX_NUMBER_OF_PLAYERS && !winnerHit; k++) {
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
if((*it)->getMyUniqueID() == dealerPosition) {
break;
}
}
if(it == seatsList->end()) {
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
}
for(j=0; j<winnerCount; j++) { ++it;
if(it == seatsList->end())
it = seatsList->begin();
winnerHit = false; for(l=2; l<potLevel.size(); l++) {
if((*it)->getMyUniqueID() == potLevel[l]) winnerHit = true;
}
for(k=0; k<MAX_NUMBER_OF_PLAYERS && !winnerHit; k++) {
++it;
if(it == seatsList->end())
it = seatsList->begin();
for(l=2; l<potLevel.size(); l++) {
if((*it)->getMyUniqueID() == potLevel[l]) winnerHit = true;
} }
} if(j<mod) {
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
if(j<mod) { // filling winners vector
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1); winners.push_back((*it)->getMyUniqueID());
// filling winners vector (*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + ((potLevel[1])/winnerCount) + 1 );
winners.push_back((*it)->getMyUniqueID()); } else {
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + ((potLevel[1])/winnerCount) + 1 ); (*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount));
} else { // filling winners vector
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount)); winners.push_back((*it)->getMyUniqueID());
// filling winners vector (*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
winners.push_back((*it)->getMyUniqueID()); }
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
} }
} }
potCarryOver = 0;
// pot refresh
pot -= potLevel[1];
} else {
potCarryOver = potLevel[1];
} }
// reevaluate the player sets // reevaluate the player sets
@@ -211,9 +235,6 @@ void LocalBoard::distributePot()
playerSetsSort = playerSets; playerSetsSort = playerSets;
sort(playerSetsSort.begin(), playerSetsSort.end()); sort(playerSetsSort.begin(), playerSetsSort.end());
// pot refresh
pot -= potLevel[1];
// clear potLevel // clear potLevel
potLevel.clear(); potLevel.clear();