adds activePlayerList and runningPlayerList (V)

This commit is contained in:
doitux
2007-09-25 09:07:36 +00:00
parent f6a316fc2e
commit f39a7d393a
5 changed files with 30 additions and 37 deletions
+10 -21
View File
@@ -30,16 +30,10 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) :
setHighestSet(2*getSmallBlind()); setHighestSet(2*getSmallBlind());
// // BigBlind ermitteln // // BigBlind ermitteln
// bigBlindPosition = getDealerPosition();
bigBlindPosition = getMyHand()->getActivePlayerList()->begin();
// int i;
// for(i=0; i<MAX_NUMBER_OF_PLAYERS && getMyHand()->getPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) {
// bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS);
// }
PlayerListIterator it; PlayerListIterator it;
bigBlindPosition = getMyHand()->getActivePlayerList()->begin();
for(it=getMyHand()->getActivePlayerList()->begin(); it!=getMyHand()->getActivePlayerList()->end(); it++) { for(it=getMyHand()->getActivePlayerList()->begin(); it!=getMyHand()->getActivePlayerList()->end(); it++) {
if((*it)->getMyButton() == BUTTON_BIG_BLIND) { if((*it)->getMyButton() == BUTTON_BIG_BLIND) {
bigBlindPosition = it; bigBlindPosition = it;
@@ -63,23 +57,18 @@ LocalBeRoPreflop::~LocalBeRoPreflop()
void LocalBeRoPreflop::run() { void LocalBeRoPreflop::run() {
int i; 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 ) // test if all running players have same sets (else allHighestSet = false)
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); it++) {
if(getMyHand()->getPlayerArray()[i]->getMyActiveStatus() && getMyHand()->getPlayerArray()[i]->getMyAction() != PLAYER_ACTION_FOLD && getMyHand()->getPlayerArray()[i]->getMyAction() != PLAYER_ACTION_ALLIN) { if(getHighestSet() != (*it)->getMySet()) {
if(getHighestSet() != getMyHand()->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } allHighestSet = false;
} }
} }
// BigBlind ermitteln // determine next player
// bigBlindPosition = getDealerPosition();
// for(i=0; i<MAX_NUMBER_OF_PLAYERS && getMyHand()->getPlayerArray()[bigBlindPosition]->getMyButton() != BUTTON_BIG_BLIND; i++) {
// bigBlindPosition = (bigBlindPosition+1)%(MAX_NUMBER_OF_PLAYERS);
// }
// naechsten Spieler ermitteln
for(i=0; (i<MAX_NUMBER_OF_PLAYERS && (!(getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyActiveStatus()) || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_FOLD || getMyHand()->getPlayerArray()[getPlayersTurn()]->getMyAction() == PLAYER_ACTION_ALLIN)) || i==0; i++) { for(i=0; (i<MAX_NUMBER_OF_PLAYERS && (!(getMyHand()->getPlayerArray()[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)); setPlayersTurn((getPlayersTurn()+1)%(MAX_NUMBER_OF_PLAYERS));
@@ -34,7 +34,6 @@ public:
void run(); void run();
private: private:
// int bigBlindPosition;
PlayerListIterator bigBlindPosition; PlayerListIterator bigBlindPosition;
}; };
+10
View File
@@ -970,6 +970,16 @@ void LocalPlayer::action() {
myTurn = 0; myTurn = 0;
// cout << "jetzt" << endl; // 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 //set that i was the last active player. need this for unhighlighting groupbox
actualHand->setLastPlayersTurn(myID); actualHand->setLastPlayersTurn(myID);
+9 -9
View File
@@ -35,8 +35,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
startQuantityPlayers(startData.numberOfPlayers), startQuantityPlayers(startData.numberOfPlayers),
startCash(gameData.startMoney), startSmallBlind(gameData.smallBlind), startCash(gameData.startMoney), startSmallBlind(gameData.smallBlind),
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise), startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
myGameID(gameId), actualQuantityPlayers(startData.numberOfPlayers), myGameID(gameId), actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0)
actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0)
{ {
// cout << "Create Game Object" << "\n"; // cout << "Create Game Object" << "\n";
int i; int i;
@@ -102,13 +101,11 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
playerArray.push_back(tmpPlayer); playerArray.push_back(tmpPlayer);
if(startQuantityPlayers > i) { if(startQuantityPlayers > i) {
activePlayerList->push_back(tmpPlayer); 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); playerArray[i]->setNetSessionData(myNetSession);
} }
actualBoard->setPlayerLists(playerArray, activePlayerList, runningPlayerList); 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 //Spieler Action auf 0 setzen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
playerArray[i]->setMyAction(0); playerArray[i]->setMyAction(0);
} }
runningPlayerList->clear();
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
runningPlayerList->push_back(*it);
}
// Hand erstellen // Hand erstellen
actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, dealerPosition, actualSmallBlind, startCash); actualHand = myFactory->createHand(myFactory, myGui, actualBoard, playerArray, activePlayerList, runningPlayerList, actualHandID, startQuantityPlayers, dealerPosition, actualSmallBlind, startCash);
-5
View File
@@ -69,10 +69,6 @@ public:
int getMyGameID() const { return myGameID; } int getMyGameID() const { return myGameID; }
//Zufgriff Laufvariablen
void setActualQuantityPlayers(int theValue) { actualQuantityPlayers = theValue; }
int getActualQuantityPlayers() const { return actualQuantityPlayers; }
void setActualSmallBlind(int theValue) { actualSmallBlind = theValue; } void setActualSmallBlind(int theValue) { actualSmallBlind = theValue; }
int getActualSmallBlind() const { return actualSmallBlind; } int getActualSmallBlind() const { return actualSmallBlind; }
@@ -104,7 +100,6 @@ private:
int guiPlayerNum; int guiPlayerNum;
//Laufvariablen //Laufvariablen
int actualQuantityPlayers;
int actualSmallBlind; int actualSmallBlind;
int actualHandID; int actualHandID;
int dealerPosition; int dealerPosition;