one ConfigFile for all
This commit is contained in:
@@ -20,8 +20,8 @@
|
|||||||
#include "localenginefactory.h"
|
#include "localenginefactory.h"
|
||||||
|
|
||||||
|
|
||||||
LocalEngineFactory::LocalEngineFactory()
|
LocalEngineFactory::LocalEngineFactory(ConfigFile *c)
|
||||||
: EngineFactory()
|
: EngineFactory(), myConfig(c)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ HandInterface* LocalEngineFactory::createHand(EngineFactory *f, GuiInterface *g,
|
|||||||
|
|
||||||
BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; }
|
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); }
|
PreflopInterface* LocalEngineFactory::createPreflop(HandInterface* hi, int id, int aP, int dP, int sB) { return new LocalPreflop(hi, id, aP, dP, sB); }
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,12 @@
|
|||||||
#include "localturn.h"
|
#include "localturn.h"
|
||||||
#include "localriver.h"
|
#include "localriver.h"
|
||||||
|
|
||||||
|
#include "configfile.h"
|
||||||
|
|
||||||
class LocalEngineFactory : public EngineFactory
|
class LocalEngineFactory : public EngineFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocalEngineFactory();
|
LocalEngineFactory(ConfigFile*);
|
||||||
|
|
||||||
~LocalEngineFactory();
|
~LocalEngineFactory();
|
||||||
|
|
||||||
@@ -44,6 +46,9 @@ 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);
|
||||||
|
private:
|
||||||
|
|
||||||
|
ConfigFile *myConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
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)
|
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(), 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)
|
: 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
|
// for statistic development
|
||||||
@@ -84,12 +84,10 @@ void LocalPlayer::setHand(HandInterface* br) { actualHand = br; }
|
|||||||
|
|
||||||
void LocalPlayer::action() {
|
void LocalPlayer::action() {
|
||||||
|
|
||||||
ConfigFile myConfig;
|
|
||||||
|
|
||||||
switch(actualHand->getActualRound()) {
|
switch(actualHand->getActualRound()) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
||||||
if(myConfig.readConfigInt("EngineVersion")) preflopEngine3();
|
if(myConfig->readConfigInt("EngineVersion")) preflopEngine3();
|
||||||
else preflopEngine();
|
else preflopEngine();
|
||||||
|
|
||||||
actualBoard->collectSets();
|
actualBoard->collectSets();
|
||||||
@@ -98,7 +96,7 @@ void LocalPlayer::action() {
|
|||||||
} break;
|
} break;
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
||||||
if(myConfig.readConfigInt("EngineVersion")) flopEngine3();
|
if(myConfig->readConfigInt("EngineVersion")) flopEngine3();
|
||||||
else flopEngine();
|
else flopEngine();
|
||||||
|
|
||||||
actualBoard->collectSets();
|
actualBoard->collectSets();
|
||||||
@@ -107,7 +105,7 @@ void LocalPlayer::action() {
|
|||||||
} break;
|
} break;
|
||||||
case 2: {
|
case 2: {
|
||||||
|
|
||||||
if(myConfig.readConfigInt("EngineVersion")) turnEngine3();
|
if(myConfig->readConfigInt("EngineVersion")) turnEngine3();
|
||||||
else turnEngine();
|
else turnEngine();
|
||||||
|
|
||||||
actualBoard->collectSets();
|
actualBoard->collectSets();
|
||||||
@@ -116,7 +114,7 @@ void LocalPlayer::action() {
|
|||||||
} break;
|
} break;
|
||||||
case 3: {
|
case 3: {
|
||||||
|
|
||||||
if(myConfig.readConfigInt("EngineVersion")) riverEngine3();
|
if(myConfig->readConfigInt("EngineVersion")) riverEngine3();
|
||||||
else riverEngine();
|
else riverEngine();
|
||||||
|
|
||||||
actualBoard->collectSets();
|
actualBoard->collectSets();
|
||||||
@@ -810,7 +808,6 @@ void LocalPlayer::flopEngine() {
|
|||||||
|
|
||||||
void LocalPlayer::turnEngine() {
|
void LocalPlayer::turnEngine() {
|
||||||
|
|
||||||
ConfigFile myConfig;
|
|
||||||
|
|
||||||
// int tempArray[6];
|
// int tempArray[6];
|
||||||
// int boardCards[5];
|
// int boardCards[5];
|
||||||
@@ -1057,8 +1054,6 @@ void LocalPlayer::turnEngine() {
|
|||||||
|
|
||||||
void LocalPlayer::riverEngine() {
|
void LocalPlayer::riverEngine() {
|
||||||
|
|
||||||
ConfigFile myConfig;
|
|
||||||
|
|
||||||
// int tempArray[6];
|
// int tempArray[6];
|
||||||
// int boardCards[5];
|
// int boardCards[5];
|
||||||
// int i;
|
// int i;
|
||||||
@@ -2058,7 +2053,6 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
|||||||
|
|
||||||
void LocalPlayer::readFile() {
|
void LocalPlayer::readFile() {
|
||||||
|
|
||||||
ConfigFile myConfig;
|
|
||||||
int handCode;
|
int handCode;
|
||||||
|
|
||||||
switch(actualHand->getActualRound()) {
|
switch(actualHand->getActualRound()) {
|
||||||
@@ -2067,7 +2061,7 @@ void LocalPlayer::readFile() {
|
|||||||
|
|
||||||
handCode = preflopCardsValue(myCards);
|
handCode = preflopCardsValue(myCards);
|
||||||
|
|
||||||
std::string fileName = myConfig.readConfigString("DataDir")+"preflopValues";
|
std::string fileName = myConfig->readConfigString("DataDir")+"preflopValues";
|
||||||
|
|
||||||
ifstream fin;
|
ifstream fin;
|
||||||
|
|
||||||
@@ -2121,7 +2115,7 @@ void LocalPlayer::readFile() {
|
|||||||
|
|
||||||
// cout << "\t" << handCode << endl;
|
// cout << "\t" << handCode << endl;
|
||||||
|
|
||||||
std::string fileName = myConfig.readConfigString("DataDir")+"flopValues";
|
std::string fileName = myConfig->readConfigString("DataDir")+"flopValues";
|
||||||
|
|
||||||
ifstream fin;
|
ifstream fin;
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ class BoardInterface;
|
|||||||
|
|
||||||
class LocalPlayer : public PlayerInterface{
|
class LocalPlayer : public PlayerInterface{
|
||||||
public:
|
public:
|
||||||
LocalPlayer(
|
LocalPlayer(ConfigFile*, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
|
||||||
BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
|
|
||||||
|
|
||||||
~LocalPlayer();
|
~LocalPlayer();
|
||||||
|
|
||||||
@@ -142,6 +141,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
ConfigFile *myConfig;
|
||||||
HandInterface *actualHand;
|
HandInterface *actualHand;
|
||||||
BoardInterface *actualBoard;
|
BoardInterface *actualBoard;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -30,12 +30,12 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId)
|
Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId, ConfigFile *c)
|
||||||
: myGui(gui), actualHand(0), actualBoard(0), startQuantityPlayers(gameData.numberOfPlayers),
|
: myGui(gui), actualHand(0), actualBoard(0), startQuantityPlayers(gameData.numberOfPlayers),
|
||||||
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
||||||
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
||||||
myGameID(gameId), actualQuantityPlayers(gameData.numberOfPlayers),
|
myGameID(gameId), actualQuantityPlayers(gameData.numberOfPlayers),
|
||||||
actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0)
|
actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0), myConfig(c)
|
||||||
{
|
{
|
||||||
// cout << "Create Game Object" << "\n";
|
// cout << "Create Game Object" << "\n";
|
||||||
int i;
|
int i;
|
||||||
@@ -47,7 +47,7 @@ Game::Game(GuiInterface* gui, const PlayerDataList &playerDataList, const GameDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
//EngineFactory erstellen
|
//EngineFactory erstellen
|
||||||
myFactory = new LocalEngineFactory; // LocalEngine erstellen
|
myFactory = new LocalEngineFactory(myConfig); // LocalEngine erstellen
|
||||||
|
|
||||||
|
|
||||||
// Board erstellen
|
// Board erstellen
|
||||||
|
|||||||
+4
-1
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "game_defs.h"
|
#include "game_defs.h"
|
||||||
#include "playerdata.h"
|
#include "playerdata.h"
|
||||||
|
#include "configfile.h"
|
||||||
|
|
||||||
class GuiInterface;
|
class GuiInterface;
|
||||||
class HandInterface;
|
class HandInterface;
|
||||||
@@ -37,7 +38,7 @@ struct GameData;
|
|||||||
class Game {
|
class Game {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(GuiInterface *gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId);
|
Game(GuiInterface *gui, const PlayerDataList &playerDataList, const GameData &gameData, int gameId, ConfigFile*);
|
||||||
|
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
@@ -95,6 +96,8 @@ private:
|
|||||||
int actualSmallBlind;
|
int actualSmallBlind;
|
||||||
int actualHandID;
|
int actualHandID;
|
||||||
int dealerPosition;
|
int dealerPosition;
|
||||||
|
|
||||||
|
ConfigFile *myConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ void Session::startGame(const GameData &gameData) {
|
|||||||
|
|
||||||
playerDataList.push_back(playerData);
|
playerDataList.push_back(playerData);
|
||||||
}
|
}
|
||||||
currentGame = new Game(myGui, playerDataList, gameData, currentGameID);
|
currentGame = new Game(myGui, playerDataList, gameData, currentGameID, myConfig);
|
||||||
|
|
||||||
//// SPIEL-SCHLEIFE
|
//// SPIEL-SCHLEIFE
|
||||||
currentGame->initHand();
|
currentGame->initHand();
|
||||||
|
|||||||
Reference in New Issue
Block a user