Changed network code for new player lists.
This commit is contained in:
@@ -33,7 +33,6 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
||||
|
||||
int i, j, k;
|
||||
PlayerListIterator it;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
CardsValue myCardsValue;
|
||||
|
||||
@@ -72,19 +71,19 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
||||
|
||||
k = 0;
|
||||
myBoard->setMyCards(tempBoardArray);
|
||||
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++, k++) {
|
||||
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++, k++) {
|
||||
|
||||
(*it_c)->getMyBestHandPosition(bestHandPos);
|
||||
(*it)->getMyBestHandPosition(bestHandPos);
|
||||
|
||||
for(j=0; j<2; j++) {
|
||||
tempPlayerArray[j] = cardsArray[2*k+j+5];
|
||||
tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5];
|
||||
}
|
||||
|
||||
(*it_c)->setMyCards(tempPlayerArray);
|
||||
(*it_c)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos));
|
||||
(*it_c)->setMyBestHandPosition(bestHandPos);
|
||||
(*it_c)->setMyRoundStartCash((*it_c)->getMyCash());
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos));
|
||||
(*it)->setMyBestHandPosition(bestHandPos);
|
||||
(*it)->setMyRoundStartCash((*it)->getMyCash());
|
||||
|
||||
// myBestHandPosition auf Fehler ueberpruefen
|
||||
for(j=0; j<5; j++) {
|
||||
@@ -94,10 +93,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
||||
}
|
||||
|
||||
// sBluff für alle aktiver Spieler außer human player setzen --> TODO for ai-player in internet
|
||||
if((*it_c)->getMyID() != 0) {
|
||||
if((*it)->getMyID() != 0) {
|
||||
Tools::getRandNumber(1,100,1,&sBluff,0);
|
||||
(*it_c)->setSBluff(sBluff);
|
||||
(*it_c)->setSBluffStatus(0);
|
||||
(*it)->setSBluff(sBluff);
|
||||
(*it)->setSBluffStatus(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +431,6 @@ void LocalHand::switchRounds() {
|
||||
|
||||
// cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get
|
||||
|
||||
int i;
|
||||
PlayerListIterator it, it_1;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
|
||||
@@ -44,12 +44,14 @@ ClientBeRo::setHighestCardsValue(int theValue)
|
||||
void
|
||||
ClientBeRo::setLastActionPlayer ( int theValue )
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
lastActionPlayer = theValue;
|
||||
}
|
||||
|
||||
int
|
||||
ClientBeRo::getLastActionPlayer() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return lastActionPlayer;
|
||||
}
|
||||
|
||||
@@ -70,48 +72,56 @@ ClientBeRo::getPlayersTurn() const
|
||||
void
|
||||
ClientBeRo::setCurrentPlayersTurnIt(PlayerListIterator theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
currentPlayersTurnIt = theValue;
|
||||
}
|
||||
|
||||
PlayerListIterator
|
||||
ClientBeRo::getCurrentPlayersTurnIt() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return currentPlayersTurnIt;
|
||||
}
|
||||
|
||||
void
|
||||
ClientBeRo::setLastPlayersTurnIt(PlayerListIterator theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
lastPlayersTurnIt = theValue;
|
||||
}
|
||||
|
||||
PlayerListIterator
|
||||
ClientBeRo::getLastPlayersTurnIt() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return lastPlayersTurnIt;
|
||||
}
|
||||
|
||||
void
|
||||
ClientBeRo::setCurrentPlayersTurnId(unsigned theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
currentPlayersTurnId = theValue;
|
||||
}
|
||||
|
||||
unsigned
|
||||
ClientBeRo::getCurrentPlayersTurnId() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return currentPlayersTurnId;
|
||||
}
|
||||
|
||||
void
|
||||
ClientBeRo::setFirstRoundLastPlayersTurnId(unsigned theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
firstRoundLastPlayersTurnId = theValue;
|
||||
}
|
||||
|
||||
unsigned
|
||||
ClientBeRo::getFirstRoundLastPlayersTurnId() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return firstRoundLastPlayersTurnId;
|
||||
}
|
||||
|
||||
@@ -174,12 +184,14 @@ ClientBeRo::getSmallBlind() const
|
||||
void
|
||||
ClientBeRo::setMinimumRaise ( int theValue )
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
minimumRaise = theValue;
|
||||
}
|
||||
|
||||
int
|
||||
ClientBeRo::getMinimumRaise() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return minimumRaise;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,32 +26,29 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, Boar
|
||||
smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0),
|
||||
cardsShown(false), bettingRoundsPlayed(0)
|
||||
{
|
||||
activePlayersCounter = activePlayerList->size();
|
||||
|
||||
int i;
|
||||
lastPlayersTurn = 0;
|
||||
PlayerListIterator it;
|
||||
|
||||
myBoard->setHand(this);
|
||||
|
||||
|
||||
for(i=0; i<startQuantityPlayers; i++) {
|
||||
playerArray[i]->setHand(this);
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
(*it)->setHand(this);
|
||||
// myFlipCards auf 0 setzen
|
||||
playerArray[i]->setMyCardsFlip(0, 0);
|
||||
(*it)->setMyCardsFlip(0, 0);
|
||||
}
|
||||
|
||||
|
||||
// roundStartCashArray fuellen
|
||||
// cardsvalue zuruecksetzen
|
||||
// remove all buttons
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
|
||||
playerArray[i]->setMyCardsValueInt(0);
|
||||
playerArray[i]->setMyButton(0);
|
||||
}
|
||||
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
|
||||
|
||||
// assign dealer button
|
||||
playerArray[dealerPosition]->setMyButton(1);
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = *it;
|
||||
|
||||
tmpPlayer->setMyRoundStartCash(tmpPlayer->getMyCash());
|
||||
tmpPlayer->setMyCardsValueInt(0);
|
||||
tmpPlayer->setMyButton(0);
|
||||
if (tmpPlayer->getMyUniqueID() == dealerPosition)
|
||||
tmpPlayer->setMyButton(1);
|
||||
}
|
||||
|
||||
// the rest of the buttons are assigned later as received from the server.
|
||||
|
||||
@@ -127,25 +124,25 @@ ClientHand::getBoard() const
|
||||
boost::shared_ptr<BeRoInterface>
|
||||
ClientHand::getPreflop() const
|
||||
{
|
||||
return myBeRo[actualRound];
|
||||
return myBeRo[GAME_STATE_PREFLOP];
|
||||
}
|
||||
|
||||
boost::shared_ptr<BeRoInterface>
|
||||
ClientHand::getFlop() const
|
||||
{
|
||||
return myBeRo[actualRound];
|
||||
return myBeRo[GAME_STATE_FLOP];
|
||||
}
|
||||
|
||||
boost::shared_ptr<BeRoInterface>
|
||||
ClientHand::getTurn() const
|
||||
{
|
||||
return myBeRo[actualRound];
|
||||
return myBeRo[GAME_STATE_TURN];
|
||||
}
|
||||
|
||||
boost::shared_ptr<BeRoInterface>
|
||||
ClientHand::getRiver() const
|
||||
{
|
||||
return myBeRo[actualRound];
|
||||
return myBeRo[GAME_STATE_RIVER];
|
||||
}
|
||||
|
||||
boost::shared_ptr<BeRoInterface>
|
||||
@@ -305,10 +302,24 @@ void
|
||||
ClientHand::switchRounds()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
// update active players counter.
|
||||
activePlayersCounter = 0;
|
||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if (playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyActiveStatus() == 1) activePlayersCounter++;
|
||||
|
||||
PlayerListIterator it, it_1;
|
||||
|
||||
// refresh runningPlayerList
|
||||
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) {
|
||||
if((*it)->getMyAction() == PLAYER_ACTION_FOLD || (*it)->getMyAction() == PLAYER_ACTION_ALLIN) {
|
||||
it = runningPlayerList->erase(it);
|
||||
if(!(runningPlayerList->empty())) {
|
||||
|
||||
it_1 = it;
|
||||
if(it_1 == runningPlayerList->begin()) it_1 = runningPlayerList->end();
|
||||
it_1--;
|
||||
getCurrentBeRo()->setCurrentPlayersTurnId((*it_1)->getMyUniqueID());
|
||||
|
||||
}
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,6 @@ class ClientHand : public HandInterface
|
||||
int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
|
||||
int smallBlind;
|
||||
int startCash;
|
||||
int activePlayersCounter;
|
||||
|
||||
int lastPlayersTurn;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user