adds activePlayerList and runningPlayerList (XIV) - !!! BROKEN !!! - last sable rev866

This commit is contained in:
doitux
2007-09-26 19:45:58 +00:00
parent 7bbf76fe5d
commit 1f21fe815e
23 changed files with 252 additions and 79 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ public:
virtual HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0; virtual HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
virtual BoardInterface* createBoard() =0; virtual BoardInterface* createBoard() =0;
virtual boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0; virtual boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0;
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int dP, int sB) =0; virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, unsigned dP, int sB) =0;
}; };
#endif #endif
+3
View File
@@ -40,6 +40,9 @@ public:
virtual PlayerList getActivePlayerList() const =0; virtual PlayerList getActivePlayerList() const =0;
virtual PlayerList getRunningPlayerList() const =0; virtual PlayerList getRunningPlayerList() const =0;
virtual PlayerListIterator getActivePlayerIt(unsigned) const =0;
virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0;
virtual BoardInterface* getBoard() const =0; virtual BoardInterface* getBoard() const =0;
virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0; virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0;
virtual boost::shared_ptr<BeRoInterface> getFlop() const =0; virtual boost::shared_ptr<BeRoInterface> getFlop() const =0;
+30 -3
View File
@@ -13,12 +13,36 @@
using namespace std; using namespace std;
LocalBeRo::LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS) LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(false), minimumRaise(2*sB), firstRun(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurn(0), firstRoundLastPlayersTurn(0), logBoardCardsDone(false) : BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(false), minimumRaise(2*sB), firstRun(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false)
{ {
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin(); currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin(); lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
PlayerListConstIterator it_c;
// determine bigBlindPosition
for(it_c=myHand->getActivePlayerList()->begin(); it_c!=myHand->getActivePlayerList()->end(); it_c++) {
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
bigBlindPositionId = (*it_c)->getMyUniqueID();
break;
}
}
assert(it_c!=myHand->getActivePlayerList()->end());
// determine smallBlindPosition
for(it_c=myHand->getActivePlayerList()->begin(); it_c!=myHand->getActivePlayerList()->end(); it_c++) {
if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) {
smallBlindPositionId = (*it_c)->getMyUniqueID();
break;
}
}
assert(it_c!=myHand->getActivePlayerList()->end());
// int i; // int i;
//SmallBlind-Position ermitteln //SmallBlind-Position ermitteln
@@ -40,7 +64,10 @@ void LocalBeRo::nextPlayer() {
// cout << "playerID in nextPlayer(): " << (*currentPlayersTurnIt)->getMyID() << endl; // cout << "playerID in nextPlayer(): " << (*currentPlayersTurnIt)->getMyID() << endl;
(*currentPlayersTurnIt)->action(); PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId);
assert( currentPlayersTurnConstIt != myHand->getRunningPlayerList()->end() );
(*currentPlayersTurnConstIt)->action();
} }
+23 -7
View File
@@ -24,7 +24,7 @@
*/ */
class LocalBeRo : public BeRoInterface{ class LocalBeRo : public BeRoInterface{
public: public:
LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS); LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
~LocalBeRo(); ~LocalBeRo();
GameState getMyBeRoID() const { return myBeRoID; } GameState getMyBeRoID() const { return myBeRoID; }
@@ -53,11 +53,11 @@ protected:
void setPlayersTurn(int theValue) { playersTurn = theValue; } void setPlayersTurn(int theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn;} int getPlayersTurn() const { return playersTurn;}
void setCurrentPlayersTurn(unsigned theValue) { currentPlayersTurn = theValue; } void setCurrentPlayersTurnId(unsigned theValue) { currentPlayersTurnId = theValue; }
unsigned getCurrentPlayersTurn() const { return currentPlayersTurn;} unsigned getCurrentPlayersTurnId() const { return currentPlayersTurnId;}
void setFirstRoundLastPlayersTurn(unsigned theValue) { firstRoundLastPlayersTurn = theValue; } void setFirstRoundLastPlayersTurnId(unsigned theValue) { firstRoundLastPlayersTurnId = theValue; }
unsigned getFirstRoundLastPlayersTurn() const { return firstRoundLastPlayersTurn;} unsigned getFirstRoundLastPlayersTurnId() const { return firstRoundLastPlayersTurnId;}
void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; } void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; }
PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; } PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; }
@@ -71,6 +71,17 @@ protected:
void setFirstRound(bool theValue) { firstRound = theValue;} void setFirstRound(bool theValue) { firstRound = theValue;}
bool getFirstRound() const { return firstRound;} bool getFirstRound() const { return firstRound;}
void setDealerPositionId(unsigned theValue) { dealerPositionId = theValue;}
unsigned getDealerPositionId() const { return dealerPositionId; }
void setSmallBlindPositionId(unsigned theValue) { smallBlindPositionId = theValue;}
unsigned getSmallBlindPositionId() const { return smallBlindPositionId; }
void setBigBlindPositionId(unsigned theValue) { bigBlindPositionId = theValue;}
unsigned getBigBlindPositionId() const { return bigBlindPositionId; }
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;} void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; } int getSmallBlindPosition() const { return smallBlindPosition; }
@@ -92,6 +103,11 @@ private:
int dealerPosition; int dealerPosition;
int smallBlindPosition; int smallBlindPosition;
unsigned dealerPositionId;
unsigned smallBlindPositionId;
unsigned bigBlindPositionId;
int smallBlind; int smallBlind;
int highestSet; int highestSet;
int minimumRaise; int minimumRaise;
@@ -104,8 +120,8 @@ private:
PlayerListIterator currentPlayersTurnIt; // iterator for runningPlayerList PlayerListIterator currentPlayersTurnIt; // iterator for runningPlayerList
PlayerListIterator lastPlayersTurnIt; // iterator for runningPlayerList PlayerListIterator lastPlayersTurnIt; // iterator for runningPlayerList
unsigned currentPlayersTurn; unsigned currentPlayersTurnId;
unsigned firstRoundLastPlayersTurn; unsigned firstRoundLastPlayersTurnId;
bool logBoardCardsDone; bool logBoardCardsDone;
+1 -1
View File
@@ -24,7 +24,7 @@
using namespace std; using namespace std;
LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_FLOP) LocalBeRoFlop::LocalBeRoFlop(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_FLOP)
{ {
} }
+1 -1
View File
@@ -28,7 +28,7 @@ class HandInterface;
class LocalBeRoFlop : public LocalBeRo{ class LocalBeRoFlop : public LocalBeRo{
public: public:
LocalBeRoFlop(HandInterface*, int, int, int); LocalBeRoFlop(HandInterface*, int, unsigned, int);
~LocalBeRoFlop(); ~LocalBeRoFlop();
}; };
+114 -49
View File
@@ -24,70 +24,93 @@
using namespace std; using namespace std;
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP), bigBlindPosition(0) LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP)
{ {
PlayerListConstIterator it_c; // PlayerListConstIterator it_c;
setHighestSet(2*getSmallBlind()); setHighestSet(2*getSmallBlind());
// determine bigBlindPosition // determine bigBlindPosition -> old: delete
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;
} // }
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); it_c++) {
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
bigBlindPosition = (*it_c)->getMyUniqueID();
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, it_3; // PlayerListIterator it_1, it_2, it_3;
PlayerListIterator it;
// search bigBlindPosition in runningPlayerList -> old: delete
// it_1 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *bigBlindPositionIt);
// search bigBlindPosition in runningPlayerList // search bigBlindPosition in runningPlayerList
it_1 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *bigBlindPositionIt); PlayerListIterator bigBlindPositionIt = getMyHand()->getRunningPlayerIt(getBigBlindPositionId());
// more than 2 players are still active -> runningPlayerList is not empty // more than 2 players are still active -> runningPlayerList is not empty
if(getMyHand()->getActivePlayerList()->size() > 2) { if(getMyHand()->getActivePlayerList()->size() > 2) {
// bigBlindPlayer not found in runningPlayerList (he is all in) -> bigBlindPlayer is not the running player before first action player // bigBlindPlayer not found in runningPlayerList (he is all in) -> bigBlindPlayer is not the running player before first action player
if(it_1 == getMyHand()->getRunningPlayerList()->end()) { if(bigBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
// search smallBlindPosition in runningPlayerList // search smallBlindPosition in runningPlayerList
PlayerListIterator smallBlindPositionIt = bigBlindPositionIt; PlayerListIterator smallBlindPositionIt = getMyHand()->getRunningPlayerIt(getSmallBlindPositionId());
if(smallBlindPositionIt == getMyHand()->getActivePlayerList()->begin()) smallBlindPositionIt = getMyHand()->getActivePlayerList()->end(); // 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(smallBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
it_2 = smallBlindPositionIt;
if(it_2 == getMyHand()->getActivePlayerList()->begin()) it_2 = getMyHand()->getActivePlayerList()->end(); it = getMyHand()->getActivePlayerIt(getSmallBlindPositionId());
it_2--; assert(it != getMyHand()->getActivePlayerList()->end());
it_3 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *it_2);
if(it_3 == getMyHand()->getRunningPlayerList()->end()) { if(it == getMyHand()->getActivePlayerList()->begin()) it = getMyHand()->getActivePlayerList()->end();
cout << "ERROR - lastPlayersTurnIt-detection in localBeRoPreflop" << endl; it--;
} else {
setLastPlayersTurnIt(it_3); setFirstRoundLastPlayersTurnId( (*it)->getMyUniqueID() );
}
// 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 {
setLastPlayersTurnIt(it_2); setFirstRoundLastPlayersTurnId( getSmallBlindPositionId() );
} }
} }
// bigBlindPlayer found in runningPlayerList -> player before first action player // bigBlindPlayer found in runningPlayerList -> player before first action player
else { else {
setLastPlayersTurnIt(it_1); setFirstRoundLastPlayersTurnId( getBigBlindPositionId() );
} }
} }
// heads up -> dealer/smallBlindPlayer is first action player and bigBlindPlayer is player before // heads up -> dealer/smallBlindPlayer is first action player and bigBlindPlayer is player before
else { else {
setLastPlayersTurnIt(it_1);
// bigBlindPlayer not found in runningPlayerList (he is all in) -> only smallBlind has to choose fold or call the bigBlindAmount
if(bigBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
// search smallBlindPosition in runningPlayerList
PlayerListIterator smallBlindPositionIt = getMyHand()->getRunningPlayerIt(getSmallBlindPositionId());
// smallBlindPlayer not found in runningPlayerList (he is all in) -> no running player -> showdown and no firstRoundLastPlayersTurnId is used
if(smallBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) {
}
// smallBlindPlayer found in runningPlayerList -> running player before first action player (himself)
else {
setFirstRoundLastPlayersTurnId( getSmallBlindPositionId() );
}
}
setFirstRoundLastPlayersTurnId( getBigBlindPositionId() );
} }
setCurrentPlayersTurnIt(getLastPlayersTurnIt()); setCurrentPlayersTurnId( getFirstRoundLastPlayersTurnId() );
// cout << "playerID constructor beropreflop: " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl; // cout << "playerID constructor beropreflop: " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl;
@@ -97,7 +120,7 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) :
it_1 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *bigBlindPositionIt); // it_1 = find(getMyHand()->getRunningPlayerList()->begin(), getMyHand()->getRunningPlayerList()->end(), *bigBlindPositionIt);
// bigBlindPosition is not all in // bigBlindPosition is not all in
// if(it!=getMyHand()->getRunningPlayerList()->end()) { // if(it!=getMyHand()->getRunningPlayerList()->end()) {
@@ -142,13 +165,14 @@ void LocalBeRoPreflop::run() {
int i; int i;
bool allHighestSet = true; bool allHighestSet = true;
PlayerListIterator it; // PlayerListIterator it;
PlayerListConstIterator it_c;
// test if all running players have same sets (else allHighestSet = false) // test if all running players have same sets (else allHighestSet = false)
for(it=getMyHand()->getRunningPlayerList()->begin(); it!=getMyHand()->getRunningPlayerList()->end(); it++) { for(it_c=getMyHand()->getRunningPlayerList()->begin(); it_c!=getMyHand()->getRunningPlayerList()->end(); it_c++) {
if(getHighestSet() != (*it)->getMySet()) { if(getHighestSet() != (*it_c)->getMySet()) {
allHighestSet = false; allHighestSet = false;
} }
} }
@@ -157,26 +181,59 @@ void LocalBeRoPreflop::run() {
// cout << "playerID begin preflopRun(): " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl; // cout << "playerID begin preflopRun(): " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl;
it = getCurrentPlayersTurnIt(); // it++;
it++; PlayerListIterator currentPlayersTurnIt = getMyHand()->getRunningPlayerIt( getCurrentPlayersTurnId() );
assert( currentPlayersTurnIt != getMyHand()->getRunningPlayerList()->end() );
setCurrentPlayersTurnIt(it); currentPlayersTurnIt++;
if(currentPlayersTurnIt == getMyHand()->getRunningPlayerList()->end()) currentPlayersTurnIt = getMyHand()->getRunningPlayerList()->begin();
if(getCurrentPlayersTurnIt() == getMyHand()->getRunningPlayerList()->end()) setCurrentPlayersTurnIt(getMyHand()->getRunningPlayerList()->begin()); setCurrentPlayersTurnId( (*currentPlayersTurnIt)->getMyUniqueID() );
// setCurrentPlayersTurnIt(++getCurrentPlayersTurnIt());
// if(getCurrentPlayersTurnIt() == getMyHand()->getRunningPlayerList()->end()) setCurrentPlayersTurnIt(getMyHand()->getRunningPlayerList()->begin());
// if(getCurrentPlayersTurnIt() == getMyHand()->getRunningPlayerList()->end()) cout << "!!!" << endl; // if(getCurrentPlayersTurnIt() == getMyHand()->getRunningPlayerList()->end()) cout << "!!!" << endl;
// cout << "playerID middle preflopRun(): " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl; // cout << "playerID middle preflopRun(): " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl;
// exceptions // exceptions
// if next player is small blind and only all-in-big-blind with less than smallblind amount is nonfold too -> preflop is over // if next player is small blind and only all-in-big-blind with less than smallblind amount is nonfold too -> preflop is over
if((*(getCurrentPlayersTurnIt()))->getMyButton() == BUTTON_SMALL_BLIND && (*bigBlindPositionIt)->getMySet() <= getSmallBlind() && getMyHand()->getRunningPlayerList()->size() == 1) { PlayerListConstIterator bigBlindPositionIt = getMyHand()->getActivePlayerIt(getBigBlindPositionId());
assert(bigBlindPositionIt != getMyHand()->getActivePlayerList()->end());
PlayerListConstIterator currentPlayersTurnConstIt = getMyHand()->getRunningPlayerIt( getCurrentPlayersTurnId() );
assert(currentPlayersTurnConstIt != getMyHand()->getRunningPlayerList()->end());
if((*currentPlayersTurnConstIt)->getMyButton() == BUTTON_SMALL_BLIND && (*bigBlindPositionIt)->getMySet() <= getSmallBlind() && getMyHand()->getRunningPlayerList()->size() == 1) {
setFirstRound(false); setFirstRound(false);
allHighestSet = true; allHighestSet = true;
} }
// determine next player // determine next player
// for(i=0; (i<MAX_NUMBER_OF_PLAYERS && (!(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyActiveStatus()) || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_FOLD || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_ALLIN)) || i==0; i++) { // for(i=0; (i<MAX_NUMBER_OF_PLAYERS && (!(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyActiveStatus()) || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_FOLD || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_ALLIN)) || i==0; i++) {
// //
@@ -198,8 +255,8 @@ void LocalBeRoPreflop::run() {
getMyHand()->setActualRound(GAME_STATE_FLOP); getMyHand()->setActualRound(GAME_STATE_FLOP);
//Action loeschen und ActionButtons refresh //Action loeschen und ActionButtons refresh
for(it=getMyHand()->getRunningPlayerList()->begin(); it!=getMyHand()->getRunningPlayerList()->end(); it++) { for(it_c=getMyHand()->getRunningPlayerList()->begin(); it_c!=getMyHand()->getRunningPlayerList()->end(); it_c++) {
(*it)->setMyAction(PLAYER_ACTION_NONE); (*it_c)->setMyAction(PLAYER_ACTION_NONE);
} }
//Action loeschen und ActionButtons refresh //Action loeschen und ActionButtons refresh
@@ -225,24 +282,32 @@ void LocalBeRoPreflop::run() {
// if(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyButton() == BUTTON_BIG_BLIND) setFirstRound(0); // if(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyButton() == BUTTON_BIG_BLIND) setFirstRound(0);
// lastPlayersTurn -> PreflopFirstRound is over // lastPlayersTurn -> PreflopFirstRound is over
if( (*(getCurrentPlayersTurnIt())) == (*(getLastPlayersTurnIt())) ) { // if( (*(getCurrentPlayersTurnIt())) == (*(getLastPlayersTurnIt())) ) {
// setFirstRound(false);
// }
// lastPlayersTurn -> PreflopFirstRound is over
if( getCurrentPlayersTurnId() == getFirstRoundLastPlayersTurnId() ) {
setFirstRound(false); setFirstRound(false);
} }
// getMyHand()->getPlayerArray()[getPlayersTurn()]->setMyTurn(1); // getMyHand()->getPlayerArray()[getPlayersTurn()]->setMyTurn(1);
(*(getCurrentPlayersTurnIt()))->setMyTurn(true); (*currentPlayersTurnConstIt)->setMyTurn(true);
// (*(getCurrentPlayersTurnIt()))->setMyTurn(true);
//highlight active players groupbox and clear action //highlight active players groupbox and clear action
// getMyHand()->getGuiInterface()->refreshGroupbox(getPlayersTurn(),2); // getMyHand()->getGuiInterface()->refreshGroupbox(getPlayersTurn(),2);
// getMyHand()->getGuiInterface()->refreshAction(getPlayersTurn(),PLAYER_ACTION_NONE); // getMyHand()->getGuiInterface()->refreshAction(getPlayersTurn(),PLAYER_ACTION_NONE);
//highlight active players groupbox and clear action //highlight active players groupbox and clear action
getMyHand()->getGuiInterface()->refreshGroupbox( (*(getCurrentPlayersTurnIt()))->getMyID() , 2 ); getMyHand()->getGuiInterface()->refreshGroupbox( getCurrentPlayersTurnId() , 2 );
getMyHand()->getGuiInterface()->refreshAction( (*(getCurrentPlayersTurnIt()))->getMyID() , PLAYER_ACTION_NONE ); getMyHand()->getGuiInterface()->refreshAction( getCurrentPlayersTurnId() , PLAYER_ACTION_NONE );
if((*(getCurrentPlayersTurnIt()))->getMyID() == 0) { if( getCurrentPlayersTurnId() == 0) {
// Wir sind dran // Wir sind dran
getMyHand()->getGuiInterface()->meInAction(); getMyHand()->getGuiInterface()->meInAction();
} }
+3 -3
View File
@@ -28,14 +28,14 @@ class HandInterface;
class LocalBeRoPreflop : public LocalBeRo{ class LocalBeRoPreflop : public LocalBeRo{
public: public:
LocalBeRoPreflop(HandInterface*, int, int, int); LocalBeRoPreflop(HandInterface*, int, unsigned, int);
~LocalBeRoPreflop(); ~LocalBeRoPreflop();
void run(); void run();
private: private:
PlayerListIterator bigBlindPositionIt; // iterator for activePlayerList // PlayerListIterator bigBlindPositionIt; // iterator for activePlayerList
unsigned bigBlindPosition; // unsigned bigBlindPositionId;
}; };
#endif #endif
+1 -1
View File
@@ -25,7 +25,7 @@
using namespace std; using namespace std;
LocalBeRoRiver::LocalBeRoRiver(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_RIVER) LocalBeRoRiver::LocalBeRoRiver(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_RIVER)
{ {
} }
+1 -1
View File
@@ -28,7 +28,7 @@ class HandInterface;
class LocalBeRoRiver : public LocalBeRo{ class LocalBeRoRiver : public LocalBeRo{
public: public:
LocalBeRoRiver(HandInterface*, int, int, int); LocalBeRoRiver(HandInterface*, int, unsigned, int);
~LocalBeRoRiver(); ~LocalBeRoRiver();
}; };
+1 -1
View File
@@ -24,7 +24,7 @@
using namespace std; using namespace std;
LocalBeRoTurn::LocalBeRoTurn(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_TURN) LocalBeRoTurn::LocalBeRoTurn(HandInterface* hi, int id, unsigned dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_TURN)
{ {
} }
+1 -1
View File
@@ -27,7 +27,7 @@ class HandInterface;
class LocalBeRoTurn : public LocalBeRo{ class LocalBeRoTurn : public LocalBeRo{
public: public:
LocalBeRoTurn(HandInterface*, int, int, int); LocalBeRoTurn(HandInterface*, int, unsigned, int);
~LocalBeRoTurn(); ~LocalBeRoTurn();
}; };
@@ -48,7 +48,7 @@ BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
boost::shared_ptr<PlayerInterface> LocalEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) { return boost::shared_ptr<PlayerInterface> (new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB)); } boost::shared_ptr<PlayerInterface> LocalEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) { return boost::shared_ptr<PlayerInterface> (new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB)); }
std::vector<boost::shared_ptr<BeRoInterface> > LocalEngineFactory::createBeRo(HandInterface* hi, int id, int dP, int sB) { std::vector<boost::shared_ptr<BeRoInterface> > LocalEngineFactory::createBeRo(HandInterface* hi, int id, unsigned dP, int sB) {
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
+1 -1
View File
@@ -40,7 +40,7 @@ public:
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
BoardInterface* createBoard(); BoardInterface* createBoard();
boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int dP, int sB); std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, unsigned dP, int sB);
private: private:
ConfigFile *myConfig; ConfigFile *myConfig;
+29 -1
View File
@@ -26,7 +26,7 @@
using namespace std; using namespace std;
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC)
: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(false), : myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(false),
cardsShown(false), bettingRoundsPlayed(0) cardsShown(false), bettingRoundsPlayed(0)
{ {
@@ -495,3 +495,31 @@ void LocalHand::switchRounds() {
} }
} }
PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const {
PlayerListIterator it;
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
if((*it)->getMyUniqueID() == uniqueId) {
break;
}
}
return it;
}
PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const {
PlayerListIterator it;
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); it++) {
if((*it)->getMyUniqueID() == uniqueId) {
break;
}
}
return it;
}
+5 -2
View File
@@ -34,7 +34,7 @@
class LocalHand : public HandInterface{ class LocalHand : public HandInterface{
public: public:
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, int, int, int, int, int); LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, int, int, unsigned, int, int);
~LocalHand(); ~LocalHand();
void start(); void start();
@@ -43,6 +43,9 @@ public:
PlayerList getActivePlayerList() const {return activePlayerList;} PlayerList getActivePlayerList() const {return activePlayerList;}
PlayerList getRunningPlayerList() const {return runningPlayerList;} PlayerList getRunningPlayerList() const {return runningPlayerList;}
PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const;
BoardInterface* getBoard() const { return myBoard; } BoardInterface* getBoard() const { return myBoard; }
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; } boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; } boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
@@ -100,7 +103,7 @@ private:
int myID; int myID;
int startQuantityPlayers; int startQuantityPlayers;
int dealerPosition; // -1 -> neutral unsigned dealerPosition; // -1 -> neutral
int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
int smallBlind; int smallBlind;
int startCash; int startCash;
+1 -1
View File
@@ -11,7 +11,7 @@
// //
#include "clientbero.h" #include "clientbero.h"
ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, int dP, int sB, GameState gS) ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, unsigned dP, int sB, GameState gS)
: BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), playersTurn(dP), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(0) : BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), playersTurn(dP), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(0)
{ {
} }
+1 -1
View File
@@ -22,7 +22,7 @@ class HandInterface;
*/ */
class ClientBeRo : public BeRoInterface{ class ClientBeRo : public BeRoInterface{
public: public:
ClientBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS); ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
~ClientBeRo(); ~ClientBeRo();
GameState getMyBeRoID() const; GameState getMyBeRoID() const;
@@ -50,7 +50,7 @@ boost::shared_ptr<PlayerInterface> ClientEngineFactory::createPlayer(BoardInter
return boost::shared_ptr<PlayerInterface> (new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB)); return boost::shared_ptr<PlayerInterface> (new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB));
} }
std::vector<boost::shared_ptr<BeRoInterface> > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int dP, int sB) { std::vector<boost::shared_ptr<BeRoInterface> > ClientEngineFactory::createBeRo(HandInterface* hi, int id, unsigned dP, int sB) {
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
@@ -40,7 +40,7 @@ public:
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
BoardInterface* createBoard(); BoardInterface* createBoard();
boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int dP, int sB); std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, unsigned dP, int sB);
}; };
+28
View File
@@ -76,6 +76,34 @@ ClientHand::getPlayerArray() const
return playerArray; return playerArray;
} }
PlayerListIterator
ClientHand::getActivePlayerIt(unsigned uniqueId) const
{
PlayerListIterator it;
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
if((*it)->getMyUniqueID() == uniqueId) {
break;
}
}
return it;
}
PlayerListIterator
ClientHand::getRunningPlayerIt(unsigned uniqueId) const
{
PlayerListIterator it;
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); it++) {
if((*it)->getMyUniqueID() == uniqueId) {
break;
}
}
return it;
}
BoardInterface* BoardInterface*
ClientHand::getBoard() const ClientHand::getBoard() const
{ {
+3
View File
@@ -41,6 +41,9 @@ class ClientHand : public HandInterface
PlayerList getActivePlayerList() const {return activePlayerList;} PlayerList getActivePlayerList() const {return activePlayerList;}
PlayerList getRunningPlayerList() const {return runningPlayerList;} PlayerList getRunningPlayerList() const {return runningPlayerList;}
PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const;
BoardInterface* getBoard() const; BoardInterface* getBoard() const;
boost::shared_ptr<BeRoInterface> getPreflop() const; boost::shared_ptr<BeRoInterface> getPreflop() const;
boost::shared_ptr<BeRoInterface> getFlop() const; boost::shared_ptr<BeRoInterface> getFlop() const;
+1 -1
View File
@@ -103,7 +103,7 @@ private:
//Laufvariablen //Laufvariablen
int actualSmallBlind; int actualSmallBlind;
int actualHandID; int actualHandID;
int dealerPosition; unsigned dealerPosition;
}; };
#endif #endif