buggy!!!
This commit is contained in:
@@ -46,7 +46,7 @@ HandInterface* LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f
|
|||||||
|
|
||||||
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
|
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
|
||||||
|
|
||||||
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 new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB); }
|
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)); }
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<BeRoInterface> > LocalEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) {
|
std::vector<boost::shared_ptr<BeRoInterface> > LocalEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) {
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ ClientBoard::~ClientBoard()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientBoard::setPlayer(PlayerInterface** p)
|
ClientBoard::setPlayer(std::vector<boost::shared_ptr<PlayerInterface> > p)
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
playerArray = p;
|
playerArray = p;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include <boardinterface.h>
|
#include <boardinterface.h>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
class PlayerInterface;
|
class PlayerInterface;
|
||||||
class HandInterface;
|
class HandInterface;
|
||||||
@@ -32,7 +34,7 @@ public:
|
|||||||
ClientBoard();
|
ClientBoard();
|
||||||
~ClientBoard();
|
~ClientBoard();
|
||||||
|
|
||||||
void setPlayer(PlayerInterface**);
|
void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >);
|
||||||
void setHand(HandInterface*);
|
void setHand(HandInterface*);
|
||||||
|
|
||||||
void setMyCards(int* theValue);
|
void setMyCards(int* theValue);
|
||||||
@@ -51,7 +53,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
mutable boost::recursive_mutex m_syncMutex;
|
mutable boost::recursive_mutex m_syncMutex;
|
||||||
|
|
||||||
PlayerInterface **playerArray;
|
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
|
||||||
HandInterface *actualHand;
|
HandInterface *actualHand;
|
||||||
|
|
||||||
int myCards[5];
|
int myCards[5];
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ BoardInterface* ClientEngineFactory::createBoard()
|
|||||||
|
|
||||||
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)
|
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)
|
||||||
{
|
{
|
||||||
return new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB);
|
return boost::shared_ptr<PlayerInterface> (new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<BeRoInterface> > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) {
|
std::vector<boost::shared_ptr<BeRoInterface> > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
ClientEngineFactory();
|
ClientEngineFactory();
|
||||||
~ClientEngineFactory();
|
~ClientEngineFactory();
|
||||||
|
|
||||||
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC);
|
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > p, int id, int sP, int aP, int dP, int sB,int sC);
|
||||||
BoardInterface* createBoard();
|
BoardInterface* createBoard();
|
||||||
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);
|
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, int aP, int dP, int sB);
|
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC)
|
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > p, int id, int sP, int aP, int dP, int sB,int sC)
|
||||||
: myFactory(f), myGui(g), myBoard(b), playerArray(p), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0),
|
: myFactory(f), myGui(g), myBoard(b), playerArray(p), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0),
|
||||||
smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0),
|
smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0),
|
||||||
cardsShown(false), bettingRoundsPlayed(0)
|
cardsShown(false), bettingRoundsPlayed(0)
|
||||||
@@ -68,7 +68,7 @@ ClientHand::start()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerInterface**
|
std::vector<boost::shared_ptr<PlayerInterface> >
|
||||||
ClientHand::getPlayerArray() const
|
ClientHand::getPlayerArray() const
|
||||||
{
|
{
|
||||||
return playerArray;
|
return playerArray;
|
||||||
|
|||||||
@@ -32,12 +32,12 @@
|
|||||||
class ClientHand : public HandInterface
|
class ClientHand : public HandInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int );
|
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> > , int, int, int, int, int, int );
|
||||||
~ClientHand();
|
~ClientHand();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
PlayerInterface** getPlayerArray() const;
|
std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() const;
|
||||||
BoardInterface* getBoard() const;
|
BoardInterface* getBoard() const;
|
||||||
boost::shared_ptr<BeRoInterface> getPreflop() const;
|
boost::shared_ptr<BeRoInterface> getPreflop() const;
|
||||||
boost::shared_ptr<BeRoInterface> getFlop() const;
|
boost::shared_ptr<BeRoInterface> getFlop() const;
|
||||||
@@ -91,7 +91,7 @@ class ClientHand : public HandInterface
|
|||||||
boost::shared_ptr<EngineFactory> myFactory;
|
boost::shared_ptr<EngineFactory> myFactory;
|
||||||
GuiInterface *myGui;
|
GuiInterface *myGui;
|
||||||
BoardInterface *myBoard;
|
BoardInterface *myBoard;
|
||||||
PlayerInterface **playerArray;
|
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
|
||||||
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
|
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
|
||||||
|
|
||||||
int myID;
|
int myID;
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
|||||||
{
|
{
|
||||||
NetPacketEndOfGame::Data endData;
|
NetPacketEndOfGame::Data endData;
|
||||||
packet->ToNetPacketEndOfGame()->GetData(endData);
|
packet->ToNetPacketEndOfGame()->GetData(endData);
|
||||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
client.GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID());
|
client.GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID());
|
||||||
@@ -618,7 +618,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
{
|
{
|
||||||
NetPacketPlayersActionDone::Data actionDoneData;
|
NetPacketPlayersActionDone::Data actionDoneData;
|
||||||
packet->ToNetPacketPlayersActionDone()->GetData(actionDoneData);
|
packet->ToNetPacketPlayersActionDone()->GetData(actionDoneData);
|
||||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
@@ -667,7 +667,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
{
|
{
|
||||||
NetPacketPlayersTurn::Data turnData;
|
NetPacketPlayersTurn::Data turnData;
|
||||||
packet->ToNetPacketPlayersTurn()->GetData(turnData);
|
packet->ToNetPacketPlayersTurn()->GetData(turnData);
|
||||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
@@ -759,7 +759,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
|
|
||||||
while (i != end)
|
while (i != end)
|
||||||
{
|
{
|
||||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
@@ -786,7 +786,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
NetPacketEndOfHandHideCards::Data endHandData;
|
NetPacketEndOfHandHideCards::Data endHandData;
|
||||||
packet->ToNetPacketEndOfHandHideCards()->GetData(endHandData);
|
packet->ToNetPacketEndOfHandHideCards()->GetData(endHandData);
|
||||||
|
|
||||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
@@ -823,7 +823,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
int highestValueOfCards = 0;
|
int highestValueOfCards = 0;
|
||||||
while (i != end)
|
while (i != end)
|
||||||
{
|
{
|
||||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ ClientThread::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];
|
boost::shared_ptr<PlayerInterface> tmpPlayer = m_game->getPlayerArray()[i];
|
||||||
if (tmpPlayer->getMyActiveStatus())
|
if (tmpPlayer->getMyActiveStatus())
|
||||||
{
|
{
|
||||||
// If a player is not in the player data list, it was disconnected.
|
// If a player is not in the player data list, it was disconnected.
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ using namespace std;
|
|||||||
// Helper functions
|
// Helper functions
|
||||||
// TODO: these are hacks.
|
// TODO: these are hacks.
|
||||||
|
|
||||||
static PlayerInterface *GetCurrentPlayer(Game &curGame)
|
static boost::shared_ptr<PlayerInterface> GetCurrentPlayer(Game &curGame)
|
||||||
{
|
{
|
||||||
int curPlayerNum = curGame.getCurrentHand()->getCurrentBeRo()->getPlayersTurn();
|
int curPlayerNum = curGame.getCurrentHand()->getCurrentBeRo()->getPlayersTurn();
|
||||||
assert(curPlayerNum < curGame.getStartQuantityPlayers()); // TODO: throw exception
|
assert(curPlayerNum < curGame.getStartQuantityPlayers()); // TODO: throw exception
|
||||||
@@ -450,7 +450,7 @@ ServerRecvStateStartHand::Process(ServerRecvThread &server)
|
|||||||
curGame.getCurrentHand()->getTurn()->resetFirstRun();
|
curGame.getCurrentHand()->getTurn()->resetFirstRun();
|
||||||
curGame.getCurrentHand()->getRiver()->resetFirstRun();
|
curGame.getCurrentHand()->getRiver()->resetFirstRun();
|
||||||
|
|
||||||
PlayerInterface **playerArray = curGame.getPlayerArray();
|
std::vector<boost::shared_ptr<PlayerInterface> >playerArray = curGame.getPlayerArray();
|
||||||
|
|
||||||
// Send cards to all players.
|
// Send cards to all players.
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers(); i++)
|
for (int i = 0; i < curGame.getStartQuantityPlayers(); i++)
|
||||||
@@ -595,7 +595,7 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server)
|
|||||||
assert (!curGame.getCurrentHand()->getAllInCondition()); // this would be an error.
|
assert (!curGame.getCurrentHand()->getAllInCondition()); // this would be an error.
|
||||||
|
|
||||||
// Retrieve current player.
|
// Retrieve current player.
|
||||||
PlayerInterface *curPlayer = GetCurrentPlayer(curGame);
|
boost::shared_ptr<PlayerInterface> curPlayer = GetCurrentPlayer(curGame);
|
||||||
assert(curPlayer); // TODO throw exception
|
assert(curPlayer); // TODO throw exception
|
||||||
assert(curPlayer->getMyActiveStatus()); // TODO throw exception
|
assert(curPlayer->getMyActiveStatus()); // TODO throw exception
|
||||||
|
|
||||||
@@ -696,10 +696,10 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server)
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<PlayerInterface *>
|
std::list<boost::shared_ptr<PlayerInterface> >
|
||||||
ServerRecvStateStartRound::GetActivePlayers(Game &curGame)
|
ServerRecvStateStartRound::GetActivePlayers(Game &curGame)
|
||||||
{
|
{
|
||||||
std::list<PlayerInterface *> activePlayers;
|
std::list<boost::shared_ptr<PlayerInterface> > activePlayers;
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers() ; i++)
|
for (int i = 0; i < curGame.getStartQuantityPlayers() ; i++)
|
||||||
{
|
{
|
||||||
if (curGame.getPlayerArray()[i]->getMyActiveStatus()
|
if (curGame.getPlayerArray()[i]->getMyActiveStatus()
|
||||||
@@ -733,7 +733,7 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
|
|||||||
{
|
{
|
||||||
int retVal;
|
int retVal;
|
||||||
|
|
||||||
PlayerInterface *tmpPlayer = GetCurrentPlayer(server.GetGame());
|
boost::shared_ptr<PlayerInterface> tmpPlayer = GetCurrentPlayer(server.GetGame());
|
||||||
assert(tmpPlayer);
|
assert(tmpPlayer);
|
||||||
assert(!tmpPlayer->getMyName().empty());
|
assert(!tmpPlayer->getMyName().empty());
|
||||||
|
|
||||||
|
|||||||
@@ -468,7 +468,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];
|
boost::shared_ptr<PlayerInterface> tmpPlayer = m_game->getPlayerArray()[i];
|
||||||
if (!IsPlayerConnected(tmpPlayer->getMyUniqueID()) && tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN)
|
if (!IsPlayerConnected(tmpPlayer->getMyUniqueID()) && tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN)
|
||||||
{
|
{
|
||||||
tmpPlayer->setMyCash(0);
|
tmpPlayer->setMyCash(0);
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ protected:
|
|||||||
// Protected constructor - this is a singleton.
|
// Protected constructor - this is a singleton.
|
||||||
ServerRecvStateStartRound();
|
ServerRecvStateStartRound();
|
||||||
|
|
||||||
static std::list<PlayerInterface *> GetActivePlayers(Game &curGame);
|
static std::list<boost::shared_ptr<PlayerInterface> > GetActivePlayers(Game &curGame);
|
||||||
};
|
};
|
||||||
|
|
||||||
// State: Wait for a player action.
|
// State: Wait for a player action.
|
||||||
|
|||||||
Reference in New Issue
Block a user