Some include file optimizations. Fixes for the server.
This commit is contained in:
@@ -20,9 +20,7 @@
|
||||
#ifndef LOCALBOARD_H
|
||||
#define LOCALBOARD_H
|
||||
|
||||
#include "boardinterface.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <boardinterface.h>
|
||||
|
||||
class PlayerInterface;
|
||||
class HandInterface;
|
||||
@@ -30,9 +28,8 @@ class HandInterface;
|
||||
|
||||
class LocalBoard : public BoardInterface{
|
||||
public:
|
||||
LocalBoard();
|
||||
|
||||
~LocalBoard();
|
||||
LocalBoard();
|
||||
~LocalBoard();
|
||||
|
||||
void setPlayer(PlayerInterface**);
|
||||
void setHand(HandInterface*);
|
||||
|
||||
@@ -19,9 +19,19 @@
|
||||
***************************************************************************/
|
||||
#include "localenginefactory.h"
|
||||
|
||||
#include "localhand.h"
|
||||
#include "localboard.h"
|
||||
#include "localplayer.h"
|
||||
#include "localpreflop.h"
|
||||
#include "localflop.h"
|
||||
#include "localturn.h"
|
||||
#include "localriver.h"
|
||||
|
||||
#include <configfile.h>
|
||||
|
||||
|
||||
LocalEngineFactory::LocalEngineFactory(ConfigFile *c)
|
||||
: EngineFactory(), myConfig(c)
|
||||
: myConfig(c)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -22,22 +22,21 @@
|
||||
|
||||
#include <enginefactory.h>
|
||||
|
||||
#include "localhand.h"
|
||||
#include "localboard.h"
|
||||
#include "localplayer.h"
|
||||
#include "localpreflop.h"
|
||||
#include "localflop.h"
|
||||
#include "localturn.h"
|
||||
#include "localriver.h"
|
||||
#include <handinterface.h>
|
||||
#include <boardinterface.h>
|
||||
#include <playerinterface.h>
|
||||
#include <preflopinterface.h>
|
||||
#include <flopinterface.h>
|
||||
#include <turninterface.h>
|
||||
#include <riverinterface.h>
|
||||
|
||||
#include "configfile.h"
|
||||
class ConfigFile;
|
||||
|
||||
class LocalEngineFactory : public EngineFactory
|
||||
{
|
||||
public:
|
||||
LocalEngineFactory(ConfigFile*);
|
||||
|
||||
~LocalEngineFactory();
|
||||
LocalEngineFactory(ConfigFile*);
|
||||
~LocalEngineFactory();
|
||||
|
||||
HandInterface* createHand(EngineFactory *f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC);
|
||||
BoardInterface* createBoard();
|
||||
@@ -46,8 +45,8 @@ 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:
|
||||
|
||||
private:
|
||||
ConfigFile *myConfig;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
***************************************************************************/
|
||||
#include "localflop.h"
|
||||
#include <game_defs.h>
|
||||
#include <handinterface.h>
|
||||
|
||||
using namespace std;
|
||||
//using namespace std;
|
||||
|
||||
LocalFlop::LocalFlop(HandInterface* bR, int id, int qP, int dP, int sB) : FlopInterface(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstFlopRun(1), firstFlopRound(1), playersTurn(dP)
|
||||
|
||||
@@ -83,7 +84,6 @@ void LocalFlop::flopRun() {
|
||||
myHand->getGuiInterface()->refreshAction();
|
||||
|
||||
myHand->switchRounds();
|
||||
|
||||
}
|
||||
else {
|
||||
// Flop ist wirklich dran
|
||||
|
||||
@@ -20,17 +20,15 @@
|
||||
#ifndef LOCALFLOP_H
|
||||
#define LOCALFLOP_H
|
||||
|
||||
#include "flopinterface.h"
|
||||
#include "handinterface.h"
|
||||
#include <flopinterface.h>
|
||||
|
||||
#include <iostream>
|
||||
class HandInterface;
|
||||
|
||||
class LocalFlop : public FlopInterface{
|
||||
|
||||
public:
|
||||
LocalFlop(HandInterface*, int, int, int, int);
|
||||
|
||||
~LocalFlop();
|
||||
public:
|
||||
LocalFlop(HandInterface*, int, int, int, int);
|
||||
~LocalFlop();
|
||||
|
||||
|
||||
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "localhand.h"
|
||||
#include "tools.h"
|
||||
#include "cardsvalue.h"
|
||||
#include <game_defs.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -17,28 +17,23 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#ifndef HandInterface_H
|
||||
#define HandInterface_H
|
||||
|
||||
#include "enginefactory.h"
|
||||
|
||||
#include "handinterface.h"
|
||||
#include "guiinterface.h"
|
||||
|
||||
|
||||
#include "tools.h"
|
||||
#include "cardsvalue.h"
|
||||
#include "localpreflop.h"
|
||||
#include "localflop.h"
|
||||
#include "localturn.h"
|
||||
#include "localriver.h"
|
||||
#ifndef LOCALHAND_H
|
||||
#define LOCALHAND_H
|
||||
|
||||
#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>
|
||||
|
||||
|
||||
class LocalHand : public HandInterface{
|
||||
public:
|
||||
LocalHand(EngineFactory*, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int);
|
||||
|
||||
~LocalHand();
|
||||
|
||||
void start();
|
||||
@@ -89,13 +84,6 @@ public:
|
||||
|
||||
void highlightRoundLabel();
|
||||
void switchRounds();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -18,8 +18,12 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "localplayer.h"
|
||||
|
||||
#include "localhand.h"
|
||||
#include "tools.h"
|
||||
#include "cardsvalue.h"
|
||||
#include <configfile.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -20,17 +20,14 @@
|
||||
#ifndef LOCALPLAYER_H
|
||||
#define LOCALPLAYER_H
|
||||
|
||||
#include "playerinterface.h"
|
||||
|
||||
#include "cardsvalue.h"
|
||||
|
||||
#include "configfile.h"
|
||||
#include <playerinterface.h>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
class CardsValue;
|
||||
class ConfigFile;
|
||||
class HandInterface;
|
||||
class BoardInterface;
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
***************************************************************************/
|
||||
#include "localpreflop.h"
|
||||
|
||||
#include "handinterface.h"
|
||||
#include <handinterface.h>
|
||||
#include <game_defs.h>
|
||||
|
||||
using namespace std;
|
||||
//using namespace std;
|
||||
|
||||
LocalPreflop::LocalPreflop(HandInterface* bR, int id, int qP, int dP, int sB) : PreflopInterface(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), bigBlindPosition(0), smallBlind(sB), highestSet(2*sB), preflopFirstRound(1), playersTurn(0)
|
||||
|
||||
@@ -86,7 +86,6 @@ void LocalPreflop::preflopRun() {
|
||||
myHand->getGuiInterface()->refreshAction();
|
||||
|
||||
myHand->switchRounds();
|
||||
|
||||
}
|
||||
else {
|
||||
// Preflop ist wirklich dran
|
||||
|
||||
@@ -20,18 +20,15 @@
|
||||
#ifndef LOCALPREFLOP_H
|
||||
#define LOCALPREFLOP_H
|
||||
|
||||
#include "preflopinterface.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <preflopinterface.h>
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class LocalPreflop : public PreflopInterface{
|
||||
|
||||
public:
|
||||
LocalPreflop(HandInterface*, int, int, int, int);
|
||||
|
||||
~LocalPreflop();
|
||||
LocalPreflop(HandInterface*, int, int, int, int);
|
||||
~LocalPreflop();
|
||||
|
||||
|
||||
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "localriver.h"
|
||||
#include <handinterface.h>
|
||||
#include <game_defs.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -84,7 +86,6 @@ void LocalRiver::riverRun() {
|
||||
myHand->getGuiInterface()->refreshAction();
|
||||
|
||||
myHand->switchRounds();
|
||||
|
||||
}
|
||||
else {
|
||||
// River ist wirklich dran
|
||||
|
||||
@@ -20,18 +20,15 @@
|
||||
#ifndef LOCALRIVER_H
|
||||
#define LOCALRIVER_H
|
||||
|
||||
#include "riverinterface.h"
|
||||
#include <riverinterface.h>
|
||||
|
||||
#include <iostream>
|
||||
class HandInterface;
|
||||
|
||||
#include "handinterface.h"
|
||||
|
||||
class LocalRiver : public RiverInterface{
|
||||
|
||||
public:
|
||||
LocalRiver(HandInterface*, int, int, int, int);
|
||||
|
||||
~LocalRiver();
|
||||
LocalRiver(HandInterface*, int, int, int, int);
|
||||
~LocalRiver();
|
||||
|
||||
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "localturn.h"
|
||||
#include <handinterface.h>
|
||||
#include <game_defs.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
//using namespace std;
|
||||
|
||||
LocalTurn::LocalTurn(HandInterface* bR, int id, int qP, int dP, int sB) : TurnInterface(), myHand(bR), myID(id), actualQuantityPlayers(qP), dealerPosition(dP), smallBlindPosition(0), smallBlind(sB), highestSet(0), firstTurnRun(1), firstTurnRound(1), playersTurn(dP)
|
||||
|
||||
@@ -85,7 +86,6 @@ void LocalTurn::turnRun() {
|
||||
myHand->getGuiInterface()->refreshAction();
|
||||
|
||||
myHand->switchRounds();
|
||||
|
||||
}
|
||||
else {
|
||||
// Turn ist wirklich dran
|
||||
|
||||
@@ -20,18 +20,14 @@
|
||||
#ifndef LOCALTURN_H
|
||||
#define LOCALTURN_H
|
||||
|
||||
#include "turninterface.h"
|
||||
#include <turninterface.h>
|
||||
|
||||
#include "handinterface.h"
|
||||
|
||||
#include <iostream>
|
||||
class HandInterface;
|
||||
|
||||
class LocalTurn : public TurnInterface{
|
||||
|
||||
public:
|
||||
LocalTurn(HandInterface*, int, int, int, int);
|
||||
|
||||
~LocalTurn();
|
||||
LocalTurn(HandInterface*, int, int, int, int);
|
||||
~LocalTurn();
|
||||
|
||||
void setPlayersTurn(const int& theValue) { playersTurn = theValue; }
|
||||
int getPlayersTurn() const { return playersTurn; }
|
||||
|
||||
+3
-7
@@ -20,13 +20,9 @@
|
||||
#include "game.h"
|
||||
#include "gamedata.h"
|
||||
|
||||
#include "enginefactory.h"
|
||||
#include "localenginefactory.h"
|
||||
|
||||
#include "guiinterface.h"
|
||||
#include "boardinterface.h"
|
||||
#include "playerinterface.h"
|
||||
#include "handinterface.h"
|
||||
#include <localenginefactory.h>
|
||||
#include <guiinterface.h>
|
||||
#include <tools.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -81,8 +81,6 @@ public:
|
||||
// virtual void postRiverAnimation2()=0;
|
||||
virtual void flipHolecardsAllIn()=0;
|
||||
|
||||
// virtual void handSwitchRounds() const=0;
|
||||
//
|
||||
// virtual void startNewHand() const=0;
|
||||
virtual void nextRoundCleanGui()=0;
|
||||
//
|
||||
|
||||
@@ -318,41 +318,24 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server)
|
||||
Game &curGame = server.GetGame();
|
||||
|
||||
curGame.getCurrentHand()->switchRounds();
|
||||
int playersTurn = 0;
|
||||
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case 0: {
|
||||
// Preflop starten
|
||||
curGame.getCurrentHand()->getPreflop()->preflopRun();
|
||||
playersTurn = curGame.getCurrentHand()->getPreflop()->getPlayersTurn();
|
||||
} break;
|
||||
case 1: {
|
||||
// Flop starten
|
||||
curGame.getCurrentHand()->getFlop()->flopRun();
|
||||
playersTurn = curGame.getCurrentHand()->getFlop()->getPlayersTurn();
|
||||
} break;
|
||||
case 2: {
|
||||
// Turn starten
|
||||
curGame.getCurrentHand()->getTurn()->turnRun();
|
||||
playersTurn = curGame.getCurrentHand()->getTurn()->getPlayersTurn();
|
||||
} break;
|
||||
case 3: {
|
||||
// River starten
|
||||
curGame.getCurrentHand()->getRiver()->riverRun();
|
||||
playersTurn = curGame.getCurrentHand()->getRiver()->getPlayersTurn();
|
||||
} break;
|
||||
default: {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
// Call main loop - if state changes, call again.
|
||||
int newRound = curGame.getCurrentHand()->getActualRound();
|
||||
int curRound;
|
||||
do
|
||||
{
|
||||
curRound = newRound;
|
||||
GameRun(curGame, curRound);
|
||||
newRound = curGame.getCurrentHand()->getActualRound();
|
||||
} while (newRound != curRound);
|
||||
|
||||
assert(playersTurn < curGame.getActualQuantityPlayers());
|
||||
// Retrieve current player.
|
||||
PlayerInterface *curPlayer = GetCurrentPlayer(curGame);
|
||||
|
||||
boost::shared_ptr<NetPacket> notification(new NetPacketPlayersTurn);
|
||||
NetPacketPlayersTurn::Data playersTurnData;
|
||||
playersTurnData.gameState = (GameState)curGame.getCurrentHand()->getActualRound();
|
||||
playersTurnData.playerId = curGame.getPlayerArray()[playersTurn]->getMyUniqueID();
|
||||
playersTurnData.playerId = curPlayer->getMyUniqueID();
|
||||
static_cast<NetPacketPlayersTurn *>(notification.get())->SetData(playersTurnData);
|
||||
|
||||
server.SendToAllPlayers(notification);
|
||||
@@ -362,6 +345,60 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server)
|
||||
return MSG_NET_GAME_SERVER_ROUND;
|
||||
}
|
||||
|
||||
void
|
||||
ServerRecvStateStartRound::GameRun(Game &curGame, int state)
|
||||
{
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(state) {
|
||||
case 0: {
|
||||
// Preflop starten
|
||||
curGame.getCurrentHand()->getPreflop()->preflopRun();
|
||||
} break;
|
||||
case 1: {
|
||||
// Flop starten
|
||||
curGame.getCurrentHand()->getFlop()->flopRun();
|
||||
} break;
|
||||
case 2: {
|
||||
// Turn starten
|
||||
curGame.getCurrentHand()->getTurn()->turnRun();
|
||||
} break;
|
||||
case 3: {
|
||||
// River starten
|
||||
curGame.getCurrentHand()->getRiver()->riverRun();
|
||||
} break;
|
||||
default: {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerInterface *
|
||||
ServerRecvStateStartRound::GetCurrentPlayer(Game &curGame)
|
||||
{
|
||||
int curPlayerNum = 0;
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case 0: {
|
||||
curPlayerNum = curGame.getCurrentHand()->getPreflop()->getPlayersTurn();
|
||||
} break;
|
||||
case 1: {
|
||||
curPlayerNum = curGame.getCurrentHand()->getFlop()->getPlayersTurn();
|
||||
} break;
|
||||
case 2: {
|
||||
curPlayerNum = curGame.getCurrentHand()->getTurn()->getPlayersTurn();
|
||||
} break;
|
||||
case 3: {
|
||||
curPlayerNum = curGame.getCurrentHand()->getRiver()->getPlayersTurn();
|
||||
} break;
|
||||
default: {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
assert(curPlayerNum < curGame.getActualQuantityPlayers());
|
||||
return curGame.getPlayerArray()[curPlayerNum];
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ServerRecvStateFinal &
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#define SERVER_INITIAL_STATE ServerRecvStateInit
|
||||
#define SERVER_START_GAME_STATE ServerRecvStateStartGame
|
||||
|
||||
class Game;
|
||||
class PlayerInterface;
|
||||
class ServerRecvThread;
|
||||
class ServerCallback;
|
||||
|
||||
@@ -128,6 +130,9 @@ protected:
|
||||
|
||||
// Protected constructor - this is a singleton.
|
||||
ServerRecvStateStartRound();
|
||||
|
||||
void GameRun(Game &curGame, int state);
|
||||
PlayerInterface *GetCurrentPlayer(Game &curGame);
|
||||
};
|
||||
|
||||
// State: Final.
|
||||
|
||||
Reference in New Issue
Block a user