adds activePlayerList and runningPlayerList (XVII) - !!! network-BROKEN !!!
This commit is contained in:
@@ -37,7 +37,7 @@ public:
|
||||
|
||||
virtual ~BoardInterface();
|
||||
//
|
||||
virtual void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList) =0;
|
||||
virtual void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, PlayerList) =0;
|
||||
virtual void setHand(HandInterface*) =0;
|
||||
//
|
||||
virtual void setMyCards(int* theValue) =0;
|
||||
|
||||
@@ -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> > sl, PlayerList apl, PlayerList rpl, int id, int sP, 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_old, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, 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, unsigned dP, int sB) =0;
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
virtual PlayerList getActivePlayerList() const =0;
|
||||
virtual PlayerList getRunningPlayerList() const =0;
|
||||
|
||||
virtual PlayerListIterator getSeatIt(unsigned) const =0;
|
||||
virtual PlayerListIterator getActivePlayerIt(unsigned) const =0;
|
||||
virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0;
|
||||
|
||||
|
||||
@@ -33,8 +33,9 @@ LocalBoard::~LocalBoard()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl) {
|
||||
playerArray = sl;
|
||||
void LocalBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl) {
|
||||
playerArray = sl_old; // delete
|
||||
seatsList = sl;
|
||||
activePlayerList = apl;
|
||||
runningPlayerList = rpl;
|
||||
}
|
||||
@@ -44,32 +45,57 @@ void LocalBoard::setHand(HandInterface* br) { currentHand = br; }
|
||||
void LocalBoard::collectSets() {
|
||||
|
||||
sets = 0;
|
||||
int i;
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) sets += playerArray[i]->getMySet();
|
||||
// int i;
|
||||
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) sets += playerArray[i]->getMySet(); //delete
|
||||
|
||||
PlayerListConstIterator it_c;
|
||||
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
|
||||
sets += (*it_c)->getMySet();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LocalBoard::collectPot() {
|
||||
int i;
|
||||
// int i;
|
||||
pot += sets;
|
||||
sets = 0;
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++){ playerArray[i]->setMySetNull(); }
|
||||
// for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++){ playerArray[i]->setMySetNull(); }
|
||||
|
||||
PlayerListIterator it;
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
(*it)->setMySetNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LocalBoard::distributePot() {
|
||||
|
||||
size_t i,j,k,l;
|
||||
PlayerListIterator it;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
// filling player sets vector
|
||||
// vector<int> playerSets;
|
||||
// for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
// if(playerArray[i]->getMyActiveStatus()) {
|
||||
// playerSets.push_back(((playerArray[i]->getMyRoundStartCash())-(playerArray[i]->getMyCash())));
|
||||
// } else {
|
||||
// playerSets.push_back(0);
|
||||
// }
|
||||
// }
|
||||
|
||||
// filling player sets vector
|
||||
vector<int> playerSets;
|
||||
for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if(playerArray[i]->getMyActiveStatus()) {
|
||||
playerSets.push_back(((playerArray[i]->getMyRoundStartCash())-(playerArray[i]->getMyCash())));
|
||||
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++) {
|
||||
if((*it_c)->getMyActiveStatus()) {
|
||||
playerSets.push_back( ( ((*it_c)->getMyRoundStartCash()) - ((*it_c)->getMyCash()) ) );
|
||||
} else {
|
||||
playerSets.push_back(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sort player sets asc
|
||||
vector<int> playerSetsSort = playerSets;
|
||||
sort(playerSetsSort.begin(), playerSetsSort.end());
|
||||
@@ -100,29 +126,51 @@ void LocalBoard::distributePot() {
|
||||
potLevel.push_back((playerSetsSort.size()-i)*potLevel[0]);
|
||||
|
||||
// determine level highestCardsValue
|
||||
for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
|
||||
// for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
|
||||
// if(playerArray[j]->getMyCardsValueInt() > highestCardsValue && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
||||
// highestCardsValue = playerArray[j]->getMyCardsValueInt();
|
||||
// }
|
||||
// }
|
||||
|
||||
if(playerArray[j]->getMyCardsValueInt() > highestCardsValue && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
||||
highestCardsValue = playerArray[j]->getMyCardsValueInt();
|
||||
// determine level highestCardsValue
|
||||
j=0;
|
||||
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++,j++) {
|
||||
if((*it_c)->getMyActiveStatus() && (*it_c)->getMyCardsValueInt() > highestCardsValue && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
||||
highestCardsValue = (*it_c)->getMyCardsValueInt();
|
||||
}
|
||||
}
|
||||
|
||||
// level winners
|
||||
for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
|
||||
if(highestCardsValue == playerArray[j]->getMyCardsValueInt() && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
||||
potLevel.push_back(playerArray[j]->getMyID());
|
||||
// for(j=0; j<MAX_NUMBER_OF_PLAYERS; j++) {
|
||||
// if(highestCardsValue == playerArray[j]->getMyCardsValueInt() && playerArray[j]->getMyActiveStatus() && playerArray[j]->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
||||
// potLevel.push_back(playerArray[j]->getMyID());
|
||||
// }
|
||||
// }
|
||||
|
||||
// level winners
|
||||
j=0;
|
||||
for(it_c=seatsList->begin(); it_c!=seatsList->end(); it_c++,j++) {
|
||||
if((*it_c)->getMyActiveStatus() && highestCardsValue == (*it_c)->getMyCardsValueInt() && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) {
|
||||
potLevel.push_back((*it_c)->getMyUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
// determine the number of level winners
|
||||
winnerCount = potLevel.size()-2;
|
||||
assert(winnerCount);
|
||||
|
||||
// distribute the pot level sum to level winners
|
||||
mod = (potLevel[1])%winnerCount;
|
||||
// pot level sum divisible by winnerCount
|
||||
if(mod == 0) {
|
||||
// for(j=2; j<potLevel.size(); j++) {
|
||||
// playerArray[potLevel[j]]->setMyCash(playerArray[potLevel[j]]->getMyCash() + ((potLevel[1])/winnerCount));
|
||||
// }
|
||||
|
||||
for(j=2; j<potLevel.size(); j++) {
|
||||
playerArray[potLevel[j]]->setMyCash(playerArray[potLevel[j]]->getMyCash() + ((potLevel[1])/winnerCount));
|
||||
it = currentHand->getSeatIt(potLevel[j]);
|
||||
assert(it != seatsList->end());
|
||||
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -148,10 +196,19 @@ void LocalBoard::distributePot() {
|
||||
|
||||
}
|
||||
|
||||
// if(j<mod) {
|
||||
// playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
||||
// } else {
|
||||
// playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount));
|
||||
// }
|
||||
|
||||
|
||||
it = currentHand->getSeatIt(winnerPointer);
|
||||
assert(it != seatsList->end());
|
||||
if(j<mod) {
|
||||
playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
||||
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
||||
} else {
|
||||
playerArray[winnerPointer]->setMyCash(playerArray[winnerPointer]->getMyCash() + (int)((potLevel[1])/winnerCount));
|
||||
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,11 +238,16 @@ void LocalBoard::distributePot() {
|
||||
if(pot!=0) cout << "distributePot-ERROR: Pot = " << pot << endl;
|
||||
|
||||
int sum = 0;
|
||||
for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if(playerArray[i]->getMyActiveStatus())
|
||||
sum += playerArray[i]->getMyCash();
|
||||
// for(i=0; i<(size_t)MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
// if(playerArray[i]->getMyActiveStatus())
|
||||
// sum += playerArray[i]->getMyCash();
|
||||
// }
|
||||
|
||||
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
|
||||
sum += (*it_c)->getMyCash();
|
||||
}
|
||||
|
||||
|
||||
if(sum != (currentHand->getStartQuantityPlayers() * currentHand->getStartCash()))
|
||||
cout << "distributePot-ERROR: PlayersSumCash = " << sum << endl;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
LocalBoard();
|
||||
~LocalBoard();
|
||||
|
||||
void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList);
|
||||
void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, PlayerList);
|
||||
void setHand(HandInterface*);
|
||||
|
||||
void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; }
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; // delete
|
||||
PlayerList seatsList;
|
||||
PlayerList activePlayerList;
|
||||
PlayerList runningPlayerList;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ LocalEngineFactory::~LocalEngineFactory()
|
||||
}
|
||||
|
||||
|
||||
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 dP, int sB,int sC) { return new LocalHand(f, g, b, sl, apl, rpl, id, sP, dP, sB, sC); }
|
||||
HandInterface* LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) { return new LocalHand(f, g, b, sl_old, sl, apl, rpl, id, sP, dP, sB, sC); }
|
||||
|
||||
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
|
||||
|
||||
|
||||
@@ -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> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
||||
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, 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, unsigned dP, int sB);
|
||||
|
||||
@@ -26,22 +26,29 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
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, unsigned dP, int sB,int sC)
|
||||
: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(false),
|
||||
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC)
|
||||
: myFactory(f), myGui(g), myBoard(b), playerArray(sl_old), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(false),
|
||||
cardsShown(false), bettingRoundsPlayed(0)
|
||||
{
|
||||
|
||||
int i, j, k;
|
||||
PlayerListIterator it;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
CardsValue myCardsValue;
|
||||
|
||||
myBoard->setHand(this);
|
||||
|
||||
for(i=0; i<startQuantityPlayers; i++) {
|
||||
playerArray[i]->setHand(this);
|
||||
// for(i=0; i<startQuantityPlayers; i++) {
|
||||
// playerArray[i]->setHand(this);
|
||||
// // myFlipCards auf 0 setzen
|
||||
// playerArray[i]->setMyCardsFlip(0, 0);
|
||||
// }
|
||||
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
(*it)->setHand(this);
|
||||
// myFlipCards auf 0 setzen
|
||||
playerArray[i]->setMyCardsFlip(0, 0);
|
||||
(*it)->setMyCardsFlip(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -286,36 +293,98 @@ void LocalHand::start() {
|
||||
void LocalHand::assignButtons() {
|
||||
|
||||
int i,j;
|
||||
PlayerListIterator it;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
// alle Buttons loeschen
|
||||
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { playerArray[i]->setMyButton(0); }
|
||||
// for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { playerArray[i]->setMyButton(0); }
|
||||
|
||||
// alle Buttons loeschen
|
||||
for (it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
(*it)->setMyButton(BUTTON_NONE);
|
||||
}
|
||||
|
||||
// DealerButton zuweisen
|
||||
playerArray[dealerPosition]->setMyButton(1);
|
||||
// playerArray[dealerPosition]->setMyButton(1);
|
||||
|
||||
// DealerButton zuweisen
|
||||
it = getSeatIt(dealerPosition);
|
||||
assert(it != seatsList->end() );
|
||||
(*it)->setMyButton(BUTTON_DEALER);
|
||||
|
||||
|
||||
// assign Small Blind next to dealer. ATTENTION: in heads up it is big blind
|
||||
i = dealerPosition;
|
||||
// i = dealerPosition;
|
||||
//
|
||||
// for(j=0; (j<MAX_NUMBER_OF_PLAYERS && !(playerArray[i]->getMyActiveStatus())) || j==0; j++) {
|
||||
//
|
||||
// i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
// if(playerArray[i]->getMyActiveStatus()) {
|
||||
// if(activePlayerList->size() > 2) playerArray[i]->setMyButton(2); //small blind normal
|
||||
// else playerArray[i]->setMyButton(3); //big blind in heads up
|
||||
// }
|
||||
// }
|
||||
|
||||
for(j=0; (j<MAX_NUMBER_OF_PLAYERS && !(playerArray[i]->getMyActiveStatus())) || j==0; j++) {
|
||||
|
||||
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
if(playerArray[i]->getMyActiveStatus()) {
|
||||
if(activePlayerList->size() > 2) playerArray[i]->setMyButton(2); //small blind normal
|
||||
else playerArray[i]->setMyButton(3); //big blind in heads up
|
||||
}
|
||||
}
|
||||
|
||||
// assign big blind next to small blind. ATTENTION: in heads up it is small blind
|
||||
for(j=0; (j<MAX_NUMBER_OF_PLAYERS && !(playerArray[i]->getMyActiveStatus())) || j==0; j++) {
|
||||
// for(j=0; (j<MAX_NUMBER_OF_PLAYERS && !(playerArray[i]->getMyActiveStatus())) || j==0; j++) {
|
||||
//
|
||||
// i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
// if(playerArray[i]->getMyActiveStatus()) {
|
||||
// if(activePlayerList->size() > 2) playerArray[i]->setMyButton(3); //big blind normal
|
||||
// else playerArray[i]->setMyButton(2); //small blind in heads up
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
i = (i+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
if(playerArray[i]->getMyActiveStatus()) {
|
||||
if(activePlayerList->size() > 2) playerArray[i]->setMyButton(3); //big blind normal
|
||||
else playerArray[i]->setMyButton(2); //small blind in heads up
|
||||
|
||||
|
||||
// assign Small Blind next to dealer. ATTENTION: in heads up it is big blind
|
||||
// assign big blind next to small blind. ATTENTION: in heads up it is small blind
|
||||
bool nextActivePlayerFound = false;
|
||||
PlayerListIterator dealerPositionIt = getSeatIt(dealerPosition);
|
||||
assert( dealerPositionIt != seatsList->end() );
|
||||
|
||||
for(i=0; i<seatsList->size(); i++) {
|
||||
|
||||
dealerPositionIt++;
|
||||
if(dealerPositionIt == seatsList->end()) dealerPositionIt = seatsList->begin();
|
||||
|
||||
it = getActivePlayerIt( (*dealerPositionIt)->getMyUniqueID() );
|
||||
if(it != activePlayerList->end() ) {
|
||||
nextActivePlayerFound = true;
|
||||
if(activePlayerList->size() > 2) (*it)->setMyButton(2); //small blind normal
|
||||
else (*it)->setMyButton(3); //big blind in heads up
|
||||
|
||||
it++;
|
||||
if(it == activePlayerList->end()) it = activePlayerList->begin();
|
||||
|
||||
if(activePlayerList->size() > 2) (*it)->setMyButton(3); //big blind normal
|
||||
else (*it)->setMyButton(2); //small blind in heads up
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert(nextActivePlayerFound);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//do sets --> TODO switch?
|
||||
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); it_c++) {
|
||||
@@ -504,6 +573,20 @@ void LocalHand::switchRounds() {
|
||||
|
||||
}
|
||||
|
||||
PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const {
|
||||
|
||||
PlayerListIterator it;
|
||||
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
if((*it)->getMyUniqueID() == uniqueId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return it;
|
||||
|
||||
}
|
||||
|
||||
PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const {
|
||||
|
||||
PlayerListIterator it;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
class LocalHand : public HandInterface{
|
||||
public:
|
||||
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, int, int, unsigned, int, int);
|
||||
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int);
|
||||
~LocalHand();
|
||||
|
||||
void start();
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
PlayerList getActivePlayerList() const {return activePlayerList;}
|
||||
PlayerList getRunningPlayerList() const {return runningPlayerList;}
|
||||
|
||||
PlayerListIterator getSeatIt(unsigned) const;
|
||||
PlayerListIterator getActivePlayerIt(unsigned) const;
|
||||
PlayerListIterator getRunningPlayerIt(unsigned) const;
|
||||
|
||||
@@ -95,7 +96,8 @@ private:
|
||||
GuiInterface *myGui;
|
||||
BoardInterface *myBoard;
|
||||
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; // delete
|
||||
PlayerList seatsList;
|
||||
PlayerList activePlayerList;
|
||||
PlayerList runningPlayerList;
|
||||
|
||||
|
||||
@@ -34,10 +34,11 @@ ClientBoard::~ClientBoard()
|
||||
}
|
||||
|
||||
void
|
||||
ClientBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl, PlayerList apl, PlayerList rpl)
|
||||
ClientBoard::setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
playerArray = sl;
|
||||
playerArray = sl_old; // delete
|
||||
seatsList = sl;
|
||||
activePlayerList = apl;
|
||||
runningPlayerList = rpl;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
ClientBoard();
|
||||
~ClientBoard();
|
||||
|
||||
void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList);
|
||||
void setPlayerLists(std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, PlayerList);
|
||||
void setHand(HandInterface*);
|
||||
|
||||
void setMyCards(int* theValue);
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
private:
|
||||
mutable boost::recursive_mutex m_syncMutex;
|
||||
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; // delete
|
||||
PlayerList seatsList;
|
||||
PlayerList activePlayerList;
|
||||
PlayerList runningPlayerList;
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ ClientEngineFactory::~ClientEngineFactory()
|
||||
}
|
||||
|
||||
|
||||
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 dP, int sB,int sC)
|
||||
HandInterface* ClientEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC)
|
||||
{
|
||||
return new ClientHand(f, g, b, sl, apl, rpl, id, sP, dP, sB, sC);
|
||||
return new ClientHand(f, g, b, sl_old, sl, apl, rpl, id, sP, 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> > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
||||
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, 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, unsigned dP, int sB);
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
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 dP, int sB,int sC)
|
||||
: myFactory(f), myGui(g), myBoard(b), playerArray(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0),
|
||||
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, std::vector<boost::shared_ptr<PlayerInterface> > sl_old, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC)
|
||||
: myFactory(f), myGui(g), myBoard(b), playerArray(sl_old), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0),
|
||||
smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0),
|
||||
cardsShown(false), bettingRoundsPlayed(0)
|
||||
{
|
||||
@@ -76,6 +76,20 @@ ClientHand::getPlayerArray() const
|
||||
return playerArray;
|
||||
}
|
||||
|
||||
PlayerListIterator
|
||||
ClientHand::getSeatIt(unsigned uniqueId) const
|
||||
{
|
||||
PlayerListIterator it;
|
||||
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||
if((*it)->getMyUniqueID() == uniqueId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
PlayerListIterator
|
||||
ClientHand::getActivePlayerIt(unsigned uniqueId) const
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
class ClientHand : public HandInterface
|
||||
{
|
||||
public:
|
||||
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList , int, int, int, int, int );
|
||||
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, std::vector<boost::shared_ptr<PlayerInterface> >, PlayerList, PlayerList, PlayerList , int, int, int, int, int );
|
||||
~ClientHand();
|
||||
|
||||
void start();
|
||||
@@ -41,6 +41,7 @@ class ClientHand : public HandInterface
|
||||
PlayerList getActivePlayerList() const {return activePlayerList;}
|
||||
PlayerList getRunningPlayerList() const {return runningPlayerList;}
|
||||
|
||||
PlayerListIterator getSeatIt(unsigned) const;
|
||||
PlayerListIterator getActivePlayerIt(unsigned) const;
|
||||
PlayerListIterator getRunningPlayerIt(unsigned) const;
|
||||
|
||||
@@ -95,7 +96,8 @@ class ClientHand : public HandInterface
|
||||
GuiInterface *myGui;
|
||||
BoardInterface *myBoard;
|
||||
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray;
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; // delete
|
||||
PlayerList seatsList;
|
||||
PlayerList activePlayerList;
|
||||
PlayerList runningPlayerList;
|
||||
|
||||
|
||||
+39
-14
@@ -68,7 +68,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
// Board erstellen
|
||||
actualBoard = myFactory->createBoard();
|
||||
|
||||
|
||||
seatsList = PlayerList(new std::list<boost::shared_ptr<PlayerInterface> >);
|
||||
activePlayerList = PlayerList(new std::list<boost::shared_ptr<PlayerInterface> >);
|
||||
runningPlayerList = PlayerList(new std::list<boost::shared_ptr<PlayerInterface> >);
|
||||
|
||||
@@ -98,17 +98,21 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
// create Player Objects
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
|
||||
|
||||
tmpPlayer->setNetSessionData(myNetSession);
|
||||
|
||||
// fill player lists
|
||||
playerArray.push_back(tmpPlayer);
|
||||
playerArray.push_back(tmpPlayer); // delete
|
||||
seatsList->push_back(tmpPlayer);
|
||||
if(startQuantityPlayers > i) {
|
||||
activePlayerList->push_back(tmpPlayer);
|
||||
}
|
||||
|
||||
(*runningPlayerList) = (*activePlayerList);
|
||||
|
||||
playerArray[i]->setNetSessionData(myNetSession);
|
||||
playerArray[i]->setNetSessionData(myNetSession); // delete
|
||||
|
||||
}
|
||||
actualBoard->setPlayerLists(playerArray, activePlayerList, runningPlayerList);
|
||||
actualBoard->setPlayerLists(playerArray, seatsList, activePlayerList, runningPlayerList); // delete playerArray
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
@@ -135,7 +139,7 @@ const HandInterface *Game::getCurrentHand() const
|
||||
void Game::initHand()
|
||||
{
|
||||
|
||||
int i;
|
||||
size_t i;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
// eventuell vorhandene Hand löschen
|
||||
@@ -177,14 +181,36 @@ void Game::initHand()
|
||||
(*runningPlayerList) = (*activePlayerList);
|
||||
|
||||
// Hand erstellen
|
||||
actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, dealerPosition, actualSmallBlind, startCash);
|
||||
actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, seatsList, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, dealerPosition, actualSmallBlind, startCash); // delete playerArray
|
||||
|
||||
|
||||
// Dealer-Button weiterschieben --> Achtung inactive -> TODO exception-rule !!! DELETE
|
||||
// for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(playerArray[dealerPosition]->getMyActiveStatus())) || i==0; i++) {
|
||||
//
|
||||
// dealerPosition = (dealerPosition+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
// }
|
||||
|
||||
// Dealer-Button weiterschieben --> Achtung inactive -> TODO exception-rule !!!
|
||||
for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(playerArray[dealerPosition]->getMyActiveStatus())) || i==0; i++) {
|
||||
bool nextDealerFound = false;
|
||||
PlayerListConstIterator dealerPositionIt = actualHand->getSeatIt(dealerPosition);
|
||||
assert( dealerPositionIt != seatsList->end() );
|
||||
|
||||
dealerPosition = (dealerPosition+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
for(i=0; i<seatsList->size(); i++) {
|
||||
|
||||
dealerPositionIt++;
|
||||
if(dealerPositionIt == seatsList->end()) dealerPositionIt = seatsList->begin();
|
||||
|
||||
it = actualHand->getActivePlayerIt( (*dealerPositionIt)->getMyUniqueID() );
|
||||
if(it != activePlayerList->end() ) {
|
||||
nextDealerFound = true;
|
||||
dealerPosition = (*it)->getMyUniqueID();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
assert(nextDealerFound);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Game::startHand()
|
||||
@@ -201,6 +227,7 @@ void Game::startHand()
|
||||
|
||||
boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
||||
{
|
||||
// TODO playerLists
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||
for (int i = 0; i < startQuantityPlayers; i++)
|
||||
{
|
||||
@@ -215,11 +242,9 @@ boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
||||
|
||||
boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
|
||||
{
|
||||
// int curPlayerNum = getCurrentHand()->getCurrentBeRo()->getPlayersTurn();
|
||||
// assert(curPlayerNum < getStartQuantityPlayers());
|
||||
// return getPlayerArray()[curPlayerNum];
|
||||
|
||||
// TODO -> checking
|
||||
return (*(getCurrentHand()->getCurrentBeRo()->getCurrentPlayersTurnIt()));
|
||||
// TODO playerLists
|
||||
int curPlayerNum = getCurrentHand()->getCurrentBeRo()->getPlayersTurn();
|
||||
assert(curPlayerNum < getStartQuantityPlayers());
|
||||
return getPlayerArray()[curPlayerNum];
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -55,6 +55,7 @@ public:
|
||||
const HandInterface *getCurrentHand() const;
|
||||
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > getPlayerArray() const {return playerArray;}
|
||||
PlayerList getSeatsList() const {return seatsList;}
|
||||
PlayerList getActivePlayerList() const {return activePlayerList;}
|
||||
PlayerList getRunningPlayerList() const {return runningPlayerList;}
|
||||
|
||||
@@ -86,7 +87,8 @@ private:
|
||||
HandInterface *actualHand;
|
||||
BoardInterface *actualBoard;
|
||||
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; // available seats --> seatList !!! TODO
|
||||
std::vector<boost::shared_ptr<PlayerInterface> > playerArray; // available seats --> seatList !!! TODO // delete
|
||||
PlayerList seatsList;
|
||||
PlayerList activePlayerList; // used seats
|
||||
PlayerList runningPlayerList; // nonfolded and nonallin active players
|
||||
|
||||
|
||||
Reference in New Issue
Block a user