diff --git a/pokerth.pro b/pokerth.pro index ff465f60..62c216af 100755 --- a/pokerth.pro +++ b/pokerth.pro @@ -101,12 +101,16 @@ HEADERS += src/game.h \ src/engine/local_engine/localboard.h \ src/engine/local_engine/localenginefactory.h \ src/engine/local_engine/localflop.h \ + src/engine/local_engine/localberoflop.h \ src/engine/local_engine/localhand.h \ src/engine/local_engine/localplayer.h \ src/engine/local_engine/localpreflop.h \ src/engine/local_engine/localberopreflop.h \ src/engine/local_engine/localriver.h \ + src/engine/local_engine/localberoriver.h \ + src/engine/local_engine/localberopostriver.h \ src/engine/local_engine/localturn.h \ + src/engine/local_engine/localberoturn.h \ src/engine/local_engine/tools.h \ src/engine/local_engine/localbero.h \ src/engine/local_engine/localberofactory.h \ @@ -183,12 +187,16 @@ SOURCES += src/game.cpp \ src/engine/local_engine/localboard.cpp \ src/engine/local_engine/localenginefactory.cpp \ src/engine/local_engine/localflop.cpp \ - src/engine/local_engine/localhand.cpp \ + src/engine/local_engine/localberoflop.cpp \ + src/engine/local_engine/localhand.cpp \ src/engine/local_engine/localplayer.cpp \ src/engine/local_engine/localpreflop.cpp \ src/engine/local_engine/localberopreflop.cpp \ src/engine/local_engine/localriver.cpp \ + src/engine/local_engine/localberoriver.cpp \ + src/engine/local_engine/localberopostriver.cpp \ src/engine/local_engine/localturn.cpp \ + src/engine/local_engine/localberoturn.cpp \ src/engine/local_engine/tools.cpp \ src/engine/local_engine/localbero.cpp \ src/engine/local_engine/localberofactory.cpp \ diff --git a/src/engine/berofactoryinterface.h b/src/engine/berofactoryinterface.h index 99ba2f12..d4fa46d1 100644 --- a/src/engine/berofactoryinterface.h +++ b/src/engine/berofactoryinterface.h @@ -23,7 +23,7 @@ public: virtual ~BeRoFactoryInterface(); - virtual BeRoInterface* switchRounds() = 0; + virtual BeRoInterface* switchRounds(int) = 0; }; diff --git a/src/engine/berointerface.h b/src/engine/berointerface.h index e7f37408..99097e9e 100644 --- a/src/engine/berointerface.h +++ b/src/engine/berointerface.h @@ -19,6 +19,8 @@ class BeRoInterface{ public: virtual ~BeRoInterface(); + + virtual int getMyBeRoID() const =0; virtual void setPlayersTurn(int) =0; virtual int getPlayersTurn() const =0; @@ -26,10 +28,12 @@ public: virtual void setHighestSet(int) =0; virtual int getHighestSet() const =0; - virtual void setPreflopFirstRound(bool) =0; - virtual bool setPreflopFirstRound() const =0; - virtual void preflopRun() =0; + virtual void flopRun() =0; + virtual void turnRun() =0; + virtual void riverRun() =0; + virtual void postRiverRun() =0; + virtual void nextPlayer2() =0; }; diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index 028b2c89..2f657386 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -43,6 +43,7 @@ public: virtual TurnInterface* getTurn() const =0; virtual RiverInterface* getRiver() const =0; virtual GuiInterface* getGuiInterface() const =0; + virtual BeRoInterface* getCurrentBeRo() const =0; virtual void setMyID(int theValue) =0; virtual int getMyID() const =0; diff --git a/src/engine/local_engine/localbero.h b/src/engine/local_engine/localbero.h index 47202eb9..24a7f06e 100644 --- a/src/engine/local_engine/localbero.h +++ b/src/engine/local_engine/localbero.h @@ -23,6 +23,12 @@ public: ~LocalBeRo(); + int getMyBeRoID() const { return myBeRoID; } + +protected: + + int myBeRoID; + }; #endif diff --git a/src/engine/local_engine/localberofactory.cpp b/src/engine/local_engine/localberofactory.cpp index 8e6fceef..4b80ed3d 100644 --- a/src/engine/local_engine/localberofactory.cpp +++ b/src/engine/local_engine/localberofactory.cpp @@ -11,6 +11,8 @@ // #include "localberofactory.h" +using namespace std; + LocalBeRoFactory::LocalBeRoFactory (HandInterface* hi, int id, int aP, int dP, int sB) : BeRoFactoryInterface() , myHand(hi), myID(id), actualQuantityPlayers(aP), dealerPosition(dP), smallBlind(sB) {} @@ -19,12 +21,68 @@ LocalBeRoFactory::LocalBeRoFactory (HandInterface* hi, int id, int aP, int dP, i LocalBeRoFactory::~LocalBeRoFactory() {} -BeRoInterface* LocalBeRoFactory::switchRounds() +BeRoInterface* LocalBeRoFactory::switchRounds(int currentRound) { BeRoInterface* myBeRo = NULL; - myBeRo = new LocalBeRoPreflop ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind ); + switch(currentRound) { + case GAME_STATE_PREFLOP: { + if(currentRound != myHand->getCurrentBeRo()->getMyBeRoID()) { + + delete myBeRo; + myBeRo = NULL; + + myBeRo = new LocalBeRoPreflop ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind ); + } + } + break; + case GAME_STATE_FLOP: { + if(currentRound != myHand->getCurrentBeRo()->getMyBeRoID()) { + + delete myBeRo; + myBeRo = NULL; + + myBeRo = new LocalBeRoFlop( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind ); + } + } + break; + case GAME_STATE_TURN: { + if(currentRound != myHand->getCurrentBeRo()->getMyBeRoID()) { + + delete myBeRo; + myBeRo = NULL; + + myBeRo = new LocalBeRoTurn( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind ); + } + } + break; + case GAME_STATE_RIVER: { + if(currentRound != myHand->getCurrentBeRo()->getMyBeRoID()) { + + delete myBeRo; + myBeRo = NULL; + + myBeRo = new LocalBeRoRiver ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind ); + } + } + break; + case GAME_STATE_POST_RIVER: { + if(currentRound != myHand->getCurrentBeRo()->getMyBeRoID()) { + + delete myBeRo; + myBeRo = NULL; + + myBeRo = new LocalBeRoPostRiver ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind ); + } + } + break; + default: { cout << "BeRoFactory-ERROR" << endl; } + } + + + + return myBeRo; } diff --git a/src/engine/local_engine/localberofactory.h b/src/engine/local_engine/localberofactory.h index 7785a005..415b899e 100644 --- a/src/engine/local_engine/localberofactory.h +++ b/src/engine/local_engine/localberofactory.h @@ -12,10 +12,16 @@ #ifndef LOCALBEROFACTORY_H #define LOCALBEROFACTORY_H +#include + #include #include #include #include +#include +#include +#include +#include /** @author FThauer FHammer @@ -27,7 +33,7 @@ public: ~LocalBeRoFactory(); - BeRoInterface* switchRounds(); + BeRoInterface* switchRounds(int); private: diff --git a/src/engine/local_engine/localberoflop.cpp b/src/engine/local_engine/localberoflop.cpp new file mode 100644 index 00000000..e8d14f91 --- /dev/null +++ b/src/engine/local_engine/localberoflop.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "localberoflop.h" + +#include +#include + +using namespace std; + +LocalBeRoFlop::LocalBeRoFlop(HandInterface* bR, int id, int qP, int dP, int sB) : LocalBeRo(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), firstHeadsUpFlopRound(1), playersTurn(dP), logBoardCardsDone(0) + +{ + + myBeRoID = GAME_STATE_FLOP; + + int i; + + //SmallBlind-Position ermitteln + for(i=0; igetPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i; + } + + cout << "LocalBeroFlop erstellt - " << myBeRoID << endl; +} + + +LocalBeRoFlop::~LocalBeRoFlop() +{ +} + +void LocalBeRoFlop::flopRun() { + + cout << "LocalBeroFlopRun!!!" << endl; + + int i; + + if (firstFlopRun) { + myHand->getGuiInterface()->dealFlopCards(); + firstFlopRun = 0; + + } + + else { + //log the turned cards + if(!logBoardCardsDone) { + int tempBoardCardsArray[5]; + + myHand->getBoard()->getMyCards(tempBoardCardsArray); + myHand->getGuiInterface()->logDealBoardCardsMsg(1, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]); + logBoardCardsDone = 1; + } + + bool allHighestSet = 1; + + // prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 ) + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) { + if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } + } + } + +// cout << "firstflopround " << firstFlopRound << endl; + + // prfen, ob Flop wirklich dran ist + if(!firstFlopRound && allHighestSet) { + + // Flop nicht dran, weil alle Sets gleich sind + //also gehe in Turn + myHand->setActualRound(2); + + //Action loeschen und ActionButtons refresh + for(i=0; igetPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0); + } + //Sets in den Pot verschieben und Sets = 0 und Pot-refresh + myHand->getBoard()->collectSets(); + myHand->getBoard()->collectPot(); + myHand->getGuiInterface()->refreshPot(); + + myHand->getGuiInterface()->refreshSet(); + myHand->getGuiInterface()->refreshCash(); + for(i=0; igetGuiInterface()->refreshAction(i,0); } + + myHand->switchRounds(); + } + else { + // Flop ist wirklich dran + + // Anzahl der effektiv gespielten Runden (des human player) erhöhen + if(myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1) { + myHand->setBettingRoundsPlayed(1); + } + + if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpFlopRound == 1) ) { +// not first round in heads up (for headsup dealer is smallblind so it is dealers turn) + + // naechsten Spieler ermitteln + do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6); + } + else { firstHeadsUpFlopRound = 0; } + + //Spieler-Position vor SmallBlind-Position ermitteln + int activePlayerBeforeSmallBlind = smallBlindPosition; + do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6); + + myHand->getPlayerArray()[playersTurn]->setMyTurn(1); + //highlight active players groupbox and clear action + myHand->getGuiInterface()->refreshGroupbox(playersTurn,2); + myHand->getGuiInterface()->refreshAction(playersTurn,0); + +// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl; +// cout << "playersTurn " << playersTurn << endl; + + // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende + if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstFlopRound = 0; } + + if(playersTurn == 0) { + // Wir sind dran +// cout << "actualRound " << myHand->getActualRound() << endl; +// cout << "highestSet vor meInAction " << highestSet << endl; + myHand->getGuiInterface()->meInAction(); + } + else { + //Gegner sind dran +// cout << "NextPlayerSpeed3 start" << endl; + myHand->getGuiInterface()->flopAnimation2(); + } + } + } +} + +void LocalBeRoFlop::nextPlayer2() { + +// cout << "NextPlayerSpeed3 stop" << endl; + myHand->getPlayerArray()[playersTurn]->action(); + +} + + diff --git a/src/engine/local_engine/localberoflop.h b/src/engine/local_engine/localberoflop.h new file mode 100644 index 00000000..113cf46a --- /dev/null +++ b/src/engine/local_engine/localberoflop.h @@ -0,0 +1,82 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef LOCALBEROFLOP_H +#define LOCALBEROFLOP_H + +#include +#include + +class HandInterface; + +class LocalBeRoFlop : public LocalBeRo{ + +public: + LocalBeRoFlop(HandInterface*, int, int, int, int); + ~LocalBeRoFlop(); + + + void setPlayersTurn(int theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(int theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setFirstFlopRound(bool theValue) { firstFlopRound = theValue;} + bool getFirstFlopRound() const { return firstFlopRound;} + + void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;} + int getSmallBlindPosition() const { return smallBlindPosition; } + + void setSmallBlind(int theValue) { smallBlind = theValue; } + int getSmallBlind() const { return smallBlind; } + + void resetFirstRun() { firstFlopRun = false; } + + void flopRun(); + void nextPlayer2(); + + //only until bero refactory is over + void preflopRun() {} + void turnRun() {} + void riverRun() {} + void postRiverRun() {} + +private: + + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int smallBlindPosition; + + int smallBlind; + int highestSet; + + bool firstFlopRun; + bool firstFlopRound; + bool firstHeadsUpFlopRound; + int playersTurn; + + bool logBoardCardsDone; + +}; + +#endif diff --git a/src/engine/local_engine/localberopostriver.cpp b/src/engine/local_engine/localberopostriver.cpp new file mode 100644 index 00000000..16e92bca --- /dev/null +++ b/src/engine/local_engine/localberopostriver.cpp @@ -0,0 +1,478 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "localberopostriver.h" +#include +#include + +#include + +using namespace std; + +LocalBeRoPostRiver::LocalBeRoPostRiver(HandInterface* bR, int id, int qP, int dP, int sB) : LocalBeRo(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRiverRun(1), firstRiverRound(1), firstHeadsUpRiverRound(1), playersTurn(dP), highestCardsValue(0), logBoardCardsDone(0) + +{ + + myBeRoID = GAME_STATE_RIVER; + + int i; + + //SmallBlind-Position ermitteln + for(i=0; igetPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i; + } +cout << "LocalBeroPostRiver erstellt - " << myBeRoID << endl; +} + +LocalBeRoPostRiver::~LocalBeRoPostRiver() +{ +} + + +void LocalBeRoPostRiver::riverRun() { + + cout << "LocalBeroPostRiverRun!!!" << endl; + int i; + + if (firstRiverRun) { + myHand->getGuiInterface()->dealRiverCard(); + firstRiverRun = 0; + + } + + else { + //log the turned cards + if(!logBoardCardsDone) { + int tempBoardCardsArray[5]; + + myHand->getBoard()->getMyCards(tempBoardCardsArray); + myHand->getGuiInterface()->logDealBoardCardsMsg(3, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]); + logBoardCardsDone = 1; + } + + bool allHighestSet = 1; + + // prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 ) + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) { +// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl; + if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } + } + } +// cout << "allHighestSet " << allHighestSet << endl; + +// cout << "firstflopround " << firstRiverRound << endl; + + // prfen, ob River wirklich dran ist + if(!firstRiverRound && allHighestSet) { + + // River nicht dran, weil alle Sets gleich sind + //also gehe in Turn + myHand->setActualRound(4); + + //Action lᅵchen und ActionButtons refresh + for(i=0; igetPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0); + } + //Sets in den Pot verschieben und Sets = 0 und Pot-refresh + myHand->getBoard()->collectSets(); + myHand->getBoard()->collectPot(); + myHand->getGuiInterface()->refreshPot(); + + myHand->getGuiInterface()->refreshSet(); + myHand->getGuiInterface()->refreshCash(); + for(i=0; igetGuiInterface()->refreshAction(i,0); } + + + myHand->switchRounds(); + } + else { + // River ist wirklich dran + + // Anzahl der effektiv gespielten Runden (des human player) erhöhen + if(myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1) { + myHand->setBettingRoundsPlayed(3); + } + + if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpRiverRound == 1) ) { +// not first round in heads up (for headsup dealer is smallblind so it is dealers turn) + + // naechsten Spieler ermitteln + do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6); + } + else { firstHeadsUpRiverRound = 0; } + + //Spieler-Position vor SmallBlind-Position ermitteln + int activePlayerBeforeSmallBlind = smallBlindPosition; + do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6); + + myHand->getPlayerArray()[playersTurn]->setMyTurn(1); + //highlight active players groupbox and clear action + myHand->getGuiInterface()->refreshGroupbox(playersTurn,2); + myHand->getGuiInterface()->refreshAction(playersTurn,0); + +// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl; +// cout << "playersTurn " << playersTurn << endl; + // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende + if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; } + + if(playersTurn == 0) { + // Wir sind dran +// cout << "actualRound " << myHand->getActualRound() << endl; +// cout << "highestSet vor meInAction " << highestSet << endl; + myHand->getGuiInterface()->meInAction(); + } + else { + //Gegner sind dran + myHand->getGuiInterface()->riverAnimation2(); + } + } + } +} + +void LocalBeRoPostRiver::postRiverRun() { + + int i; + + // für die Engine die durchschnittlichen Sets von Player 0 setzen --> UNUSED !!! +// if(myID < 5) { +// myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*(myID-1))/myID + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/myID); +// } else { +// myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*4)/5 + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/5); +// } + +// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl; + + //berechnen welcher Spieler gewonnen hat + for(i=0; igetPlayerArray()[i]->getMyCardsValueInt() << endl; + + if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyCardsValueInt() > highestCardsValue ) { + highestCardsValue = myHand->getPlayerArray()[i]->getMyCardsValueInt(); + } + } + + // Durchschnittsets des human player ermitteln + myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyRoundStartCash())-(myHand->getPlayerArray()[0]->getMyCash()))/(myHand->getBettingRoundsPlayed()+1)); +// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl; + + // Aggressivität des human player ermitteln + // anzahl der player die möglichkeit haben am pot teilzuhaben + int potPlayers = 0; + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) { + potPlayers++; + } + } + + // prüfen ob nur noch der human player an der verteilung teilnimmt und myAggressive für human player setzen + myHand->getPlayerArray()[0]->setMyAggressive(potPlayers == 1 && myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1); + +// cout << "myAggressive: " << myHand->getPlayerArray()[0]->getMyAggressive() << endl; + + // Pot-Verteilung + distributePot(); + + //Pot auf 0 setzen + myHand->getBoard()->setPot(0); + + //starte die Animaionsreihe + myHand->getGuiInterface()->postRiverRunAnimation1(); +} + +void LocalBeRoPostRiver::nextPlayer2() { + + myHand->getPlayerArray()[playersTurn]->action(); + +} + +void LocalBeRoPostRiver::distributePot() { + +// int potCalcAllinArray[5][2]; // 0 -> ID , 1 -> AllInCash + + int i, j; + + //////////////////// + // (1) EINLEITUNG // + //////////////////// + + // die Potverteilung gliedert sich in mehrere Runden: + // in der ersten Runden sucht sich der Winner der BettingRound seinen zustehenden Anteil am Pot raus. das kann alles oder nur ein Teil sein (z.b. wenn er mit wenig allin gegangen ist und der Rest weitergespielt hat) + // in den darauffolgenden Verteilungsrunden suchen sich die jeweils nᅵhsten Winner aus dem noch brig gebliebenen Pot ihren zustehenden Anteil raus + // die gesamte Potverteilung ist zuende, wenn der Pot leer ist und nichts mehr zu holen ist + + + ///////////////////// + // (2) HILFSMITTEL // + ///////////////////// + + // winnersArray erstellen -> hier werden die winner der jeweiligen Potverteilungsrunden eingetragen + int *winnersArray = new int[MAX_NUMBER_OF_PLAYERS]; + + // Anzahl der winner in einer Potverteilungsrunde + int winnersCounter = 0; + + // dieses Array ermittelt wieviel jeder Spieler wᅵrend der gesamten BettingRound gesetzt hat + int *roundSetArray = new int[MAX_NUMBER_OF_PLAYERS]; + for(i=0; igetPlayerArray()[i]->getMyActiveStatus()) { + roundSetArray[i] = myHand->getPlayerArray()[i]->getMyRoundStartCash()-myHand->getPlayerArray()[i]->getMyCash(); + } + } + + // hier steht der CardsValue der Spieler drin die an der Potverteilung teilnehmen (d.h. aktiv und nicht gefoldet), bei allen anderen steht ne 0 + int *cardsValueArray = new int[MAX_NUMBER_OF_PLAYERS]; + int playerWantsPotCounter = 0; + + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) { + // nur bei den Spielen den Kartenwert eintragen, die an der Potverteilung teilnehmen + cardsValueArray[i] = myHand->getPlayerArray()[i]->getMyCardsValueInt(); + playerWantsPotCounter++; + } + } + + int winner; + int highestCardsValueTemp; + + // fr SplitPotBerechnung; + int winnersSets; + int winnersMaxSet; + int winnersPot; + bool playerIsWinner; + + + + ////////////////////// + // (3) DIE SCHLEIFE // + ////////////////////// + + + // Potverteilungsrunden -> solange noch was aus dem pot zu vergeben ist + while(playerWantsPotCounter != 0 ) { + + // highestCardsValueTemp zu Beginn der aktuellen Potverteilungsrunde auf Null setzen + highestCardsValueTemp = 0; + + // aktuellen highestCardsValueTemp berechnen, von denen die noch an der Potverteilung teilnehmen + for(i=0; i highestCardsValueTemp ) { + highestCardsValueTemp = myHand->getPlayerArray()[i]->getMyCardsValueInt(); + } + } + + // zu Beginn der Potverteilungsrunde die Anzahl der winner auf 0 setzen + winnersCounter = 0; + // Siegerposition und -anzahl von denen ermitteln, die noch an der Potverteilung teilnehmen + for(i=0; i bekommt den gesamten Pot +// if(myHand->getPlayerArray()[winner]->getMyAction() != 6) { +// +// myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+myHand->getBoard()->getPot()); +// myHand->getBoard()->setPot(0); +// playerWantsPotCounter = 1; +// +// } + // Winner ist All In gegangen -> von denen die weniger gesetzt oder gefoldet hatten alles nehmen und von denen die mehr gesetzt hatten nur die eigenen Sets nehmen +// else { + + // alle Spieler nacheinander durchgehen und prfen von wem man wieviel Geld aus dem Pot bekommt + for(i=0; igetPlayerArray()[i]->getMyAction() == 1) { + + // diesen Teil aus dem Pot holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]); + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nimmt der Winner dann von diesen Spielern 0 Dollar aus dem Pot + roundSetArray[i] = 0; + + } + + // nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht von einem selber + if(i != winner && cardsValueArray[i] != 0) { + + // zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten + if(roundSetArray[winner] >= roundSetArray[i]) { + + // von denen alles holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]); + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // diese Spieler dann von der weiteren Potverteilung ausschlieᅵn + cardsValueArray[i] = 0; + playerWantsPotCounter--; + // deren Sets auf Null seztzen, da sie schon alles abgegeben haben + roundSetArray[i] = 0; + + } + // nun alle Spieler die mehr gesetzt hatten + else { + + // den eigenen Setanteil aus dem Pot holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]); + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]); + // den Set des Gegners um den bereits abgenommenen Setanteil verkleinern + roundSetArray[i] = roundSetArray[i] - roundSetArray[winner]; + // diese Spieler nehmen an der weiteren Potverteilung teil + + } + } + } +// // } + + // zum Scluss noch eingenen Set wieder holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]); + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]); + // nicht mehr an der weiteren Potverteilung teilnehmen, da man sich alles geholt hat was einem zusteht + cardsValueArray[winner] = 0; + playerWantsPotCounter--; + // eigene Sets auf Null seztzen, da sie eben eingesammelt wurden + roundSetArray[winner] = 0; + + } + + + // ---------------------------------------------------------------------- + // B) mehrere haben die aktuelle Potverteilungsrunde gewonnen -> SplitPot + // ---------------------------------------------------------------------- + else { + + // hierfr wird ein temporᅵer WinnersPot erstellt; dort flieᅵn erstmal alle zustehenden Anteile aus dem Pot rauf; am Ende wird dies auf die Winners verteilt + winnersPot = 0; + // hᅵhster Set aller Winner + winnersMaxSet = 0; + + // den hᅵhsten Set aller Winner ermitteln + for(i=0; i winnersMaxSet) winnersMaxSet = roundSetArray[i]; + } + + // gesamtSet aller Winner + winnersSets = 0; + for(i=0; i Spieler i gehᅵt zu den Winnern + } + + // zuerst prfen ob ein gefoldeter Spieler was gesetzt hatte + if(!playerIsWinner && myHand->getPlayerArray()[i]->getMyAction() == 1) { + + // diesen Teil aus dem Pot holen und dem winnersPot geben + winnersPot += roundSetArray[i]; + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nehmen die Winner dann von diesen Spielern 0 Dollar aus dem Pot + roundSetArray[i] = 0; + + } + + // nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht zu den Winnern gehᅵen + if(!playerIsWinner && cardsValueArray[i] != 0) { + + // zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten + if(winnersMaxSet >= roundSetArray[i]) { + + // von denen alles holen + winnersPot += roundSetArray[i]; + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // diese Spieler dann von der weiteren Potverteilung ausschlieᅵn + cardsValueArray[i] = 0; + playerWantsPotCounter--; + // deren Sets auf Null seztzen, da sie schon alles abgegeben haben + roundSetArray[i] = 0; + + } + // nun alle Spieler die mehr gesetzt hatten + else { + + // den eigenen Setanteil aus dem Pot holen + winnersPot += winnersMaxSet; + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersMaxSet); + // den Set des Gegners um den bereits abgenommenen Setanteil verkleinern + roundSetArray[i] = roundSetArray[i] - winnersMaxSet; + // diese Spieler nehmen an der weiteren Potverteilung teil + + } + } + } + + // zum Schluss noch die eingenen Set aus dem Pot holen + winnersPot += winnersSets; + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersSets); + + // winnersPot verteilen (anteilmᅵig) + for(i=0; igetPlayerArray()[winnersArray[i]]->setMyCash(myHand->getPlayerArray()[winnersArray[i]]->getMyCash()+((roundSetArray[winnersArray[i]]*winnersPot)/winnersSets)); + } + + + for(i=0; igetBoard()->getPot() != 0) cout << "!!! Pot: " << myHand->getBoard()->getPot() << endl; + + delete[] winnersArray; + delete[] roundSetArray; + delete[] cardsValueArray; + + +} diff --git a/src/engine/local_engine/localberopostriver.h b/src/engine/local_engine/localberopostriver.h new file mode 100644 index 00000000..9be872bd --- /dev/null +++ b/src/engine/local_engine/localberopostriver.h @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef LOCALBEROPOSTRIVER_H +#define LOCALBEROPOSTRIVER_H + +#include +#include + +class HandInterface; + + +class LocalBeRoPostRiver : public LocalBeRo{ +public: + LocalBeRoPostRiver(HandInterface*, int, int, int, int); + ~LocalBeRoPostRiver(); + + void setPlayersTurn(int theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(int theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setFirstRiverRound(bool theValue) { firstRiverRound = theValue;} + bool getFirstRiverRound() const { return firstRiverRound;} + + void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;} + int getSmallBlindPosition() const { return smallBlindPosition; } + + void setSmallBlind(int theValue) { smallBlind = theValue; } + int getSmallBlind() const { return smallBlind; } + + void setHighestCardsValue(int theValue) { highestCardsValue = theValue;} + int getHighestCardsValue() const { return highestCardsValue;} + + void resetFirstRun() { firstRiverRun = false; } + + void riverRun(); + void postRiverRun(); + void nextPlayer2(); + void distributePot(); + + //only until bero refactory is over + void preflopRun() {} + void turnRun() {} + void flopRun() {} + +private: + + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int smallBlindPosition; + + int smallBlind; + int highestSet; + + bool firstRiverRun; + bool firstRiverRound; + bool firstHeadsUpRiverRound; + int playersTurn; + + int highestCardsValue; + + bool logBoardCardsDone; + +}; + +#endif diff --git a/src/engine/local_engine/localberopreflop.cpp b/src/engine/local_engine/localberopreflop.cpp index 29727839..4a22aea5 100644 --- a/src/engine/local_engine/localberopreflop.cpp +++ b/src/engine/local_engine/localberopreflop.cpp @@ -27,6 +27,8 @@ using namespace std; LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* bR, int id, int qP, int dP, int sB) : LocalBeRo(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0) { + myBeRoID = GAME_STATE_PREFLOP; + // // BigBlind ermitteln bigBlindPosition = dealerPosition; while (myHand->getPlayerArray()[bigBlindPosition]->getMyButton() != 3) { @@ -36,7 +38,7 @@ LocalBeRoPreflop::LocalBeRoPreflop(HandInterface* bR, int id, int qP, int dP, in // // erste Spielernummer fr preflopRun() setzen playersTurn = bigBlindPosition; - cout << "LocalBeroPreflop erstellt" << endl; + cout << "LocalBeroPreflop erstellt - " << myBeRoID << endl; } diff --git a/src/engine/local_engine/localberopreflop.h b/src/engine/local_engine/localberopreflop.h index 1bcda052..45953438 100644 --- a/src/engine/local_engine/localberopreflop.h +++ b/src/engine/local_engine/localberopreflop.h @@ -38,17 +38,20 @@ public: void setHighestSet(int theValue) { highestSet = theValue; } int getHighestSet() const { return highestSet;} - void setPreflopFirstRound(bool theValue) { preflopFirstRound = theValue; } - bool setPreflopFirstRound() const { return preflopFirstRound; } - void preflopRun(); void nextPlayer2(); - + + //only until bero refactory is over + void flopRun() {} + void turnRun() {} + void riverRun() {} + void postRiverRun() {} private: HandInterface *myHand; + int myID; int actualQuantityPlayers; int dealerPosition; diff --git a/src/engine/local_engine/localberoriver.cpp b/src/engine/local_engine/localberoriver.cpp new file mode 100644 index 00000000..00c735f9 --- /dev/null +++ b/src/engine/local_engine/localberoriver.cpp @@ -0,0 +1,478 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "localberoriver.h" +#include +#include + +#include + +using namespace std; + +LocalBeRoRiver::LocalBeRoRiver(HandInterface* bR, int id, int qP, int dP, int sB) : LocalBeRo(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRiverRun(1), firstRiverRound(1), firstHeadsUpRiverRound(1), playersTurn(dP), highestCardsValue(0), logBoardCardsDone(0) + +{ + + myBeRoID = GAME_STATE_RIVER; + + int i; + + //SmallBlind-Position ermitteln + for(i=0; igetPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i; + } +cout << "LocalBeroRiver erstellt - " << myBeRoID << endl; +} + +LocalBeRoRiver::~LocalBeRoRiver() +{ +} + + +void LocalBeRoRiver::riverRun() { + + cout << "LocalBeroRiverRun!!!" << endl; + int i; + + if (firstRiverRun) { + myHand->getGuiInterface()->dealRiverCard(); + firstRiverRun = 0; + + } + + else { + //log the turned cards + if(!logBoardCardsDone) { + int tempBoardCardsArray[5]; + + myHand->getBoard()->getMyCards(tempBoardCardsArray); + myHand->getGuiInterface()->logDealBoardCardsMsg(3, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]); + logBoardCardsDone = 1; + } + + bool allHighestSet = 1; + + // prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 ) + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) { +// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl; + if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } + } + } +// cout << "allHighestSet " << allHighestSet << endl; + +// cout << "firstflopround " << firstRiverRound << endl; + + // prfen, ob River wirklich dran ist + if(!firstRiverRound && allHighestSet) { + + // River nicht dran, weil alle Sets gleich sind + //also gehe in Turn + myHand->setActualRound(4); + + //Action lᅵchen und ActionButtons refresh + for(i=0; igetPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0); + } + //Sets in den Pot verschieben und Sets = 0 und Pot-refresh + myHand->getBoard()->collectSets(); + myHand->getBoard()->collectPot(); + myHand->getGuiInterface()->refreshPot(); + + myHand->getGuiInterface()->refreshSet(); + myHand->getGuiInterface()->refreshCash(); + for(i=0; igetGuiInterface()->refreshAction(i,0); } + + + myHand->switchRounds(); + } + else { + // River ist wirklich dran + + // Anzahl der effektiv gespielten Runden (des human player) erhöhen + if(myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1) { + myHand->setBettingRoundsPlayed(3); + } + + if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpRiverRound == 1) ) { +// not first round in heads up (for headsup dealer is smallblind so it is dealers turn) + + // naechsten Spieler ermitteln + do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6); + } + else { firstHeadsUpRiverRound = 0; } + + //Spieler-Position vor SmallBlind-Position ermitteln + int activePlayerBeforeSmallBlind = smallBlindPosition; + do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6); + + myHand->getPlayerArray()[playersTurn]->setMyTurn(1); + //highlight active players groupbox and clear action + myHand->getGuiInterface()->refreshGroupbox(playersTurn,2); + myHand->getGuiInterface()->refreshAction(playersTurn,0); + +// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl; +// cout << "playersTurn " << playersTurn << endl; + // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende + if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; } + + if(playersTurn == 0) { + // Wir sind dran +// cout << "actualRound " << myHand->getActualRound() << endl; +// cout << "highestSet vor meInAction " << highestSet << endl; + myHand->getGuiInterface()->meInAction(); + } + else { + //Gegner sind dran + myHand->getGuiInterface()->riverAnimation2(); + } + } + } +} + +void LocalBeRoRiver::postRiverRun() { + + int i; + + // für die Engine die durchschnittlichen Sets von Player 0 setzen --> UNUSED !!! +// if(myID < 5) { +// myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*(myID-1))/myID + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/myID); +// } else { +// myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyAverageSets())*4)/5 + (myHand->getPlayerArray()[0]->getMyRoundStartCash()-myHand->getPlayerArray()[0]->getMyCash())/5); +// } + +// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl; + + //berechnen welcher Spieler gewonnen hat + for(i=0; igetPlayerArray()[i]->getMyCardsValueInt() << endl; + + if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyCardsValueInt() > highestCardsValue ) { + highestCardsValue = myHand->getPlayerArray()[i]->getMyCardsValueInt(); + } + } + + // Durchschnittsets des human player ermitteln + myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyRoundStartCash())-(myHand->getPlayerArray()[0]->getMyCash()))/(myHand->getBettingRoundsPlayed()+1)); +// cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl; + + // Aggressivität des human player ermitteln + // anzahl der player die möglichkeit haben am pot teilzuhaben + int potPlayers = 0; + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) { + potPlayers++; + } + } + + // prüfen ob nur noch der human player an der verteilung teilnimmt und myAggressive für human player setzen + myHand->getPlayerArray()[0]->setMyAggressive(potPlayers == 1 && myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1); + +// cout << "myAggressive: " << myHand->getPlayerArray()[0]->getMyAggressive() << endl; + + // Pot-Verteilung + distributePot(); + + //Pot auf 0 setzen + myHand->getBoard()->setPot(0); + + //starte die Animaionsreihe + myHand->getGuiInterface()->postRiverRunAnimation1(); +} + +void LocalBeRoRiver::nextPlayer2() { + + myHand->getPlayerArray()[playersTurn]->action(); + +} + +void LocalBeRoRiver::distributePot() { + +// int potCalcAllinArray[5][2]; // 0 -> ID , 1 -> AllInCash + + int i, j; + + //////////////////// + // (1) EINLEITUNG // + //////////////////// + + // die Potverteilung gliedert sich in mehrere Runden: + // in der ersten Runden sucht sich der Winner der BettingRound seinen zustehenden Anteil am Pot raus. das kann alles oder nur ein Teil sein (z.b. wenn er mit wenig allin gegangen ist und der Rest weitergespielt hat) + // in den darauffolgenden Verteilungsrunden suchen sich die jeweils nᅵhsten Winner aus dem noch brig gebliebenen Pot ihren zustehenden Anteil raus + // die gesamte Potverteilung ist zuende, wenn der Pot leer ist und nichts mehr zu holen ist + + + ///////////////////// + // (2) HILFSMITTEL // + ///////////////////// + + // winnersArray erstellen -> hier werden die winner der jeweiligen Potverteilungsrunden eingetragen + int *winnersArray = new int[MAX_NUMBER_OF_PLAYERS]; + + // Anzahl der winner in einer Potverteilungsrunde + int winnersCounter = 0; + + // dieses Array ermittelt wieviel jeder Spieler wᅵrend der gesamten BettingRound gesetzt hat + int *roundSetArray = new int[MAX_NUMBER_OF_PLAYERS]; + for(i=0; igetPlayerArray()[i]->getMyActiveStatus()) { + roundSetArray[i] = myHand->getPlayerArray()[i]->getMyRoundStartCash()-myHand->getPlayerArray()[i]->getMyCash(); + } + } + + // hier steht der CardsValue der Spieler drin die an der Potverteilung teilnehmen (d.h. aktiv und nicht gefoldet), bei allen anderen steht ne 0 + int *cardsValueArray = new int[MAX_NUMBER_OF_PLAYERS]; + int playerWantsPotCounter = 0; + + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) { + // nur bei den Spielen den Kartenwert eintragen, die an der Potverteilung teilnehmen + cardsValueArray[i] = myHand->getPlayerArray()[i]->getMyCardsValueInt(); + playerWantsPotCounter++; + } + } + + int winner; + int highestCardsValueTemp; + + // fr SplitPotBerechnung; + int winnersSets; + int winnersMaxSet; + int winnersPot; + bool playerIsWinner; + + + + ////////////////////// + // (3) DIE SCHLEIFE // + ////////////////////// + + + // Potverteilungsrunden -> solange noch was aus dem pot zu vergeben ist + while(playerWantsPotCounter != 0 ) { + + // highestCardsValueTemp zu Beginn der aktuellen Potverteilungsrunde auf Null setzen + highestCardsValueTemp = 0; + + // aktuellen highestCardsValueTemp berechnen, von denen die noch an der Potverteilung teilnehmen + for(i=0; i highestCardsValueTemp ) { + highestCardsValueTemp = myHand->getPlayerArray()[i]->getMyCardsValueInt(); + } + } + + // zu Beginn der Potverteilungsrunde die Anzahl der winner auf 0 setzen + winnersCounter = 0; + // Siegerposition und -anzahl von denen ermitteln, die noch an der Potverteilung teilnehmen + for(i=0; i bekommt den gesamten Pot +// if(myHand->getPlayerArray()[winner]->getMyAction() != 6) { +// +// myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+myHand->getBoard()->getPot()); +// myHand->getBoard()->setPot(0); +// playerWantsPotCounter = 1; +// +// } + // Winner ist All In gegangen -> von denen die weniger gesetzt oder gefoldet hatten alles nehmen und von denen die mehr gesetzt hatten nur die eigenen Sets nehmen +// else { + + // alle Spieler nacheinander durchgehen und prfen von wem man wieviel Geld aus dem Pot bekommt + for(i=0; igetPlayerArray()[i]->getMyAction() == 1) { + + // diesen Teil aus dem Pot holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]); + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nimmt der Winner dann von diesen Spielern 0 Dollar aus dem Pot + roundSetArray[i] = 0; + + } + + // nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht von einem selber + if(i != winner && cardsValueArray[i] != 0) { + + // zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten + if(roundSetArray[winner] >= roundSetArray[i]) { + + // von denen alles holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[i]); + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // diese Spieler dann von der weiteren Potverteilung ausschlieᅵn + cardsValueArray[i] = 0; + playerWantsPotCounter--; + // deren Sets auf Null seztzen, da sie schon alles abgegeben haben + roundSetArray[i] = 0; + + } + // nun alle Spieler die mehr gesetzt hatten + else { + + // den eigenen Setanteil aus dem Pot holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]); + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]); + // den Set des Gegners um den bereits abgenommenen Setanteil verkleinern + roundSetArray[i] = roundSetArray[i] - roundSetArray[winner]; + // diese Spieler nehmen an der weiteren Potverteilung teil + + } + } + } +// // } + + // zum Scluss noch eingenen Set wieder holen + myHand->getPlayerArray()[winner]->setMyCash(myHand->getPlayerArray()[winner]->getMyCash()+roundSetArray[winner]); + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[winner]); + // nicht mehr an der weiteren Potverteilung teilnehmen, da man sich alles geholt hat was einem zusteht + cardsValueArray[winner] = 0; + playerWantsPotCounter--; + // eigene Sets auf Null seztzen, da sie eben eingesammelt wurden + roundSetArray[winner] = 0; + + } + + + // ---------------------------------------------------------------------- + // B) mehrere haben die aktuelle Potverteilungsrunde gewonnen -> SplitPot + // ---------------------------------------------------------------------- + else { + + // hierfr wird ein temporᅵer WinnersPot erstellt; dort flieᅵn erstmal alle zustehenden Anteile aus dem Pot rauf; am Ende wird dies auf die Winners verteilt + winnersPot = 0; + // hᅵhster Set aller Winner + winnersMaxSet = 0; + + // den hᅵhsten Set aller Winner ermitteln + for(i=0; i winnersMaxSet) winnersMaxSet = roundSetArray[i]; + } + + // gesamtSet aller Winner + winnersSets = 0; + for(i=0; i Spieler i gehᅵt zu den Winnern + } + + // zuerst prfen ob ein gefoldeter Spieler was gesetzt hatte + if(!playerIsWinner && myHand->getPlayerArray()[i]->getMyAction() == 1) { + + // diesen Teil aus dem Pot holen und dem winnersPot geben + winnersPot += roundSetArray[i]; + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // deren Sets auf Null seztzen -> in den nᅵhsten Potverteilungsrunden nehmen die Winner dann von diesen Spielern 0 Dollar aus dem Pot + roundSetArray[i] = 0; + + } + + // nun nur von den Spielern holen, die noch an der Potverteilung teilnehmen und natrlich nicht zu den Winnern gehᅵen + if(!playerIsWinner && cardsValueArray[i] != 0) { + + // zuerst alle rauspicken, die weniger oder das gleiche gesetzt hatten + if(winnersMaxSet >= roundSetArray[i]) { + + // von denen alles holen + winnersPot += roundSetArray[i]; + // Pot dementsprechend verkleinern + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - roundSetArray[i]); + // diese Spieler dann von der weiteren Potverteilung ausschlieᅵn + cardsValueArray[i] = 0; + playerWantsPotCounter--; + // deren Sets auf Null seztzen, da sie schon alles abgegeben haben + roundSetArray[i] = 0; + + } + // nun alle Spieler die mehr gesetzt hatten + else { + + // den eigenen Setanteil aus dem Pot holen + winnersPot += winnersMaxSet; + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersMaxSet); + // den Set des Gegners um den bereits abgenommenen Setanteil verkleinern + roundSetArray[i] = roundSetArray[i] - winnersMaxSet; + // diese Spieler nehmen an der weiteren Potverteilung teil + + } + } + } + + // zum Schluss noch die eingenen Set aus dem Pot holen + winnersPot += winnersSets; + myHand->getBoard()->setPot(myHand->getBoard()->getPot() - winnersSets); + + // winnersPot verteilen (anteilmᅵig) + for(i=0; igetPlayerArray()[winnersArray[i]]->setMyCash(myHand->getPlayerArray()[winnersArray[i]]->getMyCash()+((roundSetArray[winnersArray[i]]*winnersPot)/winnersSets)); + } + + + for(i=0; igetBoard()->getPot() != 0) cout << "!!! Pot: " << myHand->getBoard()->getPot() << endl; + + delete[] winnersArray; + delete[] roundSetArray; + delete[] cardsValueArray; + + +} diff --git a/src/engine/local_engine/localberoriver.h b/src/engine/local_engine/localberoriver.h new file mode 100644 index 00000000..407b8dcc --- /dev/null +++ b/src/engine/local_engine/localberoriver.h @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef LOCALBERORIVER_H +#define LOCALBERORIVER_H + +#include +#include + +class HandInterface; + + +class LocalBeRoRiver : public LocalBeRo{ +public: + LocalBeRoRiver(HandInterface*, int, int, int, int); + ~LocalBeRoRiver(); + + void setPlayersTurn(int theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(int theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setFirstRiverRound(bool theValue) { firstRiverRound = theValue;} + bool getFirstRiverRound() const { return firstRiverRound;} + + void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;} + int getSmallBlindPosition() const { return smallBlindPosition; } + + void setSmallBlind(int theValue) { smallBlind = theValue; } + int getSmallBlind() const { return smallBlind; } + + void setHighestCardsValue(int theValue) { highestCardsValue = theValue;} + int getHighestCardsValue() const { return highestCardsValue;} + + void resetFirstRun() { firstRiverRun = false; } + + void riverRun(); + void postRiverRun(); + void nextPlayer2(); + void distributePot(); + + //only until bero refactory is over + void preflopRun() {} + void flopRun() {} + void turnRun() {} + +private: + + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int smallBlindPosition; + + int smallBlind; + int highestSet; + + bool firstRiverRun; + bool firstRiverRound; + bool firstHeadsUpRiverRound; + int playersTurn; + + int highestCardsValue; + + bool logBoardCardsDone; + +}; + +#endif diff --git a/src/engine/local_engine/localberoturn.cpp b/src/engine/local_engine/localberoturn.cpp new file mode 100644 index 00000000..e8bd5b2d --- /dev/null +++ b/src/engine/local_engine/localberoturn.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "localberoturn.h" +#include +#include + + +using namespace std; + +LocalBeRoTurn::LocalBeRoTurn(HandInterface* bR, int id, int qP, int dP, int sB) : LocalBeRo(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstTurnRun(1), firstTurnRound(1), firstHeadsUpTurnRound(1), playersTurn(dP), logBoardCardsDone(0) + +{ + + myBeRoID = GAME_STATE_TURN; + + int i; + + //SmallBlind-Position ermitteln + for(i=0; igetPlayerArray()[i]->getMyButton() == 2) smallBlindPosition = i; + } + +cout << "LocalBeroTurn erstellt - " << myBeRoID << endl; + +} + +LocalBeRoTurn::~LocalBeRoTurn() +{ +} + + +void LocalBeRoTurn::turnRun() { + + cout << "LocalBeroTurnRun!!!" << endl; + int i; + + if (firstTurnRun) { + myHand->getGuiInterface()->dealTurnCard(); + firstTurnRun = 0; + + } + + else { + //log the turned cards + if(!logBoardCardsDone) { + int tempBoardCardsArray[5]; + + myHand->getBoard()->getMyCards(tempBoardCardsArray); + myHand->getGuiInterface()->logDealBoardCardsMsg(2, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]); + logBoardCardsDone = 1; + } + + bool allHighestSet = 1; + + // prfe, ob alle Sets gleich sind ( falls nicht, dann allHighestSet = 0 ) + for(i=0; igetPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) { +// cout << "Spieler " << i << " Set " << myHand->getPlayerArray()[i]->getMySet() << endl; + if(highestSet != myHand->getPlayerArray()[i]->getMySet()) { allHighestSet=0; } + } + } +// cout << "allHighestSet " << allHighestSet << endl; + +// cout << "firstflopround " << firstTurnRound << endl; + + // prfen, ob Turn wirklich dran ist + if(!firstTurnRound && allHighestSet) { + + // Turn nicht dran, weil alle Sets gleich sind + //also gehe in Turn + myHand->setActualRound(3); + + //Action l�chen und ActionButtons refresh + for(i=0; igetPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0); + } + //Sets in den Pot verschieben und Sets = 0 und Pot-refresh + myHand->getBoard()->collectSets(); + myHand->getBoard()->collectPot(); + myHand->getGuiInterface()->refreshPot(); + + myHand->getGuiInterface()->refreshSet(); + myHand->getGuiInterface()->refreshCash(); + for(i=0; igetGuiInterface()->refreshAction(i,0); } + + myHand->switchRounds(); + } + else { + // Turn ist wirklich dran + + // Anzahl der effektiv gespielten Runden (des human player) erhöhen + if(myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1) { + myHand->setBettingRoundsPlayed(2); + } + + if( !(myHand->getActualQuantityPlayers() < 3 && firstHeadsUpTurnRound == 1) ) { +// not first round in heads up (for headsup dealer is smallblind so it is dealers turn) + + // naechsten Spieler ermitteln + do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6); + } + else { firstHeadsUpTurnRound = 0; } + + //Spieler-Position vor SmallBlind-Position ermitteln + int activePlayerBeforeSmallBlind = smallBlindPosition; + do { activePlayerBeforeSmallBlind = (activePlayerBeforeSmallBlind + MAX_NUMBER_OF_PLAYERS - 1 ) % (MAX_NUMBER_OF_PLAYERS); + } while(!(myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyActiveStatus()) || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==1 || (myHand->getPlayerArray()[activePlayerBeforeSmallBlind]->getMyAction())==6); + + myHand->getPlayerArray()[playersTurn]->setMyTurn(1); + //highlight active players groupbox and clear action + myHand->getGuiInterface()->refreshGroupbox(playersTurn,2); + myHand->getGuiInterface()->refreshAction(playersTurn,0); + +// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl; +// cout << "playersTurn " << playersTurn << endl; + // wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende + if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstTurnRound = 0; } + + if(playersTurn == 0) { + // Wir sind dran +// cout << "actualRound " << myHand->getActualRound() << endl; +// cout << "highestSet vor meInAction " << highestSet << endl; + myHand->getGuiInterface()->meInAction(); + } + else { + //Gegner sind dran +// cout << "NextPlayerSpeed3 start" << endl; + myHand->getGuiInterface()->turnAnimation2(); + } + } + } +} + +void LocalBeRoTurn::nextPlayer2() { +// cout << "NextPlayerSpeed3 stop" << endl; + myHand->getPlayerArray()[playersTurn]->action(); + +} + + diff --git a/src/engine/local_engine/localberoturn.h b/src/engine/local_engine/localberoturn.h new file mode 100644 index 00000000..29efaad3 --- /dev/null +++ b/src/engine/local_engine/localberoturn.h @@ -0,0 +1,80 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef LOCALBEROTURN_H +#define LOCALBEROTURN_H + +#include +#include + +class HandInterface; + +class LocalBeRoTurn : public LocalBeRo{ +public: + LocalBeRoTurn(HandInterface*, int, int, int, int); + ~LocalBeRoTurn(); + + void setPlayersTurn(int theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(int theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setFirstTurnRound(bool theValue) { firstTurnRound = theValue;} + bool getFirstTurnRound() const { return firstTurnRound;} + + void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;} + int getSmallBlindPosition() const { return smallBlindPosition; } + + void setSmallBlind(int theValue) { smallBlind = theValue; } + int getSmallBlind() const { return smallBlind; } + + void resetFirstRun() { firstTurnRun = false; } + + void nextPlayer2(); + void turnRun(); + + //only until bero refactory is over + void preflopRun() {} + void flopRun() {} + void riverRun() {} + void postRiverRun() {} + +private: + + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int smallBlindPosition; + + int smallBlind; + int highestSet; + + bool firstTurnRun; + bool firstTurnRound; + bool firstHeadsUpTurnRound; + int playersTurn; + + bool logBoardCardsDone; + +}; + +#endif diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index d6762bc2..af49c97d 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -173,7 +173,10 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI myRiver = myFactory->createRiver(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); myBeRoFactory = myFactory->createBeRoFactory(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); - myBeRo = myBeRoFactory->switchRounds(); + + int currentRound = actualRound; // for Lothar ;-) + + myBeRo = myBeRoFactory->switchRounds(currentRound); } @@ -378,6 +381,8 @@ void LocalHand::switchRounds() { myGui->refreshGameLabels((GameState)getActualRound()); // /*/*/*/*cout <<*/*/*/*/ "NextPlayerSpeed1 stop" << endl; // + + // cout << "NextPlayerSpeed2 start" << endl; switch(actualRound) { case 0: { diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 561cffb4..2dd50637 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -47,6 +47,7 @@ public: TurnInterface* getTurn() const { return myTurn; } RiverInterface* getRiver() const { return myRiver; } GuiInterface* getGuiInterface() const { return myGui; } + BeRoInterface* getCurrentBeRo() const { return myBeRo; } void setMyID(int theValue) { myID = theValue; } int getMyID() const { return myID; } diff --git a/src/engine/local_engine/localpreflop.cpp b/src/engine/local_engine/localpreflop.cpp index 9081cd66..f157acff 100755 --- a/src/engine/local_engine/localpreflop.cpp +++ b/src/engine/local_engine/localpreflop.cpp @@ -22,11 +22,12 @@ #include #include -//using namespace std; +using namespace std; LocalPreflop::LocalPreflop(HandInterface* bR, int id, int qP, int dP, int sB) : PreflopInterface(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0) { +cout << "OLD PREFLOP INIT!!!" << endl; // // BigBlind ermitteln bigBlindPosition = dealerPosition; while (myHand->getPlayerArray()[bigBlindPosition]->getMyButton() != 3) { @@ -48,7 +49,7 @@ LocalPreflop::~LocalPreflop() void LocalPreflop::preflopRun() { -// cout << "NextPlayerSpeed2 stop" << endl; + cout << "OLD PREFLOPRUN" << endl; int i; bool allHighestSet = 1; diff --git a/src/engine/local_engine/localpreflop.h b/src/engine/local_engine/localpreflop.h index 0f6ae4a5..7e3aaba4 100755 --- a/src/engine/local_engine/localpreflop.h +++ b/src/engine/local_engine/localpreflop.h @@ -21,6 +21,7 @@ #define LOCALPREFLOP_H #include +#include class HandInterface; @@ -37,9 +38,6 @@ public: void setHighestSet(int theValue) { highestSet = theValue; } int getHighestSet() const { return highestSet;} - void setPreflopFirstRound(bool theValue) { preflopFirstRound = theValue; } - bool setPreflopFirstRound() const { return preflopFirstRound; } - void preflopRun(); void nextPlayer2(); diff --git a/src/engine/network_engine/clientbero.h b/src/engine/network_engine/clientbero.h index 8bddb041..85608c82 100644 --- a/src/engine/network_engine/clientbero.h +++ b/src/engine/network_engine/clientbero.h @@ -24,6 +24,12 @@ public: ~ClientBeRo(); + int getMyBeRoID() const { return myBeRoID; } + +protected: + + int myBeRoID; + }; #endif diff --git a/src/engine/network_engine/clientberofactory.cpp b/src/engine/network_engine/clientberofactory.cpp index 878e09a3..ff0b153a 100644 --- a/src/engine/network_engine/clientberofactory.cpp +++ b/src/engine/network_engine/clientberofactory.cpp @@ -22,4 +22,4 @@ ClientBeRoFactory::~ClientBeRoFactory() } -BeRoInterface* ClientBeRoFactory::switchRounds() { return NULL;} +BeRoInterface* ClientBeRoFactory::switchRounds(int currentRound) { return NULL;} diff --git a/src/engine/network_engine/clientberofactory.h b/src/engine/network_engine/clientberofactory.h index 160ef1d1..0fe5e96a 100644 --- a/src/engine/network_engine/clientberofactory.h +++ b/src/engine/network_engine/clientberofactory.h @@ -25,7 +25,7 @@ public: ~ClientBeRoFactory(); - BeRoInterface* switchRounds(); + BeRoInterface* switchRounds(int); }; diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index c549d9bb..9ee24102 100644 --- a/src/engine/network_engine/clienthand.cpp +++ b/src/engine/network_engine/clienthand.cpp @@ -108,6 +108,13 @@ ClientHand::getRiver() const return myRiver; } +BeRoInterface* +ClientHand::getCurrentBeRo() const +{ + return myBeRo; +} + + GuiInterface* ClientHand::getGuiInterface() const { diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index 8f4993b6..001c7953 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -47,6 +47,7 @@ public: TurnInterface* getTurn() const; RiverInterface* getRiver() const; GuiInterface* getGuiInterface() const; + BeRoInterface* getCurrentBeRo() const; void setMyID(int theValue); int getMyID() const; diff --git a/src/engine/network_engine/clientpreflop.cpp b/src/engine/network_engine/clientpreflop.cpp index 4b30524d..26582eda 100644 --- a/src/engine/network_engine/clientpreflop.cpp +++ b/src/engine/network_engine/clientpreflop.cpp @@ -62,20 +62,6 @@ ClientPreflop::getHighestSet() const return highestSet; } -void -ClientPreflop::setPreflopFirstRound(bool theValue) -{ - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - preflopFirstRound = theValue; -} - -bool -ClientPreflop::setPreflopFirstRound() const -{ - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - return preflopFirstRound; -} - void ClientPreflop::preflopRun() { diff --git a/src/engine/network_engine/clientpreflop.h b/src/engine/network_engine/clientpreflop.h index 6aab3372..99d6ffbe 100644 --- a/src/engine/network_engine/clientpreflop.h +++ b/src/engine/network_engine/clientpreflop.h @@ -36,9 +36,6 @@ public: void setHighestSet(int theValue); int getHighestSet() const; - void setPreflopFirstRound(bool theValue); - bool setPreflopFirstRound() const; - void preflopRun(); void nextPlayer2(); diff --git a/src/engine/preflopinterface.h b/src/engine/preflopinterface.h index 0b87553e..f9c652ad 100644 --- a/src/engine/preflopinterface.h +++ b/src/engine/preflopinterface.h @@ -31,9 +31,6 @@ public: virtual void setHighestSet(int theValue) =0; virtual int getHighestSet() const =0; - virtual void setPreflopFirstRound(bool theValue) =0; - virtual bool setPreflopFirstRound() const =0; - virtual void preflopRun() =0; virtual void nextPlayer2() =0;