Removed dependencies on old preflop/flop/turn/river interface from networking. Compiles, but networking is BROKEN. Also includes first try of computer players for networking, which is broken, too.

This commit is contained in:
lotodore
2007-08-06 21:38:09 +00:00
parent 96419b3588
commit 0aef0d9e42
18 changed files with 233 additions and 121 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ public:
int getMyBeRoID() const { return myBeRoID; } int getMyBeRoID() const { return myBeRoID; }
int getHighestCardsValue() const {} int getHighestCardsValue() const {return 0;}
void setHighestCardsValue(int theValue) {} void setHighestCardsValue(int theValue) {}
void run() {} void run() {}
@@ -11,6 +11,12 @@
// //
#include "localberofactory.h" #include "localberofactory.h"
#include <localberopreflop.h>
#include <localberoflop.h>
#include <localberoturn.h>
#include <localberoriver.h>
#include <localberopostriver.h>
using namespace std; using namespace std;
LocalBeRoFactory::LocalBeRoFactory (HandInterface* hi, int id, int aP, int dP, int sB) LocalBeRoFactory::LocalBeRoFactory (HandInterface* hi, int id, int aP, int dP, int sB)
@@ -21,11 +21,6 @@
#include <berofactoryinterface.h> #include <berofactoryinterface.h>
#include <berointerface.h> #include <berointerface.h>
#include <handinterface.h> #include <handinterface.h>
#include <localberopreflop.h>
#include <localberoflop.h>
#include <localberoturn.h>
#include <localberoriver.h>
#include <localberopostriver.h>
/** /**
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
+18 -10
View File
@@ -10,10 +10,13 @@
// //
// //
#include "clientberofactory.h" #include "clientberofactory.h"
#include "berointerface.h" #include <clientpreflop.h>
#include <clientflop.h>
#include <clientturn.h>
#include <clientriver.h>
ClientBeRoFactory::ClientBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB) ClientBeRoFactory::ClientBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB)
: BeRoFactoryInterface() : myHand(hi), myID(id), actualQuantityPlayers(aP), dealerPosition(dP), smallBlind(sB)
{ {
} }
@@ -24,14 +27,19 @@ ClientBeRoFactory::~ClientBeRoFactory()
std::vector<boost::shared_ptr<BeRoInterface> > ClientBeRoFactory::createBeRo() std::vector<boost::shared_ptr<BeRoInterface> > ClientBeRoFactory::createBeRo()
{ {
std::vector<boost::shared_ptr<BeRoInterface> > bettingRounds; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
//         bettingRounds.push_back(boost::shared_ptr<BeRoInterface>(new
// LocalBeRoPreflop(...))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoPreflop(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
//         bettingRounds.push_back(boost::shared_ptr<BeRoInterface>(new
// LocalBeRoFlop(...))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoFlop(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
//
//         ... myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoTurn(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
return bettingRounds;
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoRiver(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
// myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoPostRiver(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
return myBeRo;
} }
@@ -35,6 +35,14 @@ public:
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(); std::vector<boost::shared_ptr<BeRoInterface> > createBeRo();
private:
HandInterface* myHand;
int myID;
int actualQuantityPlayers;
int dealerPosition;
int smallBlind;
}; };
#endif #endif
@@ -56,22 +56,22 @@ PlayerInterface* ClientEngineFactory::createPlayer(BoardInterface *b, int id, un
PreflopInterface* ClientEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) PreflopInterface* ClientEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB)
{ {
return new ClientPreflop(hi, id, aP, dP, sB); return NULL;
} }
FlopInterface* ClientEngineFactory::createFlop(HandInterface* hi, int id, int aP, int dP, int sB) FlopInterface* ClientEngineFactory::createFlop(HandInterface* hi, int id, int aP, int dP, int sB)
{ {
return new ClientFlop(hi, id, aP, dP, sB); return NULL;
} }
TurnInterface* ClientEngineFactory::createTurn(HandInterface* hi, int id, int aP, int dP, int sB) TurnInterface* ClientEngineFactory::createTurn(HandInterface* hi, int id, int aP, int dP, int sB)
{ {
return new ClientTurn(hi, id, aP, dP, sB); return NULL;
} }
RiverInterface* ClientEngineFactory::createRiver(HandInterface* hi, int id, int aP, int dP, int sB) RiverInterface* ClientEngineFactory::createRiver(HandInterface* hi, int id, int aP, int dP, int sB)
{ {
return new ClientRiver(hi, id, aP, dP, sB); return NULL;
} }
BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB) BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB)
+20 -19
View File
@@ -22,100 +22,101 @@
//using namespace std; //using namespace std;
ClientFlop::ClientFlop(HandInterface* bR, int id, int qP, int dP, int sB) ClientBeRoFlop::ClientBeRoFlop(HandInterface* bR, int id, int qP, int dP, int sB)
: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), playersTurn(dP) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), playersTurn(dP)
{ {
} }
ClientFlop::~ClientFlop() ClientBeRoFlop::~ClientBeRoFlop()
{ {
} }
int
ClientBeRoFlop::getMyBeRoID() const
{
return GAME_STATE_FLOP;
}
void void
ClientFlop::setPlayersTurn(int theValue) ClientBeRoFlop::setPlayersTurn(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue; playersTurn = theValue;
} }
int int
ClientFlop::getPlayersTurn() const ClientBeRoFlop::getPlayersTurn() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn; return playersTurn;
} }
void void
ClientFlop::setHighestSet(int theValue) ClientBeRoFlop::setHighestSet(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue; highestSet = theValue;
} }
int int
ClientFlop::getHighestSet() const ClientBeRoFlop::getHighestSet() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet; return highestSet;
} }
void void
ClientFlop::setFirstFlopRound(bool theValue) ClientBeRoFlop::setFirstFlopRound(bool theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstFlopRound = theValue; firstFlopRound = theValue;
} }
bool bool
ClientFlop::getFirstFlopRound() const ClientBeRoFlop::getFirstFlopRound() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return firstFlopRound; return firstFlopRound;
} }
void void
ClientFlop::setSmallBlindPosition(int theValue) ClientBeRoFlop::setSmallBlindPosition(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlindPosition = theValue; smallBlindPosition = theValue;
} }
int int
ClientFlop::getSmallBlindPosition() const ClientBeRoFlop::getSmallBlindPosition() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlindPosition; return smallBlindPosition;
} }
void void
ClientFlop::setSmallBlind(int theValue) ClientBeRoFlop::setSmallBlind(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlind = theValue; smallBlind = theValue;
} }
int int
ClientFlop::getSmallBlind() const ClientBeRoFlop::getSmallBlind() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlind; return smallBlind;
} }
void void
ClientFlop::resetFirstRun() ClientBeRoFlop::resetFirstRun()
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstFlopRun = false; firstFlopRun = false;
} }
void void
ClientFlop::flopRun() ClientBeRoFlop::run()
{
}
void
ClientFlop::nextPlayer2()
{ {
} }
+17 -6
View File
@@ -19,17 +19,18 @@
#ifndef CLIENTFLOP_H #ifndef CLIENTFLOP_H
#define CLIENTFLOP_H #define CLIENTFLOP_H
#include "flopinterface.h" #include "berointerface.h"
#include <boost/thread.hpp> #include <boost/thread.hpp>
class HandInterface; class HandInterface;
class ClientFlop : public FlopInterface class ClientBeRoFlop : public BeRoInterface
{ {
public: public:
ClientFlop(HandInterface*, int, int, int, int); ClientBeRoFlop(HandInterface*, int, int, int, int);
~ClientFlop(); ~ClientBeRoFlop();
int getMyBeRoID() const;
void setPlayersTurn(int theValue); void setPlayersTurn(int theValue);
int getPlayersTurn() const; int getPlayersTurn() const;
@@ -46,10 +47,20 @@ public:
void setSmallBlind(int theValue); void setSmallBlind(int theValue);
int getSmallBlind() const; int getSmallBlind() const;
void setHighestCardsValue(int theValue) {}
int getHighestCardsValue() const {return 0;}
void resetFirstRun(); void resetFirstRun();
void flopRun(); void run();
void nextPlayer2();
void preflopRun() {}
void flopRun() {}
void turnRun() {}
void riverRun() {}
void postRiverRun() {}
void nextPlayer2() {}
private: private:
mutable boost::recursive_mutex m_syncMutex; mutable boost::recursive_mutex m_syncMutex;
+14 -8
View File
@@ -23,52 +23,58 @@
using namespace std; using namespace std;
ClientPreflop::ClientPreflop(HandInterface* bR, int id, int qP, int dP, int sB) ClientBeRoPreflop::ClientBeRoPreflop(HandInterface* bR, int id, int qP, int dP, int sB)
: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0)
{ {
} }
ClientPreflop::~ClientPreflop() ClientBeRoPreflop::~ClientBeRoPreflop()
{ {
} }
int
ClientBeRoPreflop::getMyBeRoID() const
{
return GAME_STATE_PREFLOP;
}
void void
ClientPreflop::setPlayersTurn(int theValue) ClientBeRoPreflop::setPlayersTurn(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue; playersTurn = theValue;
} }
int int
ClientPreflop::getPlayersTurn() const ClientBeRoPreflop::getPlayersTurn() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn; return playersTurn;
} }
void void
ClientPreflop::setHighestSet(int theValue) ClientBeRoPreflop::setHighestSet(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue; highestSet = theValue;
} }
int int
ClientPreflop::getHighestSet() const ClientBeRoPreflop::getHighestSet() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet; return highestSet;
} }
void void
ClientPreflop::preflopRun() ClientBeRoPreflop::resetFirstRun()
{ {
} }
void void
ClientPreflop::nextPlayer2() ClientBeRoPreflop::run()
{ {
} }
+20 -6
View File
@@ -19,16 +19,18 @@
#ifndef CLIENTPREFLOP_H #ifndef CLIENTPREFLOP_H
#define CLIENTPREFLOP_H #define CLIENTPREFLOP_H
#include <preflopinterface.h> #include <berointerface.h>
#include <boost/thread.hpp> #include <boost/thread.hpp>
class HandInterface; class HandInterface;
class ClientPreflop : public PreflopInterface{ class ClientBeRoPreflop : public BeRoInterface{
public: public:
ClientPreflop(HandInterface*, int, int, int, int); ClientBeRoPreflop(HandInterface*, int, int, int, int);
~ClientPreflop(); ~ClientBeRoPreflop();
int getMyBeRoID() const;
void setPlayersTurn(int theValue); void setPlayersTurn(int theValue);
int getPlayersTurn() const; int getPlayersTurn() const;
@@ -36,8 +38,20 @@ public:
void setHighestSet(int theValue); void setHighestSet(int theValue);
int getHighestSet() const; int getHighestSet() const;
void preflopRun(); void setHighestCardsValue(int theValue) {}
void nextPlayer2(); int getHighestCardsValue() const {return 0;}
void resetFirstRun();
void run();
void preflopRun() {}
void flopRun() {}
void turnRun() {}
void riverRun() {}
void postRiverRun() {}
void nextPlayer2() {}
private: private:
mutable boost::recursive_mutex m_syncMutex; mutable boost::recursive_mutex m_syncMutex;
+23 -26
View File
@@ -22,122 +22,119 @@
//using namespace std; //using namespace std;
ClientRiver::ClientRiver(HandInterface* bR, int id, int qP, int dP, int sB) ClientBeRoRiver::ClientBeRoRiver(HandInterface* bR, int id, int qP, int dP, int sB)
: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRiverRun(1), firstRiverRound(1), playersTurn(dP), highestCardsValue(0) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRiverRun(1), firstRiverRound(1), playersTurn(dP), highestCardsValue(0)
{ {
} }
ClientRiver::~ClientRiver() ClientBeRoRiver::~ClientBeRoRiver()
{ {
} }
int
ClientBeRoRiver::getMyBeRoID() const
{
return GAME_STATE_RIVER;
}
void void
ClientRiver::setPlayersTurn(int theValue) ClientBeRoRiver::setPlayersTurn(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue; playersTurn = theValue;
} }
int int
ClientRiver::getPlayersTurn() const ClientBeRoRiver::getPlayersTurn() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn; return playersTurn;
} }
void void
ClientRiver::setHighestSet(int theValue) ClientBeRoRiver::setHighestSet(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue; highestSet = theValue;
} }
int int
ClientRiver::getHighestSet() const ClientBeRoRiver::getHighestSet() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet; return highestSet;
} }
void void
ClientRiver::setFirstRiverRound(bool theValue) ClientBeRoRiver::setFirstRiverRound(bool theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstRiverRound = theValue; firstRiverRound = theValue;
} }
bool bool
ClientRiver::getFirstRiverRound() const ClientBeRoRiver::getFirstRiverRound() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return firstRiverRound; return firstRiverRound;
} }
void void
ClientRiver::setSmallBlindPosition(int theValue) ClientBeRoRiver::setSmallBlindPosition(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlindPosition = theValue; smallBlindPosition = theValue;
} }
int int
ClientRiver::getSmallBlindPosition() const ClientBeRoRiver::getSmallBlindPosition() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlindPosition; return smallBlindPosition;
} }
void void
ClientRiver::setSmallBlind(int theValue) ClientBeRoRiver::setSmallBlind(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlind = theValue; smallBlind = theValue;
} }
int int
ClientRiver::getSmallBlind() const ClientBeRoRiver::getSmallBlind() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlind; return smallBlind;
} }
void void
ClientRiver::setHighestCardsValue(int theValue) ClientBeRoRiver::setHighestCardsValue(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestCardsValue = theValue; highestCardsValue = theValue;
} }
int int
ClientRiver::getHighestCardsValue() const ClientBeRoRiver::getHighestCardsValue() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestCardsValue; return highestCardsValue;
} }
void void
ClientRiver::resetFirstRun() ClientBeRoRiver::resetFirstRun()
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstRiverRun = false; firstRiverRun = false;
} }
void void
ClientRiver::riverRun() ClientBeRoRiver::distributePot()
{ {
} }
void void
ClientRiver::postRiverRun() ClientBeRoRiver::run()
{ {
} }
void
ClientRiver::nextPlayer2()
{
}
void
ClientRiver::distributePot()
{
}
+17 -8
View File
@@ -19,16 +19,18 @@
#ifndef CLIENTRIVER_H #ifndef CLIENTRIVER_H
#define CLIENTRIVER_H #define CLIENTRIVER_H
#include <riverinterface.h> #include <berointerface.h>
#include <boost/thread.hpp> #include <boost/thread.hpp>
class HandInterface; class HandInterface;
class ClientRiver : public RiverInterface{ class ClientBeRoRiver : public BeRoInterface{
public: public:
ClientRiver(HandInterface*, int, int, int, int); ClientBeRoRiver(HandInterface*, int, int, int, int);
~ClientRiver(); ~ClientBeRoRiver();
int getMyBeRoID() const;
void setPlayersTurn(int theValue); void setPlayersTurn(int theValue);
int getPlayersTurn() const; int getPlayersTurn() const;
@@ -50,11 +52,18 @@ public:
void resetFirstRun(); void resetFirstRun();
void riverRun();
void postRiverRun();
void nextPlayer2();
void distributePot(); void distributePot();
void run();
void preflopRun() {}
void flopRun() {}
void turnRun() {}
void riverRun() {}
void postRiverRun() {}
void nextPlayer2() {}
private: private:
mutable boost::recursive_mutex m_syncMutex; mutable boost::recursive_mutex m_syncMutex;
+20 -19
View File
@@ -22,99 +22,100 @@
//using namespace std; //using namespace std;
ClientTurn::ClientTurn(HandInterface* bR, int id, int qP, int dP, int sB) ClientBeRoTurn::ClientBeRoTurn(HandInterface* bR, int id, int qP, int dP, int sB)
: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstTurnRun(1), firstTurnRound(1), playersTurn(dP) : myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstTurnRun(1), firstTurnRound(1), playersTurn(dP)
{ {
} }
ClientTurn::~ClientTurn() ClientBeRoTurn::~ClientBeRoTurn()
{ {
} }
int
ClientBeRoTurn::getMyBeRoID() const
{
return GAME_STATE_TURN;
}
void void
ClientTurn::setPlayersTurn(int theValue) ClientBeRoTurn::setPlayersTurn(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playersTurn = theValue; playersTurn = theValue;
} }
int int
ClientTurn::getPlayersTurn() const ClientBeRoTurn::getPlayersTurn() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return playersTurn; return playersTurn;
} }
void void
ClientTurn::setHighestSet(int theValue) ClientBeRoTurn::setHighestSet(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
highestSet = theValue; highestSet = theValue;
} }
int int
ClientTurn::getHighestSet() const ClientBeRoTurn::getHighestSet() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return highestSet; return highestSet;
} }
void void
ClientTurn::setFirstTurnRound(bool theValue) ClientBeRoTurn::setFirstTurnRound(bool theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstTurnRound = theValue; firstTurnRound = theValue;
} }
bool bool
ClientTurn::getFirstTurnRound() const ClientBeRoTurn::getFirstTurnRound() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return firstTurnRound; return firstTurnRound;
} }
void void
ClientTurn::setSmallBlindPosition(int theValue) ClientBeRoTurn::setSmallBlindPosition(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlindPosition = theValue; smallBlindPosition = theValue;
} }
int int
ClientTurn::getSmallBlindPosition() const ClientBeRoTurn::getSmallBlindPosition() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlindPosition; return smallBlindPosition;
} }
void void
ClientTurn::setSmallBlind(int theValue) ClientBeRoTurn::setSmallBlind(int theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
smallBlind = theValue; smallBlind = theValue;
} }
int int
ClientTurn::getSmallBlind() const ClientBeRoTurn::getSmallBlind() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlind; return smallBlind;
} }
void void
ClientTurn::resetFirstRun() ClientBeRoTurn::resetFirstRun()
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
firstTurnRun = false; firstTurnRun = false;
} }
void void
ClientTurn::turnRun() ClientBeRoTurn::run()
{
}
void
ClientTurn::nextPlayer2()
{ {
} }
+18 -6
View File
@@ -19,15 +19,17 @@
#ifndef CLIENTTURN_H #ifndef CLIENTTURN_H
#define CLIENTTURN_H #define CLIENTTURN_H
#include <turninterface.h> #include <berointerface.h>
#include <boost/thread.hpp> #include <boost/thread.hpp>
class HandInterface; class HandInterface;
class ClientTurn : public TurnInterface{ class ClientBeRoTurn : public BeRoInterface{
public: public:
ClientTurn(HandInterface*, int, int, int, int); ClientBeRoTurn(HandInterface*, int, int, int, int);
~ClientTurn(); ~ClientBeRoTurn();
int getMyBeRoID() const;
void setPlayersTurn(int theValue); void setPlayersTurn(int theValue);
int getPlayersTurn() const; int getPlayersTurn() const;
@@ -44,10 +46,20 @@ public:
void setSmallBlind(int theValue); void setSmallBlind(int theValue);
int getSmallBlind() const; int getSmallBlind() const;
void setHighestCardsValue(int theValue) {}
int getHighestCardsValue() const {return 0;}
void resetFirstRun(); void resetFirstRun();
void turnRun(); void run();
void nextPlayer2();
void preflopRun() {}
void flopRun() {}
void turnRun() {}
void riverRun() {}
void postRiverRun() {}
void nextPlayer2() {}
private: private:
mutable boost::recursive_mutex m_syncMutex; mutable boost::recursive_mutex m_syncMutex;
+33 -2
View File
@@ -340,6 +340,22 @@ ServerRecvStateInit::InternalProcess(ServerRecvThread &server, SessionWrapper se
} }
else if (packet->ToNetPacketStartEvent()) else if (packet->ToNetPacketStartEvent())
{ {
boost::shared_ptr<PlayerData> tmpPlayerData(
new PlayerData(m_curUniquePlayerId++, 0, PLAYER_TYPE_COMPUTER, PLAYER_RIGHTS_NORMAL));
tmpPlayerData->SetName("Computer");
// Send "Player Joined" to other fully connected clients.
boost::shared_ptr<NetPacket> thisPlayerJoined(new NetPacketPlayerJoined);
NetPacketPlayerJoined::Data thisPlayerJoinedData;
thisPlayerJoinedData.playerId = tmpPlayerData->GetUniqueId();
thisPlayerJoinedData.playerName = tmpPlayerData->GetName();
thisPlayerJoinedData.ptype = tmpPlayerData->GetType();
thisPlayerJoinedData.prights = tmpPlayerData->GetRights();
static_cast<NetPacketPlayerJoined *>(thisPlayerJoined.get())->SetData(thisPlayerJoinedData);
server.SendToAllPlayers(thisPlayerJoined);
server.AddComputerPlayer(tmpPlayerData);
server.InternalStartGame(); server.InternalStartGame();
server.SetState(SERVER_START_GAME_STATE::Instance()); server.SetState(SERVER_START_GAME_STATE::Instance());
} }
@@ -762,11 +778,17 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
{ {
int retVal; int retVal;
// If the player we are waiting for left, continue without him.
PlayerInterface *tmpPlayer = GetCurrentPlayer(server.GetGame()); PlayerInterface *tmpPlayer = GetCurrentPlayer(server.GetGame());
assert(tmpPlayer); assert(tmpPlayer);
assert(!tmpPlayer->getMyName().empty()); assert(!tmpPlayer->getMyName().empty());
if (!server.IsPlayerConnected(tmpPlayer->getMyName()))
// If the player is computer controlled, let the engine act.
if (tmpPlayer->getMyType() == PLAYER_TYPE_COMPUTER)
{
tmpPlayer->action();
}
// If the player we are waiting for left, continue without him.
else if (!server.IsPlayerConnected(tmpPlayer->getMyName()))
{ {
PerformPlayerAction(server, tmpPlayer, PLAYER_ACTION_FOLD, 0); PerformPlayerAction(server, tmpPlayer, PLAYER_ACTION_FOLD, 0);
@@ -832,6 +854,15 @@ ServerRecvStateWaitPlayerAction::PerformPlayerAction(ServerRecvThread &server, P
curGame.getCurrentHand()->getBoard()->collectSets(); curGame.getCurrentHand()->getBoard()->collectSets();
} }
SendPlayerAction(server, player);
}
void
ServerRecvStateWaitPlayerAction::SendPlayerAction(ServerRecvThread &server, PlayerInterface *player)
{
Game &curGame = server.GetGame();
assert(player);
boost::shared_ptr<NetPacket> notifyActionDone(new NetPacketPlayersActionDone); boost::shared_ptr<NetPacket> notifyActionDone(new NetPacketPlayersActionDone);
NetPacketPlayersActionDone::Data actionDoneData; NetPacketPlayersActionDone::Data actionDoneData;
actionDoneData.gameState = static_cast<GameState>(curGame.getCurrentHand()->getActualRound()); actionDoneData.gameState = static_cast<GameState>(curGame.getCurrentHand()->getActualRound());
+9 -1
View File
@@ -469,7 +469,7 @@ ServerRecvThread::RemoveDisconnectedPlayers()
for (int i = 0; i < m_game->getStartQuantityPlayers(); i++) for (int i = 0; i < m_game->getStartQuantityPlayers(); i++)
{ {
PlayerInterface *tmpPlayer = m_game->getPlayerArray()[i]; PlayerInterface *tmpPlayer = m_game->getPlayerArray()[i];
if (!IsPlayerConnected(tmpPlayer->getMyUniqueID())) if (!IsPlayerConnected(tmpPlayer->getMyUniqueID()) && tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN)
{ {
tmpPlayer->setMyCash(0); tmpPlayer->setMyCash(0);
tmpPlayer->setMyActiveStatus(false); tmpPlayer->setMyActiveStatus(false);
@@ -479,6 +479,12 @@ ServerRecvThread::RemoveDisconnectedPlayers()
} }
} }
void
ServerRecvThread::AddComputerPlayer(boost::shared_ptr<PlayerData> player)
{
m_computerPlayers.push_back(player);
}
size_t size_t
ServerRecvThread::GetCurNumberOfPlayers() const ServerRecvThread::GetCurNumberOfPlayers() const
{ {
@@ -552,6 +558,8 @@ ServerRecvThread::GetPlayerDataList() const
} }
++session_i; ++session_i;
} }
if (!m_computerPlayers.empty())
playerList.insert(playerList.end(), m_computerPlayers.begin(), m_computerPlayers.end());
return playerList; return playerList;
} }
+1
View File
@@ -208,6 +208,7 @@ protected:
virtual int InternalProcess(ServerRecvThread &server, SessionWrapper session, boost::shared_ptr<NetPacket> packet); virtual int InternalProcess(ServerRecvThread &server, SessionWrapper session, boost::shared_ptr<NetPacket> packet);
static void PerformPlayerAction(ServerRecvThread &server, PlayerInterface *player, PlayerAction action, int bet); static void PerformPlayerAction(ServerRecvThread &server, PlayerInterface *player, PlayerAction action, int bet);
static void SendPlayerAction(ServerRecvThread &server, PlayerInterface *player);
static int GetHighestSet(Game &curGame); static int GetHighestSet(Game &curGame);
static void SetHighestSet(Game &curGame, int highestSet); static void SetHighestSet(Game &curGame, int highestSet);
}; };
+4
View File
@@ -112,6 +112,8 @@ protected:
void RemoveNotEstablishedSessions(); void RemoveNotEstablishedSessions();
void RemoveDisconnectedPlayers(); void RemoveDisconnectedPlayers();
void AddComputerPlayer(boost::shared_ptr<PlayerData> player);
size_t GetCurNumberOfPlayers() const; size_t GetCurNumberOfPlayers() const;
bool IsPlayerConnected(const std::string &playerName) const; bool IsPlayerConnected(const std::string &playerName) const;
bool IsPlayerConnected(unsigned uniquePlayerId) const; bool IsPlayerConnected(unsigned uniquePlayerId) const;
@@ -147,6 +149,8 @@ private:
SocketSessionMap m_sessionMap; SocketSessionMap m_sessionMap;
mutable boost::mutex m_sessionMapMutex; mutable boost::mutex m_sessionMapMutex;
PlayerDataList m_computerPlayers;
CloseSessionList m_closeSessionList; CloseSessionList m_closeSessionList;
std::auto_ptr<ReceiverHelper> m_receiver; std::auto_ptr<ReceiverHelper> m_receiver;