diff --git a/src/engine/boardinterface.h b/src/engine/boardinterface.h index b65234b8..fd4e7818 100644 --- a/src/engine/boardinterface.h +++ b/src/engine/boardinterface.h @@ -20,24 +20,27 @@ #ifndef BOARDINTERFACE_H #define BOARDINTERFACE_H +class PlayerInterface; +class HandInterface; + class BoardInterface { public: virtual ~BoardInterface(); // -// virtual void setPlayer(LocalPlayer**) =0; -// virtual void setHand(LocalHand*) =0; + virtual void setPlayer(PlayerInterface**) =0; + virtual void setHand(HandInterface*) =0; // -// virtual void setMyCards(int* theValue) =0; -// virtual void getMyCards(int* theValue) =0; + virtual void setMyCards(int* theValue) =0; + virtual void getMyCards(int* theValue) =0; // -// virtual int getPot() const=0; -// virtual void setPot(int theValue) =0; -// virtual int getSets() const=0; + virtual int getPot() const=0; + virtual void setPot(int theValue) =0; + virtual int getSets() const=0; // -// virtual void collectSets() const=0; -// virtual void collectPot() const=0; + virtual void collectSets() const=0; + virtual void collectPot() const=0; }; diff --git a/src/engine/enginefactory.h b/src/engine/enginefactory.h index 5e24502b..ffd8dc56 100644 --- a/src/engine/enginefactory.h +++ b/src/engine/enginefactory.h @@ -41,9 +41,9 @@ public: virtual ~EngineFactory(); - virtual HandInterface* createHand() =0; + virtual HandInterface* createHand(GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int qP, int dP, int sB,int sC) =0; virtual BoardInterface* createBoard() =0; - virtual PlayerInterface* createPlayer() =0; + virtual PlayerInterface* createPlayer(BoardInterface *b, int id, int sC, bool aS, int mB) =0; }; diff --git a/src/engine/handinterface.cpp b/src/engine/handinterface.cpp index 07d91759..9b3c8549 100644 --- a/src/engine/handinterface.cpp +++ b/src/engine/handinterface.cpp @@ -19,11 +19,6 @@ ***************************************************************************/ #include "handinterface.h" -HandInterface::HandInterface() -{ -} - - HandInterface::~HandInterface() { } diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index a9a23757..8234643e 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -20,14 +20,46 @@ #ifndef HANDINTERFACE_H #define HANDINTERFACE_H -/** - @author FThauer FHammer -*/ +#include "guiinterface.h" + class HandInterface{ public: - HandInterface(); + + virtual ~HandInterface(); - ~HandInterface(); + virtual PlayerInterface** getPlayerArray() const =0; + virtual BoardInterface* getBoard() const =0; +// virtual LocalPreflop* getPreflop() const =0; +// virtual LocalFlop* getFlop() const =0; +// virtual LocalTurn* getTurn() const =0; +// virtual LocalRiver* getRiver() const =0; + virtual GuiInterface* getGuiInterface() const =0; + + virtual void setMyID(const int& theValue) =0; + virtual int getMyID() const =0; + + virtual void setActualQuantityPlayers(const int& theValue) =0; + virtual int getActualQuantityPlayers() const =0; + + virtual void setActualRound(const int& theValue) =0; + virtual int getActualRound() const =0; + + virtual void setDealerPosition(const int& theValue) =0; + virtual int getDealerPosition() const =0; + + virtual void setSmallBlind(const int& theValue) =0; + virtual int getSmallBlind() const =0; + + virtual void setAllInCondition(bool theValue) =0; + virtual bool getAllInCondition() const =0; + + virtual void setStartCash(const int& theValue) =0; + virtual int getStartCash() const =0; + + virtual void assignButtons(); + + virtual void highlightRoundLabel(); + virtual void switchRounds(); }; diff --git a/src/engine/local_engine/localboard.cpp b/src/engine/local_engine/localboard.cpp index 2c5526db..c776abb4 100755 --- a/src/engine/local_engine/localboard.cpp +++ b/src/engine/local_engine/localboard.cpp @@ -23,7 +23,7 @@ using namespace std; -LocalBoard::LocalBoard() : playerArray(0), actualHand(0), pot(0), sets(0) +LocalBoard::LocalBoard() : BoardInterface(), playerArray(0), actualHand(0), pot(0), sets(0) { } @@ -32,7 +32,7 @@ LocalBoard::~LocalBoard() { } -void LocalBoard::setPlayer(LocalPlayer** p) { playerArray = p; } +void LocalBoard::setPlayer(PlayerInterface** p) { playerArray = p; } void LocalBoard::setHand(LocalHand* br) { actualHand = br; } diff --git a/src/engine/local_engine/localboard.h b/src/engine/local_engine/localboard.h index 64caadcf..d295eeb6 100755 --- a/src/engine/local_engine/localboard.h +++ b/src/engine/local_engine/localboard.h @@ -20,20 +20,22 @@ #ifndef LOCALBOARD_H #define LOCALBOARD_H +#include "boardinterface.h" + #include -class LocalPlayer; -class LocalHand; +class PlayerInterface; +class HandInterface; -class LocalBoard{ +class LocalBoard : public BoardInterface{ public: LocalBoard(); ~LocalBoard(); - void setPlayer(LocalPlayer**); - void setHand(LocalHand*); + void setPlayer(PlayerInterface**); + void setHand(HandInterface*); void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; } void getMyCards(int* theValue) { int i; for(i=0; i<5; i++) theValue[i] = myCards[i]; } @@ -47,8 +49,8 @@ public: private: - LocalPlayer **playerArray; - LocalHand *actualHand; + PlayerInterface **playerArray; + HandInterface *actualHand; int myCards[5]; int pot; diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index 1078009e..cc42ff71 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -38,11 +38,11 @@ LocalEngineFactory::~LocalEngineFactory() } -HandInterface* LocalEngineFactory::createHand() { /*return new LocalHand;*/ } +HandInterface* LocalEngineFactory::createHand(GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int qP, int dP, int sB,int sC) { return new LocalHand(g, b, p, id, qP, dP, sB, sC); } BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } -PlayerInterface* LocalEngineFactory::createPlayer() { /*return new LocalPlayer;*/ } +PlayerInterface* LocalEngineFactory::createPlayer(BoardInterface *b, int id, int sC, bool aS, int mB) { return new LocalPlayer(b, id, sC, aS, mB); } PreflopInterface* LocalEngineFactory::createPreflop() {/* return new LocalPreflop;*/ } diff --git a/src/engine/local_engine/localenginefactory.h b/src/engine/local_engine/localenginefactory.h index df0558e5..8ba24313 100644 --- a/src/engine/local_engine/localenginefactory.h +++ b/src/engine/local_engine/localenginefactory.h @@ -22,7 +22,6 @@ #include -class BoardInterface; class LocalEngineFactory : public EngineFactory { @@ -31,9 +30,9 @@ public: ~LocalEngineFactory(); - HandInterface* createHand(); + HandInterface* createHand(GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int qP, int dP, int sB,int sC); BoardInterface* createBoard(); - PlayerInterface* createPlayer(); + PlayerInterface* createPlayer(BoardInterface *b, int id, int sC, bool aS, int mB); PreflopInterface* createPreflop(); FlopInterface* createFlop(); TurnInterface* createTurn(); diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index efc1b20f..0e5998ed 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -21,7 +21,7 @@ using namespace std; -LocalHand::LocalHand(GuiInterface *g, LocalBoard *b, LocalPlayer **p, int id, int qP, int dP, int sB,int sC) : myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0) +LocalHand::LocalHand(GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int qP, int dP, int sB,int sC) : HandInterface(), myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0) { int i, j; CardsValue myCardsValue; diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 0ebecd44..f591c5dd 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -20,10 +20,10 @@ #ifndef LOCALHAND_H #define LOCALHAND_H - #include "guiinterface.h" -#include "localboard.h" -#include "localplayer.h" + +#include "handinterface.h" + #include "tools.h" #include "localpreflop.h" #include "localflop.h" @@ -32,23 +32,26 @@ class GuiInterface; -class LocalBoard; -class LocalPlayer; +class BoardInterface; +class PlayerInterface; +class HandInterface; + class LocalPreflop; class LocalFlop; class LocalTurn; class LocalRiver; -class LocalHand { - +class LocalHand : public HandInterface{ public: - LocalHand(GuiInterface*, LocalBoard*, LocalPlayer**, int, int, int, int, int); + LocalHand(GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int); ~LocalHand(); + + - LocalPlayer** getPlayerArray() const { return playerArray; } - LocalBoard* getBoard() const { return myBoard; } + PlayerInterface** getPlayerArray() const { return playerArray; } + BoardInterface* getBoard() const { return myBoard; } LocalPreflop* getPreflop() const { return myPreflop; } LocalFlop* getFlop() const { return myFlop; } LocalTurn* getTurn() const { return myTurn; } @@ -64,6 +67,9 @@ public: void setActualRound(const int& theValue) { actualRound = theValue; } int getActualRound() const { return actualRound; } + void setDealerPosition(const int& theValue) { dealerPosition = theValue; } + int getDealerPosition() const { return dealerPosition; } + void setSmallBlind(const int& theValue) { smallBlind = theValue; } int getSmallBlind() const { return smallBlind; } @@ -79,12 +85,15 @@ public: void switchRounds(); + + + private: GuiInterface *myGui; - LocalBoard *myBoard; - LocalPlayer **playerArray; + BoardInterface *myBoard; + PlayerInterface **playerArray; LocalPreflop *myPreflop; LocalFlop *myFlop; LocalTurn *myTurn; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 54e18e7f..a803eb80 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -23,7 +23,7 @@ using namespace std; -LocalPlayer::LocalPlayer(LocalBoard *b, int id, int sC, bool aS, int mB) : actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myDude(0), myCardsValueInt(0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), myAverageSets(0) +LocalPlayer::LocalPlayer(BoardInterface *b, int id, int sC, bool aS, int mB) : PlayerInterface(), actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myDude(0), myCardsValueInt(0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), myAverageSets(0) { Tools myTool; diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index e5368878..30ffaad9 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -20,6 +20,8 @@ #ifndef LOCALPLAYER_H #define LOCALPLAYER_H +#include "playerinterface.h" + #include "cardsvalue.h" #include @@ -28,11 +30,11 @@ class CardsValue; class LocalHand; -class LocalBoard; +class BoardInterface; -class LocalPlayer{ +class LocalPlayer : public PlayerInterface{ public: - LocalPlayer(LocalBoard*, int, int, bool, int); + LocalPlayer(BoardInterface*, int, int, bool, int); ~LocalPlayer(); @@ -91,7 +93,7 @@ public: private: LocalHand *actualHand; - LocalBoard *actualBoard; + BoardInterface *actualBoard; CardsValue *myCardsValue; diff --git a/src/engine/playerinterface.cpp b/src/engine/playerinterface.cpp index 239c8ad6..5f60eb33 100644 --- a/src/engine/playerinterface.cpp +++ b/src/engine/playerinterface.cpp @@ -19,11 +19,6 @@ ***************************************************************************/ #include "playerinterface.h" -PlayerInterface::PlayerInterface() -{ -} - - PlayerInterface::~PlayerInterface() { } diff --git a/src/engine/playerinterface.h b/src/engine/playerinterface.h index 9812e35d..aabcd423 100644 --- a/src/engine/playerinterface.h +++ b/src/engine/playerinterface.h @@ -20,14 +20,59 @@ #ifndef PLAYERINTERFACE_H #define PLAYERINTERFACE_H -/** - @author FThauer FHammer -*/ class PlayerInterface{ public: - PlayerInterface(); - ~PlayerInterface(); + virtual ~PlayerInterface() =0; + + virtual void setHand(HandInterface*) =0; + + virtual void setMyID(const int& theValue) =0; + virtual int getMyID() const =0; + + virtual void setMyDude(const int& theValue) =0; + virtual int getMyDude() const =0; + + virtual void setMyName(const std::string& theValue) =0; + virtual std::string getMyName() const =0; + + virtual void setMyCash(const int& theValue) =0; + virtual int getMyCash() const =0; + + virtual void setMySet(const int& theValue) =0; + virtual void setMySetNull() =0; + virtual int getMySet() const =0; + + virtual void setMyAction(const int& theValue) =0; + virtual int getMyAction() const =0; + + virtual void setMyButton(const int& theValue) =0; + virtual int getMyButton() const =0; + + virtual void setMyActiveStatus(bool theValue) =0; + virtual bool getMyActiveStatus() const =0; + + virtual void setMyCards(int* theValue) =0; + virtual void getMyCards(int* theValue) =0; + + virtual void setMyTurn(bool theValue) =0; + virtual bool getMyTurn() const =0; + + virtual void setMyCardsValueInt(const int& theValue) =0; + virtual int getMyCardsValueInt() const =0; + + virtual void setMyRoundStartCash(const int& theValue) =0; + virtual int getMyRoundStartCash() const =0; + + virtual void setMyAverageSets(const int& theValue) =0; + virtual int getMyAverageSets() const =0; + + virtual void action() =0; + + virtual void preflopEngine() =0; + virtual void flopEngine() =0; + virtual void turnEngine() =0; + virtual void riverEngine() =0; }; diff --git a/src/game.cpp b/src/game.cpp index a256b83b..4194e085 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -45,23 +45,22 @@ Game::Game(GuiInterface* g, int qP, int sC, int sB) : myGui(g), actualHand(0), a myGui->setGame(this); //EngineFactory erstellen - EngineFactory *myFactory; myFactory = new LocalEngineFactory; // LocalEngine erstellen // Board erstellen - actualBoard = new LocalBoard(); - - + actualBoard = myFactory->createBoard(); + // ersten Dealer bestimmen Tools myTool; myTool.getRandNumber(0, startQuantityPlayers-1, 1, &dealerPosition, 0); // Player erstellen - LocalPlayer *tempPlayer; + PlayerInterface *tempPlayer; for(i=0; igetMaxQuantityPlayers(); i++) { - tempPlayer = new LocalPlayer(actualBoard, i, startCash, startQuantityPlayers > i, 0); +// tempPlayer = new LocalPlayer(actualBoard, i, startCash, startQuantityPlayers > i, 0); + tempPlayer = myFactory->createPlayer(actualBoard, i, startCash, startQuantityPlayers > i, 0); playerArray[i] = tempPlayer; } actualBoard->setPlayer(playerArray); @@ -85,7 +84,7 @@ Game::~Game() delete actualHand; actualHand = 0; - LocalPlayer *tempPlayer; + PlayerInterface *tempPlayer; for(i=0; igetMaxQuantityPlayers(); i++) { tempPlayer = playerArray[i]; playerArray[i] = 0; @@ -120,8 +119,9 @@ void Game::startHand() } // Hand erstellen - actualHand = new LocalHand(myGui, actualBoard, playerArray, actualHandID, actualQuantityPlayers, dealerPosition, actualSmallBlind, startCash); + actualHand = myFactory->createHand(myGui, actualBoard, playerArray, actualHandID, actualQuantityPlayers, dealerPosition, actualSmallBlind, startCash); + //GUI bereinigen myGui->nextRoundCleanGui(); diff --git a/src/game.h b/src/game.h index 074d2e44..f6fa157f 100755 --- a/src/game.h +++ b/src/game.h @@ -22,10 +22,11 @@ #include -class LocalHand; -class LocalBoard; class GuiInterface; -class LocalPlayer; +class HandInterface; +class PlayerInterface; +class BoardInterface; +class EngineFactory; class Game { @@ -64,11 +65,12 @@ public: private: + EngineFactory *myFactory; GuiInterface *myGui; - LocalHand *actualHand; - LocalBoard *actualBoard; - LocalPlayer *playerArray[5]; + HandInterface *actualHand; + BoardInterface *actualBoard; + PlayerInterface *playerArray[5]; //Startvariablen int startQuantityPlayers; diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 19751745..aad89909 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -37,7 +37,7 @@ public: //wird nach Einbau der EngineInterfaces umbenannt in setGameInterface und cp. virtual void setGame(Game*) =0; - virtual void setHand(LocalHand*) =0; + virtual void setHand(HandInterface*) =0; virtual void setSession(Session*) =0; // virtual int getMaxQuantityPlayers() const=0; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index c5cd3c97..a24ad55c 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -45,7 +45,7 @@ GuiWrapper::~GuiWrapper() } void GuiWrapper::setGame(Game *g) { myW->setGame(g); } -void GuiWrapper::setHand(LocalHand *lh) { myW->setHand(lh); } +void GuiWrapper::setHand(HandInterface *lh) { myW->setHand(lh); } void GuiWrapper::setSession(Session *s) { myW->setSession(s); } int GuiWrapper::getMaxQuantityPlayers() const { return myW->getMaxQuantityPlayers(); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 0a941ef5..93b1fe7f 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -39,7 +39,7 @@ public: ~GuiWrapper(); void setGame(Game*); - void setHand(LocalHand*); + void setHand(HandInterface*); void setSession(Session*); int getMaxQuantityPlayers() const; diff --git a/src/gui/qt/mainwindowimpl.cpp b/src/gui/qt/mainwindowimpl.cpp index eed4f6db..255aeb75 100755 --- a/src/gui/qt/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindowimpl.cpp @@ -21,8 +21,12 @@ #include "newgamedialogimpl.h" #include "aboutpokerthimpl.h" + +#include "handinterface.h" +#include "playerinterface.h" +#include "boardinterface.h" + #include "game.h" -#include "localhand.h" #include "session.h" // #include "player.h" @@ -219,7 +223,7 @@ void mainWindowImpl::callAboutPokerthDialog() { void mainWindowImpl::setGame(Game *g) { actualGame = g; } -void mainWindowImpl::setHand(LocalHand* br) { actualHand = br; } +void mainWindowImpl::setHand(HandInterface* br) { actualHand = br; } void mainWindowImpl::setSession(Session* s) { mySession = s; } diff --git a/src/gui/qt/mainwindowimpl.h b/src/gui/qt/mainwindowimpl.h index 228ddc18..7160ec19 100755 --- a/src/gui/qt/mainwindowimpl.h +++ b/src/gui/qt/mainwindowimpl.h @@ -29,7 +29,10 @@ class Game; class Session; -class LocalHand; + +class BoardInterface; +class HandInterface; +class PlayerInterface; class QColor; @@ -39,7 +42,7 @@ Q_OBJECT public: mainWindowImpl(QMainWindow *parent = 0, const char *name = 0 ); void setGame(Game*); - void setHand(LocalHand*); + void setHand(HandInterface*); void setSession(Session*); @@ -143,7 +146,7 @@ public slots: private: Game *actualGame; - LocalHand *actualHand; + HandInterface *actualHand; Session *mySession;