This commit is contained in:
doitux
2007-08-10 23:16:21 +00:00
parent 8319442b6a
commit a9a2d33e3f
13 changed files with 48 additions and 33 deletions
+4 -1
View File
@@ -20,6 +20,9 @@
#ifndef BOARDINTERFACE_H #ifndef BOARDINTERFACE_H
#define BOARDINTERFACE_H #define BOARDINTERFACE_H
#include <vector>
#include <boost/shared_ptr.hpp>
class PlayerInterface; class PlayerInterface;
class HandInterface; class HandInterface;
@@ -29,7 +32,7 @@ public:
virtual ~BoardInterface(); virtual ~BoardInterface();
// //
virtual void setPlayer(PlayerInterface**) =0; virtual void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >) =0;
virtual void setHand(HandInterface*) =0; virtual void setHand(HandInterface*) =0;
// //
virtual void setMyCards(int* theValue) =0; virtual void setMyCards(int* theValue) =0;
+2 -2
View File
@@ -33,9 +33,9 @@ public:
virtual ~EngineFactory(); virtual ~EngineFactory();
virtual 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) =0; virtual 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) =0;
virtual BoardInterface* createBoard() =0; virtual BoardInterface* createBoard() =0;
virtual PlayerInterface* createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0; virtual 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) =0;
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) =0; virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) =0;
}; };
+1 -1
View File
@@ -36,7 +36,7 @@ public:
virtual void start() = 0; virtual void start() = 0;
virtual PlayerInterface** getPlayerArray() const =0; virtual std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() const =0;
virtual BoardInterface* getBoard() const =0; virtual BoardInterface* getBoard() const =0;
virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0; virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0;
virtual boost::shared_ptr<BeRoInterface> getFlop() const =0; virtual boost::shared_ptr<BeRoInterface> getFlop() const =0;
+1 -1
View File
@@ -33,7 +33,7 @@ LocalBoard::~LocalBoard()
{ {
} }
void LocalBoard::setPlayer(PlayerInterface** p) { playerArray = p; } void LocalBoard::setPlayer(std::vector<boost::shared_ptr<PlayerInterface> > p) { playerArray = p; }
void LocalBoard::setHand(HandInterface* br) { currentHand = br; } void LocalBoard::setHand(HandInterface* br) { currentHand = br; }
+3 -2
View File
@@ -22,6 +22,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <boost/shared_ptr.hpp>
#include <boardinterface.h> #include <boardinterface.h>
@@ -34,7 +35,7 @@ public:
LocalBoard(); LocalBoard();
~LocalBoard(); ~LocalBoard();
void setPlayer(PlayerInterface**); void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >);
void setHand(HandInterface*); void setHand(HandInterface*);
void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; } void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; }
@@ -52,7 +53,7 @@ public:
private: private:
PlayerInterface **playerArray; std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
HandInterface *currentHand; HandInterface *currentHand;
int myCards[5]; int myCards[5];
@@ -42,11 +42,11 @@ LocalEngineFactory::~LocalEngineFactory()
} }
HandInterface* LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) { return new LocalHand(f, g, b, p, id, sP, aP, dP, sB, sC); } HandInterface* LocalEngineFactory::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) { return new LocalHand(f, g, b, p, id, sP, aP, dP, sB, sC); }
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
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 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) {
+5 -2
View File
@@ -26,6 +26,9 @@
#include <boardinterface.h> #include <boardinterface.h>
#include <playerinterface.h> #include <playerinterface.h>
#include <boost/shared_ptr.hpp>
#include <vector>
class ConfigFile; class ConfigFile;
class LocalEngineFactory : public EngineFactory class LocalEngineFactory : public EngineFactory
@@ -34,9 +37,9 @@ public:
LocalEngineFactory(ConfigFile*); LocalEngineFactory(ConfigFile*);
~LocalEngineFactory(); ~LocalEngineFactory();
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();
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);
private: private:
+1 -1
View File
@@ -26,7 +26,7 @@
using namespace std; using namespace std;
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) LocalHand::LocalHand(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), myBeRo(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0), : myFactory(f), myGui(g), myBoard(b), playerArray(p), myBeRo(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0) cardsShown(false), bettingRoundsPlayed(0)
{ {
+3 -3
View File
@@ -34,12 +34,12 @@
class LocalHand : public HandInterface{ class LocalHand : public HandInterface{
public: public:
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int); LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, int, int, int, int, int, int);
~LocalHand(); ~LocalHand();
void start(); void start();
PlayerInterface** getPlayerArray() const { return playerArray; } std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() const { return playerArray; }
BoardInterface* getBoard() const { return myBoard; } BoardInterface* getBoard() const { return myBoard; }
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; } boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; } boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
@@ -94,7 +94,7 @@ private:
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;
@@ -35,7 +35,7 @@ ClientEngineFactory::~ClientEngineFactory()
} }
HandInterface* ClientEngineFactory::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* ClientEngineFactory::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)
{ {
return new ClientHand(f, g, b, p, id, sP, aP, dP, sB, sC); return new ClientHand(f, g, b, p, id, sP, aP, dP, sB, sC);
} }
@@ -45,7 +45,7 @@ BoardInterface* ClientEngineFactory::createBoard()
return new ClientBoard; return new ClientBoard;
} }
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 new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB);
} }
@@ -25,6 +25,10 @@
#include <boardinterface.h> #include <boardinterface.h>
#include <playerinterface.h> #include <playerinterface.h>
#include <boost/shared_ptr.hpp>
#include <vector>
class ConfigFile; class ConfigFile;
class ClientEngineFactory : public EngineFactory class ClientEngineFactory : public EngineFactory
@@ -35,7 +39,7 @@ public:
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, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC);
BoardInterface* createBoard(); BoardInterface* createBoard();
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);
}; };
+15 -12
View File
@@ -43,9 +43,9 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
actualHandID = 0; actualHandID = 0;
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { // for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
playerArray[i] = 0; // playerArray[i] = 0;
} // }
// Dealer Position bestimmen // Dealer Position bestimmen
PlayerDataList::const_iterator player_i = playerDataList.begin(); PlayerDataList::const_iterator player_i = playerDataList.begin();
@@ -93,7 +93,10 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
} }
//PlayerObjekte erzeugen //PlayerObjekte erzeugen
playerArray[i] = myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0); playerArray.push_back(myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0));
// playerArray[i] = myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
playerArray[i]->setNetSessionData(myNetSession); playerArray[i]->setNetSessionData(myNetSession);
} }
actualBoard->setPlayer(playerArray); actualBoard->setPlayer(playerArray);
@@ -110,12 +113,12 @@ Game::~Game()
delete actualHand; delete actualHand;
actualHand = 0; actualHand = 0;
PlayerInterface *tempPlayer; // PlayerInterface *tempPlayer;
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { // for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
tempPlayer = playerArray[i]; // tempPlayer = playerArray[i];
playerArray[i] = 0; // playerArray[i] = 0;
delete tempPlayer; // delete tempPlayer;
} // }
} }
@@ -183,9 +186,9 @@ void Game::startHand()
actualHand->start(); actualHand->start();
} }
PlayerInterface *Game::getPlayerByUniqueId(unsigned id) boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
{ {
PlayerInterface *tmpPlayer = NULL; boost::shared_ptr<PlayerInterface> tmpPlayer;
for (int i = 0; i < startQuantityPlayers; i++) for (int i = 0; i < startQuantityPlayers; i++)
{ {
if (playerArray[i]->getMyUniqueID() == id) if (playerArray[i]->getMyUniqueID() == id)
+4 -3
View File
@@ -49,7 +49,7 @@ public:
HandInterface *getCurrentHand(); HandInterface *getCurrentHand();
PlayerInterface** getPlayerArray() {return playerArray;} std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() {return playerArray;}
//Zufgriff Startvariablen //Zufgriff Startvariablen
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; }
@@ -73,7 +73,7 @@ public:
void setActualHandID(int theValue) { actualHandID = theValue; } void setActualHandID(int theValue) { actualHandID = theValue; }
int getActualHandID() const { return actualHandID; } int getActualHandID() const { return actualHandID; }
PlayerInterface * getPlayerByUniqueId(unsigned id); boost::shared_ptr<PlayerInterface> getPlayerByUniqueId(unsigned id);
private: private:
boost::shared_ptr<EngineFactory> myFactory; boost::shared_ptr<EngineFactory> myFactory;
@@ -81,7 +81,8 @@ private:
GuiInterface *myGui; GuiInterface *myGui;
HandInterface *actualHand; HandInterface *actualHand;
BoardInterface *actualBoard; BoardInterface *actualBoard;
PlayerInterface *playerArray[MAX_NUMBER_OF_PLAYERS]; std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
// PlayerInterface *playerArray[MAX_NUMBER_OF_PLAYERS];
//Startvariablen //Startvariablen
int startQuantityPlayers; int startQuantityPlayers;