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
|
||||
HEADERS += src/game.h \
|
||||
src/session.h \
|
||||
src/playerdata.h \
|
||||
src/config/configfile.h \
|
||||
src/core/rand.h \
|
||||
src/core/thread.h \
|
||||
@@ -119,6 +120,7 @@ FORMS += src/gui/qt/mainwindow.ui \
|
||||
SOURCES += src/game.cpp \
|
||||
src/pokerth.cpp \
|
||||
src/session.cpp \
|
||||
src/playerdata.cpp \
|
||||
src/config/configfile.cpp \
|
||||
src/engine/boardinterface.cpp \
|
||||
src/engine/enginefactory.cpp \
|
||||
|
||||
+20
-16
@@ -27,14 +27,16 @@
|
||||
#include "playerinterface.h"
|
||||
#include "handinterface.h"
|
||||
|
||||
#include "configfile.h"
|
||||
|
||||
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";
|
||||
int i;
|
||||
startQuantityPlayers = actualQuantityPlayers = playerData.size();
|
||||
|
||||
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);
|
||||
|
||||
// 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++) {
|
||||
|
||||
//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"; }
|
||||
string myName;
|
||||
string myAvatarFile;
|
||||
|
||||
if (player_i != player_end)
|
||||
{
|
||||
myName = (*player_i)->GetName();
|
||||
myAvatarFile = (*player_i)->GetAvatarFile();
|
||||
// TODO: set player type
|
||||
++player_i;
|
||||
}
|
||||
|
||||
//PlayerObjekte erzeugen
|
||||
tempPlayer = myFactory->createPlayer(actualBoard, i, myConfig->readConfigString(myName.str()), myConfig->readConfigString(myAvatar.str()), startCash, startQuantityPlayers > i, 0);
|
||||
playerArray[i] = tempPlayer;
|
||||
playerArray[i] = myFactory->createPlayer(actualBoard, i, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
|
||||
}
|
||||
actualBoard->setPlayer(playerArray);
|
||||
|
||||
|
||||
//// SPIEL-SCHLEIFE
|
||||
|
||||
startHand();
|
||||
@@ -116,8 +121,7 @@ void Game::startHand()
|
||||
actualHandID++;
|
||||
|
||||
// smallBlind alle x Runden erhöhen
|
||||
int handsBeforeRaiseSmallBLind = myConfig->readConfigInt("HandsBeforeRaiseSmallBlind");
|
||||
if(actualHandID%handsBeforeRaiseSmallBLind == 0) actualSmallBlind *= 2;
|
||||
if(actualHandID%startHandsBeforeRaiseSmallBlind == 0) actualSmallBlind *= 2;
|
||||
|
||||
//Spieler Action auf 0 setzen
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
|
||||
+3
-11
@@ -25,19 +25,19 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "game_defs.h"
|
||||
#include "playerdata.h"
|
||||
|
||||
class GuiInterface;
|
||||
class HandInterface;
|
||||
class PlayerInterface;
|
||||
class BoardInterface;
|
||||
class EngineFactory;
|
||||
class ConfigFile;
|
||||
|
||||
|
||||
class Game {
|
||||
|
||||
public:
|
||||
Game(ConfigFile*, GuiInterface*, int, int, int, int);
|
||||
Game(GuiInterface *gui, const PlayerDataList &playerData, int sC, int sB, int hbrsB, int gameId);
|
||||
|
||||
~Game();
|
||||
|
||||
@@ -69,9 +69,6 @@ public:
|
||||
void setActualHandID(const int& theValue) { actualHandID = theValue; }
|
||||
int getActualHandID() const { return actualHandID; }
|
||||
|
||||
void setRoundsToRaiseSmallBlind(const int& theValue) { roundsToRaiseSmallBlind = theValue; }
|
||||
int getRoundsToRaiseSmallBlind() const { return roundsToRaiseSmallBlind; }
|
||||
|
||||
void startHand();
|
||||
|
||||
|
||||
@@ -82,8 +79,6 @@ public:
|
||||
private:
|
||||
EngineFactory *myFactory;
|
||||
|
||||
ConfigFile *myConfig;
|
||||
|
||||
GuiInterface *myGui;
|
||||
HandInterface *actualHand;
|
||||
BoardInterface *actualBoard;
|
||||
@@ -93,6 +88,7 @@ private:
|
||||
int startQuantityPlayers;
|
||||
int startCash;
|
||||
int startSmallBlind;
|
||||
int startHandsBeforeRaiseSmallBlind;
|
||||
int myGameID;
|
||||
|
||||
//Laufvariablen
|
||||
@@ -100,10 +96,6 @@ private:
|
||||
int actualSmallBlind;
|
||||
int actualHandID;
|
||||
int dealerPosition;
|
||||
|
||||
int roundsToRaiseSmallBlind;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -608,7 +608,7 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
||||
//positioning Slider
|
||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
||||
//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
|
||||
else {
|
||||
@@ -618,7 +618,7 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
|
||||
//positioning Slider
|
||||
horizontalSlider_speed->setValue(guiGameSpeed);
|
||||
//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_
|
||||
#define _NETPACKET_H_
|
||||
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <playerdata.h>
|
||||
#include <net/socket_helper.h>
|
||||
|
||||
#define MIN_PACKET_SIZE 4
|
||||
@@ -30,12 +29,6 @@
|
||||
#define MAX_NAME_SIZE 64
|
||||
#define MAX_PASSWORD_SIZE 64
|
||||
|
||||
// TODO: move this somewhere else
|
||||
enum PlayerType
|
||||
{
|
||||
PLAYER_TYPE_COMPUTER,
|
||||
PLAYER_TYPE_HUMAN
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
+4
-6
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
~Session();
|
||||
|
||||
void startGame(int, int, int);
|
||||
void startGame(int qP, int sC, int sB, int hbrsB);
|
||||
void deleteGame();
|
||||
|
||||
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
|
||||
@@ -45,14 +45,12 @@ public:
|
||||
void initiateNetworkServerGame();
|
||||
void terminateNetworkServer();
|
||||
|
||||
void setActualGameID(const int& theValue) { actualGameID = theValue; }
|
||||
int getActualGameID() const { return actualGameID; }
|
||||
|
||||
// void createConfig();
|
||||
void setCurrentGameID(const int& theValue) { currentGameID = theValue; }
|
||||
int getCurrentGameID() const { return currentGameID; }
|
||||
|
||||
private:
|
||||
|
||||
int actualGameID;
|
||||
int currentGameID;
|
||||
|
||||
ClientThread *myNetClient;
|
||||
ServerThread *myNetServer;
|
||||
|
||||
Reference in New Issue
Block a user