From f6a316fc2e0fc6abfa58cf2576c5e2ae899b2d61 Mon Sep 17 00:00:00 2001 From: doitux Date: Mon, 24 Sep 2007 21:09:36 +0000 Subject: [PATCH] adds activePlayerList and runningPlayerList (IV) --- src/engine/boardinterface.h | 3 +- src/engine/enginefactory.h | 2 +- src/engine/local_engine/localbero.cpp | 4 +-- src/engine/local_engine/localberopreflop.cpp | 31 +++++++++++------ src/engine/local_engine/localberopreflop.h | 3 +- .../local_engine/localenginefactory.cpp | 2 +- src/engine/local_engine/localenginefactory.h | 2 +- src/engine/local_engine/localhand.cpp | 34 +++++++++---------- src/engine/local_engine/localhand.h | 2 +- src/engine/local_engine/localplayer.cpp | 20 +++++------ .../network_engine/clientenginefactory.cpp | 4 +-- .../network_engine/clientenginefactory.h | 2 +- src/engine/network_engine/clienthand.cpp | 6 ++-- src/engine/network_engine/clienthand.h | 2 +- src/game.cpp | 18 +++++----- src/game.h | 3 +- src/gui/qt/mainwindow/mainwindowimpl.cpp | 4 +-- 17 files changed, 79 insertions(+), 63 deletions(-) diff --git a/src/engine/boardinterface.h b/src/engine/boardinterface.h index 4b8ab943..28adc9b8 100644 --- a/src/engine/boardinterface.h +++ b/src/engine/boardinterface.h @@ -27,7 +27,8 @@ class PlayerInterface; class HandInterface; -typedef std::list > PlayerList; +typedef boost::shared_ptr > > PlayerList; +typedef std::list >::iterator PlayerListIterator; class BoardInterface { diff --git a/src/engine/enginefactory.h b/src/engine/enginefactory.h index 4e6fcb09..e0dba9da 100644 --- a/src/engine/enginefactory.h +++ b/src/engine/enginefactory.h @@ -33,7 +33,7 @@ public: virtual ~EngineFactory(); - virtual HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) =0; + virtual HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0; virtual BoardInterface* createBoard() =0; virtual boost::shared_ptr 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 > createBeRo(HandInterface* hi, int id, int dP, int sB) =0; diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index cac06181..285032c0 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -145,8 +145,8 @@ void LocalBeRo::run() { // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende // ausnahme bei heads up !!! --> TODO - if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind && myHand->getActivePlayerList().size() >= 3) { firstRound = 0; } - if(myHand->getActivePlayerList().size() < 3 && (myHand->getPlayerArray()[playersTurn]->getMyID() == dealerPosition || myHand->getPlayerArray()[playersTurn]->getMyID() == smallBlindPosition)) { firstRound = 0; } + if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind && myHand->getActivePlayerList()->size() >= 3) { firstRound = 0; } + if(myHand->getActivePlayerList()->size() < 3 && (myHand->getPlayerArray()[playersTurn]->getMyID() == dealerPosition || myHand->getPlayerArray()[playersTurn]->getMyID() == smallBlindPosition)) { firstRound = 0; } if(playersTurn == 0) { // Wir sind dran diff --git a/src/engine/local_engine/localberopreflop.cpp b/src/engine/local_engine/localberopreflop.cpp index 809d6b95..3bc447b7 100644 --- a/src/engine/local_engine/localberopreflop.cpp +++ b/src/engine/local_engine/localberopreflop.cpp @@ -24,21 +24,30 @@ using namespace std; -LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP), bigBlindPosition(0) +LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP) { setHighestSet(2*getSmallBlind()); // // BigBlind ermitteln - bigBlindPosition = getDealerPosition(); +// bigBlindPosition = getDealerPosition(); + bigBlindPosition = getMyHand()->getActivePlayerList()->begin(); - int i; - for(i=0; igetPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) { - bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS); +// int i; +// for(i=0; igetPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) { +// bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS); +// } + + PlayerListIterator it; + + for(it=getMyHand()->getActivePlayerList()->begin(); it!=getMyHand()->getActivePlayerList()->end(); it++) { + if((*it)->getMyButton() == BUTTON_BIG_BLIND) { + bigBlindPosition = it; + } } // // erste Spielernummer fr preflopRun() setzen - setPlayersTurn(bigBlindPosition); + setPlayersTurn((*bigBlindPosition)->getMyID()); } @@ -64,18 +73,18 @@ void LocalBeRoPreflop::run() { } // BigBlind ermitteln - bigBlindPosition = getDealerPosition(); +// bigBlindPosition = getDealerPosition(); - for(i=0; igetPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) { - bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS); - } +// for(i=0; igetPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) { +// bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS); +// } // naechsten Spieler ermitteln for(i=0; (igetPlayerArray()[getPlayersTurn()]->getMyActiveStatus()) || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_FOLD || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_ALLIN)) || i==0; i++) { setPlayersTurn((getPlayersTurn()+1)%(MAX_NUMBER_OF_PLAYERS)); // falls BigBlind, dann PreflopFirstRound zuende - if(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyButton() == BUTTON_BIG_BLIND && getMyHand()->getPlayerArray()[bigBlindPosition]->getMySet() < 2*getSmallBlind()) setFirstRound(0); + if(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyButton() == BUTTON_BIG_BLIND && (*bigBlindPosition)->getMySet() < 2*getSmallBlind()) setFirstRound(0); } diff --git a/src/engine/local_engine/localberopreflop.h b/src/engine/local_engine/localberopreflop.h index 5e97c4c5..d758e303 100644 --- a/src/engine/local_engine/localberopreflop.h +++ b/src/engine/local_engine/localberopreflop.h @@ -34,7 +34,8 @@ public: void run(); private: - int bigBlindPosition; +// int bigBlindPosition; + PlayerListIterator bigBlindPosition; }; #endif diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index fab9d61c..b3192606 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -42,7 +42,7 @@ LocalEngineFactory::~LocalEngineFactory() } -HandInterface* LocalEngineFactory::createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > 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); } +HandInterface* LocalEngineFactory::createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > 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); } BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } diff --git a/src/engine/local_engine/localenginefactory.h b/src/engine/local_engine/localenginefactory.h index 6fc6d6c6..fb69887d 100644 --- a/src/engine/local_engine/localenginefactory.h +++ b/src/engine/local_engine/localenginefactory.h @@ -37,7 +37,7 @@ public: LocalEngineFactory(ConfigFile*); ~LocalEngineFactory(); - HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC); + HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); BoardInterface* createBoard(); boost::shared_ptr createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); std::vector > createBeRo(HandInterface* hi, int id, int dP, int sB); diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 1cd821ca..a18c7e96 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -26,13 +26,13 @@ using namespace std; -LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) +LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > 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), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0), cardsShown(false), bettingRoundsPlayed(0) { int i, j, k; - PlayerList::iterator it; + PlayerListIterator it; CardsValue myCardsValue; @@ -51,8 +51,8 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI } // Karten generieren und Board sowie Player zuweisen - int *cardsArray = new int[2*activePlayerList.size()+5]; - Tools::getRandNumber(0, 51, 2*activePlayerList.size()+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]; @@ -65,7 +65,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI k = 0; myBoard->setMyCards(tempBoardArray); - for(it=activePlayerList.begin(); it!=activePlayerList.end(); it++, k++) { + for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++, k++) { (*it)->getMyBestHandPosition(bestHandPos); @@ -85,8 +85,8 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI } } - // sBluff für alle aktiver Spieler außer human player setzen - if(it!=activePlayerList.begin()) { + // sBluff für alle aktiver Spieler außer human player setzen --> TODO for ai-player in internet + if((*it)->getMyID() != 0) { Tools::getRandNumber(1,100,1,&sBluff,0); (*it)->setSBluff(sBluff); (*it)->setSBluffStatus(0); @@ -285,7 +285,7 @@ void LocalHand::start() { void LocalHand::assignButtons() { int i,j; - PlayerList::iterator it; + PlayerListIterator it; // alle Buttons loeschen for (i=0; isetMyButton(0); } @@ -300,7 +300,7 @@ void LocalHand::assignButtons() { i = (i+1)%(MAX_NUMBER_OF_PLAYERS); if(playerArray[i]->getMyActiveStatus()) { - if(activePlayerList.size() > 2) playerArray[i]->setMyButton(2); //small blind normal + if(activePlayerList->size() > 2) playerArray[i]->setMyButton(2); //small blind normal else playerArray[i]->setMyButton(3); //big blind in heads up } } @@ -310,14 +310,14 @@ void LocalHand::assignButtons() { i = (i+1)%(MAX_NUMBER_OF_PLAYERS); if(playerArray[i]->getMyActiveStatus()) { - if(activePlayerList.size() > 2) playerArray[i]->setMyButton(3); //big blind normal + if(activePlayerList->size() > 2) playerArray[i]->setMyButton(3); //big blind normal else playerArray[i]->setMyButton(2); //small blind in heads up } } //do sets - for (it=activePlayerList.begin(); it!=activePlayerList.end(); it++) { + for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { //small blind if((*it)->getMyButton() == 2) { @@ -329,7 +329,7 @@ void LocalHand::assignButtons() { // 1 to do not log this (*it)->setMyAction(6,1); // delete this player from runningPlayerList - it = runningPlayerList.erase(it); + it = runningPlayerList->erase(it); } else { (*it)->setMySet(smallBlind); } @@ -345,7 +345,7 @@ void LocalHand::assignButtons() { // 1 to do not log this (*it)->setMyAction(6,1); // delete this player from runningPlayerList - it = runningPlayerList.erase(it); + it = runningPlayerList->erase(it); } else { (*it)->setMySet(2*smallBlind); } @@ -358,17 +358,17 @@ void LocalHand::assignButtons() { void LocalHand::switchRounds() { int i; - PlayerList::iterator it; + PlayerListIterator it; // Anzahl der Spieler ermitteln, welche All In sind int allInPlayersCounter = 0; - for (it=activePlayerList.begin(); it!=activePlayerList.end(); it++) { + for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { if ((*it)->getMyAction() == 6) allInPlayersCounter++; } // TODO -> runningPlayerList.size() int nonFoldPlayerCounter = 0; - for (it=activePlayerList.begin(); it!=activePlayerList.end(); it++) { + for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { if ((*it)->getMyAction() != 1) nonFoldPlayerCounter++; } @@ -407,7 +407,7 @@ void LocalHand::switchRounds() { // HeadsUp-Ausnahme -> spieler ermitteln, der all in ist und als bb nur weniger als sb setzen konnte for(i=0; igetMyAction() == 6 && playerArray[i]->getMyActiveStatus() == 1 && playerArray[i]->getMyButton()==3 && playerArray[i]->getMySet()<=smallBlind) { + if(activePlayerList->size()==2 && playerArray[i]->getMyAction() == 6 && playerArray[i]->getMyActiveStatus() == 1 && playerArray[i]->getMyButton()==3 && playerArray[i]->getMySet()<=smallBlind) { allInCondition = 1; } diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index d1f1fa15..aee884ad 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -34,7 +34,7 @@ class LocalHand : public HandInterface{ public: - LocalHand(boost::shared_ptr f, GuiInterface*, BoardInterface*, std::vector >, PlayerList, PlayerList, int, int, int, int, int, int); + LocalHand(boost::shared_ptr f, GuiInterface*, BoardInterface*, std::vector >, PlayerList, PlayerList, int, int, int, int, int); ~LocalHand(); void start(); diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 9503027b..fe91641d 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -987,7 +987,7 @@ void LocalPlayer::preflopEngine() { int cBluff; // temporär solange preflopValue und flopValue noch nicht bereinigt für sechs und sieben spieler - int players = actualHand->getActivePlayerList().size(); + int players = actualHand->getActivePlayerList()->size(); if(players > 5) players = 5; // myOdds auslesen @@ -1018,7 +1018,7 @@ void LocalPlayer::preflopEngine() { // cout << myID << ": " << myHoleCardsValue << " - " << myNiveau[0] << " " << myNiveau[2] << " - " << myCards[0] << " " << myCards[1] << endl; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList()->size())*21.0); // cout << aggValue << " "; @@ -1122,7 +1122,7 @@ void LocalPlayer::preflopEngine() { // cout << sBluff << endl; // auf sBluff testen --> raise statt call oder fold - if((sBluff < 100/(((actualHand->getActivePlayerList().size()-2)*6)+3) && myOdds < myNiveau[2] && actualHand->getCurrentBeRo()->getHighestSet() == 2*actualHand->getSmallBlind() && sBluffStatus == 0) || sBluffStatus == 1) { + if((sBluff < 100/(((actualHand->getActivePlayerList()->size()-2)*6)+3) && myOdds < myNiveau[2] && actualHand->getCurrentBeRo()->getHighestSet() == 2*actualHand->getSmallBlind() && sBluffStatus == 0) || sBluffStatus == 1) { // cout << "sBLUFF!" << endl; sBluffStatus = 1; @@ -1143,7 +1143,7 @@ void LocalPlayer::preflopEngine() { // Standard-Raise-Routine else { // raise-Betrag ermitteln - raise = (sBluff/(8-actualHand->getActivePlayerList().size()))*actualHand->getSmallBlind(); + raise = (sBluff/(8-actualHand->getActivePlayerList()->size()))*actualHand->getSmallBlind(); // raise-Betrag zu klein -> mindestens Standard-raise // if(raise < actualHand->getCurrentBeRo()->getHighestSet()) { // raise = actualHand->getCurrentBeRo()->getHighestSet(); @@ -1255,7 +1255,7 @@ void LocalPlayer::flopEngine() { int rand; // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = actualHand->getActivePlayerList().size(); + int players = actualHand->getActivePlayerList()->size(); if(players > 5) players = 5; calcMyOdds(); @@ -1273,7 +1273,7 @@ void LocalPlayer::flopEngine() { if(individualHighestSet > myCash) individualHighestSet = myCash; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList()->size())*21.0); if(actualHand->getPlayerArray()[0]->getMyActiveStatus() && actualHand->getPlayerArray()[0]->getMyAction() != 1) { for(i=0; i<3; i++) { @@ -1843,7 +1843,7 @@ void LocalPlayer::turnEngine() { myNiveau[2] = 69 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList()->size())*21.0); if(actualHand->getPlayerArray()[0]->getMyActiveStatus() && actualHand->getPlayerArray()[0]->getMyAction() != 1) { for(i=0; i<3; i++) { @@ -2179,7 +2179,7 @@ void LocalPlayer::riverEngine() { myNiveau[2] = 69 + myDude4/* - 6*(actualHand->getActivePlayerList().size() - 2)*/; // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist - int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList().size())*21.0); + int aggValue = (int)(((actualHand->getPlayerArray()[0]->getMyAggressive()*1.0)/7.0 - 1.0/actualHand->getActivePlayerList()->size())*21.0); if(actualHand->getPlayerArray()[0]->getMyActiveStatus() && actualHand->getPlayerArray()[0]->getMyAction() != 1) { for(i=0; i<3; i++) { @@ -3226,7 +3226,7 @@ void LocalPlayer::calcMyOdds() { handCode = preflopCardsValue(myCards); // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = actualHand->getActivePlayerList().size(); + int players = actualHand->getActivePlayerList()->size(); if(players > 5) players = 5; // paranoia if(players < 2) players = 2; @@ -3259,7 +3259,7 @@ void LocalPlayer::calcMyOdds() { // cout << "\t" << handCode << endl; // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = actualHand->getActivePlayerList().size(); + int players = actualHand->getActivePlayerList()->size(); if(players > 5) players = 5; // paranoia if(players < 2) players = 2; diff --git a/src/engine/network_engine/clientenginefactory.cpp b/src/engine/network_engine/clientenginefactory.cpp index 6c37ade4..ac4da6c1 100644 --- a/src/engine/network_engine/clientenginefactory.cpp +++ b/src/engine/network_engine/clientenginefactory.cpp @@ -35,9 +35,9 @@ ClientEngineFactory::~ClientEngineFactory() } -HandInterface* ClientEngineFactory::createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) +HandInterface* ClientEngineFactory::createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > 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, aP, dP, sB, sC); + return new ClientHand(f, g, b, sl, apl, rpl, id, sP, dP, sB, sC); } BoardInterface* ClientEngineFactory::createBoard() diff --git a/src/engine/network_engine/clientenginefactory.h b/src/engine/network_engine/clientenginefactory.h index c3022f38..f02a7251 100644 --- a/src/engine/network_engine/clientenginefactory.h +++ b/src/engine/network_engine/clientenginefactory.h @@ -37,7 +37,7 @@ public: ClientEngineFactory(); ~ClientEngineFactory(); - HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC); + HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); BoardInterface* createBoard(); boost::shared_ptr createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); std::vector > createBeRo(HandInterface* hi, int id, int dP, int sB); diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index c0c70f54..7753af9f 100644 --- a/src/engine/network_engine/clienthand.cpp +++ b/src/engine/network_engine/clienthand.cpp @@ -21,11 +21,13 @@ using namespace std; -ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > sl, PlayerList apl, PlayerList rpl, int id, int sP, int aP, int dP, int sB,int sC) +ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > 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), - smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0), + smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0), cardsShown(false), bettingRoundsPlayed(0) { + activePlayersCounter = activePlayerList->size(); + int i; lastPlayersTurn = 0; diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index ec5f1fdb..8bc37141 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -32,7 +32,7 @@ class ClientHand : public HandInterface { public: - ClientHand ( boost::shared_ptr f, GuiInterface*, BoardInterface*, std::vector >, PlayerList, PlayerList , int, int, int, int, int, int ); + ClientHand ( boost::shared_ptr f, GuiInterface*, BoardInterface*, std::vector >, PlayerList, PlayerList , int, int, int, int, int ); ~ClientHand(); void start(); diff --git a/src/game.cpp b/src/game.cpp index 5cf0cebc..4361804b 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -71,6 +71,9 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, // Player erstellen + activePlayerList = PlayerList(new std::list >); + runningPlayerList = PlayerList(new std::list >); + player_i = playerDataList.begin(); player_end = playerDataList.end(); for(i=0; i factory, // fill player lists playerArray.push_back(tmpPlayer); if(startQuantityPlayers > i) { - activePlayerList.push_back(tmpPlayer); - runningPlayerList.push_back(tmpPlayer); + activePlayerList->push_back(tmpPlayer); + runningPlayerList->push_back(tmpPlayer); } @@ -111,7 +114,6 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, actualBoard->setPlayerLists(playerArray, activePlayerList, runningPlayerList); } - Game::~Game() { // cout << "Delete Game Object" << "\n"; @@ -150,17 +152,17 @@ void Game::initHand() if((actualHandID-1)%startHandsBeforeRaiseSmallBlind == 0 && actualHandID > 1) { actualSmallBlind *= 2; } // Spieler mit leerem Cash auf inactive setzen - PlayerList::iterator it; + PlayerListIterator it; - for(it = activePlayerList.begin(); it != activePlayerList.end(); it++) { + for(it = activePlayerList->begin(); it != activePlayerList->end(); it++) { if((*it)->getMyCash() == 0) { (*it)->setMyActiveStatus(0); - it = activePlayerList.erase(it); + it = activePlayerList->erase(it); } } // Anzahl noch aktiver Spieler ermitteln - actualQuantityPlayers = activePlayerList.size(); // TODO -> delete !!! + actualQuantityPlayers = activePlayerList->size(); // TODO -> delete !!! //Spieler Action auf 0 setzen for(i=0; icreateHand(myFactory, myGui, actualBoard, playerArray, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, actualQuantityPlayers, dealerPosition, actualSmallBlind, startCash); + actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, dealerPosition, actualSmallBlind, startCash); // Dealer-Button weiterschieben --> Achtung inactive diff --git a/src/game.h b/src/game.h index b17ef3ea..b3ff91a3 100755 --- a/src/game.h +++ b/src/game.h @@ -35,7 +35,8 @@ class EngineFactory; struct GameData; struct StartData; -typedef std::list > PlayerList; +typedef boost::shared_ptr > > PlayerList; +typedef std::list >::iterator PlayerListIterator; class Game { diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 4b5d095f..10f52153 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -2083,7 +2083,7 @@ void mainWindowImpl::postRiverRunAnimation3() { actionLabelArray[i]->setPixmap(QPixmap(myAppDataPath +"gfx/gui/table/default/action_winner.png")); //show winnercards if more than one player is active - if ( currentHand->getActivePlayerList().size() != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) { + if ( currentHand->getActivePlayerList()->size() != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) { int j; int bestHandPos[5]; @@ -2150,7 +2150,7 @@ void mainWindowImpl::postRiverRunAnimation3() { } else { - if( currentHand->getActivePlayerList().size() != 1 && currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyActiveStatus() && myConfig->readConfigInt("ShowFadeOutCardsAnimation") ) { + if( currentHand->getActivePlayerList()->size() != 1 && currentHand->getPlayerArray()[i]->getMyAction() != 1 && currentHand->getPlayerArray()[i]->getMyActiveStatus() && myConfig->readConfigInt("ShowFadeOutCardsAnimation") ) { //aufgedeckte Gegner auch ausblenden holeCardsArray[i][0]->startFadeOut(guiGameSpeed);