adds activePlayerList and runningPlayerList

This commit is contained in:
doitux
2007-09-23 21:30:51 +00:00
parent 8f029d2ea4
commit 84c857cbff
16 changed files with 74 additions and 34 deletions
+4 -1
View File
@@ -21,18 +21,21 @@
#define BOARDINTERFACE_H #define BOARDINTERFACE_H
#include <vector> #include <vector>
#include <list>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
class PlayerInterface; class PlayerInterface;
class HandInterface; class HandInterface;
typedef std::list<boost::shared_ptr<PlayerInterface> > PlayerList;
class BoardInterface { class BoardInterface {
public: public:
virtual ~BoardInterface(); virtual ~BoardInterface();
// //
virtual void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >) =0; virtual void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList) =0;
virtual void setHand(HandInterface*) =0; virtual void setHand(HandInterface*) =0;
// //
virtual void setMyCards(int* theValue) =0; virtual void setMyCards(int* theValue) =0;
+1 -1
View File
@@ -33,7 +33,7 @@ public:
virtual ~EngineFactory(); virtual ~EngineFactory();
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 HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) =0;
virtual BoardInterface* createBoard() =0; virtual BoardInterface* createBoard() =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 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;
+5 -1
View File
@@ -33,7 +33,11 @@ LocalBoard::~LocalBoard()
{ {
} }
void LocalBoard::setPlayer(std::vector<boost::shared_ptr<PlayerInterface> > p) { playerArray = p; } void LocalBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl) {
playerArray = sl;
activePlayerList = apl;
runningPlayerList = rpl;
}
void LocalBoard::setHand(HandInterface* br) { currentHand = br; } void LocalBoard::setHand(HandInterface* br) { currentHand = br; }
+4 -1
View File
@@ -35,7 +35,7 @@ public:
LocalBoard(); LocalBoard();
~LocalBoard(); ~LocalBoard();
void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >); void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList);
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]; }
@@ -54,6 +54,9 @@ public:
private: private:
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
HandInterface *currentHand; HandInterface *currentHand;
int myCards[5]; int myCards[5];
@@ -42,7 +42,7 @@ LocalEngineFactory::~LocalEngineFactory()
} }
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); } HandInterface* LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) { return new LocalHand(f, g, b, sl, apl, rpl, id, sP, aP, dP, sB, sC); }
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
+1 -1
View File
@@ -37,7 +37,7 @@ public:
LocalEngineFactory(ConfigFile*); LocalEngineFactory(ConfigFile*);
~LocalEngineFactory(); ~LocalEngineFactory();
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); HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, 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);
+4 -4
View File
@@ -26,8 +26,8 @@
using namespace std; using namespace std;
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) LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, 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(sl), activePlayerList(apl), runningPlayerList(rpl), 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)
{ {
@@ -50,8 +50,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
} }
// Karten generieren und Board sowie Player zuweisen // Karten generieren und Board sowie Player zuweisen
int *cardsArray = new int[2*actualQuantityPlayers+5]; int *cardsArray = new int[2*activePlayerList.size()+5];
Tools::getRandNumber(0, 51, 2*actualQuantityPlayers+5, cardsArray, 1); Tools::getRandNumber(0, 51, 2*activePlayerList.size()+5, cardsArray, 1);
int tempBoardArray[5]; int tempBoardArray[5];
int tempPlayerArray[2]; int tempPlayerArray[2];
int tempPlayerAndBoardArray[7]; int tempPlayerAndBoardArray[7];
+5 -1
View File
@@ -34,7 +34,7 @@
class LocalHand : public HandInterface{ class LocalHand : public HandInterface{
public: public:
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, int, int, int, int, int, int); LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, int, int, int, int, int, int);
~LocalHand(); ~LocalHand();
void start(); void start();
@@ -94,7 +94,11 @@ private:
boost::shared_ptr<EngineFactory> myFactory; boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui; GuiInterface *myGui;
BoardInterface *myBoard; BoardInterface *myBoard;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID; int myID;
+4 -2
View File
@@ -34,10 +34,12 @@ ClientBoard::~ClientBoard()
} }
void void
ClientBoard::setPlayer(std::vector<boost::shared_ptr<PlayerInterface> > p) ClientBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
playerArray = p; playerArray = sl;
activePlayerList = apl;
runningPlayerList = rpl;
} }
void void
+4 -1
View File
@@ -34,7 +34,7 @@ public:
ClientBoard(); ClientBoard();
~ClientBoard(); ~ClientBoard();
void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >); void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList);
void setHand(HandInterface*); void setHand(HandInterface*);
void setMyCards(int* theValue); void setMyCards(int* theValue);
@@ -54,6 +54,9 @@ private:
mutable boost::recursive_mutex m_syncMutex; mutable boost::recursive_mutex m_syncMutex;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
HandInterface *actualHand; HandInterface *actualHand;
int myCards[5]; int myCards[5];
@@ -35,9 +35,9 @@ ClientEngineFactory::~ClientEngineFactory()
} }
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) HandInterface* ClientEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, 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, sl, apl, rpl, id, sP, aP, dP, sB, sC);
} }
BoardInterface* ClientEngineFactory::createBoard() BoardInterface* ClientEngineFactory::createBoard()
@@ -37,7 +37,7 @@ public:
ClientEngineFactory(); ClientEngineFactory();
~ClientEngineFactory(); ~ClientEngineFactory();
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); HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, 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);
+2 -2
View File
@@ -21,8 +21,8 @@
using namespace std; using namespace std;
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) ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl, 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(sl), activePlayerList(apl), runningPlayerList(rpl), 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)
{ {
+5 -1
View File
@@ -32,7 +32,7 @@
class ClientHand : public HandInterface class ClientHand : public HandInterface
{ {
public: public:
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> > , int, int, int, int, int, int ); ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList , int, int, int, int, int, int );
~ClientHand(); ~ClientHand();
void start(); void start();
@@ -91,7 +91,11 @@ class ClientHand : public HandInterface
boost::shared_ptr<EngineFactory> myFactory; boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui; GuiInterface *myGui;
BoardInterface *myBoard; BoardInterface *myBoard;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID; int myID;
+21 -12
View File
@@ -92,14 +92,23 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
++player_i; ++player_i;
} }
//PlayerObjekte erzeugen // create Player Objects
playerArray.push_back(myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0)); boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
// fill player lists
playerArray.push_back(tmpPlayer);
if(startQuantityPlayers > i) {
activePlayerList.push_back(tmpPlayer);
runningPlayerList.push_back(tmpPlayer);
}
// playerArray[i] = 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->setPlayerLists(playerArray, activePlayerList, runningPlayerList);
} }
@@ -140,18 +149,18 @@ void Game::initHand()
// smallBlind alle x Runden erhöhen // smallBlind alle x Runden erhöhen
if((actualHandID-1)%startHandsBeforeRaiseSmallBlind == 0 && actualHandID > 1) { actualSmallBlind *= 2; } if((actualHandID-1)%startHandsBeforeRaiseSmallBlind == 0 && actualHandID > 1) { actualSmallBlind *= 2; }
// Spieler mit leerem Cash auf inactive setzen // Spieler mit leerem Cash auf inactive setzen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { PlayerList::iterator it;
if(playerArray[i]->getMyCash() == 0) playerArray[i]->setMyActiveStatus(0);
for(it = activePlayerList.begin(); it != activePlayerList.end(); it++) {
if((*it)->getMyCash() == 0) {
(*it)->setMyActiveStatus(0);
it = activePlayerList.erase(it);
}
} }
// Anzahl noch aktiver Spieler ermitteln // Anzahl noch aktiver Spieler ermitteln
actualQuantityPlayers = 0; actualQuantityPlayers = activePlayerList.size(); // TODO -> delete !!!
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(playerArray[i]->getMyActiveStatus()) actualQuantityPlayers++;
}
//Spieler Action auf 0 setzen //Spieler Action auf 0 setzen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
@@ -159,7 +168,7 @@ void Game::initHand()
} }
// Hand erstellen // Hand erstellen
actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, actualHandID, startQuantityPlayers, actualQuantityPlayers, dealerPosition, actualSmallBlind, startCash); actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, actualQuantityPlayers, dealerPosition, actualSmallBlind, startCash);
// Dealer-Button weiterschieben --> Achtung inactive // Dealer-Button weiterschieben --> Achtung inactive
+9 -1
View File
@@ -35,6 +35,8 @@ class EngineFactory;
struct GameData; struct GameData;
struct StartData; struct StartData;
typedef std::list<boost::shared_ptr<PlayerInterface> > PlayerList;
class Game { class Game {
public: public:
@@ -51,6 +53,8 @@ public:
const HandInterface *getCurrentHand() const; const HandInterface *getCurrentHand() const;
std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() {return playerArray;} std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() {return playerArray;}
std::list<boost::shared_ptr<PlayerInterface> > getActivePlayerList() {return activePlayerList;}
std::list<boost::shared_ptr<PlayerInterface> > getRunningPlayerList() {return runningPlayerList;}
//Zufgriff Startvariablen //Zufgriff Startvariablen
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; }
@@ -83,7 +87,11 @@ private:
GuiInterface *myGui; GuiInterface *myGui;
HandInterface *actualHand; HandInterface *actualHand;
BoardInterface *actualBoard; BoardInterface *actualBoard;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; // available seats --> seatList !!! TODO
std::list<boost::shared_ptr<PlayerInterface> > activePlayerList; // used seats
std::list<boost::shared_ptr<PlayerInterface> > runningPlayerList; // nonfolded and nonallin active players
// boost::shared_ptr<PlayerInterface> playerArray[MAX_NUMBER_OF_PLAYERS]; // boost::shared_ptr<PlayerInterface> playerArray[MAX_NUMBER_OF_PLAYERS];
//Startvariablen //Startvariablen