Changed network code for new player lists.

This commit is contained in:
lotodore
2007-09-27 14:17:07 +00:00
parent c469eb5848
commit 78bf4820af
11 changed files with 160 additions and 220 deletions
+12
View File
@@ -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;
}
+35 -24
View File
@@ -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++;
}
}
}
-1
View File
@@ -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;