bugfix: playerNeedToShowCards-List for all in situations

This commit is contained in:
floty
2010-09-04 23:30:55 +00:00
parent 0829e80d49
commit 0380ae0ced
+158 -138
View File
@@ -239,179 +239,199 @@ void LocalBoard::distributePot() {
void LocalBoard::determinePlayerNeedToShowCards() {
playerNeedToShowCards.clear();
// in All In Condition everybody have to show the cards
if(currentHand->getAllInCondition()) {
// all winners have to show their cards
// playerNeedToShowCards = winners;
PlayerListConstIterator it_c;
// std::_List_const_iterator<unsigned> it_c;
std::list<int*> level;
// 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;
// }
//
//
//
PlayerListConstIterator lastActionPlayerIt;
PlayerListConstIterator it_c;
// cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl;
// search lastActionPlayer
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); it_c++) {
if((*it_c)->getMyUniqueID() == currentHand->getLastActionPlayer() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
// cout << (*it_c)->getMyUniqueID() << endl;
break;
}
}
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;
playerNeedToShowCards.push_back((*it_c)->getMyUniqueID());
}
}
}
// the player who has done the last action has to show his cards first
playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID());
else {
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();
// level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()};
// cout << level_tmp[0] << "," << level_tmp[1] << endl;
// all winners have to show their cards
// playerNeedToShowCards = winners;
level.push_back(level_tmp);
// std::_List_const_iterator<unsigned> it_c;
std::_List_iterator<int*> level_it;
std::_List_iterator<int*> level_it_tmp;
std::_List_iterator<int*> next_level_it;
std::list<int*> level;
// PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt;
// firstAfterLastActionPlayerIt++;
// 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;
// }
//
//
//
it_c = lastActionPlayerIt;
it_c++;
for(unsigned i = 0; i < activePlayerList->size(); i++) {
PlayerListConstIterator lastActionPlayerIt;
PlayerListConstIterator it_c;
if(it_c == activePlayerList->end()) it_c = activePlayerList->begin();
// cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl;
// search lastActionPlayer
for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); it_c++) {
if((*it_c)->getMyUniqueID() == currentHand->getLastActionPlayer() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
lastActionPlayerIt = it_c;
cout << (*it_c)->getMyUniqueID() << endl;
break;
}
}
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
// for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) {
// if(it_c == lastActionPlayerIt) {
// break;
// }
// }
for(level_it = level.begin(); level_it != level.end(); level_it++) {
if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) {
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.push_back(level_tmp);
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;
}
} else {
if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
// }
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();
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
// }
level.insert(level_it,level_tmp);
// for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
// cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
// }
break;
}
}
}
}
}
// the player who has done the last action has to show his cards first
playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID());
it_c++;
cout << (*lastActionPlayerIt)->getMyUniqueID() << " - " << (*lastActionPlayerIt)->getMyName() << endl;
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();
// level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()};
cout << level_tmp[0] << "," << level_tmp[1] << endl;
level.push_back(level_tmp);
std::_List_iterator<int*> level_it;
std::_List_iterator<int*> level_it_tmp;
std::_List_iterator<int*> next_level_it;
// PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt;
// firstAfterLastActionPlayerIt++;
it_c = lastActionPlayerIt;
it_c++;
for(unsigned i = 0; i < activePlayerList->size(); i++) {
if(it_c == activePlayerList->end()) it_c = activePlayerList->begin();
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
// for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) {
// if(it_c == lastActionPlayerIt) {
// break;
// }
// }
for(level_it = level.begin(); level_it != level.end(); level_it++) {
if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) {
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.push_back(level_tmp);
break;
}
} else {
if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) {
next_level_it = level_it;
next_level_it++;
for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
}
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();
for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
}
level.insert(level_it,level_tmp);
for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) {
cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl;
}
break;
}
}
}
}
}
it_c++;
}
// bool showCards;
// 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();
//// }
// }
}
// bool showCards;
// 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();
//// }
// }
// sort and unique the list
playerNeedToShowCards.sort();
playerNeedToShowCards.unique();
std::_List_iterator<unsigned> playerNeedToShowCardsIt;
// for(playerNeedToShowCardsIt = playerNeedToShowCards.begin(); playerNeedToShowCardsIt!=playerNeedToShowCards.end(); playerNeedToShowCardsIt++) {
// cout << (*playerNeedToShowCardsIt) << '\t';
// }
// cout << endl;
for(playerNeedToShowCardsIt = playerNeedToShowCards.begin(); playerNeedToShowCardsIt!=playerNeedToShowCards.end(); playerNeedToShowCardsIt++) {
cout << (*playerNeedToShowCardsIt) << '\t';
}
cout << endl;
}