remove hand-object from board
This commit is contained in:
@@ -31,7 +31,6 @@ public:
|
||||
virtual ~BoardInterface();
|
||||
//
|
||||
virtual void setPlayerLists(PlayerList, PlayerList, PlayerList) =0;
|
||||
virtual void setHand(HandInterface*) =0;
|
||||
//
|
||||
virtual void setMyCards(int* theValue) =0;
|
||||
virtual void getMyCards(int* theValue) =0;
|
||||
@@ -40,6 +39,9 @@ public:
|
||||
virtual void setPot(int theValue) =0;
|
||||
virtual int getSets() const=0;
|
||||
virtual void setSets(int theValue) =0;
|
||||
|
||||
virtual void setAllInCondition(bool theValue) =0;
|
||||
virtual void setLastActionPlayer(unsigned theValue) =0;
|
||||
//
|
||||
virtual void collectSets() =0;
|
||||
virtual void collectPot() =0;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
virtual ~EngineFactory();
|
||||
|
||||
virtual HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
|
||||
virtual BoardInterface* createBoard() =0;
|
||||
virtual BoardInterface* createBoard(unsigned dp) =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, unsigned dP, int sB) =0;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
LocalBoard::LocalBoard() : BoardInterface(), currentHand(0), pot(0), sets(0)
|
||||
LocalBoard::LocalBoard(unsigned dp) : BoardInterface(), pot(0), sets(0), dealerPosition(dp), allInCondition(false)
|
||||
{
|
||||
myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
|
||||
}
|
||||
@@ -42,8 +42,6 @@ void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl) {
|
||||
runningPlayerList = rpl;
|
||||
}
|
||||
|
||||
void LocalBoard::setHand(HandInterface* br) { currentHand = br; }
|
||||
|
||||
void LocalBoard::collectSets() {
|
||||
|
||||
sets = 0;
|
||||
@@ -141,7 +139,12 @@ void LocalBoard::distributePot() {
|
||||
if(mod == 0) {
|
||||
|
||||
for(j=2; j<potLevel.size(); j++) {
|
||||
it = currentHand->getSeatIt(potLevel[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);
|
||||
}
|
||||
@@ -158,8 +161,14 @@ void LocalBoard::distributePot() {
|
||||
else {
|
||||
|
||||
// winnerPointer = currentHand->getDealerPosition();
|
||||
it = currentHand->getSeatIt(currentHand->getDealerPosition());
|
||||
if(it == seatsList->end()) {
|
||||
|
||||
// find Seat with dealerPosition
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -243,7 +252,7 @@ void LocalBoard::determinePlayerNeedToShowCards() {
|
||||
playerNeedToShowCards.clear();
|
||||
|
||||
// in All In Condition everybody have to show the cards
|
||||
if(currentHand->getAllInCondition()) {
|
||||
if(allInCondition) {
|
||||
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
@@ -288,7 +297,7 @@ void LocalBoard::determinePlayerNeedToShowCards() {
|
||||
// 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) {
|
||||
if((*it_c)->getMyUniqueID() == lastActionPlayer && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
|
||||
lastActionPlayerIt = it_c;
|
||||
// cout << (*it_c)->getMyUniqueID() << endl;
|
||||
break;
|
||||
|
||||
@@ -32,15 +32,17 @@ class HandInterface;
|
||||
|
||||
class LocalBoard : public BoardInterface{
|
||||
public:
|
||||
LocalBoard();
|
||||
LocalBoard(unsigned dealerPosition);
|
||||
~LocalBoard();
|
||||
|
||||
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
||||
void setHand(HandInterface*);
|
||||
|
||||
void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; }
|
||||
void getMyCards(int* theValue) { int i; for(i=0; i<5; i++) theValue[i] = myCards[i]; }
|
||||
|
||||
void setAllInCondition(bool theValue) { allInCondition = theValue; }
|
||||
void setLastActionPlayer(unsigned theValue) { lastActionPlayer = theValue; }
|
||||
|
||||
int getPot() const { return pot;}
|
||||
void setPot(int theValue) { pot = theValue;}
|
||||
int getSets() const { return sets; }
|
||||
@@ -64,14 +66,15 @@ private:
|
||||
PlayerList activePlayerList;
|
||||
PlayerList runningPlayerList;
|
||||
|
||||
HandInterface *currentHand;
|
||||
|
||||
std::list<unsigned> winners;
|
||||
std::list<unsigned> playerNeedToShowCards;
|
||||
std::list<unsigned> playerNeedToShowCards;
|
||||
|
||||
int myCards[5];
|
||||
int pot;
|
||||
int sets;
|
||||
unsigned dealerPosition;
|
||||
bool allInCondition;
|
||||
unsigned lastActionPlayer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface
|
||||
return new LocalHand(f, g, b, l, sl, apl, rpl, id, sP, dP, sB, sC);
|
||||
}
|
||||
|
||||
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
|
||||
BoardInterface* LocalEngineFactory::createBoard(unsigned dp) { return new LocalBoard(dp); }
|
||||
|
||||
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)); }
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
~LocalEngineFactory();
|
||||
|
||||
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
||||
BoardInterface* createBoard();
|
||||
BoardInterface* createBoard(unsigned dp);
|
||||
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, unsigned dP, int sB);
|
||||
|
||||
|
||||
@@ -40,8 +40,6 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
||||
|
||||
CardsValue myCardsValue;
|
||||
|
||||
myBoard->setHand(this);
|
||||
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
(*it)->setHand(this);
|
||||
// set myFlipCards 0
|
||||
@@ -439,6 +437,7 @@ void LocalHand::assignButtons() {
|
||||
|
||||
// first player after dealer have to show his cards first (in showdown)
|
||||
lastActionPlayer = (*it)->getMyUniqueID();
|
||||
myBoard->setLastActionPlayer(lastActionPlayer);
|
||||
|
||||
it++;
|
||||
if(it == activePlayerList->end()) it = activePlayerList->begin();
|
||||
@@ -551,6 +550,7 @@ void LocalHand::switchRounds() {
|
||||
// 1) all players all in
|
||||
if(allInPlayersCounter == nonFoldPlayerCounter) {
|
||||
allInCondition = true;
|
||||
myBoard->setAllInCondition(true);
|
||||
}
|
||||
|
||||
// 2) all players but one all in and he has highest set
|
||||
@@ -560,6 +560,7 @@ void LocalHand::switchRounds() {
|
||||
|
||||
if((*it_c)->getMySet() >= myBeRo[currentRound]->getHighestSet()) {
|
||||
allInCondition = true;
|
||||
myBoard->setAllInCondition(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -578,14 +579,16 @@ void LocalHand::switchRounds() {
|
||||
}
|
||||
if( (*bigBlindIt_c)->getMySet() <= smallBlind && tempCounter == allInPlayersCounter) {
|
||||
allInCondition = true;
|
||||
myBoard->setAllInCondition(true);
|
||||
}
|
||||
}
|
||||
|
||||
// no.2: heads up -> detect player who is all in and bb but could set less than sb
|
||||
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
|
||||
|
||||
if(activePlayerList->size()==2 && (*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMyButton()==BUTTON_BIG_BLIND && (*it_c)->getMySet()<=smallBlind && currentRound == GAME_STATE_PREFLOP) {
|
||||
allInCondition = true;
|
||||
if(activePlayerList->size()==2 && (*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMyButton()==BUTTON_BIG_BLIND && (*it_c)->getMySet()<=smallBlind && currentRound == GAME_STATE_PREFLOP) {
|
||||
allInCondition = true;
|
||||
myBoard->setAllInCondition(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -694,3 +697,8 @@ PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const {
|
||||
return it;
|
||||
|
||||
}
|
||||
|
||||
void LocalHand::setLastActionPlayer(unsigned theValue) {
|
||||
lastActionPlayer = theValue;
|
||||
myBoard->setLastActionPlayer(theValue);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; }
|
||||
int getLastPlayersTurn() const { return lastPlayersTurn; }
|
||||
|
||||
void setLastActionPlayer ( unsigned theValue ) { lastActionPlayer = theValue; }
|
||||
void setLastActionPlayer ( unsigned theValue );
|
||||
unsigned getLastActionPlayer() const { return lastActionPlayer; }
|
||||
|
||||
void setCardsShown(bool theValue) { cardsShown = theValue; }
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
ClientBoard::ClientBoard()
|
||||
: currentHand(0), pot(0), sets(0)
|
||||
ClientBoard::ClientBoard(unsigned dp)
|
||||
: currentHand(0), pot(0), sets(0), dealerPosition(dp)
|
||||
{
|
||||
myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
|
||||
}
|
||||
@@ -94,6 +94,20 @@ ClientBoard::setSets(int theValue)
|
||||
sets = theValue;
|
||||
}
|
||||
|
||||
void
|
||||
ClientBoard::setAllInCondition(bool theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
allInCondition = theValue;
|
||||
}
|
||||
|
||||
void
|
||||
ClientBoard::setLastActionPlayer(unsigned theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
lastActionPlayer = theValue;
|
||||
}
|
||||
|
||||
void
|
||||
ClientBoard::collectSets()
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ class HandInterface;
|
||||
class ClientBoard : public BoardInterface
|
||||
{
|
||||
public:
|
||||
ClientBoard();
|
||||
ClientBoard(unsigned dealerPosition);
|
||||
~ClientBoard();
|
||||
|
||||
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
||||
@@ -45,6 +45,9 @@ public:
|
||||
int getSets() const;
|
||||
void setSets(int theValue);
|
||||
|
||||
void setAllInCondition(bool theValue);
|
||||
void setLastActionPlayer(unsigned theValue);
|
||||
|
||||
void collectSets();
|
||||
void collectPot();
|
||||
|
||||
@@ -72,6 +75,9 @@ private:
|
||||
int myCards[5];
|
||||
int pot;
|
||||
int sets;
|
||||
unsigned dealerPosition;
|
||||
bool allInCondition;
|
||||
unsigned lastActionPlayer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,9 +40,9 @@ HandInterface* ClientEngineFactory::createHand(boost::shared_ptr<EngineFactory>
|
||||
return new ClientHand(f, g, b, l, sl, apl, rpl, id, sP, dP, sB, sC);
|
||||
}
|
||||
|
||||
BoardInterface* ClientEngineFactory::createBoard()
|
||||
BoardInterface* ClientEngineFactory::createBoard(unsigned dp)
|
||||
{
|
||||
return new ClientBoard;
|
||||
return new ClientBoard(dp);
|
||||
}
|
||||
|
||||
boost::shared_ptr<PlayerInterface> ClientEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
~ClientEngineFactory();
|
||||
|
||||
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
||||
BoardInterface* createBoard();
|
||||
BoardInterface* createBoard(unsigned dp);
|
||||
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, unsigned dP, int sB);
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, Boar
|
||||
{
|
||||
PlayerListIterator it;
|
||||
|
||||
myBoard->setHand(this);
|
||||
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
(*it)->setHand(this);
|
||||
// myFlipCards auf 0 setzen
|
||||
|
||||
Reference in New Issue
Block a user