std::vector<boost::shared_ptr<BeRoInterface> > implemented

This commit is contained in:
doitux
2007-08-06 20:35:26 +00:00
parent 562e8760f5
commit 96419b3588
22 changed files with 172 additions and 139 deletions
+6
View File
@@ -16,6 +16,10 @@
@author FThauer FHammer <webmaster@pokerth.net>
*/
#include <vector>
#include <boost/shared_ptr.hpp>
#include <berointerface.h>
class BeRoFactoryInterface{
@@ -27,6 +31,8 @@ public:
virtual BeRoInterface* createBeRoPreflop() =0;
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo() =0;
};
#endif
+2
View File
@@ -32,6 +32,8 @@ public:
virtual void resetFirstRun() =0;
virtual int getHighestCardsValue() const =0;
virtual void run() =0;
virtual void preflopRun() =0;
virtual void flopRun() =0;
virtual void turnRun() =0;
+9 -5
View File
@@ -20,6 +20,10 @@
#ifndef HANDINTERFACE_H
#define HANDINTERFACE_H
#include <vector>
#include <boost/shared_ptr.hpp>
#include "guiinterface.h"
#include "boardinterface.h"
#include "playerinterface.h"
@@ -38,12 +42,12 @@ public:
virtual PlayerInterface** getPlayerArray() const =0;
virtual BoardInterface* getBoard() const =0;
virtual BeRoInterface* getPreflop() const =0;
virtual BeRoInterface* getFlop() const =0;
virtual BeRoInterface* getTurn() const =0;
virtual BeRoInterface* getRiver() const =0;
virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0;
virtual boost::shared_ptr<BeRoInterface> getFlop() const =0;
virtual boost::shared_ptr<BeRoInterface> getTurn() const =0;
virtual boost::shared_ptr<BeRoInterface> getRiver() const =0;
virtual GuiInterface* getGuiInterface() const =0;
virtual BeRoInterface* getCurrentBeRo() const =0;
virtual boost::shared_ptr<BeRoInterface> getCurrentBeRo() const =0;
virtual void setMyID(int theValue) =0;
virtual int getMyID() const =0;
+2 -1
View File
@@ -28,7 +28,8 @@ public:
int getHighestCardsValue() const {}
void setHighestCardsValue(int theValue) {}
//only until bero refactory is over
void run() {}
//only until bero refactoring is over
void preflopRun() {}
void flopRun() {}
void riverRun() {}
@@ -21,6 +21,24 @@ LocalBeRoFactory::LocalBeRoFactory (HandInterface* hi, int id, int aP, int dP, i
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 );
@@ -14,6 +14,10 @@
#include <istream>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <berofactoryinterface.h>
#include <berointerface.h>
#include <handinterface.h>
@@ -37,6 +41,9 @@ public:
BeRoInterface* createBeRoPreflop();
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo();
private:
HandInterface* myHand;
+1 -1
View File
@@ -45,7 +45,7 @@ LocalBeRoFlop::~LocalBeRoFlop()
{
}
void LocalBeRoFlop::flopRun() {
void LocalBeRoFlop::run() {
cout << "LocalBeroFlopRun!!!" << endl;
+2 -1
View File
@@ -49,7 +49,8 @@ public:
void resetFirstRun() { firstFlopRun = false; }
void flopRun();
void run();
void nextPlayer2();
private:
+1 -1
View File
@@ -50,7 +50,7 @@ LocalBeRoPreflop::~LocalBeRoPreflop()
}
void LocalBeRoPreflop::preflopRun() {
void LocalBeRoPreflop::run() {
cout << "LocalBeroPreflopRun!!!" << endl;
+1 -1
View File
@@ -37,7 +37,7 @@ public:
void setHighestSet(int theValue) { highestSet = theValue; }
int getHighestSet() const { return highestSet;}
void preflopRun();
void run();
void nextPlayer2();
+1 -1
View File
@@ -45,7 +45,7 @@ LocalBeRoRiver::~LocalBeRoRiver()
}
void LocalBeRoRiver::riverRun() {
void LocalBeRoRiver::run() {
cout << "LocalBeroRiverRun!!!" << endl;
int i;
+1 -1
View File
@@ -51,7 +51,7 @@ public:
void resetFirstRun() { firstRiverRun = false; }
void riverRun();
void run();
void postRiverRun();
void nextPlayer2();
void distributePot();
+1 -1
View File
@@ -46,7 +46,7 @@ LocalBeRoTurn::~LocalBeRoTurn()
}
void LocalBeRoTurn::turnRun() {
void LocalBeRoTurn::run() {
cout << "LocalBeroTurnRun!!!" << endl;
int i;
+1 -1
View File
@@ -48,7 +48,7 @@ public:
void resetFirstRun() { firstTurnRun = false; }
void nextPlayer2();
void turnRun();
void run();
private:
+4 -33
View File
@@ -27,12 +27,11 @@
using namespace std;
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> 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), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0),
: myFactory(f), myBeRo(0), myGui(g), myBoard(b), playerArray(p), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0)
{
int i, j, k;
CardsValue myCardsValue;
@@ -166,33 +165,17 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
// Dealer, SB, BB bestimmen
assignButtons();
// Preflop, Flop, Turn und River erstellen
// myPreflop = myFactory->createPreflop(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
// myFlop = myFactory->createFlop(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
// myTurn = myFactory->createTurn(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
// myRiver = myFactory->createRiver(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
myBeRoFactory = myFactory->createBeRoFactory(this, myID, actualQuantityPlayers, dealerPosition, smallBlind);
int currentRound = actualRound; // for Lothar ;-)
myBeRo = myBeRoFactory->createBeRoPreflop();
myBeRo = myBeRoFactory->createBeRo();
}
LocalHand::~LocalHand()
{
delete myPreflop;
myPreflop = 0;
delete myFlop;
myFlop = 0;
delete myTurn;
myTurn = 0;
delete myRiver;
myRiver = 0;
}
void LocalHand::start() {
@@ -327,17 +310,7 @@ void LocalHand::switchRounds() {
// Spieler ermitteln, der noch nicht All In ist
if(playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyAction() != 6 && playerArray[i]->getMyActiveStatus() == 1) {
tempHighestSet = 0;
switch (actualRound) {
case 0: {tempHighestSet = myBeRo->getHighestSet();}
break;
case 1: {tempHighestSet = myBeRo->getHighestSet();}
break;
case 2: {tempHighestSet = myBeRo->getHighestSet();}
break;
case 3: {tempHighestSet = myBeRo->getHighestSet();}
break;
default: {}
}
tempHighestSet = myBeRo[actualRound]->getHighestSet();
// cout << "tempHighestSet: " << tempHighestSet << "playerArray[i]->getMySet(): " << playerArray[i]->getMySet() << endl;
if(playerArray[i]->getMySet() >= tempHighestSet) {
@@ -383,8 +356,6 @@ void LocalHand::switchRounds() {
//
int currentRound = actualRound;
myBeRo = myBeRoFactory->switchRounds(myBeRo, currentRound);
// cout << "NextPlayerSpeed2 start" << endl;
switch(actualRound) {
+10 -14
View File
@@ -20,15 +20,15 @@
#ifndef LOCALHAND_H
#define LOCALHAND_H
#include <vector>
#include <boost/shared_ptr.hpp>
#include <enginefactory.h>
#include <guiinterface.h>
#include <boardinterface.h>
#include <playerinterface.h>
#include <handinterface.h>
#include <preflopinterface.h>
#include <flopinterface.h>
#include <turninterface.h>
#include <riverinterface.h>
#include <berointerface.h>
#include <berofactoryinterface.h>
@@ -42,12 +42,12 @@ public:
PlayerInterface** getPlayerArray() const { return playerArray; }
BoardInterface* getBoard() const { return myBoard; }
BeRoInterface* getPreflop() const { return myBeRo; }
BeRoInterface* getFlop() const { return myBeRo; }
BeRoInterface* getTurn() const { return myBeRo; }
BeRoInterface* getRiver() const { return myBeRo; }
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[actualRound]; }
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[actualRound]; }
boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[actualRound]; }
boost::shared_ptr<BeRoInterface> getRiver() const { return myBeRo[actualRound]; }
GuiInterface* getGuiInterface() const { return myGui; }
BeRoInterface* getCurrentBeRo() const { return myBeRo; }
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const { return myBeRo[actualRound]; }
void setMyID(int theValue) { myID = theValue; }
int getMyID() const { return myID; }
@@ -96,12 +96,8 @@ private:
GuiInterface *myGui;
BoardInterface *myBoard;
PlayerInterface **playerArray;
PreflopInterface *myPreflop;
FlopInterface *myFlop;
TurnInterface *myTurn;
RiverInterface *myRiver;
BeRoInterface *myBeRo;
BeRoFactoryInterface *myBeRoFactory;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
int myID;
int actualQuantityPlayers;
+6
View File
@@ -12,6 +12,10 @@
#ifndef CLIENTBERO_H
#define CLIENTBERO_H
#include <vector>
#include <boost/shared_ptr.hpp>
#include "berointerface.h"
@@ -26,6 +30,8 @@ public:
int getMyBeRoID() const { return myBeRoID; }
void run() {}
protected:
int myBeRoID;
@@ -22,6 +22,19 @@ ClientBeRoFactory::~ClientBeRoFactory()
{
}
std::vector<boost::shared_ptr<BeRoInterface> > ClientBeRoFactory::createBeRo()
{
std::vector<boost::shared_ptr<BeRoInterface> > bettingRounds;
//         bettingRounds.push_back(boost::shared_ptr<BeRoInterface>(new
// LocalBeRoPreflop(...)));
//         bettingRounds.push_back(boost::shared_ptr<BeRoInterface>(new
// LocalBeRoFlop(...)));
//
//         ...
return bettingRounds;
}
BeRoInterface* ClientBeRoFactory::switchRounds(BeRoInterface* currentBeRo, int currentRound) { return NULL;}
@@ -12,6 +12,10 @@
#ifndef CLIENTBEROFACTORY_H
#define CLIENTBEROFACTORY_H
#include <vector>
#include <boost/shared_ptr.hpp>
#include <berofactoryinterface.h>
#include <handinterface.h>
@@ -29,6 +33,8 @@ public:
BeRoInterface* createBeRoPreflop();
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo();
};
#endif
+10 -10
View File
@@ -84,34 +84,34 @@ ClientHand::getBoard() const
return myBoard;
}
BeRoInterface*
boost::shared_ptr<BeRoInterface>
ClientHand::getPreflop() const
{
return myBeRo;
return myBeRo[actualRound];
}
BeRoInterface*
boost::shared_ptr<BeRoInterface>
ClientHand::getFlop() const
{
return myBeRo;
return myBeRo[actualRound];
}
BeRoInterface*
boost::shared_ptr<BeRoInterface>
ClientHand::getTurn() const
{
return myBeRo;
return myBeRo[actualRound];
}
BeRoInterface*
boost::shared_ptr<BeRoInterface>
ClientHand::getRiver() const
{
return myBeRo;
return myBeRo[actualRound];
}
BeRoInterface*
boost::shared_ptr<BeRoInterface>
ClientHand::getCurrentBeRo() const
{
return myBeRo;
return myBeRo[actualRound];
}
+66 -63
View File
@@ -32,91 +32,94 @@
#include <boost/thread.hpp>
#include <vector>
class ClientHand : public HandInterface
{
public:
ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int);
~ClientHand();
public:
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int );
~ClientHand();
void start();
void start();
PlayerInterface** getPlayerArray() const;
BoardInterface* getBoard() const;
BeRoInterface* getPreflop() const;
BeRoInterface* getFlop() const;
BeRoInterface* getTurn() const;
BeRoInterface* getRiver() const;
GuiInterface* getGuiInterface() const;
BeRoInterface* getCurrentBeRo() const;
PlayerInterface** getPlayerArray() const;
BoardInterface* getBoard() const;
boost::shared_ptr<BeRoInterface> getPreflop() const;
boost::shared_ptr<BeRoInterface> getFlop() const;
boost::shared_ptr<BeRoInterface> getTurn() const;
boost::shared_ptr<BeRoInterface> getRiver() const;
GuiInterface* getGuiInterface() const;
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
void setMyID(int theValue);
int getMyID() const;
void setActualQuantityPlayers(int theValue);
int getActualQuantityPlayers() const;
void setMyID ( int theValue );
int getMyID() const;
void setStartQuantityPlayers(int theValue);
int getStartQuantityPlayers() const;
void setActualQuantityPlayers ( int theValue );
int getActualQuantityPlayers() const;
void setActualRound(int theValue);
int getActualRound() const;
void setStartQuantityPlayers ( int theValue );
int getStartQuantityPlayers() const;
void setDealerPosition(int theValue);
int getDealerPosition() const;
void setActualRound ( int theValue );
int getActualRound() const;
void setSmallBlind(int theValue);
int getSmallBlind() const;
void setDealerPosition ( int theValue );
int getDealerPosition() const;
void setAllInCondition(bool theValue);
bool getAllInCondition() const;
void setSmallBlind ( int theValue );
int getSmallBlind() const;
void setStartCash(int theValue);
int getStartCash() const;
void setAllInCondition ( bool theValue );
bool getAllInCondition() const;
void setActivePlayersCounter(int theValue);
int getActivePlayersCounter() const;
void setBettingRoundsPlayed(int theValue);
int getBettingRoundsPlayed() const;
void setStartCash ( int theValue );
int getStartCash() const;
void setLastPlayersTurn(int theValue);
int getLastPlayersTurn() const;
void setActivePlayersCounter ( int theValue );
int getActivePlayersCounter() const;
void setCardsShown(bool theValue);
bool getCardsShown() const;
void setBettingRoundsPlayed ( int theValue );
int getBettingRoundsPlayed() const;
void switchRounds();
void setLastPlayersTurn ( int theValue );
int getLastPlayersTurn() const;
void setCardsShown ( bool theValue );
bool getCardsShown() const;
void switchRounds();
private:
mutable boost::recursive_mutex m_syncMutex;
private:
mutable boost::recursive_mutex m_syncMutex;
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
BoardInterface *myBoard;
PlayerInterface **playerArray;
PreflopInterface *myPreflop;
FlopInterface *myFlop;
TurnInterface *myTurn;
RiverInterface *myRiver;
BeRoInterface *myBeRo;
boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui;
BoardInterface *myBoard;
PlayerInterface **playerArray;
PreflopInterface *myPreflop;
FlopInterface *myFlop;
TurnInterface *myTurn;
RiverInterface *myRiver;
BeRoInterface *myOldBeRo;
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
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 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;
int lastPlayersTurn;
bool allInCondition;
bool cardsShown;
bool allInCondition;
bool cardsShown;
// hier steht bis zu welcher bettingRound der human player gespielt hat: 0 - nur Preflop, 1 - bis Flop, ...
int bettingRoundsPlayed;
// hier steht bis zu welcher bettingRound der human player gespielt hat: 0 - nur Preflop, 1 - bis Flop, ...
int bettingRoundsPlayed;
};
#endif