more polymorphie steps for BeRo - local game --> unstable

This commit is contained in:
doitux
2007-08-04 21:30:20 +00:00
parent 1f00b3f458
commit 07f8a2aaeb
19 changed files with 87 additions and 45 deletions
+3 -1
View File
@@ -104,6 +104,7 @@ HEADERS += src/game.h \
src/engine/local_engine/localhand.h \ src/engine/local_engine/localhand.h \
src/engine/local_engine/localplayer.h \ src/engine/local_engine/localplayer.h \
src/engine/local_engine/localpreflop.h \ src/engine/local_engine/localpreflop.h \
src/engine/local_engine/localberopreflop.h \
src/engine/local_engine/localriver.h \ src/engine/local_engine/localriver.h \
src/engine/local_engine/localturn.h \ src/engine/local_engine/localturn.h \
src/engine/local_engine/tools.h \ src/engine/local_engine/tools.h \
@@ -185,7 +186,8 @@ SOURCES += src/game.cpp \
src/engine/local_engine/localhand.cpp \ src/engine/local_engine/localhand.cpp \
src/engine/local_engine/localplayer.cpp \ src/engine/local_engine/localplayer.cpp \
src/engine/local_engine/localpreflop.cpp \ src/engine/local_engine/localpreflop.cpp \
src/engine/local_engine/localriver.cpp \ src/engine/local_engine/localberopreflop.cpp \
src/engine/local_engine/localriver.cpp \
src/engine/local_engine/localturn.cpp \ src/engine/local_engine/localturn.cpp \
src/engine/local_engine/tools.cpp \ src/engine/local_engine/tools.cpp \
src/engine/local_engine/localbero.cpp \ src/engine/local_engine/localbero.cpp \
-5
View File
@@ -11,11 +11,6 @@
// //
#include "berofactoryinterface.h" #include "berofactoryinterface.h"
BeRoFactoryInterface::BeRoFactoryInterface()
{
}
BeRoFactoryInterface::~BeRoFactoryInterface() BeRoFactoryInterface::~BeRoFactoryInterface()
{ {
} }
+6 -2
View File
@@ -15,11 +15,15 @@
/** /**
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
*/ */
#include <berointerface.h>
class BeRoFactoryInterface{ class BeRoFactoryInterface{
public: public:
BeRoFactoryInterface();
~BeRoFactoryInterface(); virtual ~BeRoFactoryInterface();
virtual BeRoInterface* switchRounds() = 0;
}; };
-4
View File
@@ -11,10 +11,6 @@
// //
#include "berointerface.h" #include "berointerface.h"
BeRoInterface::BeRoInterface()
{
}
BeRoInterface::~BeRoInterface() BeRoInterface::~BeRoInterface()
{ {
+13 -2
View File
@@ -17,9 +17,20 @@
*/ */
class BeRoInterface{ class BeRoInterface{
public: public:
BeRoInterface();
~BeRoInterface(); virtual ~BeRoInterface();
virtual void setPlayersTurn(int) =0;
virtual int getPlayersTurn() const =0;
virtual void setHighestSet(int) =0;
virtual int getHighestSet() const =0;
virtual void setPreflopFirstRound(bool) =0;
virtual bool setPreflopFirstRound() const =0;
virtual void preflopRun() =0;
virtual void nextPlayer2() =0;
}; };
+8 -2
View File
@@ -45,8 +45,14 @@ public:
virtual FlopInterface* createFlop(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 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 RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB) =0;
virtual BeRoInterface* createBeRo() =0; // virtual BeRoInterface* createBeRo() =0;
virtual BeRoFactoryInterface* createBeRoFactory() =0; virtual BeRoFactoryInterface* createBeRoFactory(HandInterface* hi) =0;
}; };
#endif #endif
// The following code introduces the new BeRo interface step by step. This hint will be removed if refactorying was succesfull //
// new BeRo Interface code stop here //
+2 -1
View File
@@ -27,6 +27,7 @@
#include "flopinterface.h" #include "flopinterface.h"
#include "turninterface.h" #include "turninterface.h"
#include "riverinterface.h" #include "riverinterface.h"
#include "berointerface.h"
class HandInterface{ class HandInterface{
public: public:
@@ -37,7 +38,7 @@ public:
virtual PlayerInterface** getPlayerArray() const =0; virtual PlayerInterface** getPlayerArray() const =0;
virtual BoardInterface* getBoard() const =0; virtual BoardInterface* getBoard() const =0;
virtual PreflopInterface* getPreflop() const =0; virtual BeRoInterface* getPreflop() const =0;
virtual FlopInterface* getFlop() const =0; virtual FlopInterface* getFlop() const =0;
virtual TurnInterface* getTurn() const =0; virtual TurnInterface* getTurn() const =0;
virtual RiverInterface* getRiver() const =0; virtual RiverInterface* getRiver() const =0;
+14 -5
View File
@@ -1,7 +1,7 @@
// //
// C++ Implementation: localberofactory // C++ Implementation: localberofactory
// //
// Description: // Description:
// //
// //
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007 // Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
@@ -11,14 +11,23 @@
// //
#include "localberofactory.h" #include "localberofactory.h"
LocalBeRoFactory::LocalBeRoFactory() LocalBeRoFactory::LocalBeRoFactory ( HandInterface* hi )
: BeRoFactoryInterface() : BeRoFactoryInterface() , myHand ( hi )
{ {}
}
LocalBeRoFactory::~LocalBeRoFactory() LocalBeRoFactory::~LocalBeRoFactory()
{}
BeRoInterface* LocalBeRoFactory::switchRounds()
{ {
BeRoInterface* myBeRo = 0;
myBeRo = new LocalBeRoPreflop ( myHand, 0, 7, 0, 10 );
return myBeRo;
} }
+10 -1
View File
@@ -13,6 +13,9 @@
#define LOCALBEROFACTORY_H #define LOCALBEROFACTORY_H
#include <berofactoryinterface.h> #include <berofactoryinterface.h>
#include <berointerface.h>
#include <handinterface.h>
#include <localberopreflop.h>
/** /**
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
@@ -20,10 +23,16 @@
class LocalBeRoFactory : public BeRoFactoryInterface class LocalBeRoFactory : public BeRoFactoryInterface
{ {
public: public:
LocalBeRoFactory(); LocalBeRoFactory(HandInterface* hi);
~LocalBeRoFactory(); ~LocalBeRoFactory();
BeRoInterface* switchRounds();
private:
HandInterface* myHand;
}; };
#endif #endif
@@ -57,7 +57,7 @@ TurnInterface* LocalEngineFactory::createTurn(HandInterface* hi, int id, int aP,
RiverInterface* LocalEngineFactory::createRiver(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalRiver(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); }
BeRoInterface* LocalEngineFactory::createBeRo() { return new LocalBeRo(); } // BeRoInterface* LocalEngineFactory::createBeRo() { return new LocalBeRo(); }
BeRoFactoryInterface* LocalEngineFactory::createBeRoFactory() { return new LocalBeRoFactory(); } BeRoFactoryInterface* LocalEngineFactory::createBeRoFactory(HandInterface* hi) { return new LocalBeRoFactory(hi); }
+3 -3
View File
@@ -29,7 +29,7 @@
#include <flopinterface.h> #include <flopinterface.h>
#include <turninterface.h> #include <turninterface.h>
#include <riverinterface.h> #include <riverinterface.h>
#include <berointerface.h> // #include <berointerface.h>
#include <berofactoryinterface.h> #include <berofactoryinterface.h>
class ConfigFile; class ConfigFile;
@@ -47,8 +47,8 @@ public:
FlopInterface* createFlop(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); TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB);
RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB); RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB);
BeRoInterface* createBeRo(); // BeRoInterface* createBeRo();
BeRoFactoryInterface* createBeRoFactory(); BeRoFactoryInterface* createBeRoFactory(HandInterface* hi);
private: private:
ConfigFile *myConfig; ConfigFile *myConfig;
+3 -2
View File
@@ -172,7 +172,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
myTurn = myFactory->createTurn(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); myTurn = myFactory->createTurn(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
myRiver = myFactory->createRiver(this, myID, actualQuantityPlayers, dealerPosition, smallBlind); myRiver = myFactory->createRiver(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
myBeRo = myFactory->createBeRo(); myBeRoFactory = myFactory->createBeRoFactory(this);
myBeRo = myBeRoFactory->switchRounds();
} }
@@ -324,7 +325,7 @@ void LocalHand::switchRounds() {
if(playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyAction() != 6 && playerArray[i]->getMyActiveStatus() == 1) { if(playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyAction() != 6 && playerArray[i]->getMyActiveStatus() == 1) {
tempHighestSet = 0; tempHighestSet = 0;
switch (actualRound) { switch (actualRound) {
case 0: {tempHighestSet = myPreflop->getHighestSet();} case 0: {tempHighestSet = myBeRo->getHighestSet();}
break; break;
case 1: {tempHighestSet = myFlop->getHighestSet();} case 1: {tempHighestSet = myFlop->getHighestSet();}
break; break;
+3 -1
View File
@@ -30,6 +30,7 @@
#include <turninterface.h> #include <turninterface.h>
#include <riverinterface.h> #include <riverinterface.h>
#include <berointerface.h> #include <berointerface.h>
#include <berofactoryinterface.h>
class LocalHand : public HandInterface{ class LocalHand : public HandInterface{
@@ -41,7 +42,7 @@ public:
PlayerInterface** getPlayerArray() const { return playerArray; } PlayerInterface** getPlayerArray() const { return playerArray; }
BoardInterface* getBoard() const { return myBoard; } BoardInterface* getBoard() const { return myBoard; }
PreflopInterface* getPreflop() const { return myPreflop; } BeRoInterface* getPreflop() const { return myBeRo; }
FlopInterface* getFlop() const { return myFlop; } FlopInterface* getFlop() const { return myFlop; }
TurnInterface* getTurn() const { return myTurn; } TurnInterface* getTurn() const { return myTurn; }
RiverInterface* getRiver() const { return myRiver; } RiverInterface* getRiver() const { return myRiver; }
@@ -99,6 +100,7 @@ private:
TurnInterface *myTurn; TurnInterface *myTurn;
RiverInterface *myRiver; RiverInterface *myRiver;
BeRoInterface *myBeRo; BeRoInterface *myBeRo;
BeRoFactoryInterface *myBeRoFactory;
int myID; int myID;
int actualQuantityPlayers; int actualQuantityPlayers;
@@ -11,7 +11,7 @@
// //
#include "clientberofactory.h" #include "clientberofactory.h"
ClientBeRoFactory::ClientBeRoFactory() ClientBeRoFactory::ClientBeRoFactory(HandInterface* hi)
: BeRoFactoryInterface() : BeRoFactoryInterface()
{ {
} }
@@ -22,3 +22,4 @@ ClientBeRoFactory::~ClientBeRoFactory()
} }
BeRoInterface* ClientBeRoFactory::switchRounds() {}
@@ -13,6 +13,7 @@
#define CLIENTBEROFACTORY_H #define CLIENTBEROFACTORY_H
#include <berofactoryinterface.h> #include <berofactoryinterface.h>
#include <handinterface.h>
/** /**
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
@@ -20,10 +21,12 @@
class ClientBeRoFactory : public BeRoFactoryInterface class ClientBeRoFactory : public BeRoFactoryInterface
{ {
public: public:
ClientBeRoFactory(); ClientBeRoFactory(HandInterface* hi);
~ClientBeRoFactory(); ~ClientBeRoFactory();
BeRoInterface* switchRounds();
}; };
#endif #endif
@@ -75,12 +75,12 @@ RiverInterface* ClientEngineFactory::createRiver(HandInterface* hi, int id, int
return new ClientRiver(hi, id, aP, dP, sB); return new ClientRiver(hi, id, aP, dP, sB);
} }
BeRoInterface* ClientEngineFactory::createBeRo() // BeRoInterface* ClientEngineFactory::createBeRo()
{ // {
return new ClientBeRo(); // return new ClientBeRo();
} // }
BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory() BeRoFactoryInterface* ClientEngineFactory::createBeRoFactory(HandInterface* hi)
{ {
return new ClientBeRoFactory(); return new ClientBeRoFactory(hi);
} }
@@ -28,7 +28,7 @@
#include <flopinterface.h> #include <flopinterface.h>
#include <turninterface.h> #include <turninterface.h>
#include <riverinterface.h> #include <riverinterface.h>
#include <berointerface.h> // #include <berointerface.h>
#include <berofactoryinterface.h> #include <berofactoryinterface.h>
@@ -47,8 +47,8 @@ public:
FlopInterface* createFlop(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); TurnInterface* createTurn(HandInterface* hi, int id, int aP, int dP, int sB);
RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB); RiverInterface* createRiver(HandInterface* hi, int id, int aP, int dP, int sB);
BeRoInterface* createBeRo(); // BeRoInterface* createBeRo();
BeRoFactoryInterface* createBeRoFactory(); BeRoFactoryInterface* createBeRoFactory(HandInterface* hi);
}; };
+2 -2
View File
@@ -84,10 +84,10 @@ ClientHand::getBoard() const
return myBoard; return myBoard;
} }
PreflopInterface* BeRoInterface*
ClientHand::getPreflop() const ClientHand::getPreflop() const
{ {
return myPreflop; return myBeRo;
} }
FlopInterface* FlopInterface*
+3 -1
View File
@@ -28,6 +28,7 @@
#include <flopinterface.h> #include <flopinterface.h>
#include <turninterface.h> #include <turninterface.h>
#include <riverinterface.h> #include <riverinterface.h>
#include <berointerface.h>
#include <boost/thread.hpp> #include <boost/thread.hpp>
@@ -41,7 +42,7 @@ public:
PlayerInterface** getPlayerArray() const; PlayerInterface** getPlayerArray() const;
BoardInterface* getBoard() const; BoardInterface* getBoard() const;
PreflopInterface* getPreflop() const; BeRoInterface* getPreflop() const;
FlopInterface* getFlop() const; FlopInterface* getFlop() const;
TurnInterface* getTurn() const; TurnInterface* getTurn() const;
RiverInterface* getRiver() const; RiverInterface* getRiver() const;
@@ -97,6 +98,7 @@ private:
FlopInterface *myFlop; FlopInterface *myFlop;
TurnInterface *myTurn; TurnInterface *myTurn;
RiverInterface *myRiver; RiverInterface *myRiver;
BeRoInterface *myBeRo;
int myID; int myID;
int actualQuantityPlayers; int actualQuantityPlayers;