BeRo refactoring

This commit is contained in:
doitux
2007-08-06 22:58:47 +00:00
parent c8207f9b8e
commit 722ab71189
15 changed files with 3 additions and 395 deletions
-6
View File
@@ -78,7 +78,6 @@ HEADERS += src/game.h \
src/engine/riverinterface.h \
src/engine/turninterface.h \
src/engine/berointerface.h \
src/engine/berofactoryinterface.h \
src/gui/guiinterface.h \
src/net/clientcallback.h \
src/net/clientcontext.h \
@@ -111,7 +110,6 @@ HEADERS += src/game.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 \
src/engine/network_engine/clientboard.h \
src/engine/network_engine/clientenginefactory.h \
src/engine/network_engine/clientflop.h \
@@ -121,7 +119,6 @@ HEADERS += src/game.h \
src/engine/network_engine/clientriver.h \
src/engine/network_engine/clientturn.h \
src/engine/network_engine/clientbero.h \
src/engine/network_engine/clientberofactory.h \
src/gui/qt/sound/sdlplayer.h \
src/gui/qt/mainwindow/mainwindowimpl.h \
src/gui/qt/mainwindow/mycardspixmaplabel.h \
@@ -172,7 +169,6 @@ SOURCES += src/game.cpp \
src/engine/riverinterface.cpp \
src/engine/turninterface.cpp \
src/engine/berointerface.cpp \
src/engine/berofactoryinterface.cpp \
src/gui/guiinterface.cpp \
src/core/common/thread.cpp \
src/core/tinyxml/tinystr.cpp \
@@ -195,7 +191,6 @@ SOURCES += src/game.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 \
src/engine/network_engine/clientboard.cpp \
src/engine/network_engine/clientenginefactory.cpp \
src/engine/network_engine/clientflop.cpp \
@@ -205,7 +200,6 @@ SOURCES += src/game.cpp \
src/engine/network_engine/clientriver.cpp \
src/engine/network_engine/clientturn.cpp \
src/engine/network_engine/clientbero.cpp \
src/engine/network_engine/clientberofactory.cpp \
src/net/common/connectdata.cpp \
src/net/common/clientcallback.cpp \
src/net/common/clientcontext.cpp \
-18
View File
@@ -1,18 +0,0 @@
//
// C++ Implementation: berofactoryinterface
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "berofactoryinterface.h"
BeRoFactoryInterface::~BeRoFactoryInterface()
{
}
-38
View File
@@ -1,38 +0,0 @@
//
// C++ Interface: berofactoryinterface
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef BEROFACTORYINTERFACE_H
#define BEROFACTORYINTERFACE_H
/**
@author FThauer FHammer <webmaster@pokerth.net>
*/
#include <vector>
#include <boost/shared_ptr.hpp>
#include <berointerface.h>
class BeRoFactoryInterface{
public:
virtual ~BeRoFactoryInterface();
virtual BeRoInterface* switchRounds(BeRoInterface*, int) = 0;
virtual BeRoInterface* createBeRoPreflop() =0;
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo() =0;
};
#endif
+2
View File
@@ -34,10 +34,12 @@ public:
virtual void run() =0;
// for network
virtual void preflopRun() =0;
virtual void flopRun() =0;
virtual void turnRun() =0;
virtual void riverRun() =0;
virtual void postRiverRun() =0;
virtual void nextPlayer2() =0;
-11
View File
@@ -23,12 +23,7 @@
#include "boardinterface.h"
#include "handinterface.h"
#include "playerinterface.h"
#include "preflopinterface.h"
#include "flopinterface.h"
#include "turninterface.h"
#include "riverinterface.h"
#include "berointerface.h"
#include "berofactoryinterface.h"
#include <boost/shared_ptr.hpp>
@@ -41,12 +36,6 @@ public:
virtual HandInterface* createHand(boost::shared_ptr<EngineFactory> 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;
virtual FlopInterface* createFlop(HandInterface* hi, int id, int aP, int dP, int sB) =0;
virtual TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB) =0;
virtual RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB) =0;
// virtual BeRoInterface* createBeRo() =0;
virtual BeRoFactoryInterface* createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB) =0;
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) =0;
};
@@ -1,101 +0,0 @@
//
// C++ Implementation: localberofactory
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "localberofactory.h"
#include <localberopreflop.h>
#include <localberoflop.h>
#include <localberoturn.h>
#include <localberoriver.h>
#include <localberopostriver.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)
{}
LocalBeRoFactory::~LocalBeRoFactory()
{}
std::vector<boost::shared_ptr<BeRoInterface> > LocalBeRoFactory::createBeRo() {
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPreflop(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoFlop(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoTurn(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoRiver(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPostRiver(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
return myBeRo;
}
BeRoInterface* LocalBeRoFactory::createBeRoPreflop() {
BeRoInterface* preflopBeRo = new LocalBeRoPreflop ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind );
return preflopBeRo;
}
BeRoInterface* LocalBeRoFactory::switchRounds(BeRoInterface* currentBeRo, int currentRound)
{
if(currentRound != currentBeRo->getMyBeRoID()) {
delete currentBeRo;
currentBeRo = NULL;
switch(currentRound) {
case GAME_STATE_PREFLOP: {
currentBeRo = new LocalBeRoPreflop ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind );
}
break;
case GAME_STATE_FLOP: {
currentBeRo = new LocalBeRoFlop( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind );
}
break;
case GAME_STATE_TURN: {
currentBeRo = new LocalBeRoTurn( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind );
}
break;
case GAME_STATE_RIVER: {
currentBeRo = new LocalBeRoRiver ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind );
}
break;
case GAME_STATE_POST_RIVER: {
currentBeRo = new LocalBeRoPostRiver ( myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind );
}
break;
default: { cout << "BeRoFactory-ERROR" << endl; }
}
}
return currentBeRo;
}
@@ -1,59 +0,0 @@
//
// C++ Interface: localberofactory
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef LOCALBEROFACTORY_H
#define LOCALBEROFACTORY_H
#include <istream>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <berofactoryinterface.h>
#include <berointerface.h>
#include <handinterface.h>
/**
@author FThauer FHammer <webmaster@pokerth.net>
*/
class LocalBeRoFactory : public BeRoFactoryInterface
{
public:
LocalBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB);
~LocalBeRoFactory();
BeRoInterface* switchRounds(BeRoInterface*, int);
BeRoInterface* createBeRoPreflop();
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo();
private:
HandInterface* myHand;
int myID;
int actualQuantityPlayers;
int dealerPosition;
int bigBlindPosition;
int smallBlind;
int highestSet;
bool preflopFirstRound;
int playersTurn;
};
#endif
@@ -22,11 +22,6 @@
#include "localhand.h"
#include "localboard.h"
#include "localplayer.h"
#include "localpreflop.h"
#include "localflop.h"
#include "localturn.h"
#include "localriver.h"
#include "localberofactory.h"
#include "localberopreflop.h"
#include "localberoflop.h"
#include "localberoturn.h"
@@ -53,16 +48,6 @@ BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
PlayerInterface* LocalEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) { return new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB); }
PreflopInterface* LocalEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalPreflop(hi, id, aP, dP, sB); }
FlopInterface* LocalEngineFactory::createFlop(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalFlop(hi, id, aP, dP, sB); }
TurnInterface* LocalEngineFactory::createTurn(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalTurn(hi, id, aP, dP, sB); }
RiverInterface* LocalEngineFactory::createRiver(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalRiver(hi, id, aP, dP, sB); }
BeRoFactoryInterface* LocalEngineFactory::createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalBeRoFactory(hi, id, aP, dP, sB); }
std::vector<boost::shared_ptr<BeRoInterface> > LocalEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) {
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
@@ -25,11 +25,6 @@
#include <handinterface.h>
#include <boardinterface.h>
#include <playerinterface.h>
#include <preflopinterface.h>
#include <flopinterface.h>
#include <turninterface.h>
#include <riverinterface.h>
#include <berofactoryinterface.h>
class ConfigFile;
@@ -42,11 +37,6 @@ public:
HandInterface* createHand(boost::shared_ptr<EngineFactory> 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);
BeRoFactoryInterface* createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB);
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB);
private:
-2
View File
@@ -30,7 +30,6 @@
#include <playerinterface.h>
#include <handinterface.h>
#include <berointerface.h>
#include <berofactoryinterface.h>
class LocalHand : public HandInterface{
@@ -96,7 +95,6 @@ private:
GuiInterface *myGui;
BoardInterface *myBoard;
PlayerInterface **playerArray;
BeRoFactoryInterface *myBeRoFactory;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID;
@@ -1,49 +0,0 @@
//
// C++ Implementation: clientberofactory
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "clientberofactory.h"
#include <clientpreflop.h>
#include <clientflop.h>
#include <clientturn.h>
#include <clientriver.h>
ClientBeRoFactory::ClientBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB)
: myHand(hi), myID(id), actualQuantityPlayers(aP), dealerPosition(dP), smallBlind(sB)
{
}
ClientBeRoFactory::~ClientBeRoFactory()
{
}
std::vector<boost::shared_ptr<BeRoInterface> > ClientBeRoFactory::createBeRo()
{
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoPreflop(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoFlop(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoTurn(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoRiver(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
// myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRoPostRiver(myHand, myID, actualQuantityPlayers, dealerPosition, smallBlind)));
return myBeRo;
}
BeRoInterface* ClientBeRoFactory::switchRounds(BeRoInterface* currentBeRo, int currentRound) { return NULL;}
BeRoInterface* ClientBeRoFactory::createBeRoPreflop() { return NULL; }
@@ -1,48 +0,0 @@
//
// C++ Interface: clientberofactory
//
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef CLIENTBEROFACTORY_H
#define CLIENTBEROFACTORY_H
#include <vector>
#include <boost/shared_ptr.hpp>
#include <berofactoryinterface.h>
#include <handinterface.h>
/**
@author FThauer FHammer <webmaster@pokerth.net>
*/
class ClientBeRoFactory : public BeRoFactoryInterface
{
public:
ClientBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB);
~ClientBeRoFactory();
BeRoInterface* switchRounds(BeRoInterface*, int);
BeRoInterface* createBeRoPreflop();
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo();
private:
HandInterface* myHand;
int myID;
int actualQuantityPlayers;
int dealerPosition;
int smallBlind;
};
#endif
@@ -25,7 +25,6 @@
#include "clientflop.h"
#include "clientturn.h"
#include "clientriver.h"
#include "clientberofactory.h"
@@ -54,31 +53,6 @@ PlayerInterface* ClientEngineFactory::createPlayer(BoardInterface *b, int id, un
return new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB);
}
PreflopInterface* ClientEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB)
{
return NULL;
}
FlopInterface* ClientEngineFactory::createFlop(HandInterface* hi, int id, int aP, int dP, int sB)
{
return NULL;
}
TurnInterface* ClientEngineFactory::createTurn(HandInterface* hi, int id, int aP, int dP, int sB)
{
return NULL;
}
RiverInterface* ClientEngineFactory::createRiver(HandInterface* hi, int id, int aP, int dP, int sB)
{
return NULL;
}
BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB)
{
return new ClientBeRoFactory(hi, id, aP, dP, sB);
}
std::vector<boost::shared_ptr<BeRoInterface> > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) {
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
@@ -24,12 +24,6 @@
#include <handinterface.h>
#include <boardinterface.h>
#include <playerinterface.h>
#include <preflopinterface.h>
#include <flopinterface.h>
#include <turninterface.h>
#include <riverinterface.h>
// #include <berofactoryinterface.h>
class ConfigFile;
@@ -42,11 +36,6 @@ public:
HandInterface* createHand(boost::shared_ptr<EngineFactory> 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);
BeRoFactoryInterface* createBeRoFactory(HandInterface* hi, int id, int aP, int dP, int sB);
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB);
};
+1 -1
View File
@@ -55,7 +55,7 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, Boar
// the rest of the buttons are assigned later as received from the server.
// Preflop, Flop, Turn und River erstellen
myBeRo = myFactory->createBeRoFactory(this, myID, actualQuantityPlayers, dealerPosition, smallBlind)->createBeRo();
myBeRo = myFactory->createBeRo(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
}