adds activePlayerList and runningPlayerList (XIII) - BUGGY!!! - last sable rev866

This commit is contained in:
doitux
2007-09-26 10:13:10 +00:00
parent 8ac5673c00
commit 6c19233c18
10 changed files with 96 additions and 75 deletions
+1
View File
@@ -29,6 +29,7 @@ class HandInterface;
typedef boost::shared_ptr<std::list<boost::shared_ptr<PlayerInterface> > > PlayerList; typedef boost::shared_ptr<std::list<boost::shared_ptr<PlayerInterface> > > PlayerList;
typedef std::list<boost::shared_ptr<PlayerInterface> >::iterator PlayerListIterator; typedef std::list<boost::shared_ptr<PlayerInterface> >::iterator PlayerListIterator;
typedef std::list<boost::shared_ptr<PlayerInterface> >::const_iterator PlayerListConstIterator;
class BoardInterface { class BoardInterface {
+2 -2
View File
@@ -14,7 +14,7 @@
using namespace std; using namespace std;
LocalBeRo::LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS) LocalBeRo::LocalBeRo(HandInterface* hi, int id, int dP, int sB, GameState gS)
: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(false), minimumRaise(2*sB), firstRun(true), firstRound(true), firstHeadsUpRound(true), logBoardCardsDone(false) : BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(false), minimumRaise(2*sB), firstRun(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurn(0), firstRoundLastPlayersTurn(0), logBoardCardsDone(false)
{ {
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin(); currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin(); lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
@@ -38,7 +38,7 @@ void LocalBeRo::nextPlayer() {
// myHand->getPlayerArray()[playersTurn]->action(); // myHand->getPlayerArray()[playersTurn]->action();
cout << "playerID in nextPlayer(): " << (*currentPlayersTurnIt)->getMyID() << endl; // cout << "playerID in nextPlayer(): " << (*currentPlayersTurnIt)->getMyID() << endl;
(*currentPlayersTurnIt)->action(); (*currentPlayersTurnIt)->action();
+9
View File
@@ -53,6 +53,12 @@ protected:
void setPlayersTurn(int theValue) { playersTurn = theValue; } void setPlayersTurn(int theValue) { playersTurn = theValue; }
int getPlayersTurn() const { return playersTurn;} int getPlayersTurn() const { return playersTurn;}
void setCurrentPlayersTurn(unsigned theValue) { currentPlayersTurn = theValue; }
unsigned getCurrentPlayersTurn() const { return currentPlayersTurn;}
void setFirstRoundLastPlayersTurn(unsigned theValue) { firstRoundLastPlayersTurn = theValue; }
unsigned getFirstRoundLastPlayersTurn() const { return firstRoundLastPlayersTurn;}
void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; } void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; }
PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; } PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; }
@@ -98,6 +104,9 @@ private:
PlayerListIterator currentPlayersTurnIt; // iterator for runningPlayerList PlayerListIterator currentPlayersTurnIt; // iterator for runningPlayerList
PlayerListIterator lastPlayersTurnIt; // iterator for runningPlayerList PlayerListIterator lastPlayersTurnIt; // iterator for runningPlayerList
unsigned currentPlayersTurn;
unsigned firstRoundLastPlayersTurn;
bool logBoardCardsDone; bool logBoardCardsDone;
int lastActionPlayer; int lastActionPlayer;
+11 -2
View File
@@ -24,8 +24,10 @@
using namespace std; using namespace std;
LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP) LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) : LocalBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP), bigBlindPosition(0)
{ {
PlayerListConstIterator it_c;
setHighestSet(2*getSmallBlind()); setHighestSet(2*getSmallBlind());
// determine bigBlindPosition // determine bigBlindPosition
@@ -33,6 +35,13 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) :
if((*bigBlindPositionIt)->getMyButton() == BUTTON_BIG_BLIND) break; if((*bigBlindPositionIt)->getMyButton() == BUTTON_BIG_BLIND) break;
} }
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); it_c++) {
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
bigBlindPosition = (*it_c)->getMyUniqueID();
break;
};
}
// search player in runningPlayerList before first action player -> run() determine next player who will do first action // search player in runningPlayerList before first action player -> run() determine next player who will do first action
PlayerListIterator it_1, it_2, it_3; PlayerListIterator it_1, it_2, it_3;
@@ -80,7 +89,7 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* hi, int id, int dP, int sB) :
setCurrentPlayersTurnIt(getLastPlayersTurnIt()); setCurrentPlayersTurnIt(getLastPlayersTurnIt());
cout << "playerID constructor preflopRun(): " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl; // cout << "playerID constructor beropreflop: " << (*(getCurrentPlayersTurnIt()))->getMyID() << endl;
/////////////// testing /////////////// testing
@@ -35,6 +35,7 @@ public:
private: private:
PlayerListIterator bigBlindPositionIt; // iterator for activePlayerList PlayerListIterator bigBlindPositionIt; // iterator for activePlayerList
unsigned bigBlindPosition;
}; };
#endif #endif
+40 -45
View File
@@ -27,12 +27,12 @@
using namespace std; 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, int dP, int sB,int sC) 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 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), : 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),
cardsShown(false), bettingRoundsPlayed(0) cardsShown(false), bettingRoundsPlayed(0)
{ {
int i, j, k; int i, j, k;
PlayerListIterator it; PlayerListConstIterator it_c;
CardsValue myCardsValue; CardsValue myCardsValue;
@@ -46,9 +46,9 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// roundStartCashArray fllen // roundStartCashArray fllen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { // for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash()); // playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
} // }
// Karten generieren und Board sowie Player zuweisen // Karten generieren und Board sowie Player zuweisen
int *cardsArray = new int[2*activePlayerList->size()+5]; int *cardsArray = new int[2*activePlayerList->size()+5];
@@ -65,18 +65,19 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
k = 0; k = 0;
myBoard->setMyCards(tempBoardArray); myBoard->setMyCards(tempBoardArray);
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++, k++) { for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++, k++) {
(*it)->getMyBestHandPosition(bestHandPos); (*it_c)->getMyBestHandPosition(bestHandPos);
for(j=0; j<2; j++) { for(j=0; j<2; j++) {
tempPlayerArray[j] = cardsArray[2*k+j+5]; tempPlayerArray[j] = cardsArray[2*k+j+5];
tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5]; tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5];
} }
(*it)->setMyCards(tempPlayerArray); (*it_c)->setMyCards(tempPlayerArray);
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos)); (*it_c)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos));
(*it)->setMyBestHandPosition(bestHandPos); (*it_c)->setMyBestHandPosition(bestHandPos);
(*it_c)->setMyRoundStartCash((*it_c)->getMyCash());
// myBestHandPosition auf Fehler ueberpruefen // myBestHandPosition auf Fehler ueberpruefen
for(j=0; j<5; j++) { for(j=0; j<5; j++) {
@@ -86,10 +87,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
} }
// sBluff für alle aktiver Spieler außer human player setzen --> TODO for ai-player in internet // sBluff für alle aktiver Spieler außer human player setzen --> TODO for ai-player in internet
if((*it)->getMyID() != 0) { if((*it_c)->getMyID() != 0) {
Tools::getRandNumber(1,100,1,&sBluff,0); Tools::getRandNumber(1,100,1,&sBluff,0);
(*it)->setSBluff(sBluff); (*it_c)->setSBluff(sBluff);
(*it)->setSBluffStatus(0); (*it_c)->setSBluffStatus(0);
} }
} }
@@ -99,7 +100,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
if(DEBUG_MODE) { if(DEBUG_MODE) {
int temp5Array[5]; // int temp5Array[5];
switch(myID) { switch(myID) {
@@ -285,7 +286,7 @@ void LocalHand::start() {
void LocalHand::assignButtons() { void LocalHand::assignButtons() {
int i,j; int i,j;
PlayerListIterator it; PlayerListConstIterator it_c;
// alle Buttons loeschen // 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); }
@@ -317,50 +318,43 @@ void LocalHand::assignButtons() {
} }
//do sets --> TODO switch? //do sets --> TODO switch?
for (it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) { for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); it_c++) {
//small blind //small blind
if((*it)->getMyButton() == 2) { if((*it_c)->getMyButton() == 2) {
// All in ? // All in ?
if((*it)->getMyCash() <= smallBlind) { if((*it_c)->getMyCash() <= smallBlind) {
(*it)->setMySet((*it)->getMyCash()); (*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this // 1 to do not log this
(*it)->setMyAction(6,1); (*it_c)->setMyAction(6,1);
// delete this player from runningPlayerList // delete this player from runningPlayerList
it = runningPlayerList->erase(it); // it_c = runningPlayerList->erase(it_c);
} }
else { else {
(*it)->setMySet(smallBlind); (*it_c)->setMySet(smallBlind);
it++; }
} }
} else {
//big blind //big blind
if((*it)->getMyButton() == 3) { if((*it_c)->getMyButton() == 3) {
// all in ? // all in ?
if((*it)->getMyCash() <= 2*smallBlind) { if((*it_c)->getMyCash() <= 2*smallBlind) {
(*it)->setMySet((*it)->getMyCash()); (*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this // 1 to do not log this
(*it)->setMyAction(6,1); (*it_c)->setMyAction(6,1);
// delete this player from runningPlayerList // delete this player from runningPlayerList
it = runningPlayerList->erase(it); // it_c = runningPlayerList->erase(it_c);
} }
else { else {
(*it)->setMySet(2*smallBlind); (*it_c)->setMySet(2*smallBlind);
it++;
} }
} else {
it++;
} }
}
} }
} }
@@ -370,16 +364,17 @@ void LocalHand::switchRounds() {
// cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get // cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get
int i; int i;
PlayerListIterator it, it_1; PlayerListIterator it;
PlayerListConstIterator it_c;
// refresh runningPlayerList // refresh runningPlayerList
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) { for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) {
if((*it)->getMyAction() == 1 || (*it)->getMyAction() == 6) { if((*it)->getMyAction() == 1 || (*it)->getMyAction() == 6) {
it = runningPlayerList->erase(it); it = runningPlayerList->erase(it);
it_1 = it; // it_1 = it;
if(it_1 == runningPlayerList->begin()) it_1 = runningPlayerList->end(); // if(it_1 == runningPlayerList->begin()) it_1 = runningPlayerList->end();
it_1--; // it_1--;
getCurrentBeRo()->setCurrentPlayersTurnIt(it_1); // getCurrentBeRo()->setCurrentPlayersTurnIt(it_1);
} else { } else {
it++; it++;
} }
@@ -387,14 +382,14 @@ void LocalHand::switchRounds() {
// Anzahl der Spieler ermitteln, welche All In sind // Anzahl der Spieler ermitteln, welche All In sind
int allInPlayersCounter = 0; int allInPlayersCounter = 0;
for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
if ((*it)->getMyAction() == 6) allInPlayersCounter++; if ((*it_c)->getMyAction() == 6) allInPlayersCounter++;
} }
// TODO -> runningPlayerList.size() // TODO -> runningPlayerList.size()
int nonFoldPlayerCounter = 0; int nonFoldPlayerCounter = 0;
for (it=activePlayerList->begin(); it!=activePlayerList->end(); it++) { for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
if ((*it)->getMyAction() != 1) nonFoldPlayerCounter++; if ((*it_c)->getMyAction() != 1) nonFoldPlayerCounter++;
} }
//wenn nur noch einer nicht-folded dann gleich den Pot verteilen //wenn nur noch einer nicht-folded dann gleich den Pot verteilen
+1 -1
View File
@@ -976,7 +976,7 @@ void LocalPlayer::action() {
actualHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, mySet); actualHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, mySet);
actualHand->getGuiInterface()->nextPlayerAnimation(); actualHand->getGuiInterface()->nextPlayerAnimation();
cout << "playerID in action(): " << (*(actualHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl; // cout << "playerID in action(): " << (*(actualHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl;
} }
+17 -12
View File
@@ -69,10 +69,11 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
actualBoard = myFactory->createBoard(); actualBoard = myFactory->createBoard();
// Player erstellen
activePlayerList = 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> >); runningPlayerList = PlayerList(new std::list<boost::shared_ptr<PlayerInterface> >);
// Player erstellen
player_i = playerDataList.begin(); player_i = playerDataList.begin();
player_end = playerDataList.end(); player_end = playerDataList.end();
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
@@ -135,6 +136,7 @@ void Game::initHand()
{ {
int i; int i;
PlayerListConstIterator it_c;
// eventuell vorhandene Hand löschen // eventuell vorhandene Hand löschen
if(actualHand) { if(actualHand) {
@@ -147,10 +149,20 @@ void Game::initHand()
// smallBlind alle x Runden erhöhen // smallBlind alle x Runden erhöhen
if((actualHandID-1)%startHandsBeforeRaiseSmallBlind == 0 && actualHandID > 1) { actualSmallBlind *= 2; } if((actualHandID-1)%startHandsBeforeRaiseSmallBlind == 0 && actualHandID > 1) { actualSmallBlind *= 2; }
// Spieler mit leerem Cash auf inactive setzen //Spieler Action auf 0 setzen
PlayerListIterator it; // for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
// playerArray[i]->setMyAction(0);
// }
for(it=activePlayerList->begin(); it!=activePlayerList->end(); ) { //Spieler Action auf 0 setzen
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++) {
(*it_c)->setMyAction(PLAYER_ACTION_NONE);
}
// Spieler mit leerem Cash auf inactive setzen
PlayerListIterator it = activePlayerList->begin();
while( it!=activePlayerList->end() ) {
if((*it)->getMyCash() == 0) { if((*it)->getMyCash() == 0) {
// cout << "playerID: " << (*it)->getMyID() << endl; // cout << "playerID: " << (*it)->getMyID() << endl;
@@ -161,11 +173,6 @@ void Game::initHand()
} }
} }
//Spieler Action auf 0 setzen
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
playerArray[i]->setMyAction(0);
}
runningPlayerList->clear(); runningPlayerList->clear();
(*runningPlayerList) = (*activePlayerList); (*runningPlayerList) = (*activePlayerList);
@@ -173,13 +180,11 @@ void Game::initHand()
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);
// Dealer-Button weiterschieben --> Achtung inactive // Dealer-Button weiterschieben --> Achtung inactive -> TODO exception-rule !!!
for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(playerArray[dealerPosition]->getMyActiveStatus())) || i==0; i++) { for(i=0; (i<MAX_NUMBER_OF_PLAYERS && !(playerArray[dealerPosition]->getMyActiveStatus())) || i==0; i++) {
dealerPosition = (dealerPosition+1)%(MAX_NUMBER_OF_PLAYERS); dealerPosition = (dealerPosition+1)%(MAX_NUMBER_OF_PLAYERS);
} }
// Abfrage Cash==0 -> player inactive -> actualQuantityPlayer--
} }
void Game::startHand() void Game::startHand()
+1
View File
@@ -37,6 +37,7 @@ struct StartData;
typedef boost::shared_ptr<std::list<boost::shared_ptr<PlayerInterface> > > PlayerList; typedef boost::shared_ptr<std::list<boost::shared_ptr<PlayerInterface> > > PlayerList;
typedef std::list<boost::shared_ptr<PlayerInterface> >::iterator PlayerListIterator; typedef std::list<boost::shared_ptr<PlayerInterface> >::iterator PlayerListIterator;
typedef std::list<boost::shared_ptr<PlayerInterface> >::const_iterator PlayerListConstIterator;
class Game { class Game {
+2 -2
View File
@@ -2082,8 +2082,8 @@ void mainWindowImpl::postRiverRunAnimation3() {
// groupBoxArray[i]->setPalette(tempPalette); // groupBoxArray[i]->setPalette(tempPalette);
actionLabelArray[i]->setPixmap(QPixmap(myAppDataPath +"gfx/gui/table/default/action_winner.png")); actionLabelArray[i]->setPixmap(QPixmap(myAppDataPath +"gfx/gui/table/default/action_winner.png"));
//show winnercards if more than one player is active //show winnercards if more than one player is active TODO
if ( currentHand->getRunningPlayerList()->size() != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) { if ( currentHand->getActivePlayerList()->size() != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) {
int j; int j;
int bestHandPos[5]; int bestHandPos[5];