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
#include <vector>
#include <list>
#include <boost/shared_ptr.hpp>
class PlayerInterface;
class HandInterface;
typedef std::list<boost::shared_ptr<PlayerInterface> > PlayerList;
class BoardInterface {
public:
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 setMyCards(int* theValue) =0;
+1 -1
View File
@@ -33,7 +33,7 @@ public:
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 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;
+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; }
+4 -1
View File
@@ -35,7 +35,7 @@ public:
LocalBoard();
~LocalBoard();
void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >);
void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList);
void setHand(HandInterface*);
void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; }
@@ -54,6 +54,9 @@ public:
private:
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
HandInterface *currentHand;
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; }
+1 -1
View File
@@ -37,7 +37,7 @@ public:
LocalEngineFactory(ConfigFile*);
~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();
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);
+4 -4
View File
@@ -26,8 +26,8 @@
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)
: 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),
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(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)
{
@@ -50,8 +50,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
}
// Karten generieren und Board sowie Player zuweisen
int *cardsArray = new int[2*actualQuantityPlayers+5];
Tools::getRandNumber(0, 51, 2*actualQuantityPlayers+5, cardsArray, 1);
int *cardsArray = new int[2*activePlayerList.size()+5];
Tools::getRandNumber(0, 51, 2*activePlayerList.size()+5, cardsArray, 1);
int tempBoardArray[5];
int tempPlayerArray[2];
int tempPlayerAndBoardArray[7];
+5 -1
View File
@@ -34,7 +34,7 @@
class LocalHand : public HandInterface{
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();
void start();
@@ -94,7 +94,11 @@ private:
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
BoardInterface *myBoard;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID;
+4 -2
View File
@@ -34,10 +34,12 @@ ClientBoard::~ClientBoard()
}
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);
playerArray = p;
playerArray = sl;
activePlayerList = apl;
runningPlayerList = rpl;
}
void
+4 -1
View File
@@ -34,7 +34,7 @@ public:
ClientBoard();
~ClientBoard();
void setPlayer(std::vector<boost::shared_ptr<PlayerInterface> >);
void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList);
void setHand(HandInterface*);
void setMyCards(int* theValue);
@@ -54,6 +54,9 @@ private:
mutable boost::recursive_mutex m_syncMutex;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
HandInterface *actualHand;
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()
@@ -37,7 +37,7 @@ public:
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();
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,8 +21,8 @@
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)
: myFactory(f), myGui(g), myBoard(b), playerArray(p), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0),
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(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),
cardsShown(false), bettingRoundsPlayed(0)
{
+5 -1
View File
@@ -32,7 +32,7 @@
class ClientHand : public HandInterface
{
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();
void start();
@@ -91,7 +91,11 @@ class ClientHand : public HandInterface
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
BoardInterface *myBoard;
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
PlayerList activePlayerList;
PlayerList runningPlayerList;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID;
+22 -13
View File
@@ -92,14 +92,23 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
++player_i;
}
//PlayerObjekte erzeugen
playerArray.push_back(myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0));
// create Player Objects
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]->setNetSessionData(myNetSession);
}
actualBoard->setPlayer(playerArray);
actualBoard->setPlayerLists(playerArray, activePlayerList, runningPlayerList);
}
@@ -140,26 +149,26 @@ void Game::initHand()
// smallBlind alle x Runden erhöhen
if((actualHandID-1)%startHandsBeforeRaiseSmallBlind == 0 && actualHandID > 1) { actualSmallBlind *= 2; }
// Spieler mit leerem Cash auf inactive setzen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(playerArray[i]->getMyCash() == 0) playerArray[i]->setMyActiveStatus(0);
PlayerList::iterator it;
for(it = activePlayerList.begin(); it != activePlayerList.end(); it++) {
if((*it)->getMyCash() == 0) {
(*it)->setMyActiveStatus(0);
it = activePlayerList.erase(it);
}
}
// Anzahl noch aktiver Spieler ermitteln
actualQuantityPlayers = 0;
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
if(playerArray[i]->getMyActiveStatus()) actualQuantityPlayers++;
}
actualQuantityPlayers = activePlayerList.size(); // TODO -> delete !!!
//Spieler Action auf 0 setzen
//Spieler Action auf 0 setzen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
playerArray[i]->setMyAction(0);
}
// 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
+9 -1
View File
@@ -35,6 +35,8 @@ class EngineFactory;
struct GameData;
struct StartData;
typedef std::list<boost::shared_ptr<PlayerInterface> > PlayerList;
class Game {
public:
@@ -51,6 +53,8 @@ public:
const HandInterface *getCurrentHand() const;
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
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; }
@@ -83,7 +87,11 @@ private:
GuiInterface *myGui;
HandInterface *actualHand;
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];
//Startvariablen