Client engine should now be completely thread safe. const int& -> int. Player CardsValue is now returned as copy, not the array itself.

This commit is contained in:
lotodore
2007-06-11 17:48:22 +00:00
parent dfffa16565
commit 07dc39d107
30 changed files with 1128 additions and 225 deletions
+52 -4
View File
@@ -18,7 +18,7 @@
***************************************************************************/
#include "clientboard.h"
#include "localhand.h"
#include <handinterface.h>
#include <game_defs.h>
using namespace std;
@@ -36,26 +36,74 @@ ClientBoard::~ClientBoard()
void
ClientBoard::setPlayer(PlayerInterface** p)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playerArray = p;
}
void
ClientBoard::setHand(HandInterface* br)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
actualHand = br;
}
void
ClientBoard::setMyCards(int* theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i = 0; i < 5; i++)
myCards[i] = theValue[i];
}
void
ClientBoard::getMyCards(int* theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i = 0; i < 5; i++)
theValue[i] = myCards[i];
}
int
ClientBoard::getPot() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return pot;
}
void
ClientBoard::setPot(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
pot = theValue;
}
int
ClientBoard::getSets() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return sets;
}
void
ClientBoard::setSets(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
sets = theValue;
}
void
ClientBoard::collectSets()
{
sets = 0;
int i;
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) sets += playerArray[i]->getMySet();
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
sets = 0;
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
sets += playerArray[i]->getMySet();
}
void
ClientBoard::collectPot()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
pot += sets;
sets = 0;
}
+11 -7
View File
@@ -20,12 +20,14 @@
#define CLIENTBOARD_H
#include <boardinterface.h>
#include <boost/thread.hpp>
class PlayerInterface;
class HandInterface;
class ClientBoard : public BoardInterface{
class ClientBoard : public BoardInterface
{
public:
ClientBoard();
~ClientBoard();
@@ -33,18 +35,20 @@ public:
void setPlayer(PlayerInterface**);
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 setMyCards(int* theValue);
void getMyCards(int* theValue);
int getPot() const { return pot;}
void setPot(int theValue) { pot = theValue;}
int getSets() const { return sets; }
void setSets(int theValue) { sets = theValue; }
int getPot() const;
void setPot(int theValue);
int getSets() const;
void setSets(int theValue);
void collectSets();
void collectPot();
private:
mutable boost::recursive_mutex m_syncMutex;
PlayerInterface **playerArray;
HandInterface *actualHand;
+77 -1
View File
@@ -32,6 +32,83 @@ ClientFlop::~ClientFlop()
{
}
void
ClientFlop::setPlayersTurn(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue;
}
int
ClientFlop::getPlayersTurn() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn;
}
void
ClientFlop::setHighestSet(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue;
}
int
ClientFlop::getHighestSet() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet;
}
void
ClientFlop::setFirstFlopRound(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstFlopRound = theValue;
}
bool
ClientFlop::getFirstFlopRound() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return firstFlopRound;
}
void
ClientFlop::setSmallBlindPosition(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlindPosition = theValue;
}
int
ClientFlop::getSmallBlindPosition() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlindPosition;
}
void
ClientFlop::setSmallBlind(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlind = theValue;
}
int
ClientFlop::getSmallBlind() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlind;
}
void
ClientFlop::resetFirstRun()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstFlopRun = false;
}
void
ClientFlop::flopRun()
{
@@ -42,4 +119,3 @@ ClientFlop::nextPlayer2()
{
}
+16 -13
View File
@@ -20,36 +20,39 @@
#define CLIENTFLOP_H
#include "flopinterface.h"
#include <boost/thread.hpp>
class HandInterface;
class ClientFlop : public FlopInterface{
class ClientFlop : public FlopInterface
{
public:
ClientFlop(HandInterface*, int, int, int, int);
~ClientFlop();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setPlayersTurn(int theValue);
int getPlayersTurn() const;
void setFirstFlopRound(bool theValue) { firstFlopRound = theValue;}
bool getFirstFlopRound() const { return firstFlopRound;}
void setHighestSet(int theValue);
int getHighestSet() const;
void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; }
void setFirstFlopRound(bool theValue);
bool getFirstFlopRound() const;
void setSmallBlind(const int& theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setSmallBlindPosition(int theValue);
int getSmallBlindPosition() const;
void resetFirstRun() { firstFlopRun = false; }
void setSmallBlind(int theValue);
int getSmallBlind() const;
void resetFirstRun();
void flopRun();
void nextPlayer2();
private:
mutable boost::recursive_mutex m_syncMutex;
HandInterface *myHand;
+211 -2
View File
@@ -74,9 +74,220 @@ ClientHand::start()
{
}
PlayerInterface**
ClientHand::getPlayerArray() const
{
return playerArray;
}
BoardInterface*
ClientHand::getBoard() const
{
return myBoard;
}
PreflopInterface*
ClientHand::getPreflop() const
{
return myPreflop;
}
FlopInterface*
ClientHand::getFlop() const
{
return myFlop;
}
TurnInterface*
ClientHand::getTurn() const
{
return myTurn;
}
RiverInterface*
ClientHand::getRiver() const
{
return myRiver;
}
GuiInterface*
ClientHand::getGuiInterface() const
{
return myGui;
}
void
ClientHand::setMyID(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myID = theValue;
}
int
ClientHand::getMyID() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myID;
}
void
ClientHand::setActualQuantityPlayers(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
actualQuantityPlayers = theValue;
}
int
ClientHand::getActualQuantityPlayers() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return actualQuantityPlayers;
}
void
ClientHand::setStartQuantityPlayers(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
startQuantityPlayers = theValue;
}
int
ClientHand::getStartQuantityPlayers() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return startQuantityPlayers;
}
void
ClientHand::setActualRound(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
actualRound = theValue;
}
int
ClientHand::getActualRound() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return actualRound;
}
void
ClientHand::setDealerPosition(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
dealerPosition = theValue;
}
int
ClientHand::getDealerPosition() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return dealerPosition;
}
void
ClientHand::setSmallBlind(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlind = theValue;
}
int
ClientHand::getSmallBlind() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlind;
}
void
ClientHand::setAllInCondition(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
allInCondition = theValue;
}
bool
ClientHand::getAllInCondition() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return allInCondition;
}
void
ClientHand::setStartCash(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
startCash = theValue;
}
int
ClientHand::getStartCash() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return startCash;
}
void
ClientHand::setActivePlayersCounter(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
activePlayersCounter = theValue;
}
int
ClientHand::getActivePlayersCounter() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return activePlayersCounter;
}
void
ClientHand::setBettingRoundsPlayed(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
bettingRoundsPlayed = theValue;
}
int
ClientHand::getBettingRoundsPlayed() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return bettingRoundsPlayed;
}
void
ClientHand::setLastPlayersTurn(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
lastPlayersTurn = theValue;
}
int
ClientHand::getLastPlayersTurn() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return lastPlayersTurn;
}
void
ClientHand::setCardsShown(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
cardsShown = theValue;
}
bool
ClientHand::getCardsShown() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return cardsShown;
}
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++) {
@@ -84,5 +295,3 @@ ClientHand::switchRounds()
}
}
+33 -31
View File
@@ -29,6 +29,7 @@
#include <turninterface.h>
#include <riverinterface.h>
#include <boost/thread.hpp>
class ClientHand : public HandInterface
{
@@ -38,54 +39,55 @@ public:
void start();
PlayerInterface** getPlayerArray() const { return playerArray; }
BoardInterface* getBoard() const { return myBoard; }
PreflopInterface* getPreflop() const { return myPreflop; }
FlopInterface* getFlop() const { return myFlop; }
TurnInterface* getTurn() const { return myTurn; }
RiverInterface* getRiver() const { return myRiver; }
GuiInterface* getGuiInterface() const { return myGui; }
PlayerInterface** getPlayerArray() const;
BoardInterface* getBoard() const;
PreflopInterface* getPreflop() const;
FlopInterface* getFlop() const;
TurnInterface* getTurn() const;
RiverInterface* getRiver() const;
GuiInterface* getGuiInterface() const;
void setMyID(int theValue) { myID = theValue; }
int getMyID() const { return myID; }
void setMyID(int theValue);
int getMyID() const;
void setActualQuantityPlayers(int theValue) { actualQuantityPlayers = theValue; }
int getActualQuantityPlayers() const { return actualQuantityPlayers; }
void setActualQuantityPlayers(int theValue);
int getActualQuantityPlayers() const;
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; }
int getStartQuantityPlayers() const { return startQuantityPlayers; }
void setStartQuantityPlayers(int theValue);
int getStartQuantityPlayers() const;
void setActualRound(int theValue) { actualRound = theValue; }
int getActualRound() const { return actualRound; }
void setActualRound(int theValue);
int getActualRound() const;
void setDealerPosition(int theValue) { dealerPosition = theValue; }
int getDealerPosition() const { return dealerPosition; }
void setDealerPosition(int theValue);
int getDealerPosition() const;
void setSmallBlind(int theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setSmallBlind(int theValue);
int getSmallBlind() const;
void setAllInCondition(bool theValue) { allInCondition = theValue; }
bool getAllInCondition() const { return allInCondition; }
void setAllInCondition(bool theValue);
bool getAllInCondition() const;
void setStartCash(int theValue) { startCash = theValue; }
int getStartCash() const { return startCash; }
void setStartCash(int theValue);
int getStartCash() const;
void setActivePlayersCounter(int theValue) { activePlayersCounter = theValue; }
int getActivePlayersCounter() const { return activePlayersCounter; }
void setActivePlayersCounter(int theValue);
int getActivePlayersCounter() const;
void setBettingRoundsPlayed(int theValue) { bettingRoundsPlayed = theValue; }
int getBettingRoundsPlayed() const { return bettingRoundsPlayed; }
void setBettingRoundsPlayed(int theValue);
int getBettingRoundsPlayed() const;
void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; }
int getLastPlayersTurn() const { return lastPlayersTurn; }
void setLastPlayersTurn(int theValue);
int getLastPlayersTurn() const;
void setCardsShown(bool theValue) { cardsShown = theValue; }
bool getCardsShown() const { return cardsShown; }
void setCardsShown(bool theValue);
bool getCardsShown() const;
void switchRounds();
private:
mutable boost::recursive_mutex m_syncMutex;
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
+353 -1
View File
@@ -17,7 +17,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "clientplayer.h"
#include "handinterface.h"
#include <handinterface.h>
using namespace std;
@@ -36,9 +36,359 @@ ClientPlayer::~ClientPlayer()
void
ClientPlayer::setHand(HandInterface* br)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
actualHand = br;
}
int
ClientPlayer::getMyID() const
{
return myID;
}
unsigned
ClientPlayer::getMyUniqueID() const
{
return myUniqueID;
}
PlayerType
ClientPlayer::getMyType() const
{
return myType;
}
void
ClientPlayer::setMyDude(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myDude = theValue;
}
int
ClientPlayer::getMyDude() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myDude;
}
void
ClientPlayer::setMyDude4(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myDude4 = theValue;
}
int
ClientPlayer::getMyDude4() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myDude4;
}
void
ClientPlayer::setMyName(const std::string& theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myName = theValue;
}
std::string
ClientPlayer::getMyName() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myName;
}
void
ClientPlayer::setMyAvatar(const std::string& theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myAvatar = theValue;
}
std::string
ClientPlayer::getMyAvatar() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myAvatar;
}
void
ClientPlayer::setMyCash(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myCash = theValue;
}
int
ClientPlayer::getMyCash() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myCash;
}
void
ClientPlayer::setMySet(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myLastRelativeSet = theValue;
}
void
ClientPlayer::setMySetAbsolute(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
mySet = theValue;
}
void
ClientPlayer::setMySetNull()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
mySet = 0;
myLastRelativeSet = 0;
}
int
ClientPlayer::getMySet() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return mySet;
}
int
ClientPlayer::getMyLastRelativeSet() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myLastRelativeSet;
}
void
ClientPlayer::setMyAction(int theValue, bool blind)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myAction = theValue;
}
int
ClientPlayer::getMyAction() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myAction;
}
void
ClientPlayer::setMyButton(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myButton = theValue;
}
int
ClientPlayer::getMyButton() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myButton;
}
void
ClientPlayer::setMyActiveStatus(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myActiveStatus = theValue;
}
bool
ClientPlayer::getMyActiveStatus() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myActiveStatus;
}
void
ClientPlayer::setMyCards(int* theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i = 0; i < 2; i++)
myCards[i] = theValue[i];
}
void
ClientPlayer::getMyCards(int* theValue) const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i = 0; i < 2; i++)
theValue[i] = myCards[i];
}
void
ClientPlayer::setMyTurn(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myTurn = theValue;
}
bool
ClientPlayer::getMyTurn() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myTurn;
}
void
ClientPlayer::setMyCardsFlip(bool theValue, int state)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myCardsFlip = theValue;
// log flipping cards
if (myCardsFlip) {
switch(state) {
case 1: actualHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt);
break;
case 2: actualHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]);
break;
case 3: actualHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has");
break;
default: ;
}
}
}
bool
ClientPlayer::getMyCardsFlip() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myCardsFlip;
}
void
ClientPlayer::setMyCardsValueInt(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myCardsValueInt = theValue;
}
int
ClientPlayer::getMyCardsValueInt() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myCardsValueInt;
}
void
ClientPlayer::setMyBestHandPosition(int* theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i = 0; i < 5; i++)
myBestHandPosition[i] = theValue[i];
}
void
ClientPlayer::getMyBestHandPosition(int* theValue) const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i = 0; i < 5; i++)
theValue[i] = myBestHandPosition[i];
}
void
ClientPlayer::setMyRoundStartCash(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myRoundStartCash = theValue;
}
int
ClientPlayer::getMyRoundStartCash() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myRoundStartCash;
}
void
ClientPlayer::setMyAverageSets(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myAverageSets[0] = myAverageSets[1];
myAverageSets[1] = myAverageSets[2];
myAverageSets[2] = myAverageSets[3];
myAverageSets[3] = theValue;
}
int
ClientPlayer::getMyAverageSets() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4;
}
void
ClientPlayer::setMyAggressive(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
for (int i=0; i<6; i++)
{
myAggressive[i] = myAggressive[i+1];
}
myAggressive[6] = theValue;
}
int
ClientPlayer::getMyAggressive() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
int sum = 0;
for (int i=0; i<7; i++)
{
sum += myAggressive[i];
}
return sum;
}
void
ClientPlayer::setSBluff(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
sBluff = theValue;
}
int
ClientPlayer::getSBluff() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return sBluff;
}
void
ClientPlayer::setSBluffStatus(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
sBluffStatus = theValue;
}
bool
ClientPlayer::getSBluffStatus() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return sBluffStatus;
}
void
ClientPlayer::setMyWinnerState(bool theValue, int pot)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myWinnerState = theValue;
if(theValue)
actualHand->getGuiInterface()->logPlayerWinsMsg(myID, pot);
}
bool
ClientPlayer::getMyWinnerState() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myWinnerState;
}
void
ClientPlayer::action()
@@ -123,11 +473,13 @@ ClientPlayer::riverEngine3()
void ClientPlayer::setNetSessionData(boost::shared_ptr<SessionData> session)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myNetSessionData = session;
}
boost::shared_ptr<SessionData> ClientPlayer::getNetSessionData()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myNetSessionData;
}
+52 -79
View File
@@ -22,9 +22,9 @@
#include <playerinterface.h>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <string>
class CardsValue;
class ConfigFile;
class HandInterface;
@@ -37,100 +37,72 @@ public:
void setHand(HandInterface*);
int getMyID() const { return myID; }
unsigned getMyUniqueID() const { return myUniqueID; }
PlayerType getMyType() const { return myType; }
int getMyID() const;
unsigned getMyUniqueID() const;
PlayerType getMyType() const;
void setMyDude(int theValue) { myDude = theValue; }
int getMyDude() const { return myDude; }
void setMyDude(int theValue);
int getMyDude() const;
void setMyDude4(int theValue) { myDude4 = theValue; }
int getMyDude4() const { return myDude4; }
void setMyDude4(int theValue);
int getMyDude4() const;
void setMyName(const std::string& theValue) { myName = theValue; }
std::string getMyName() const { return myName; }
void setMyName(const std::string& theValue);
std::string getMyName() const;
void setMyAvatar(const std::string& theValue) { myAvatar = theValue; }
std::string getMyAvatar() const { return myAvatar; }
void setMyAvatar(const std::string& theValue);
std::string getMyAvatar() const;
void setMyCash(int theValue) { myCash = theValue; }
int getMyCash() const { return myCash; }
void setMyCash(int theValue);
int getMyCash() const;
void setMySet(int theValue) { myLastRelativeSet = theValue; }
void setMySetAbsolute(int theValue) { mySet = theValue; }
void setMySetNull() { mySet = 0; myLastRelativeSet = 0; }
int getMySet() const { return mySet;}
int getMyLastRelativeSet() const { return myLastRelativeSet; }
void setMySet(int theValue);
void setMySetAbsolute(int theValue);
void setMySetNull();
int getMySet() const;
int getMyLastRelativeSet() const;
void setMyAction(int theValue, bool blind) { myAction = theValue; }
int getMyAction() const { return myAction; }
void setMyAction(int theValue, bool blind);
int getMyAction() const;
void setMyButton(int theValue) { myButton = theValue; }
int getMyButton() const { return myButton; }
void setMyButton(int theValue);
int getMyButton() const;
void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; }
bool getMyActiveStatus() const { return myActiveStatus; }
void setMyActiveStatus(bool theValue);
bool getMyActiveStatus() const;
void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; }
void getMyCards(int* theValue) { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; }
void setMyCards(int* theValue);
void getMyCards(int* theValue) const;
void setMyTurn(bool theValue){ myTurn = theValue;}
bool getMyTurn() const{ return myTurn;}
void setMyTurn(bool theValue);
bool getMyTurn() const;
void setMyCardsFlip(bool theValue, int state){
myCardsFlip = theValue;
// log flipping cards
if(myCardsFlip) {
switch(state) {
case 1: actualHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt);
break;
case 2: actualHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]);
break;
case 3: actualHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has");
break;
default: ;
}
}
}
bool getMyCardsFlip() const{ return myCardsFlip;}
void setMyCardsFlip(bool theValue, int state);
bool getMyCardsFlip() const;
void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;}
int getMyCardsValueInt() const { return myCardsValueInt; }
void setMyCardsValueInt(int theValue);
int getMyCardsValueInt() const;
int* getMyBestHandPosition() { return myBestHandPosition; }
void setMyBestHandPosition(int* theValue);
void getMyBestHandPosition(int* theValue) const;
void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;}
int getMyRoundStartCash() const { return myRoundStartCash; }
void setMyRoundStartCash(int theValue);
int getMyRoundStartCash() const;
void setMyAverageSets(int theValue) { myAverageSets[0] = myAverageSets[1]; myAverageSets[1] = myAverageSets[2]; myAverageSets[2] = myAverageSets[3]; myAverageSets[3] = theValue; }
int getMyAverageSets() const { return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4; }
void setMyAggressive(bool theValue) {
int i;
for(i=0; i<6; i++) {
myAggressive[i] = myAggressive[i+1];
}
myAggressive[6] = theValue;
}
int getMyAggressive() const {
int i, sum = 0;
for(i=0; i<7; i++) {
sum += myAggressive[i];
}
return sum;
}
void setMyAverageSets(int theValue);
int getMyAverageSets() const;
void setSBluff ( int theValue ) { sBluff = theValue; }
int getSBluff() const { return sBluff; }
void setMyAggressive(bool theValue);
int getMyAggressive() const;
void setSBluffStatus ( bool theValue ) { sBluffStatus = theValue; }
bool getSBluffStatus() const { return sBluffStatus; }
void setSBluff (int theValue);
int getSBluff() const;
void setMyWinnerState ( bool theValue, int pot ) {
myWinnerState = theValue;
if(theValue) actualHand->getGuiInterface()->logPlayerWinsMsg(myID, pot);
}
bool getMyWinnerState() const { return myWinnerState;}
void setSBluffStatus (bool theValue);
bool getSBluffStatus() const;
void setMyWinnerState (bool theValue, int pot);
bool getMyWinnerState() const;
void action();
@@ -156,6 +128,7 @@ public:
boost::shared_ptr<SessionData> getNetSessionData();
private:
mutable boost::recursive_mutex m_syncMutex;
ConfigFile *myConfig;
HandInterface *actualHand;
@@ -164,9 +137,9 @@ private:
CardsValue *myCardsValue;
// Konstanten
int myID;
unsigned myUniqueID;
PlayerType myType;
const int myID;
const unsigned myUniqueID;
const PlayerType myType;
std::string myName;
std::string myAvatar;
int myDude;
@@ -34,6 +34,48 @@ ClientPreflop::~ClientPreflop()
{
}
void
ClientPreflop::setPlayersTurn(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue;
}
int
ClientPreflop::getPlayersTurn() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn;
}
void
ClientPreflop::setHighestSet(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue;
}
int
ClientPreflop::getHighestSet() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet;
}
void
ClientPreflop::setPreflopFirstRound(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
preflopFirstRound = theValue;
}
bool
ClientPreflop::setPreflopFirstRound() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return preflopFirstRound;
}
void
ClientPreflop::preflopRun()
{
@@ -43,3 +85,4 @@ void
ClientPreflop::nextPlayer2()
{
}
+10 -10
View File
@@ -20,6 +20,7 @@
#define CLIENTPREFLOP_H
#include <preflopinterface.h>
#include <boost/thread.hpp>
class HandInterface;
@@ -29,26 +30,25 @@ public:
ClientPreflop(HandInterface*, int, int, int, int);
~ClientPreflop();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setPlayersTurn(int theValue);
int getPlayersTurn() const;
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setHighestSet(int theValue);
int getHighestSet() const;
void setPreflopFirstRound(bool theValue) { preflopFirstRound = theValue; }
bool setPreflopFirstRound() const { return preflopFirstRound; }
void setPreflopFirstRound(bool theValue);
bool setPreflopFirstRound() const;
void preflopRun();
void nextPlayer2();
private:
mutable boost::recursive_mutex m_syncMutex;
HandInterface *myHand;
int myID;
int actualQuantityPlayers;
int actualQuantityPlayers;
int dealerPosition;
int bigBlindPosition;
+90
View File
@@ -31,6 +31,96 @@ ClientRiver::~ClientRiver()
{
}
void
ClientRiver::setPlayersTurn(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue;
}
int
ClientRiver::getPlayersTurn() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn;
}
void
ClientRiver::setHighestSet(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue;
}
int
ClientRiver::getHighestSet() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet;
}
void
ClientRiver::setFirstRiverRound(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstRiverRound = theValue;
}
bool
ClientRiver::getFirstRiverRound() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return firstRiverRound;
}
void
ClientRiver::setSmallBlindPosition(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlindPosition = theValue;
}
int
ClientRiver::getSmallBlindPosition() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlindPosition;
}
void
ClientRiver::setSmallBlind(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlind = theValue;
}
int
ClientRiver::getSmallBlind() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlind;
}
void
ClientRiver::setHighestCardsValue(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestCardsValue = theValue;
}
int
ClientRiver::getHighestCardsValue() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestCardsValue;
}
void
ClientRiver::resetFirstRun()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstRiverRun = false;
}
void
ClientRiver::riverRun()
+16 -13
View File
@@ -20,6 +20,7 @@
#define CLIENTRIVER_H
#include <riverinterface.h>
#include <boost/thread.hpp>
class HandInterface;
@@ -29,25 +30,25 @@ public:
ClientRiver(HandInterface*, int, int, int, int);
~ClientRiver();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setPlayersTurn(int theValue);
int getPlayersTurn() const;
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setHighestSet(int theValue);
int getHighestSet() const;
void setFirstRiverRound(bool theValue) { firstRiverRound = theValue;}
bool getFirstRiverRound() const { return firstRiverRound;}
void setFirstRiverRound(bool theValue);
bool getFirstRiverRound() const;
void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; }
void setSmallBlindPosition(int theValue);
int getSmallBlindPosition() const;
void setSmallBlind(const int& theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setSmallBlind(int theValue);
int getSmallBlind() const;
void setHighestCardsValue(const int& theValue) { highestCardsValue = theValue;}
int getHighestCardsValue() const { return highestCardsValue;}
void setHighestCardsValue(int theValue);
int getHighestCardsValue() const;
void resetFirstRun() { firstRiverRun = false; }
void resetFirstRun();
void riverRun();
void postRiverRun();
@@ -55,6 +56,7 @@ public:
void distributePot();
private:
mutable boost::recursive_mutex m_syncMutex;
HandInterface *myHand;
@@ -75,3 +77,4 @@ private:
};
#endif
+77
View File
@@ -31,6 +31,83 @@ ClientTurn::~ClientTurn()
{
}
void
ClientTurn::setPlayersTurn(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue;
}
int
ClientTurn::getPlayersTurn() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn;
}
void
ClientTurn::setHighestSet(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue;
}
int
ClientTurn::getHighestSet() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet;
}
void
ClientTurn::setFirstTurnRound(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstTurnRound = theValue;
}
bool
ClientTurn::getFirstTurnRound() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return firstTurnRound;
}
void
ClientTurn::setSmallBlindPosition(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlindPosition = theValue;
}
int
ClientTurn::getSmallBlindPosition() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlindPosition;
}
void
ClientTurn::setSmallBlind(int theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlind = theValue;
}
int
ClientTurn::getSmallBlind() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlind;
}
void
ClientTurn::resetFirstRun()
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstTurnRun = false;
}
void
ClientTurn::turnRun()
{
+13 -11
View File
@@ -20,6 +20,7 @@
#define CLIENTTURN_H
#include <turninterface.h>
#include <boost/thread.hpp>
class HandInterface;
@@ -28,27 +29,28 @@ public:
ClientTurn(HandInterface*, int, int, int, int);
~ClientTurn();
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn; }
void setPlayersTurn(int theValue);
int getPlayersTurn() const;
void setHighestSet(const int& theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void setHighestSet(int theValue);
int getHighestSet() const;
void setFirstTurnRound(bool theValue) { firstTurnRound = theValue;}
bool getFirstTurnRound() const { return firstTurnRound;}
void setFirstTurnRound(bool theValue);
bool getFirstTurnRound() const;
void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;}
int getSmallBlindPosition() const { return smallBlindPosition; }
void setSmallBlindPosition(int theValue);
int getSmallBlindPosition() const;
void setSmallBlind(const int& theValue) { smallBlind = theValue; }
int getSmallBlind() const { return smallBlind; }
void setSmallBlind(int theValue);
int getSmallBlind() const;
void resetFirstRun() { firstTurnRun = false; }
void resetFirstRun();
void turnRun();
void nextPlayer2();
private:
mutable boost::recursive_mutex m_syncMutex;
HandInterface *myHand;