Fixed bug: "hands before raise" is now taken from dialog. Removed config from game.cpp for networking.
This commit is contained in:
@@ -54,6 +54,7 @@ INCLUDEPATH += . \
|
|||||||
# Input
|
# Input
|
||||||
HEADERS += src/game.h \
|
HEADERS += src/game.h \
|
||||||
src/session.h \
|
src/session.h \
|
||||||
|
src/playerdata.h \
|
||||||
src/config/configfile.h \
|
src/config/configfile.h \
|
||||||
src/core/rand.h \
|
src/core/rand.h \
|
||||||
src/core/thread.h \
|
src/core/thread.h \
|
||||||
@@ -119,6 +120,7 @@ FORMS += src/gui/qt/mainwindow.ui \
|
|||||||
SOURCES += src/game.cpp \
|
SOURCES += src/game.cpp \
|
||||||
src/pokerth.cpp \
|
src/pokerth.cpp \
|
||||||
src/session.cpp \
|
src/session.cpp \
|
||||||
|
src/playerdata.cpp \
|
||||||
src/config/configfile.cpp \
|
src/config/configfile.cpp \
|
||||||
src/engine/boardinterface.cpp \
|
src/engine/boardinterface.cpp \
|
||||||
src/engine/enginefactory.cpp \
|
src/engine/enginefactory.cpp \
|
||||||
|
|||||||
+20
-16
@@ -27,14 +27,16 @@
|
|||||||
#include "playerinterface.h"
|
#include "playerinterface.h"
|
||||||
#include "handinterface.h"
|
#include "handinterface.h"
|
||||||
|
|
||||||
#include "configfile.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB, int gId) : myConfig(c), myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), myGameID(gId), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0)
|
Game::Game(GuiInterface* gui, const PlayerDataList &playerData, int sC, int sB, int hbrsB, int gameId)
|
||||||
|
: myGui(gui), actualHand(0), actualBoard(0), startCash(sC),
|
||||||
|
startSmallBlind(sB), startHandsBeforeRaiseSmallBlind(hbrsB),myGameID(gameId),
|
||||||
|
actualSmallBlind(sB), actualHandID(0), dealerPosition(0)
|
||||||
{
|
{
|
||||||
// cout << "Create Game Object" << "\n";
|
// cout << "Create Game Object" << "\n";
|
||||||
int i;
|
int i;
|
||||||
|
startQuantityPlayers = actualQuantityPlayers = playerData.size();
|
||||||
|
|
||||||
actualHandID = 0;
|
actualHandID = 0;
|
||||||
|
|
||||||
@@ -57,23 +59,26 @@ Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB, int gId) : my
|
|||||||
myTool.getRandNumber(0, startQuantityPlayers-1, 1, &dealerPosition, 0);
|
myTool.getRandNumber(0, startQuantityPlayers-1, 1, &dealerPosition, 0);
|
||||||
|
|
||||||
// Player erstellen
|
// Player erstellen
|
||||||
PlayerInterface *tempPlayer;
|
PlayerDataList::const_iterator player_i = playerData.begin();
|
||||||
|
PlayerDataList::const_iterator player_end = playerData.end();
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
|
||||||
//Namen und Avatarpfad abfragen
|
string myName;
|
||||||
ostringstream myName;
|
string myAvatarFile;
|
||||||
if (i==0) { myName << "MyName"; }
|
|
||||||
else { myName << "Opponent" << i << "Name"; }
|
if (player_i != player_end)
|
||||||
ostringstream myAvatar;
|
{
|
||||||
if (i==0) { myAvatar << "MyAvatar"; }
|
myName = (*player_i)->GetName();
|
||||||
else { myAvatar << "Opponent" << i << "Avatar"; }
|
myAvatarFile = (*player_i)->GetAvatarFile();
|
||||||
|
// TODO: set player type
|
||||||
|
++player_i;
|
||||||
|
}
|
||||||
|
|
||||||
//PlayerObjekte erzeugen
|
//PlayerObjekte erzeugen
|
||||||
tempPlayer = myFactory->createPlayer(actualBoard, i, myConfig->readConfigString(myName.str()), myConfig->readConfigString(myAvatar.str()), startCash, startQuantityPlayers > i, 0);
|
playerArray[i] = myFactory->createPlayer(actualBoard, i, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
|
||||||
playerArray[i] = tempPlayer;
|
|
||||||
}
|
}
|
||||||
actualBoard->setPlayer(playerArray);
|
actualBoard->setPlayer(playerArray);
|
||||||
|
|
||||||
//// SPIEL-SCHLEIFE
|
//// SPIEL-SCHLEIFE
|
||||||
|
|
||||||
startHand();
|
startHand();
|
||||||
@@ -116,8 +121,7 @@ void Game::startHand()
|
|||||||
actualHandID++;
|
actualHandID++;
|
||||||
|
|
||||||
// smallBlind alle x Runden erhöhen
|
// smallBlind alle x Runden erhöhen
|
||||||
int handsBeforeRaiseSmallBLind = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind");
|
if(actualHandID%startHandsBeforeRaiseSmallBlind == 0) actualSmallBlind *= 2;
|
||||||
if(actualHandID%handsBeforeRaiseSmallBLind == 0) actualSmallBlind *= 2;
|
|
||||||
|
|
||||||
//Spieler Action auf 0 setzen
|
//Spieler Action auf 0 setzen
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
|||||||
+3
-11
@@ -25,19 +25,19 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "game_defs.h"
|
#include "game_defs.h"
|
||||||
|
#include "playerdata.h"
|
||||||
|
|
||||||
class GuiInterface;
|
class GuiInterface;
|
||||||
class HandInterface;
|
class HandInterface;
|
||||||
class PlayerInterface;
|
class PlayerInterface;
|
||||||
class BoardInterface;
|
class BoardInterface;
|
||||||
class EngineFactory;
|
class EngineFactory;
|
||||||
class ConfigFile;
|
|
||||||
|
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(ConfigFile*, GuiInterface*, int, int, int, int);
|
Game(GuiInterface *gui, const PlayerDataList &playerData, int sC, int sB, int hbrsB, int gameId);
|
||||||
|
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
@@ -69,9 +69,6 @@ public:
|
|||||||
void setActualHandID(const int& theValue) { actualHandID = theValue; }
|
void setActualHandID(const int& theValue) { actualHandID = theValue; }
|
||||||
int getActualHandID() const { return actualHandID; }
|
int getActualHandID() const { return actualHandID; }
|
||||||
|
|
||||||
void setRoundsToRaiseSmallBlind(const int& theValue) { roundsToRaiseSmallBlind = theValue; }
|
|
||||||
int getRoundsToRaiseSmallBlind() const { return roundsToRaiseSmallBlind; }
|
|
||||||
|
|
||||||
void startHand();
|
void startHand();
|
||||||
|
|
||||||
|
|
||||||
@@ -82,8 +79,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
EngineFactory *myFactory;
|
EngineFactory *myFactory;
|
||||||
|
|
||||||
ConfigFile *myConfig;
|
|
||||||
|
|
||||||
GuiInterface *myGui;
|
GuiInterface *myGui;
|
||||||
HandInterface *actualHand;
|
HandInterface *actualHand;
|
||||||
BoardInterface *actualBoard;
|
BoardInterface *actualBoard;
|
||||||
@@ -93,6 +88,7 @@ private:
|
|||||||
int startQuantityPlayers;
|
int startQuantityPlayers;
|
||||||
int startCash;
|
int startCash;
|
||||||
int startSmallBlind;
|
int startSmallBlind;
|
||||||
|
int startHandsBeforeRaiseSmallBlind;
|
||||||
int myGameID;
|
int myGameID;
|
||||||
|
|
||||||
//Laufvariablen
|
//Laufvariablen
|
||||||
@@ -100,10 +96,6 @@ private:
|
|||||||
int actualSmallBlind;
|
int actualSmallBlind;
|
||||||
int actualHandID;
|
int actualHandID;
|
||||||
int dealerPosition;
|
int dealerPosition;
|
||||||
|
|
||||||
int roundsToRaiseSmallBlind;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
|||||||
//positioning Slider
|
//positioning Slider
|
||||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
horizontalSlider_speed->setValue(guiGameSpeed);
|
||||||
//Start Game!!!
|
//Start Game!!!
|
||||||
mySession->startGame(v->spinBox_quantityPlayers->value(), v->spinBox_startCash->value(), v->spinBox_smallBlind->value());
|
mySession->startGame(v->spinBox_quantityPlayers->value(), v->spinBox_startCash->value(), v->spinBox_smallBlind->value(), v->spinBox_handsBeforeRaiseSmallBlind->value());
|
||||||
}
|
}
|
||||||
// start with default values
|
// start with default values
|
||||||
else {
|
else {
|
||||||
@@ -618,7 +618,7 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
|||||||
//positioning Slider
|
//positioning Slider
|
||||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
horizontalSlider_speed->setValue(guiGameSpeed);
|
||||||
//Start Game!!!
|
//Start Game!!!
|
||||||
mySession->startGame(myConfig->readConfigInt("NumberOfPlayers"), myConfig->readConfigInt("StartCash"), myConfig->readConfigInt("SmallBlind"));
|
mySession->startGame(myConfig->readConfigInt("NumberOfPlayers"), myConfig->readConfigInt("StartCash"), myConfig->readConfigInt("SmallBlind"), myConfig->readConfigInt("HandsBeforeRaiseSmallBlind"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-8
@@ -21,8 +21,7 @@
|
|||||||
#ifndef _NETPACKET_H_
|
#ifndef _NETPACKET_H_
|
||||||
#define _NETPACKET_H_
|
#define _NETPACKET_H_
|
||||||
|
|
||||||
#include <string>
|
#include <playerdata.h>
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <net/socket_helper.h>
|
#include <net/socket_helper.h>
|
||||||
|
|
||||||
#define MIN_PACKET_SIZE 4
|
#define MIN_PACKET_SIZE 4
|
||||||
@@ -30,12 +29,6 @@
|
|||||||
#define MAX_NAME_SIZE 64
|
#define MAX_NAME_SIZE 64
|
||||||
#define MAX_PASSWORD_SIZE 64
|
#define MAX_PASSWORD_SIZE 64
|
||||||
|
|
||||||
// TODO: move this somewhere else
|
|
||||||
enum PlayerType
|
|
||||||
{
|
|
||||||
PLAYER_TYPE_COMPUTER,
|
|
||||||
PLAYER_TYPE_HUMAN
|
|
||||||
};
|
|
||||||
|
|
||||||
enum JoinGameErrorReason
|
enum JoinGameErrorReason
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <playerdata.h>
|
||||||
|
|
||||||
|
PlayerData::PlayerData()
|
||||||
|
: m_type(PLAYER_TYPE_COMPUTER)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData::~PlayerData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007 by Lothar May *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
/* Player data. */
|
||||||
|
|
||||||
|
#ifndef _PLAYERDATA_H_
|
||||||
|
#define _PLAYERDATA_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
enum PlayerType
|
||||||
|
{
|
||||||
|
PLAYER_TYPE_COMPUTER,
|
||||||
|
PLAYER_TYPE_HUMAN
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlayerData();
|
||||||
|
~PlayerData();
|
||||||
|
|
||||||
|
const std::string &GetName() const
|
||||||
|
{return m_name;}
|
||||||
|
void SetName(const std::string &name)
|
||||||
|
{m_name = name;}
|
||||||
|
const std::string &GetAvatarFile() const
|
||||||
|
{return m_avatarFile;}
|
||||||
|
void SetAvatarFile(const std::string &avatarFile)
|
||||||
|
{m_avatarFile = avatarFile;}
|
||||||
|
PlayerType GetType() const
|
||||||
|
{return m_type;}
|
||||||
|
void SetPlayerType(PlayerType type)
|
||||||
|
{m_type = type;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_name;
|
||||||
|
std::string m_avatarFile;
|
||||||
|
PlayerType m_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::list<boost::shared_ptr<PlayerData> > PlayerDataList;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
+25
-4
@@ -30,7 +30,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Session::Session(GuiInterface *g)
|
Session::Session(GuiInterface *g)
|
||||||
: actualGameID(0), myNetClient(0), myNetServer(0), actualGame(0), myGui(g)
|
: currentGameID(0), myNetClient(0), myNetServer(0), actualGame(0), myGui(g)
|
||||||
{
|
{
|
||||||
myConfig = new ConfigFile;
|
myConfig = new ConfigFile;
|
||||||
}
|
}
|
||||||
@@ -46,11 +46,32 @@ Session::~Session()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Session::startGame(int qP, int sC, int sB) {
|
void Session::startGame(int qP, int sC, int sB, int hbrsB) {
|
||||||
|
|
||||||
actualGameID++;
|
currentGameID++;
|
||||||
|
|
||||||
actualGame = new Game(myConfig, myGui, qP, sC, sB, actualGameID);
|
PlayerDataList playerDataList;
|
||||||
|
for(int i=0; i<qP; i++) {
|
||||||
|
|
||||||
|
//Namen und Avatarpfad abfragen
|
||||||
|
ostringstream myName;
|
||||||
|
if (i==0) { myName << "MyName"; }
|
||||||
|
else { myName << "Opponent" << i << "Name"; }
|
||||||
|
ostringstream myAvatar;
|
||||||
|
if (i==0) { myAvatar << "MyAvatar"; }
|
||||||
|
else { myAvatar << "Opponent" << i << "Avatar"; }
|
||||||
|
|
||||||
|
//PlayerData erzeugen
|
||||||
|
// TODO: PlayerType setzen
|
||||||
|
boost::shared_ptr<PlayerData> playerData(new PlayerData);
|
||||||
|
playerData->SetName(myConfig->readConfigString(myName.str()));
|
||||||
|
playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str()));
|
||||||
|
|
||||||
|
playerDataList.push_back(playerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
actualGame = new Game(myGui, playerDataList, sC, sB, hbrsB, currentGameID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::deleteGame() {
|
void Session::deleteGame() {
|
||||||
|
|||||||
+4
-6
@@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
~Session();
|
~Session();
|
||||||
|
|
||||||
void startGame(int, int, int);
|
void startGame(int qP, int sC, int sB, int hbrsB);
|
||||||
void deleteGame();
|
void deleteGame();
|
||||||
|
|
||||||
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
|
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
|
||||||
@@ -45,14 +45,12 @@ public:
|
|||||||
void initiateNetworkServerGame();
|
void initiateNetworkServerGame();
|
||||||
void terminateNetworkServer();
|
void terminateNetworkServer();
|
||||||
|
|
||||||
void setActualGameID(const int& theValue) { actualGameID = theValue; }
|
void setCurrentGameID(const int& theValue) { currentGameID = theValue; }
|
||||||
int getActualGameID() const { return actualGameID; }
|
int getCurrentGameID() const { return currentGameID; }
|
||||||
|
|
||||||
// void createConfig();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int actualGameID;
|
int currentGameID;
|
||||||
|
|
||||||
ClientThread *myNetClient;
|
ClientThread *myNetClient;
|
||||||
ServerThread *myNetServer;
|
ServerThread *myNetServer;
|
||||||
|
|||||||
Reference in New Issue
Block a user