This commit is contained in:
doitux
2007-08-10 23:34:56 +00:00
parent a9a2d33e3f
commit 7a0ae803e2
12 changed files with 28 additions and 26 deletions
@@ -46,7 +46,7 @@ HandInterface* LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f
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) {
+1 -1
View File
@@ -34,7 +34,7 @@ ClientBoard::~ClientBoard()
}
void
ClientBoard::setPlayer(PlayerInterface** p)
ClientBoard::setPlayer(std::vector<boost::shared_ptr<PlayerInterface> > p)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playerArray = p;
+4 -2
View File
@@ -21,6 +21,8 @@
#include <boardinterface.h>
#include <boost/thread.hpp>
#include <vector>
class PlayerInterface;
class HandInterface;
@@ -32,7 +34,7 @@ public:
ClientBoard();
~ClientBoard();
void setPlayer(PlayerInterface**);
void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >);
void setHand(HandInterface*);
void setMyCards(int* theValue);
@@ -51,7 +53,7 @@ public:
private:
mutable boost::recursive_mutex m_syncMutex;
PlayerInterface **playerArray;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
HandInterface *actualHand;
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)
{
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) {
@@ -37,7 +37,7 @@ public:
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();
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);
+2 -2
View File
@@ -21,7 +21,7 @@
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),
smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0)
@@ -68,7 +68,7 @@ ClientHand::start()
{
}
PlayerInterface**
std::vector<boost::shared_ptr<PlayerInterface> >
ClientHand::getPlayerArray() const
{
return playerArray;
+3 -3
View File
@@ -32,12 +32,12 @@
class ClientHand : public HandInterface
{
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();
void start();
PlayerInterface** getPlayerArray() const;
std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() const;
BoardInterface* getBoard() const;
boost::shared_ptr<BeRoInterface> getPreflop() const;
boost::shared_ptr<BeRoInterface> getFlop() const;
@@ -91,7 +91,7 @@ class ClientHand : public HandInterface
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
BoardInterface *myBoard;
PlayerInterface **playerArray;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID;
+6 -6
View File
@@ -575,7 +575,7 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptr<Net
{
NetPacketEndOfGame::Data endData;
packet->ToNetPacketEndOfGame()->GetData(endData);
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId);
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId);
if (!tmpPlayer)
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
client.GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID());
@@ -618,7 +618,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
{
NetPacketPlayersActionDone::Data actionDoneData;
packet->ToNetPacketPlayersActionDone()->GetData(actionDoneData);
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId);
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId);
if (!tmpPlayer)
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
@@ -667,7 +667,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
{
NetPacketPlayersTurn::Data turnData;
packet->ToNetPacketPlayersTurn()->GetData(turnData);
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId);
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId);
if (!tmpPlayer)
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
@@ -759,7 +759,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
while (i != end)
{
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
if (!tmpPlayer)
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
@@ -786,7 +786,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
NetPacketEndOfHandHideCards::Data endHandData;
packet->ToNetPacketEndOfHandHideCards()->GetData(endHandData);
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId);
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId);
if (!tmpPlayer)
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
@@ -823,7 +823,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
int highestValueOfCards = 0;
while (i != end)
{
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
if (!tmpPlayer)
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
+1 -1
View File
@@ -418,7 +418,7 @@ ClientThread::RemoveDisconnectedPlayers()
{
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 a player is not in the player data list, it was disconnected.
+6 -6
View File
@@ -45,7 +45,7 @@ using namespace std;
// Helper functions
// TODO: these are hacks.
static PlayerInterface *GetCurrentPlayer(Game &curGame)
static boost::shared_ptr<PlayerInterface> GetCurrentPlayer(Game &curGame)
{
int curPlayerNum = curGame.getCurrentHand()->getCurrentBeRo()->getPlayersTurn();
assert(curPlayerNum < curGame.getStartQuantityPlayers()); // TODO: throw exception
@@ -450,7 +450,7 @@ ServerRecvStateStartHand::Process(ServerRecvThread &server)
curGame.getCurrentHand()->getTurn()->resetFirstRun();
curGame.getCurrentHand()->getRiver()->resetFirstRun();
PlayerInterface **playerArray = curGame.getPlayerArray();
std::vector<boost::shared_ptr<PlayerInterface> >playerArray = curGame.getPlayerArray();
// Send cards to all players.
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.
// Retrieve current player.
PlayerInterface *curPlayer = GetCurrentPlayer(curGame);
boost::shared_ptr<PlayerInterface> curPlayer = GetCurrentPlayer(curGame);
assert(curPlayer); // TODO throw exception
assert(curPlayer->getMyActiveStatus()); // TODO throw exception
@@ -696,10 +696,10 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server)
return retVal;
}
std::list<PlayerInterface *>
std::list<boost::shared_ptr<PlayerInterface> >
ServerRecvStateStartRound::GetActivePlayers(Game &curGame)
{
std::list<PlayerInterface *> activePlayers;
std::list<boost::shared_ptr<PlayerInterface> > activePlayers;
for (int i = 0; i < curGame.getStartQuantityPlayers() ; i++)
{
if (curGame.getPlayerArray()[i]->getMyActiveStatus()
@@ -733,7 +733,7 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
{
int retVal;
PlayerInterface *tmpPlayer = GetCurrentPlayer(server.GetGame());
boost::shared_ptr<PlayerInterface> tmpPlayer = GetCurrentPlayer(server.GetGame());
assert(tmpPlayer);
assert(!tmpPlayer->getMyName().empty());
+1 -1
View File
@@ -468,7 +468,7 @@ ServerRecvThread::RemoveDisconnectedPlayers()
{
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)
{
tmpPlayer->setMyCash(0);
+1 -1
View File
@@ -184,7 +184,7 @@ protected:
// Protected constructor - this is a singleton.
ServerRecvStateStartRound();
static std::list<PlayerInterface *> GetActivePlayers(Game &curGame);
static std::list<boost::shared_ptr<PlayerInterface> > GetActivePlayers(Game &curGame);
};
// State: Wait for a player action.