one ConfigFile for all

This commit is contained in:
doitux
2007-05-13 18:17:25 +00:00
parent 60eb04a920
commit e2d394f576
7 changed files with 29 additions and 26 deletions
@@ -20,8 +20,8 @@
#include "localenginefactory.h"
LocalEngineFactory::LocalEngineFactory()
: EngineFactory()
LocalEngineFactory::LocalEngineFactory(ConfigFile *c)
: EngineFactory(), myConfig(c)
{
}
@@ -35,7 +35,7 @@ HandInterface* LocalEngineFactory::createHand(EngineFactory *f, GuiInterface *g,
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(b, id, uniqueId, type, name, avatar, sC, aS, mB); }
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); }
+6 -1
View File
@@ -30,10 +30,12 @@
#include "localturn.h"
#include "localriver.h"
#include "configfile.h"
class LocalEngineFactory : public EngineFactory
{
public:
LocalEngineFactory();
LocalEngineFactory(ConfigFile*);
~LocalEngineFactory();
@@ -44,6 +46,9 @@ public:
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
+9 -15
View File
@@ -23,8 +23,8 @@
using namespace std;
LocalPlayer::LocalPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
: PlayerInterface(), 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)
LocalPlayer::LocalPlayer(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)
{
// for statistic development
@@ -84,12 +84,10 @@ void LocalPlayer::setHand(HandInterface* br) { actualHand = br; }
void LocalPlayer::action() {
ConfigFile myConfig;
switch(actualHand->getActualRound()) {
case 0: {
if(myConfig.readConfigInt("EngineVersion")) preflopEngine3();
if(myConfig->readConfigInt("EngineVersion")) preflopEngine3();
else preflopEngine();
actualBoard->collectSets();
@@ -98,7 +96,7 @@ void LocalPlayer::action() {
} break;
case 1: {
if(myConfig.readConfigInt("EngineVersion")) flopEngine3();
if(myConfig->readConfigInt("EngineVersion")) flopEngine3();
else flopEngine();
actualBoard->collectSets();
@@ -107,7 +105,7 @@ void LocalPlayer::action() {
} break;
case 2: {
if(myConfig.readConfigInt("EngineVersion")) turnEngine3();
if(myConfig->readConfigInt("EngineVersion")) turnEngine3();
else turnEngine();
actualBoard->collectSets();
@@ -116,7 +114,7 @@ void LocalPlayer::action() {
} break;
case 3: {
if(myConfig.readConfigInt("EngineVersion")) riverEngine3();
if(myConfig->readConfigInt("EngineVersion")) riverEngine3();
else riverEngine();
actualBoard->collectSets();
@@ -810,7 +808,6 @@ void LocalPlayer::flopEngine() {
void LocalPlayer::turnEngine() {
ConfigFile myConfig;
// int tempArray[6];
// int boardCards[5];
@@ -1057,9 +1054,7 @@ void LocalPlayer::turnEngine() {
void LocalPlayer::riverEngine() {
ConfigFile myConfig;
// int tempArray[6];
// int tempArray[6];
// int boardCards[5];
// int i;
@@ -2058,7 +2053,6 @@ int LocalPlayer::flopCardsValue(int* cards) {
void LocalPlayer::readFile() {
ConfigFile myConfig;
int handCode;
switch(actualHand->getActualRound()) {
@@ -2067,7 +2061,7 @@ void LocalPlayer::readFile() {
handCode = preflopCardsValue(myCards);
std::string fileName = myConfig.readConfigString("DataDir")+"preflopValues";
std::string fileName = myConfig->readConfigString("DataDir")+"preflopValues";
ifstream fin;
@@ -2121,7 +2115,7 @@ void LocalPlayer::readFile() {
// cout << "\t" << handCode << endl;
std::string fileName = myConfig.readConfigString("DataDir")+"flopValues";
std::string fileName = myConfig->readConfigString("DataDir")+"flopValues";
ifstream fin;
+3 -2
View File
@@ -36,8 +36,7 @@ class BoardInterface;
class LocalPlayer : public PlayerInterface{
public:
LocalPlayer(
BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
LocalPlayer(ConfigFile*, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
~LocalPlayer();
@@ -142,6 +141,8 @@ public:
private:
ConfigFile *myConfig;
HandInterface *actualHand;
BoardInterface *actualBoard;