From f39a7d393a106d9f70b9cc959e34bd83b746747b Mon Sep 17 00:00:00 2001 From: doitux Date: Tue, 25 Sep 2007 09:07:36 +0000 Subject: [PATCH] adds activePlayerList and runningPlayerList (V) --- src/engine/local_engine/localberopreflop.cpp | 33 +++++++------------- src/engine/local_engine/localberopreflop.h | 1 - src/engine/local_engine/localplayer.cpp | 10 ++++++ src/game.cpp | 18 +++++------ src/game.h | 5 --- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/engine/local_engine/localberopreflop.cpp b/src/engine/local_engine/localberopreflop.cpp index 3bc447b7..9e1134d7 100644 --- a/src/engine/local_engine/localberopreflop.cpp +++ b/src/engine/local_engine/localberopreflop.cpp @@ -29,17 +29,11 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : { setHighestSet(2*getSmallBlind()); -// // BigBlind ermitteln -// 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); -// } - +// // BigBlind ermitteln PlayerListIterator it; + bigBlindPosition = getMyHand()->getActivePlayerList()->begin(); + for(it=getMyHand()->getActivePlayerList()->begin(); it!=getMyHand()->getActivePlayerList()->end(); it++) { if((*it)->getMyButton() == BUTTON_BIG_BLIND) { bigBlindPosition = it; @@ -63,23 +57,18 @@ LocalBeRoPreflop::~LocalBeRoPreflop() void LocalBeRoPreflop::run() { int i; - bool allHighestSet = 1; + bool allHighestSet = true; + PlayerListIterator it; + PlayerList runningPlayerList = getMyHand()->getRunningPlayerList(); - // prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 ) - for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && getMyHand()->getPlayerArray()[i]->getMyAction() != PLAYER_ACTION_FOLD && getMyHand()->getPlayerArray()[i]->getMyAction() != PLAYER_ACTION_ALLIN) { - if(getHighestSet() != getMyHand()->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } + // test if all running players have same sets (else allHighestSet = false) + for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); it++) { + if(getHighestSet() != (*it)->getMySet()) { + allHighestSet = false; } } - // BigBlind ermitteln -// bigBlindPosition = getDealerPosition(); - -// for(i=0; igetPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) { -// bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS); -// } - - // naechsten Spieler ermitteln + // determine next player 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)); diff --git a/src/engine/local_engine/localberopreflop.h b/src/engine/local_engine/localberopreflop.h index d758e303..122c19d6 100644 --- a/src/engine/local_engine/localberopreflop.h +++ b/src/engine/local_engine/localberopreflop.h @@ -34,7 +34,6 @@ public: void run(); private: -// int bigBlindPosition; PlayerListIterator bigBlindPosition; }; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index fe91641d..6aa64542 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -969,6 +969,16 @@ void LocalPlayer::action() { myTurn = 0; // cout << "jetzt" << endl; + + if(myAction == 1 || myAction == 6) { + PlayerListIterator it; + for(it=actualHand->getRunningPlayerList()->begin(); it!=actualHand->getRunningPlayerList()->end(); it++) { + if((*it)->getMyID() == myID) { + (*it).reset(); + it = actualHand->getRunningPlayerList()->erase(it); + } + } + } //set that i was the last active player. need this for unhighlighting groupbox actualHand->setLastPlayersTurn(myID); diff --git a/src/game.cpp b/src/game.cpp index 4361804b..56265c16 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -35,8 +35,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, startQuantityPlayers(startData.numberOfPlayers), startCash(gameData.startMoney), startSmallBlind(gameData.smallBlind), startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise), - myGameID(gameId), actualQuantityPlayers(startData.numberOfPlayers), - actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0) + myGameID(gameId), actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0) { // cout << "Create Game Object" << "\n"; int i; @@ -102,13 +101,11 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, playerArray.push_back(tmpPlayer); if(startQuantityPlayers > i) { activePlayerList->push_back(tmpPlayer); - runningPlayerList->push_back(tmpPlayer); +// runningPlayerList->push_back(tmpPlayer); } - + (*runningPlayerList) = (*activePlayerList); - -// playerArray[i] = myFactory->createPlayer(actualBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0); playerArray[i]->setNetSessionData(myNetSession); } actualBoard->setPlayerLists(playerArray, activePlayerList, runningPlayerList); @@ -161,14 +158,17 @@ void Game::initHand() } } - // Anzahl noch aktiver Spieler ermitteln - actualQuantityPlayers = activePlayerList->size(); // TODO -> delete !!! - //Spieler Action auf 0 setzen for(i=0; isetMyAction(0); } + runningPlayerList->clear(); + + for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { + runningPlayerList->push_back(*it); + } + // Hand erstellen actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, dealerPosition, actualSmallBlind, startCash); diff --git a/src/game.h b/src/game.h index b3ff91a3..e0b7a50d 100755 --- a/src/game.h +++ b/src/game.h @@ -69,10 +69,6 @@ public: int getMyGameID() const { return myGameID; } - //Zufgriff Laufvariablen - void setActualQuantityPlayers(int theValue) { actualQuantityPlayers = theValue; } - int getActualQuantityPlayers() const { return actualQuantityPlayers; } - void setActualSmallBlind(int theValue) { actualSmallBlind = theValue; } int getActualSmallBlind() const { return actualSmallBlind; } @@ -104,7 +100,6 @@ private: int guiPlayerNum; //Laufvariablen - int actualQuantityPlayers; int actualSmallBlind; int actualHandID; int dealerPosition;