adds activePlayerList and runningPlayerList (XI) - BUGGY!!! - last sable rev866
This commit is contained in:
@@ -14,17 +14,17 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
LocalBeRo::LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS)
|
LocalBeRo::LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS)
|
||||||
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), firstRun(1), firstRound(1), firstHeadsUpRound(1), logBoardCardsDone(0)
|
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(false), minimumRaise(2*sB), firstRun(true), firstRound(true), firstHeadsUpRound(true), logBoardCardsDone(false)
|
||||||
{
|
{
|
||||||
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
||||||
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
||||||
|
|
||||||
int i;
|
// int i;
|
||||||
|
|
||||||
//SmallBlind-Position ermitteln
|
//SmallBlind-Position ermitteln
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
|
// if (myHand->getPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,11 +47,57 @@ void LocalBeRo::nextPlayer() {
|
|||||||
void LocalBeRo::run() {
|
void LocalBeRo::run() {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
PlayerListIterator it;
|
||||||
|
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
|
|
||||||
|
// determine smallBlindPosition
|
||||||
|
PlayerListIterator smallBlindPositionIt;
|
||||||
|
|
||||||
|
for(smallBlindPositionIt=myHand->getActivePlayerList()->begin(); smallBlindPositionIt!=myHand->getActivePlayerList()->end(); smallBlindPositionIt++) {
|
||||||
|
if((*smallBlindPositionIt)->getMyButton() == BUTTON_SMALL_BLIND) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine running player before smallBlind (for heads up: determine dealer/smallblind)
|
||||||
|
PlayerListIterator it_1, it_2;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
// running player before smallBlind
|
||||||
|
if(myHand->getActivePlayerList()->size() > 2) {
|
||||||
|
it_1 = smallBlindPositionIt;
|
||||||
|
for(i=0; i<myHand->getActivePlayerList()->size(); i++) {
|
||||||
|
if(it_1 == myHand->getActivePlayerList()->begin()) it_1 = myHand->getActivePlayerList()->end();
|
||||||
|
it_1--;
|
||||||
|
it_2 = find(myHand->getRunningPlayerList()->begin(), myHand->getRunningPlayerList()->end(), *it_1);
|
||||||
|
// running player found
|
||||||
|
if(it_2 != myHand->getRunningPlayerList()->end()) {
|
||||||
|
lastPlayersTurnIt = it_2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// heads up: bigBlind begins -> dealer/smallBlind is running player before bigBlind
|
||||||
|
else {
|
||||||
|
it_1 = find(myHand->getRunningPlayerList()->begin(), myHand->getRunningPlayerList()->end(), *smallBlindPositionIt);
|
||||||
|
if( it_1 == myHand->getRunningPlayerList()->end() ) {
|
||||||
|
cout << "ERROR - lastPlayersTurnIt-detection in localBeRo" << endl;
|
||||||
|
}
|
||||||
|
// smallBlind found
|
||||||
|
else {
|
||||||
|
lastPlayersTurnIt = it_1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentPlayersTurnIt = lastPlayersTurnIt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
myHand->getGuiInterface()->dealBeRoCards(myBeRoID);
|
myHand->getGuiInterface()->dealBeRoCards(myBeRoID);
|
||||||
firstRun = 0;
|
firstRun = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,30 +118,44 @@ void LocalBeRo::run() {
|
|||||||
break;
|
break;
|
||||||
default: { cout << "ERROR in localbero.cpp - wrong myBeRoID" << endl;}
|
default: { cout << "ERROR in localbero.cpp - wrong myBeRoID" << endl;}
|
||||||
}
|
}
|
||||||
logBoardCardsDone = 1;
|
logBoardCardsDone = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool allHighestSet = 1;
|
bool allHighestSet = true;
|
||||||
|
|
||||||
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
|
// prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 )
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) {
|
// if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) {
|
||||||
if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
|
// if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// test if all running players have same sets (else allHighestSet = false)
|
||||||
|
for(it=myHand->getRunningPlayerList()->begin(); it!=myHand->getRunningPlayerList()->end(); it++) {
|
||||||
|
if(highestSet != (*it)->getMySet()) {
|
||||||
|
allHighestSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prfen, ob Flop wirklich dran ist
|
|
||||||
|
// prfen, ob aktuelle bero wirklich dran ist
|
||||||
if(!firstRound && allHighestSet) {
|
if(!firstRound && allHighestSet) {
|
||||||
|
|
||||||
// Flop nicht dran, weil alle Sets gleich sind
|
// aktuelle bero nicht dran, weil alle Sets gleich sind
|
||||||
//also gehe in Turn
|
//also gehe in naechste bero
|
||||||
myHand->setActualRound(myBeRoID+1);
|
myHand->setActualRound(myBeRoID+1);
|
||||||
|
|
||||||
//Action loeschen und ActionButtons refresh
|
//Action loeschen und ActionButtons refresh
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
|
// if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Action loeschen und ActionButtons refresh
|
||||||
|
for(it=myHand->getRunningPlayerList()->begin(); it!=myHand->getRunningPlayerList()->end(); it++) {
|
||||||
|
(*it)->setMyAction(PLAYER_ACTION_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sets in den Pot verschieben und Sets = 0 und Pot-refresh
|
//Sets in den Pot verschieben und Sets = 0 und Pot-refresh
|
||||||
myHand->getBoard()->collectSets();
|
myHand->getBoard()->collectSets();
|
||||||
myHand->getBoard()->collectPot();
|
myHand->getBoard()->collectPot();
|
||||||
@@ -103,12 +163,12 @@ void LocalBeRo::run() {
|
|||||||
|
|
||||||
myHand->getGuiInterface()->refreshSet();
|
myHand->getGuiInterface()->refreshSet();
|
||||||
myHand->getGuiInterface()->refreshCash();
|
myHand->getGuiInterface()->refreshCash();
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { myHand->getGuiInterface()->refreshAction(i,0); }
|
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { myHand->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); }
|
||||||
|
|
||||||
myHand->switchRounds();
|
myHand->switchRounds();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Flop ist wirklich dran
|
// aktuelle bero ist wirklich dran
|
||||||
|
|
||||||
// Anzahl der effektiv gespielten Runden (des human player) erhöhen
|
// Anzahl der effektiv gespielten Runden (des human player) erhöhen
|
||||||
if(myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1) {
|
if(myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1) {
|
||||||
@@ -127,35 +187,67 @@ void LocalBeRo::run() {
|
|||||||
// not first round in heads up (for headsup dealer is smallblind so it is dealers turn)
|
// not first round in heads up (for headsup dealer is smallblind so it is dealers turn)
|
||||||
|
|
||||||
// naechsten Spieler ermitteln
|
// naechsten Spieler ermitteln
|
||||||
int i;
|
// int i;
|
||||||
for(i=0; (i<MAX_NUMBER_OF_PLAYERS && ((myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) == 0 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6)) || i==0; i++) {
|
// for(i=0; (i<MAX_NUMBER_OF_PLAYERS && ((myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) == 0 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6)) || i==0; i++) {
|
||||||
playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
|
// playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||||
}
|
// }
|
||||||
firstHeadsUpRound = 0;
|
// firstHeadsUpRound = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// determine next running player
|
||||||
|
currentPlayersTurnIt++;
|
||||||
|
if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
// else { firstHeadsUpRound = 0; }
|
// else { firstHeadsUpRound = 0; }
|
||||||
|
|
||||||
////// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ////////////////
|
////// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ////////////////
|
||||||
|
|
||||||
//Spieler-Position vor SmallBlind-Position ermitteln
|
//Spieler-Position vor SmallBlind-Position ermitteln
|
||||||
int activePlayerBeforeSmallBlind = smallBlindPosition;
|
// int activePlayerBeforeSmallBlind = smallBlindPosition;
|
||||||
|
|
||||||
for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6) || i==0; i++) {
|
// for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6) || i==0; i++) {
|
||||||
|
|
||||||
|
// activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
|
||||||
|
|
||||||
|
(*currentPlayersTurnIt)->setMyTurn(true);
|
||||||
|
|
||||||
activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
|
|
||||||
//highlight active players groupbox and clear action
|
//highlight active players groupbox and clear action
|
||||||
myHand->getGuiInterface()->refreshGroupbox(playersTurn,2);
|
myHand->getGuiInterface()->refreshGroupbox((*currentPlayersTurnIt)->getMyID(),2);
|
||||||
myHand->getGuiInterface()->refreshAction(playersTurn,0);
|
myHand->getGuiInterface()->refreshAction((*currentPlayersTurnIt)->getMyID(),0);
|
||||||
|
|
||||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||||
// ausnahme bei heads up !!! --> TODO
|
// ausnahme bei heads up !!! --> TODO
|
||||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind && myHand->getActivePlayerList()->size() >= 3) { firstRound = 0; }
|
// if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind && myHand->getActivePlayerList()->size() >= 3) { firstRound = 0; }
|
||||||
if(myHand->getActivePlayerList()->size() < 3 && (myHand->getPlayerArray()[playersTurn]->getMyID() == dealerPosition || myHand->getPlayerArray()[playersTurn]->getMyID() == smallBlindPosition)) { firstRound = 0; }
|
// if(myHand->getActivePlayerList()->size() < 3 && (myHand->getPlayerArray()[playersTurn]->getMyID() == dealerPosition || myHand->getPlayerArray()[playersTurn]->getMyID() == smallBlindPosition)) { firstRound = 0; }
|
||||||
|
|
||||||
if(playersTurn == 0) {
|
|
||||||
|
|
||||||
|
|
||||||
|
if( (*currentPlayersTurnIt) == (*lastPlayersTurnIt) ) {
|
||||||
|
firstRound = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if((*currentPlayersTurnIt)->getMyID() == 0) {
|
||||||
// Wir sind dran
|
// Wir sind dran
|
||||||
myHand->getGuiInterface()->meInAction();
|
myHand->getGuiInterface()->meInAction();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,16 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP)
|
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP)
|
||||||
|
|
||||||
{
|
{
|
||||||
setHighestSet(2*getSmallBlind());
|
setHighestSet(2*getSmallBlind());
|
||||||
|
|
||||||
// determine bigBlindPlayer
|
// determine bigBlindPosition
|
||||||
bigBlindPositionIt = getMyHand()->getActivePlayerList()->begin();
|
|
||||||
|
|
||||||
for(bigBlindPositionIt=getMyHand()->getActivePlayerList()->begin(); bigBlindPositionIt!=getMyHand()->getActivePlayerList()->end(); bigBlindPositionIt++) {
|
for(bigBlindPositionIt=getMyHand()->getActivePlayerList()->begin(); bigBlindPositionIt!=getMyHand()->getActivePlayerList()->end(); bigBlindPositionIt++) {
|
||||||
if((*bigBlindPositionIt)->getMyButton() == BUTTON_BIG_BLIND) break;
|
if((*bigBlindPositionIt)->getMyButton() == BUTTON_BIG_BLIND) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// search player in runningPlayerList before first action player -> run() determine next player who will do first action
|
// search player in runningPlayerList before first action player -> run() determine next player who will do first action
|
||||||
PlayerListIterator it_1, it_2;
|
PlayerListIterator it_1, it_2, it_3;
|
||||||
|
|
||||||
// search bigBlindPosition in runningPlayerList
|
// search bigBlindPosition in runningPlayerList
|
||||||
it_1 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *bigBlindPositionIt);
|
it_1 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *bigBlindPositionIt);
|
||||||
@@ -50,14 +47,21 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) :
|
|||||||
|
|
||||||
// search smallBlindPosition in runningPlayerList
|
// search smallBlindPosition in runningPlayerList
|
||||||
PlayerListIterator smallBlindPositionIt = bigBlindPositionIt;
|
PlayerListIterator smallBlindPositionIt = bigBlindPositionIt;
|
||||||
|
if(smallBlindPositionIt == getMyHand()->getActivePlayerList()->begin()) smallBlindPositionIt = getMyHand()->getActivePlayerList()->end();
|
||||||
smallBlindPositionIt--;
|
smallBlindPositionIt--;
|
||||||
it_2 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *smallBlindPositionIt);
|
it_2 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *smallBlindPositionIt);
|
||||||
|
|
||||||
// smallBlindPlayer not found in runningPlayerList (he is all in) -> next active player before smallBlindPlayer is running player before first action player
|
// smallBlindPlayer not found in runningPlayerList (he is all in) -> next active player before smallBlindPlayer is running player before first action player
|
||||||
if(it_2 == getMyHand()->getRunningPlayerList()->end()) {
|
if(it_2 == getMyHand()->getRunningPlayerList()->end()) {
|
||||||
it_2 = smallBlindPositionIt;
|
it_2 = smallBlindPositionIt;
|
||||||
|
if(it_2 == getMyHand()->getActivePlayerList()->begin()) it_2 = getMyHand()->getActivePlayerList()->end();
|
||||||
it_2--;
|
it_2--;
|
||||||
setLastPlayersTurnIt(it_2);
|
it_3 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *it_2);
|
||||||
|
if(it_3 == getMyHand()->getRunningPlayerList()->end()) {
|
||||||
|
cout << "ERROR - lastPlayersTurnIt-detection in localBeRoPreflop" << endl;
|
||||||
|
} else {
|
||||||
|
setLastPlayersTurnIt(it_3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// smallBlindPlayer found in runningPlayerList -> running player before first action player
|
// smallBlindPlayer found in runningPlayerList -> running player before first action player
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -370,12 +370,16 @@ void LocalHand::switchRounds() {
|
|||||||
// cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get
|
// cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
PlayerListIterator it;
|
PlayerListIterator it, it_1;
|
||||||
|
|
||||||
// refresh runningPlayerList
|
// refresh runningPlayerList
|
||||||
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) {
|
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) {
|
||||||
if((*it)->getMyAction() == 1 || (*it)->getMyAction() == 6) {
|
if((*it)->getMyAction() == 1 || (*it)->getMyAction() == 6) {
|
||||||
it = runningPlayerList->erase(it);
|
it = runningPlayerList->erase(it);
|
||||||
|
it_1 = it;
|
||||||
|
if(it_1 == runningPlayerList->begin()) it_1 = runningPlayerList->end();
|
||||||
|
it_1--;
|
||||||
|
getCurrentBeRo()->setCurrentPlayersTurnIt(it_1);
|
||||||
} else {
|
} else {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user