diff --git a/docs/net_protocol.txt b/docs/net_protocol.txt index 46c86ba8..5f9f9d8d 100644 --- a/docs/net_protocol.txt +++ b/docs/net_protocol.txt @@ -111,7 +111,7 @@ Server Notification: Game Start +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Message Type = 5 | Message Length = 8 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Reserved | + | Start Dealer Pos | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ diff --git a/pokerth.pro b/pokerth.pro index b33104b3..f03be798 100755 --- a/pokerth.pro +++ b/pokerth.pro @@ -10,6 +10,7 @@ INCLUDEPATH += . \ src/gui \ src/net \ src/engine/local_engine \ + src/engine/network_engine \ src/config \ src/core/tinyxml \ src/gui/qt \ @@ -38,6 +39,7 @@ DEPENDPATH += . \ src/core/common \ src/core/tinyxml \ src/engine/local_engine \ + src/engine/network_engine \ src/gui/qt \ src/net/common \ src/gui/qt/mainwindow \ @@ -95,6 +97,14 @@ HEADERS += src/game.h \ src/engine/local_engine/localriver.h \ src/engine/local_engine/localturn.h \ src/engine/local_engine/tools.h \ + src/engine/network_engine/clientboard.h \ + src/engine/network_engine/clientenginefactory.h \ + src/engine/network_engine/clientflop.h \ + src/engine/network_engine/clienthand.h \ + src/engine/network_engine/clientplayer.h \ + src/engine/network_engine/clientpreflop.h \ + src/engine/network_engine/clientriver.h \ + src/engine/network_engine/clientturn.h \ src/gui/qt/mainwindow/mainwindowimpl.h \ src/gui/qt/mainwindow/mycardspixmaplabel.h \ src/gui/qt/mainwindow/startsplash/startsplash.h \ @@ -150,6 +160,14 @@ SOURCES += src/game.cpp \ src/engine/local_engine/localriver.cpp \ src/engine/local_engine/localturn.cpp \ src/engine/local_engine/tools.cpp \ + src/engine/network_engine/clientboard.cpp \ + src/engine/network_engine/clientenginefactory.cpp \ + src/engine/network_engine/clientflop.cpp \ + src/engine/network_engine/clienthand.cpp \ + src/engine/network_engine/clientplayer.cpp \ + src/engine/network_engine/clientpreflop.cpp \ + src/engine/network_engine/clientriver.cpp \ + src/engine/network_engine/clientturn.cpp \ src/net/common/connectdata.cpp \ src/net/common/clientcallback.cpp \ src/net/common/clientcontext.cpp \ diff --git a/src/engine/enginefactory.h b/src/engine/enginefactory.h index 7d928bcb..b113d06d 100644 --- a/src/engine/enginefactory.h +++ b/src/engine/enginefactory.h @@ -28,13 +28,15 @@ #include "turninterface.h" #include "riverinterface.h" +#include + class EngineFactory{ public: virtual ~EngineFactory(); - virtual HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) =0; + virtual HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) =0; virtual BoardInterface* createBoard() =0; virtual PlayerInterface* createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0; virtual PreflopInterface* createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) =0; diff --git a/src/engine/local_engine/localboard.cpp b/src/engine/local_engine/localboard.cpp index 727879cf..0150b49a 100755 --- a/src/engine/local_engine/localboard.cpp +++ b/src/engine/local_engine/localboard.cpp @@ -19,7 +19,7 @@ ***************************************************************************/ #include "localboard.h" -#include "localhand.h" +#include "handinterface.h" #include using namespace std; diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index 391bc0cc..c53ce0c4 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -41,7 +41,7 @@ LocalEngineFactory::~LocalEngineFactory() } -HandInterface* LocalEngineFactory::createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) { return new LocalHand(f, g, b, p, id, sP, aP, dP, sB, sC); } +HandInterface* LocalEngineFactory::createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) { return new LocalHand(f, g, b, p, id, sP, aP, dP, sB, sC); } BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } diff --git a/src/engine/local_engine/localenginefactory.h b/src/engine/local_engine/localenginefactory.h index 0fd13d65..c4ad2f4a 100644 --- a/src/engine/local_engine/localenginefactory.h +++ b/src/engine/local_engine/localenginefactory.h @@ -38,7 +38,7 @@ public: LocalEngineFactory(ConfigFile*); ~LocalEngineFactory(); - HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC); + HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC); BoardInterface* createBoard(); PlayerInterface* createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); PreflopInterface* createPreflop(HandInterface* hi, int id, int aP, int dP, int sB); diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index b05adf2a..5108eb04 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -24,7 +24,8 @@ using namespace std; -LocalHand::LocalHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) : HandInterface(), myFactory(f), myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0), bettingRoundsPlayed(0) +LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) +: HandInterface(), myFactory(f), myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0), bettingRoundsPlayed(0) { int i, j, k; diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 84f46ae3..307d4b59 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -33,7 +33,7 @@ class LocalHand : public HandInterface{ public: - LocalHand(EngineFactory*, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int); + LocalHand(boost::shared_ptr f, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int); ~LocalHand(); void start(); @@ -88,7 +88,7 @@ public: private: - EngineFactory *myFactory; + boost::shared_ptr myFactory; GuiInterface *myGui; BoardInterface *myBoard; PlayerInterface **playerArray; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 4392c4a4..e767bda3 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -18,7 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "localplayer.h" -#include "localhand.h" +#include "handinterface.h" #include "tools.h" #include "cardsvalue.h" #include diff --git a/src/engine/network_engine/clientboard.cpp b/src/engine/network_engine/clientboard.cpp new file mode 100644 index 00000000..cc4990b1 --- /dev/null +++ b/src/engine/network_engine/clientboard.cpp @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clientboard.h" + +#include "localhand.h" +#include + +using namespace std; + +ClientBoard::ClientBoard() +: playerArray(0), actualHand(0), pot(0), sets(0) +{ +} + + +ClientBoard::~ClientBoard() +{ +} + +void +ClientBoard::setPlayer(PlayerInterface** p) +{ + playerArray = p; +} + +void +ClientBoard::setHand(HandInterface* br) +{ + actualHand = br; +} + +void +ClientBoard::collectSets() +{ +} + +void +ClientBoard::collectPot() +{ +} + + diff --git a/src/engine/network_engine/clientboard.h b/src/engine/network_engine/clientboard.h new file mode 100644 index 00000000..87d93a13 --- /dev/null +++ b/src/engine/network_engine/clientboard.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTBOARD_H +#define CLIENTBOARD_H + +#include + +class PlayerInterface; +class HandInterface; + + +class ClientBoard : public BoardInterface{ +public: + ClientBoard(); + ~ClientBoard(); + + 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]; } + + int getPot() const { return pot;} + void setPot(int theValue) { pot = theValue;} + int getSets() const { return sets; } + + void collectSets(); + void collectPot(); + +private: + PlayerInterface **playerArray; + HandInterface *actualHand; + + int myCards[5]; + int pot; + int sets; +}; + +#endif diff --git a/src/engine/network_engine/clientenginefactory.cpp b/src/engine/network_engine/clientenginefactory.cpp new file mode 100644 index 00000000..17729ea2 --- /dev/null +++ b/src/engine/network_engine/clientenginefactory.cpp @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clientenginefactory.h" + +#include "clienthand.h" +#include "clientboard.h" +#include "clientplayer.h" +#include "clientpreflop.h" +#include "clientflop.h" +#include "clientturn.h" +#include "clientriver.h" + +#include + + +ClientEngineFactory::ClientEngineFactory(ConfigFile *c) +: myConfig(c) +{ +} + + +ClientEngineFactory::~ClientEngineFactory() +{ +} + + +HandInterface* ClientEngineFactory::createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) +{ + return new ClientHand(f, g, b, p, id, sP, aP, dP, sB, sC); +} + +BoardInterface* ClientEngineFactory::createBoard() +{ + return new ClientBoard; +} + +PlayerInterface* ClientEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) +{ + return new ClientPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB); +} + +PreflopInterface* ClientEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) +{ + return new ClientPreflop(hi, id, aP, dP, sB); +} + +FlopInterface* ClientEngineFactory::createFlop(HandInterface* hi, int id, int aP, int dP, int sB) +{ + return new ClientFlop(hi, id, aP, dP, sB); +} + +TurnInterface* ClientEngineFactory::createTurn(HandInterface* hi, int id, int aP, int dP, int sB) +{ + return new ClientTurn(hi, id, aP, dP, sB); +} + +RiverInterface* ClientEngineFactory::createRiver(HandInterface* hi, int id, int aP, int dP, int sB) +{ + return new ClientRiver(hi, id, aP, dP, sB); +} + diff --git a/src/engine/network_engine/clientenginefactory.h b/src/engine/network_engine/clientenginefactory.h new file mode 100644 index 00000000..5dae7dc5 --- /dev/null +++ b/src/engine/network_engine/clientenginefactory.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTENGINEFACTORY_H +#define CLIENTENGINEFACTORY_H + +#include + +#include +#include +#include +#include +#include +#include +#include + +class ConfigFile; + +class ClientEngineFactory : public EngineFactory +{ +public: + ClientEngineFactory(ConfigFile*); + ~ClientEngineFactory(); + + HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC); + BoardInterface* createBoard(); + PlayerInterface* createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); + PreflopInterface* createPreflop(HandInterface* hi, int id, int aP, int dP, int sB); + FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB); + TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB); + RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB); + +private: + ConfigFile *myConfig; +}; + +#endif diff --git a/src/engine/network_engine/clientflop.cpp b/src/engine/network_engine/clientflop.cpp new file mode 100644 index 00000000..feda7ee5 --- /dev/null +++ b/src/engine/network_engine/clientflop.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clientflop.h" +#include +#include + +//using namespace std; + +ClientFlop::ClientFlop(HandInterface* bR, int id, int qP, int dP, int sB) +: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), playersTurn(dP) +{ +} + + +ClientFlop::~ClientFlop() +{ +} + +void +ClientFlop::flopRun() +{ +} + +void +ClientFlop::nextPlayer2() +{ +} + + diff --git a/src/engine/network_engine/clientflop.h b/src/engine/network_engine/clientflop.h new file mode 100644 index 00000000..93310e7b --- /dev/null +++ b/src/engine/network_engine/clientflop.h @@ -0,0 +1,68 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTFLOP_H +#define CLIENTFLOP_H + +#include "flopinterface.h" + +class HandInterface; + +class ClientFlop : public FlopInterface{ +public: + ClientFlop(HandInterface*, int, int, int, int); + ~ClientFlop(); + + + void setPlayersTurn(const int& theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(const int& theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setFirstFlopRound(bool theValue) { firstFlopRound = theValue;} + bool getFirstFlopRound() const { return firstFlopRound;} + + void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;} + int getSmallBlindPosition() const { return smallBlindPosition; } + + void setSmallBlind(const int& theValue) { smallBlind = theValue; } + int getSmallBlind() const { return smallBlind; } + + void flopRun(); + void nextPlayer2(); + +private: + + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int smallBlindPosition; + + int smallBlind; + int highestSet; + + bool firstFlopRun; + bool firstFlopRound; + int playersTurn; + +}; + +#endif diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp new file mode 100644 index 00000000..e0c7c002 --- /dev/null +++ b/src/engine/network_engine/clienthand.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clienthand.h" +#include + +using namespace std; + +ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) +: myFactory(f), myGui(g), myBoard(b), playerArray(p), myPreflop(0), myFlop(0), myTurn(0), myRiver(0), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), allInCondition(0), bettingRoundsPlayed(0) +{ +} + + + +ClientHand::~ClientHand() +{ +} + +void +ClientHand::start() +{ +} + +void +ClientHand::assignButtons() +{ +} + +void +ClientHand::switchRounds() +{ +} + +void +ClientHand::highlightRoundLabel() +{ +} + diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h new file mode 100644 index 00000000..baf427df --- /dev/null +++ b/src/engine/network_engine/clienthand.h @@ -0,0 +1,118 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTHAND_H +#define CLIENTHAND_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class ClientHand : public HandInterface{ +public: + ClientHand(boost::shared_ptr f, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int); + ~ClientHand(); + + void start(); + + PlayerInterface** getPlayerArray() const { return playerArray; } + BoardInterface* getBoard() const { return myBoard; } + PreflopInterface* getPreflop() const { return myPreflop; } + FlopInterface* getFlop() const { return myFlop; } + TurnInterface* getTurn() const { return myTurn; } + RiverInterface* getRiver() const { return myRiver; } + GuiInterface* getGuiInterface() const { return myGui; } + + void setMyID(const int& theValue) { myID = theValue; } + int getMyID() const { return myID; } + + void setActualQuantityPlayers(const int& theValue) { actualQuantityPlayers = theValue; } + int getActualQuantityPlayers() const { return actualQuantityPlayers; } + + void setStartQuantityPlayers(const int& theValue) { startQuantityPlayers = theValue; } + int getStartQuantityPlayers() const { return startQuantityPlayers; } + + 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; } + + void setAllInCondition(bool theValue) { allInCondition = theValue; } + bool getAllInCondition() const { return allInCondition; } + + void setStartCash(const int& theValue) { startCash = theValue; } + int getStartCash() const { return startCash; } + + void setActivePlayersCounter(const int& theValue) { activePlayersCounter = theValue; } + int getActivePlayersCounter() const { return activePlayersCounter; } + + void setBettingRoundsPlayed(const int& theValue) { bettingRoundsPlayed = theValue; } + int getBettingRoundsPlayed() const { return bettingRoundsPlayed; } + + void setLastPlayersTurn(const int& theValue) { lastPlayersTurn = theValue; } + int getLastPlayersTurn() const { return lastPlayersTurn; } + + + void assignButtons(); + + void highlightRoundLabel(); + void switchRounds(); + + +private: + + boost::shared_ptr myFactory; + GuiInterface *myGui; + BoardInterface *myBoard; + PlayerInterface **playerArray; + PreflopInterface *myPreflop; + FlopInterface *myFlop; + TurnInterface *myTurn; + RiverInterface *myRiver; + + int myID; + int actualQuantityPlayers; + int startQuantityPlayers; + int dealerPosition; // -1 -> neutral + int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river + int smallBlind; + int startCash; + int activePlayersCounter; + + int lastPlayersTurn; + + bool allInCondition; + + // hier steht bis zu welcher bettingRound der human player gespielt hat: 0 - nur Preflop, 1 - bis Flop, ... + int bettingRoundsPlayed; +}; + +#endif + + diff --git a/src/engine/network_engine/clientplayer.cpp b/src/engine/network_engine/clientplayer.cpp new file mode 100644 index 00000000..27a6c806 --- /dev/null +++ b/src/engine/network_engine/clientplayer.cpp @@ -0,0 +1,133 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clientplayer.h" +#include "handinterface.h" + +using namespace std; + + +ClientPlayer::ClientPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) +: PlayerInterface(), myConfig(c), actualHand(0), actualBoard(b), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myAction(0), myButton(mB), myActiveStatus(aS), myTurn(0), myRoundStartCash(0), sBluff(0), sBluffStatus(0) +{ +} + + +ClientPlayer::~ClientPlayer() +{ +} + + +void +ClientPlayer::setHand(HandInterface* br) +{ + actualHand = br; +} + + +void +ClientPlayer::action() +{ +} + + +void +ClientPlayer::preflopEngine() +{ +} + + +void +ClientPlayer::flopEngine() +{ +} + + +void +ClientPlayer::turnEngine() +{ +} + + +void +ClientPlayer::riverEngine() +{ +} + + +void +ClientPlayer::evaluation(int bet, int raise) +{ +} + + +int +ClientPlayer::preflopCardsValue(int* cards) +{ + return 0; +} + + +int +ClientPlayer::flopCardsValue(int* cards) +{ + return 0; +} + + +void +ClientPlayer::readFile() +{ +} + +int +ClientPlayer::turnCardsValue(int* cards) +{ + return 0; +} + +void +ClientPlayer::preflopEngine3() +{ +} + +void +ClientPlayer::flopEngine3() +{ +} + +void +ClientPlayer::turnEngine3() +{ +} + +void +ClientPlayer::riverEngine3() +{ +} + +void ClientPlayer::setNetSessionData(boost::shared_ptr session) +{ + myNetSessionData = session; +} + +boost::shared_ptr ClientPlayer::getNetSessionData() +{ + return myNetSessionData; +} + diff --git a/src/engine/network_engine/clientplayer.h b/src/engine/network_engine/clientplayer.h new file mode 100644 index 00000000..a85a0ddb --- /dev/null +++ b/src/engine/network_engine/clientplayer.h @@ -0,0 +1,179 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTPLAYER_H +#define CLIENTPLAYER_H + +#include + +#include +#include + + +class CardsValue; +class ConfigFile; +class HandInterface; +class BoardInterface; + +class ClientPlayer : public PlayerInterface{ +public: + ClientPlayer(ConfigFile*, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); + ~ClientPlayer(); + + void setHand(HandInterface*); + + int getMyID() const { return myID; } + unsigned getMyUniqueID() const { return myUniqueID; } + PlayerType getMyType() const { return myType; } + + void setMyDude(const int& theValue) { myDude = theValue; } + int getMyDude() const { return myDude; } + + void setMyDude4(const int& theValue) { myDude4 = theValue; } + int getMyDude4() const { return myDude4; } + + void setMyName(const std::string& theValue) { myName = theValue; } + std::string getMyName() const { return myName; } + + void setMyAvatar(const std::string& theValue) { myAvatar = theValue; } + std::string getMyAvatar() const { return myAvatar; } + + void setMyCash(const int& theValue) { myCash = theValue; } + int getMyCash() const { return myCash; } + + void setMySet(const int& theValue) { mySet += theValue; myCash -= theValue; } + void setMySetNull() { mySet = 0; } + int getMySet() const { return mySet;} + + void setMyAction(const int& theValue) { myAction = theValue; } + int getMyAction() const { return myAction; } + + void setMyButton(const int& theValue) { myButton = theValue; } + int getMyButton() const { return myButton; } + + void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; } + bool getMyActiveStatus() const { return myActiveStatus; } + + void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; } + void getMyCards(int* theValue) { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; } + + void setMyTurn(bool theValue){ myTurn = theValue;} + bool getMyTurn() const{ return myTurn;} + + void setMyCardsFlip(bool theValue){ myCardsFlip = theValue;} + bool getMyCardsFlip() const{ return myCardsFlip;} + + void setMyCardsValueInt(const int& theValue) { myCardsValueInt = theValue;} + int getMyCardsValueInt() const { return myCardsValueInt; } + + int* getMyBestHandPosition() { return myBestHandPosition; } + + void setMyRoundStartCash(const int& theValue) { myRoundStartCash = theValue;} + int getMyRoundStartCash() const { return myRoundStartCash; } + + void setMyAverageSets(const int& theValue) { myAverageSets[0] = myAverageSets[1]; myAverageSets[1] = myAverageSets[2]; myAverageSets[2] = myAverageSets[3]; myAverageSets[3] = theValue; } + int getMyAverageSets() const { return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4; } + + void setMyAggressive(const bool& theValue) { + int i; + for(i=0; i<6; i++) { + myAggressive[i] = myAggressive[i+1]; + } + myAggressive[6] = theValue; + } + int getMyAggressive() const { + int i, sum = 0; + for(i=0; i<7; i++) { + sum += myAggressive[i]; + } + return sum; + } + + void setSBluff ( int theValue ) { sBluff = theValue; } + int getSBluff() const { return sBluff; } + + void setSBluffStatus ( bool theValue ) { sBluffStatus = theValue; } + bool getSBluffStatus() const { return sBluffStatus; } + + void action(); + + void preflopEngine(); + void flopEngine(); + void turnEngine(); + void riverEngine(); + + void preflopEngine3(); + void flopEngine3(); + void turnEngine3(); + void riverEngine3(); + + int preflopCardsValue(int*); + int flopCardsValue(int*); + int turnCardsValue(int*); + + void readFile(); + + void evaluation(int, int); + + void setNetSessionData(boost::shared_ptr session); + boost::shared_ptr getNetSessionData(); + +private: + + ConfigFile *myConfig; + HandInterface *actualHand; + BoardInterface *actualBoard; + + CardsValue *myCardsValue; + + // Konstanten + int myID; + unsigned myUniqueID; + PlayerType myType; + std::string myName; + std::string myAvatar; + int myDude; + int myDude4; + + + // Laufvariablen + int myCardsValueInt; + int myBestHandPosition[5]; + double myOdds; + int myNiveau[3]; + + int myCards[2]; + int myCash; + int mySet; + int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin + int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big + bool myActiveStatus; // 0 = inactive, 1 = active + bool myTurn; // 0 = no, 1 = yes + bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped, + int myRoundStartCash; + + int myAverageSets[4]; + bool myAggressive[7]; + + int sBluff; + bool sBluffStatus; + + boost::shared_ptr myNetSessionData; +}; + +#endif diff --git a/src/engine/network_engine/clientpreflop.cpp b/src/engine/network_engine/clientpreflop.cpp new file mode 100644 index 00000000..737d9984 --- /dev/null +++ b/src/engine/network_engine/clientpreflop.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clientpreflop.h" + +#include +#include + +using namespace std; + +ClientPreflop::ClientPreflop(HandInterface* bR, int id, int qP, int dP, int sB) +: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0) +{ +} + + + +ClientPreflop::~ClientPreflop() +{ +} + +void +ClientPreflop::preflopRun() +{ +} + +void +ClientPreflop::nextPlayer2() +{ +} diff --git a/src/engine/network_engine/clientpreflop.h b/src/engine/network_engine/clientpreflop.h new file mode 100644 index 00000000..21c33326 --- /dev/null +++ b/src/engine/network_engine/clientpreflop.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTPREFLOP_H +#define CLIENTPREFLOP_H + +#include + +class HandInterface; + +class ClientPreflop : public PreflopInterface{ + +public: + ClientPreflop(HandInterface*, int, int, int, int); + ~ClientPreflop(); + + + void setPlayersTurn(const int& theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(const int& theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setPreflopFirstRound(bool theValue) { preflopFirstRound = theValue; } + bool setPreflopFirstRound() const { return preflopFirstRound; } + + void preflopRun(); + void nextPlayer2(); + + + +private: + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int bigBlindPosition; + + int smallBlind; + int highestSet; + + bool preflopFirstRound; + int playersTurn; + + +}; + +#endif diff --git a/src/engine/network_engine/clientriver.cpp b/src/engine/network_engine/clientriver.cpp new file mode 100644 index 00000000..d7dae696 --- /dev/null +++ b/src/engine/network_engine/clientriver.cpp @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clientriver.h" +#include + + +//using namespace std; + +ClientRiver::ClientRiver(HandInterface* bR, int id, int qP, int dP, int sB) +: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstRiverRun(1), firstRiverRound(1), playersTurn(dP), highestCardsValue(0) +{ +} + +ClientRiver::~ClientRiver() +{ +} + + +void +ClientRiver::riverRun() +{ +} + +void +ClientRiver::postRiverRun() +{ +} + +void +ClientRiver::nextPlayer2() +{ +} + +void +ClientRiver::distributePot() +{ +} diff --git a/src/engine/network_engine/clientriver.h b/src/engine/network_engine/clientriver.h new file mode 100644 index 00000000..2dfc097b --- /dev/null +++ b/src/engine/network_engine/clientriver.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTRIVER_H +#define CLIENTRIVER_H + +#include + +class HandInterface; + + +class ClientRiver : public RiverInterface{ +public: + ClientRiver(HandInterface*, int, int, int, int); + ~ClientRiver(); + + void setPlayersTurn(const int& theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(const int& theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setFirstRiverRound(bool theValue) { firstRiverRound = theValue;} + bool getFirstRiverRound() const { return firstRiverRound;} + + void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;} + int getSmallBlindPosition() const { return smallBlindPosition; } + + void setSmallBlind(const int& theValue) { smallBlind = theValue; } + int getSmallBlind() const { return smallBlind; } + + void setHighestCardsValue(const int& theValue) { highestCardsValue = theValue;} + int getHighestCardsValue() const { return highestCardsValue;} + + void riverRun(); + void postRiverRun(); + void nextPlayer2(); + void distributePot(); + +private: + + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int smallBlindPosition; + + int smallBlind; + int highestSet; + + bool firstRiverRun; + bool firstRiverRound; + int playersTurn; + + int highestCardsValue; + +}; + +#endif diff --git a/src/engine/network_engine/clientturn.cpp b/src/engine/network_engine/clientturn.cpp new file mode 100644 index 00000000..ce03158d --- /dev/null +++ b/src/engine/network_engine/clientturn.cpp @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 "clientturn.h" +#include +#include + +//using namespace std; + +ClientTurn::ClientTurn(HandInterface* bR, int id, int qP, int dP, int sB) +: myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstTurnRun(1), firstTurnRound(1), playersTurn(dP) +{ +} + +ClientTurn::~ClientTurn() +{ +} + +void +ClientTurn::turnRun() +{ +} + +void +ClientTurn::nextPlayer2() +{ +} + diff --git a/src/engine/network_engine/clientturn.h b/src/engine/network_engine/clientturn.h new file mode 100644 index 00000000..6f8478c2 --- /dev/null +++ b/src/engine/network_engine/clientturn.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * 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 CLIENTTURN_H +#define CLIENTTURN_H + +#include + +class HandInterface; + +class ClientTurn : public TurnInterface{ +public: + ClientTurn(HandInterface*, int, int, int, int); + ~ClientTurn(); + + void setPlayersTurn(const int& theValue) { playersTurn = theValue; } + int getPlayersTurn() const { return playersTurn; } + + void setHighestSet(const int& theValue) { highestSet = theValue; } + int getHighestSet() const { return highestSet;} + + void setFirstTurnRound(bool theValue) { firstTurnRound = theValue;} + bool getFirstTurnRound() const { return firstTurnRound;} + + void setSmallBlindPosition(const int& theValue) { smallBlindPosition = theValue;} + int getSmallBlindPosition() const { return smallBlindPosition; } + + void setSmallBlind(const int& theValue) { smallBlind = theValue; } + int getSmallBlind() const { return smallBlind; } + + void turnRun(); + void nextPlayer2(); + +private: + + HandInterface *myHand; + + int myID; + int actualQuantityPlayers; + int dealerPosition; + int smallBlindPosition; + + int smallBlind; + int highestSet; + + bool firstTurnRun; + bool firstTurnRound; + int playersTurn; + +}; + +#endif diff --git a/src/game.cpp b/src/game.cpp index e566b16a..edb27659 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -20,18 +20,22 @@ #include "game.h" #include "gamedata.h" -#include +#include #include -#include + +#include +#include using namespace std; -Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId, ConfigFile *c) -: myGui(gui), actualHand(0), actualBoard(0), startQuantityPlayers(gameData.numberOfPlayers), +Game::Game(GuiInterface* gui, boost::shared_ptr factory, + const PlayerDataList &playerDataList, const GameData &gameData, int gameId) +: myGui(gui), myFactory(factory), actualHand(0), actualBoard(0), + startQuantityPlayers(gameData.numberOfPlayers), startCash(gameData.startCash), startSmallBlind(gameData.smallBlind), startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise), myGameID(gameId), actualQuantityPlayers(gameData.numberOfPlayers), - actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0), myConfig(c) + actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(gameData.startDealerPos) { // cout << "Create Game Object" << "\n"; int i; @@ -42,18 +46,11 @@ Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameDa playerArray[i] = 0; } - //EngineFactory erstellen - myFactory = new LocalEngineFactory(myConfig); // LocalEngine erstellen - // Board erstellen actualBoard = myFactory->createBoard(); - // ersten Dealer bestimmen - Tools myTool; - myTool.getRandNumber(0, startQuantityPlayers-1, 1, &dealerPosition, 0); - // Player erstellen PlayerDataList::const_iterator player_i = playerDataList.begin(); PlayerDataList::const_iterator player_end = playerDataList.end(); diff --git a/src/game.h b/src/game.h index 78a1b2c2..bbca4a69 100755 --- a/src/game.h +++ b/src/game.h @@ -20,14 +20,13 @@ #ifndef GAME_H #define GAME_H -#include -#include -#include - #include "game_defs.h" #include "playerdata.h" #include "configfile.h" +#include +#include + class GuiInterface; class HandInterface; class PlayerInterface; @@ -38,7 +37,7 @@ struct GameData; class Game { public: - Game(GuiInterface *gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId, ConfigFile*); + Game(GuiInterface *gui, boost::shared_ptr factory, const PlayerDataList &playerDataList, const GameData &gameData, int gameId); ~Game(); @@ -59,9 +58,8 @@ public: void setStartCash(const int& theValue) { startCash = theValue; } int getStartCash() const { return startCash; } - void setDealerPosition(const int& theValue) { dealerPosition = theValue; } int getDealerPosition() const { return dealerPosition; } - + void setMyGameID(const int& theValue) { myGameID = theValue;} int getMyGameID() const { return myGameID; } @@ -79,7 +77,7 @@ public: private: - EngineFactory *myFactory; + boost::shared_ptr myFactory; GuiInterface *myGui; HandInterface *actualHand; @@ -98,8 +96,6 @@ private: int actualSmallBlind; int actualHandID; int dealerPosition; - - ConfigFile *myConfig; }; #endif diff --git a/src/gamedata.h b/src/gamedata.h index 51bf01b9..0ac284dc 100644 --- a/src/gamedata.h +++ b/src/gamedata.h @@ -25,12 +25,14 @@ struct GameData { - GameData() : numberOfPlayers(0), startCash(0), smallBlind(0), handsBeforeRaise(1) {} + GameData() : numberOfPlayers(0), startCash(0), smallBlind(0), + handsBeforeRaise(1), guiSpeed(4), startDealerPos(0) {} int numberOfPlayers; int startCash; int smallBlind; int handsBeforeRaise; int guiSpeed; + int startDealerPos; }; #endif diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 40a5c984..9c6c36ec 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -95,7 +95,7 @@ void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->SignalNetClientGam void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->SignalNetClientError(errorID, osErrorID); } void GuiWrapper::SignalNetClientPlayerJoined(const string &playerName) { myW->SignalNetClientPlayerJoined(QString::fromUtf8(playerName.c_str())); } void GuiWrapper::SignalNetClientPlayerLeft(const string &playerName) { myW->SignalNetClientPlayerLeft(QString::fromUtf8(playerName.c_str())); } -void GuiWrapper::SignalNetClientGameStart(const GameData &gameData) { myW->SignalNetClientGameStart(gameData.numberOfPlayers, gameData.startCash, gameData.smallBlind, gameData.handsBeforeRaise); } +void GuiWrapper::SignalNetClientGameStart(const GameData &gameData) { myW->SignalNetClientGameStart(); } void GuiWrapper::SignalNetServerSuccess(int actionID) { } void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { } diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 927bea7d..33994f4c 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -37,9 +37,11 @@ #include "handinterface.h" #include "game.h" #include "session.h" +#include "tools.h" #include "log.h" #include "configfile.h" +#include #include #include @@ -561,7 +563,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) // Errors are handled globally, not within one dialog. connect(this, SIGNAL(SignalNetClientError(int, int)), this, SLOT(networkError(int, int))); - connect(this, SIGNAL(SignalNetClientGameStart(int, int, int, int)), this, SLOT(networkStart(int, int, int, int))); + connect(this, SIGNAL(SignalNetClientGameStart()), this, SLOT(networkStart())); connect(this, SIGNAL(SignalNetServerPlayerJoined(QString)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(QString))); connect(this, SIGNAL(SignalNetServerPlayerLeft(QString)), myStartNetworkGameDialog, SLOT(removePlayer(QString))); @@ -619,8 +621,12 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) { //Speeds gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); } + // Set dealer pos. + Tools myTool; + myTool.getRandNumber(0, gameData.numberOfPlayers-1, 1, &gameData.startDealerPos, 0); + //Start Game!!! - mySession->startGame(gameData); + mySession->startLocalGame(gameData); } @@ -2375,14 +2381,11 @@ void mainWindowImpl::networkError(int errorID, int osErrorID) { myWaitingForServerGameDialog->reject(); } -void mainWindowImpl::networkStart(int numberOfPlayers, int startCash, int smallBlind, int handsBeforeRaise) +void mainWindowImpl::networkStart() { - GameData gameData; - gameData.numberOfPlayers = numberOfPlayers; - gameData.startCash = startCash; - gameData.smallBlind = smallBlind; - gameData.handsBeforeRaise = handsBeforeRaise; - mySession->startGame(gameData); +// QMutexLocker lock(&myClientDataMutex); +// assert(!myClientPlayerDataList.empty()); +// mySession->startClientGame(myClientGameData, myClientPlayerDataList); } void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) { diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 44227c5a..b121a0f5 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -22,7 +22,6 @@ #include "ui_mainwindow.h" #include "game_defs.h" -#include #include #include @@ -96,7 +95,7 @@ signals: void SignalNetClientError(int errorID, int osErrorID); void SignalNetClientPlayerJoined(QString playerName); void SignalNetClientPlayerLeft(QString playerName); - void SignalNetClientGameStart(int numberOfPlayers, int startCash, int smallBlind, int handsBeforeRaise); + void SignalNetClientGameStart(); void SignalNetServerPlayerJoined(QString playerName); void SignalNetServerPlayerLeft(QString playerName); @@ -197,7 +196,7 @@ public slots: void paintStartSplash(); void networkError(int, int); - void networkStart(int, int, int, int); + void networkStart(); void closeEvent(QCloseEvent*); diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index f667e6e0..ab4435cb 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -115,7 +115,8 @@ struct NetPacketPlayerLeftData struct NetPacketGameStartData { NetPacketHeader head; - u_int32_t reserved; + u_int16_t startDealerPos; + u_int16_t reserved; }; struct NetPacketHandStartData @@ -760,7 +761,7 @@ NetPacketGameStart::SetData(const NetPacketGameStart::Data &inData) NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData(); assert(tmpData); - tmpData->reserved = htonl(inData.reserved); + tmpData->startDealerPos = htons(inData.startDealerPos); } void @@ -769,7 +770,7 @@ NetPacketGameStart::GetData(NetPacketGameStart::Data &outData) const NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData(); assert(tmpData); - outData.reserved = ntohl(tmpData->reserved); + outData.startDealerPos = ntohs(tmpData->startDealerPos); } const NetPacketGameStart * diff --git a/src/net/common/serverrecvstate.cpp b/src/net/common/serverrecvstate.cpp index 4afbd7ef..d4950420 100644 --- a/src/net/common/serverrecvstate.cpp +++ b/src/net/common/serverrecvstate.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -223,8 +224,18 @@ ServerRecvStateStartGame::HandleNewConnection(ServerRecvThread &server, boost::s int ServerRecvStateStartGame::Process(ServerRecvThread &server) { + GameData &gameData = server.GetGameData(); + + // Set dealer pos. + Tools myTool; + myTool.getRandNumber(0, gameData.numberOfPlayers-1, 1, &gameData.startDealerPos, 0); + boost::shared_ptr answer(new NetPacketGameStart); + NetPacketGameStart::Data gameStartData; + gameStartData.startDealerPos = gameData.startDealerPos; + static_cast(answer.get())->SetData(gameStartData); + server.SendToAllPlayers(answer); server.SetState(ServerRecvStateStartHand::Instance()); diff --git a/src/net/common/serverrecvthread.cpp b/src/net/common/serverrecvthread.cpp index 63c5679e..747db92e 100644 --- a/src/net/common/serverrecvthread.cpp +++ b/src/net/common/serverrecvthread.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -247,7 +248,11 @@ ServerRecvThread::InternalStartGame() { GuiInterface &gui = GetGui(); PlayerDataList playerData = GetPlayerDataList(); - m_game.reset(new Game(&gui, playerData, GetGameData(), m_curGameId++, m_playerConfig)); + + // EngineFactory erstellen + boost::shared_ptr factory(new LocalEngineFactory(m_playerConfig)); // LocalEngine erstellen + + m_game.reset(new Game(&gui, factory, playerData, GetGameData(), m_curGameId++)); SetState(SERVER_START_GAME_STATE::Instance()); } @@ -493,7 +498,7 @@ ServerRecvThread::GetGame() return *m_game; } -const GameData & +GameData & ServerRecvThread::GetGameData() const { assert(m_gameData.get()); diff --git a/src/net/netpacket.h b/src/net/netpacket.h index 6225787b..0cf5fde6 100644 --- a/src/net/netpacket.h +++ b/src/net/netpacket.h @@ -194,7 +194,8 @@ class NetPacketGameStart : public NetPacket public: struct Data { - u_int32_t reserved; + u_int16_t startDealerPos; + u_int16_t reserved; }; NetPacketGameStart(); diff --git a/src/net/serverrecvthread.h b/src/net/serverrecvthread.h index 4487cb30..c82a6927 100644 --- a/src/net/serverrecvthread.h +++ b/src/net/serverrecvthread.h @@ -121,7 +121,7 @@ protected: ReceiverHelper &GetReceiver(); Game &GetGame(); - const GameData &GetGameData() const; + GameData &GetGameData() const; bool CheckPassword(const std::string &password) const; ServerSenderCallback &GetSenderCallback(); diff --git a/src/session.cpp b/src/session.cpp index f2c0a3a1..3bc0ffc9 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -21,6 +21,8 @@ #include "game.h" #include "guiinterface.h" #include "configfile.h" +#include +#include #include #include @@ -46,7 +48,7 @@ Session::~Session() } -void Session::startGame(const GameData &gameData) { +void Session::startLocalGame(const GameData &gameData) { deleteGame(); myGui->initGui(gameData.guiSpeed); @@ -73,7 +75,28 @@ void Session::startGame(const GameData &gameData) { playerDataList.push_back(playerData); } - currentGame = new Game(myGui, playerDataList, gameData, currentGameID, myConfig); + // EngineFactory erstellen + boost::shared_ptr factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen + + currentGame = new Game(myGui, factory, playerDataList, gameData, currentGameID); + + //// SPIEL-SCHLEIFE + currentGame->initHand(); + currentGame->startHand(); + // SPIEL-SCHLEIFE +} + +void Session::startClientGame(const GameData &gameData, const PlayerDataList &playerDataList) +{ + deleteGame(); + myGui->initGui(gameData.guiSpeed); + + currentGameID++; + + // EngineFactory erstellen + boost::shared_ptr factory(new ClientEngineFactory(myConfig)); // LocalEngine erstellen + + currentGame = new Game(myGui, factory, playerDataList, gameData, currentGameID); //// SPIEL-SCHLEIFE currentGame->initHand(); diff --git a/src/session.h b/src/session.h index 6f86e49e..5d360179 100755 --- a/src/session.h +++ b/src/session.h @@ -20,6 +20,7 @@ #ifndef STDSESSION_H #define STDSESSION_H #include "gamedata.h" +#include "playerdata.h" #include "game_defs.h" #include @@ -36,7 +37,8 @@ public: ~Session(); - void startGame(const GameData &gameData); + void startLocalGame(const GameData &gameData); + void startClientGame(const GameData &gameData, const PlayerDataList &playerDataList); void deleteGame(); Game *getCurrentGame();