Restructured network server.
This commit is contained in:
+2
-4
@@ -111,8 +111,7 @@ HEADERS += src/game.h \
|
||||
src/gui/qttoolsinterface.h \
|
||||
src/gui/qt/qttools/qttoolswrapper.h \
|
||||
src/gui/qt/qttools/qthelper/qthelper.h \
|
||||
src/gui/generic/serverguiwrapper.h \
|
||||
src/gui/generic/genericservergui.h
|
||||
src/gui/generic/serverguiwrapper.h
|
||||
FORMS += src/gui/qt/mainwindow.ui \
|
||||
src/gui/qt/aboutpokerth.ui \
|
||||
src/gui/qt/connecttoserverdialog.ui \
|
||||
@@ -188,8 +187,7 @@ SOURCES += src/game.cpp \
|
||||
src/gui/qttoolsinterface.cpp \
|
||||
src/gui/qt/qttools/qttoolswrapper.cpp \
|
||||
src/gui/qt/qttools/qthelper/qthelper.cpp \
|
||||
src/gui/generic/serverguiwrapper.cpp \
|
||||
src/gui/generic/genericservergui.cpp
|
||||
src/gui/generic/serverguiwrapper.cpp
|
||||
RESOURCES += src/gui/qt/resources.qrc
|
||||
TRANSLATIONS = ts/pokerth_de.ts \
|
||||
ts/pokerth_es.ts \
|
||||
|
||||
@@ -69,7 +69,7 @@ void LocalFlop::flopRun() {
|
||||
//also gehe in Turn
|
||||
myHand->setActualRound(2);
|
||||
|
||||
//Action l�chen und ActionButtons refresh
|
||||
//Action loeschen und ActionButtons refresh
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ void LocalFlop::flopRun() {
|
||||
}
|
||||
|
||||
|
||||
// n�hsten Spieler ermitteln
|
||||
// naechsten Spieler ermitteln
|
||||
do { playersTurn = (playersTurn+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
} while(!(myHand->getPlayerArray()[playersTurn]->getMyActiveStatus()) || (myHand->getPlayerArray()[playersTurn]->getMyAction())==1 || (myHand->getPlayerArray()[playersTurn]->getMyAction())==6);
|
||||
|
||||
@@ -111,24 +111,16 @@ void LocalFlop::flopRun() {
|
||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstFlopRound = 0; }
|
||||
|
||||
if(myHand->getGuiInterface()->isNetworkServer())
|
||||
{
|
||||
myHand->getGuiInterface()->waitForNetworkAction(
|
||||
GAME_STATE_FLOP, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||
// cout << "highestSet vor meInAction " << highestSet << endl;
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||
// cout << "highestSet vor meInAction " << highestSet << endl;
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
// cout << "NextPlayerSpeed3 start" << endl;
|
||||
myHand->getGuiInterface()->flopAnimation2();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
// cout << "NextPlayerSpeed3 start" << endl;
|
||||
myHand->getGuiInterface()->flopAnimation2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void LocalPreflop::preflopRun() {
|
||||
//also gehe in Flop
|
||||
myHand->setActualRound(1);
|
||||
|
||||
//Action l�chen und ActionButtons refresh
|
||||
//Action loeschen und ActionButtons refresh
|
||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
if(myHand->getPlayerArray()[i]->getMyAction() != 1 && myHand->getPlayerArray()[i]->getMyAction() != 6) myHand->getPlayerArray()[i]->setMyAction(0);
|
||||
}
|
||||
@@ -103,22 +103,14 @@ void LocalPreflop::preflopRun() {
|
||||
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
|
||||
myHand->getGuiInterface()->refreshGroupbox(playersTurn,2);
|
||||
|
||||
if(myHand->getGuiInterface()->isNetworkServer())
|
||||
{
|
||||
myHand->getGuiInterface()->waitForNetworkAction(
|
||||
GAME_STATE_PREFLOP, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
// cout << "NextPlayerSpeed3 start" << endl;
|
||||
myHand->getGuiInterface()->preflopAnimation2();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
// cout << "NextPlayerSpeed3 start" << endl;
|
||||
myHand->getGuiInterface()->preflopAnimation2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,23 +111,15 @@ void LocalRiver::riverRun() {
|
||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstRiverRound = 0; }
|
||||
|
||||
if(myHand->getGuiInterface()->isNetworkServer())
|
||||
{
|
||||
myHand->getGuiInterface()->waitForNetworkAction(
|
||||
GAME_STATE_RIVER, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||
// cout << "highestSet vor meInAction " << highestSet << endl;
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||
// cout << "highestSet vor meInAction " << highestSet << endl;
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
myHand->getGuiInterface()->riverAnimation2();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
myHand->getGuiInterface()->riverAnimation2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,29 +107,21 @@ void LocalTurn::turnRun() {
|
||||
myHand->getPlayerArray()[playersTurn]->setMyTurn(1);
|
||||
myHand->getGuiInterface()->refreshGroupbox(playersTurn,2);
|
||||
|
||||
// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl;
|
||||
// cout << "playersTurn " << playersTurn << endl;
|
||||
// cout << "activePlayerBeforeSmallBlind " << activePlayerBeforeSmallBlind << endl;
|
||||
// cout << "playersTurn " << playersTurn << endl;
|
||||
// wenn wir letzter aktiver Spieler vor SmallBlind sind, dann flopFirstRound zuende
|
||||
if(myHand->getPlayerArray()[playersTurn]->getMyID() == activePlayerBeforeSmallBlind) { firstTurnRound = 0; }
|
||||
|
||||
if(myHand->getGuiInterface()->isNetworkServer())
|
||||
{
|
||||
myHand->getGuiInterface()->waitForNetworkAction(
|
||||
GAME_STATE_TURN, myHand->getPlayerArray()[playersTurn]->getMyUniqueID());
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||
// cout << "highestSet vor meInAction " << highestSet << endl;
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(playersTurn == 0) {
|
||||
// Wir sind dran
|
||||
// cout << "actualRound " << myHand->getActualRound() << endl;
|
||||
// cout << "highestSet vor meInAction " << highestSet << endl;
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
// cout << "NextPlayerSpeed3 start" << endl;
|
||||
myHand->getGuiInterface()->turnAnimation2();
|
||||
}
|
||||
else {
|
||||
//Gegner sind dran
|
||||
// cout << "NextPlayerSpeed3 start" << endl;
|
||||
myHand->getGuiInterface()->turnAnimation2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "genericservergui.h"
|
||||
#include <session.h>
|
||||
#include <game.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
GenericServerGui::GenericServerGui(ConfigFile *config)
|
||||
: myConfig(config)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GenericServerGui::~GenericServerGui()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::initGui(int speed)
|
||||
{
|
||||
}
|
||||
|
||||
Session &GenericServerGui::getSession()
|
||||
{
|
||||
assert(mySession.get());
|
||||
return *mySession;
|
||||
}
|
||||
|
||||
void GenericServerGui::setSession(boost::shared_ptr<Session> session)
|
||||
{
|
||||
mySession = session;
|
||||
}
|
||||
|
||||
void GenericServerGui::waitForNetworkAction(GameState state, unsigned uniquePlayerId)
|
||||
{
|
||||
getSession().waitForNetworkServerAction(state, uniquePlayerId);
|
||||
}
|
||||
|
||||
|
||||
void GenericServerGui::dealHoleCards()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::dealFlopCards()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::dealTurnCard()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::dealRiverCard()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::nextPlayerAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::preflopAnimation1()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::preflopAnimation2()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::flopAnimation1()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::flopAnimation2()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::turnAnimation1()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::turnAnimation2()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::riverAnimation1()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::riverAnimation2()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::postRiverAnimation1()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::postRiverRunAnimation1()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::flipHolecardsAllIn()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifndef GENERICSERVERGUI_H
|
||||
#define GENERICSERVERGUI_H
|
||||
|
||||
#include <game_defs.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class Session;
|
||||
class ConfigFile;
|
||||
|
||||
class GenericServerGui
|
||||
{
|
||||
public:
|
||||
GenericServerGui(ConfigFile *config);
|
||||
|
||||
~GenericServerGui();
|
||||
|
||||
void initGui(int speed);
|
||||
|
||||
Session &getSession();
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
|
||||
void waitForNetworkAction(GameState state, unsigned uniquePlayerId);
|
||||
|
||||
void dealHoleCards();
|
||||
void dealFlopCards();
|
||||
void dealTurnCard();
|
||||
void dealRiverCard();
|
||||
|
||||
void nextPlayerAnimation();
|
||||
|
||||
void preflopAnimation1();
|
||||
void preflopAnimation2();
|
||||
|
||||
void flopAnimation1();
|
||||
void flopAnimation2();
|
||||
|
||||
void turnAnimation1();
|
||||
void turnAnimation2();
|
||||
|
||||
void riverAnimation1();
|
||||
void riverAnimation2();
|
||||
|
||||
void postRiverAnimation1();
|
||||
void postRiverRunAnimation1();
|
||||
|
||||
void flipHolecardsAllIn();
|
||||
|
||||
private:
|
||||
|
||||
boost::shared_ptr<Session> mySession;
|
||||
ConfigFile *myConfig;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -18,16 +18,15 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "serverguiwrapper.h"
|
||||
#include "genericservergui.h"
|
||||
#include <session.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ServerGuiWrapper::ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb)
|
||||
: myClientcb(clientcb), myServercb(servercb)
|
||||
: myConfig(config), myClientcb(clientcb), myServercb(servercb)
|
||||
{
|
||||
myGui.reset(new GenericServerGui(config));
|
||||
}
|
||||
|
||||
ServerGuiWrapper::~ServerGuiWrapper()
|
||||
@@ -38,26 +37,13 @@ void ServerGuiWrapper::initGui(int speed) {}
|
||||
|
||||
Session &ServerGuiWrapper::getSession()
|
||||
{
|
||||
return myGui->getSession();
|
||||
assert(mySession.get());
|
||||
return *mySession;
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::setSession(boost::shared_ptr<Session> session)
|
||||
{
|
||||
myGui->setSession(session);
|
||||
}
|
||||
|
||||
bool
|
||||
ServerGuiWrapper::isNetworkServer() const
|
||||
{
|
||||
/* TODO hack */
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ServerGuiWrapper::waitForNetworkAction(GameState state, unsigned uniquePlayerId)
|
||||
{
|
||||
/* TODO hack */
|
||||
myGui->waitForNetworkAction(state, uniquePlayerId);
|
||||
mySession = session;
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::refreshSet() const {}
|
||||
@@ -74,32 +60,32 @@ void ServerGuiWrapper::refreshPot() const {}
|
||||
void ServerGuiWrapper::refreshGroupbox(int playerID, int status) const {}
|
||||
void ServerGuiWrapper::refreshPlayerName() const {}
|
||||
|
||||
void ServerGuiWrapper::dealHoleCards() { myGui->dealHoleCards(); }
|
||||
void ServerGuiWrapper::dealFlopCards() { myGui->dealFlopCards(); }
|
||||
void ServerGuiWrapper::dealTurnCard() { myGui->dealTurnCard(); }
|
||||
void ServerGuiWrapper::dealRiverCard() { myGui->dealRiverCard(); }
|
||||
void ServerGuiWrapper::dealHoleCards() {}
|
||||
void ServerGuiWrapper::dealFlopCards() {}
|
||||
void ServerGuiWrapper::dealTurnCard() {}
|
||||
void ServerGuiWrapper::dealRiverCard() {}
|
||||
|
||||
void ServerGuiWrapper::highlightRoundLabel(string round) const {}
|
||||
|
||||
|
||||
void ServerGuiWrapper::nextPlayerAnimation() { myGui->nextPlayerAnimation(); }
|
||||
void ServerGuiWrapper::nextPlayerAnimation() {}
|
||||
|
||||
void ServerGuiWrapper::preflopAnimation1() { myGui->preflopAnimation1(); }
|
||||
void ServerGuiWrapper::preflopAnimation2() { myGui->preflopAnimation2(); }
|
||||
void ServerGuiWrapper::preflopAnimation1() {}
|
||||
void ServerGuiWrapper::preflopAnimation2() {}
|
||||
|
||||
void ServerGuiWrapper::flopAnimation1() { myGui->flopAnimation1(); }
|
||||
void ServerGuiWrapper::flopAnimation2() { myGui->flopAnimation2(); }
|
||||
void ServerGuiWrapper::flopAnimation1() {}
|
||||
void ServerGuiWrapper::flopAnimation2() {}
|
||||
|
||||
void ServerGuiWrapper::turnAnimation1() { myGui->turnAnimation1(); }
|
||||
void ServerGuiWrapper::turnAnimation2() { myGui->turnAnimation2(); }
|
||||
void ServerGuiWrapper::turnAnimation1() {}
|
||||
void ServerGuiWrapper::turnAnimation2() {}
|
||||
|
||||
void ServerGuiWrapper::riverAnimation1() { myGui->riverAnimation1(); }
|
||||
void ServerGuiWrapper::riverAnimation2() { myGui->riverAnimation2(); }
|
||||
void ServerGuiWrapper::riverAnimation1() {}
|
||||
void ServerGuiWrapper::riverAnimation2() {}
|
||||
|
||||
void ServerGuiWrapper::postRiverAnimation1() { myGui->postRiverAnimation1(); }
|
||||
void ServerGuiWrapper::postRiverRunAnimation1() { myGui->postRiverRunAnimation1(); }
|
||||
void ServerGuiWrapper::postRiverAnimation1() {}
|
||||
void ServerGuiWrapper::postRiverRunAnimation1() {}
|
||||
|
||||
void ServerGuiWrapper::flipHolecardsAllIn() { myGui->flipHolecardsAllIn(); }
|
||||
void ServerGuiWrapper::flipHolecardsAllIn() {}
|
||||
|
||||
void ServerGuiWrapper::nextRoundCleanGui() {}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <guiinterface.h>
|
||||
|
||||
class ConfigFile;
|
||||
class GenericServerGui;
|
||||
class Session;
|
||||
|
||||
class ServerGuiWrapper : public GuiInterface
|
||||
{
|
||||
@@ -35,9 +35,6 @@ public:
|
||||
Session &getSession();
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
|
||||
bool isNetworkServer() const;
|
||||
void waitForNetworkAction(GameState state, unsigned uniquePlayerId);
|
||||
|
||||
void refreshSet() const;
|
||||
void refreshCash() const;
|
||||
void refreshAction(int =-1, int =-1) const;
|
||||
@@ -95,7 +92,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
boost::shared_ptr<GenericServerGui> myGui;
|
||||
boost::shared_ptr<Session> mySession;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
ClientCallback *myClientcb;
|
||||
ServerCallback *myServercb;
|
||||
};
|
||||
|
||||
@@ -39,9 +39,6 @@ public:
|
||||
virtual Session &getSession() =0;
|
||||
virtual void setSession(boost::shared_ptr<Session> session) =0;
|
||||
|
||||
virtual bool isNetworkServer() const =0;
|
||||
virtual void waitForNetworkAction(GameState state, unsigned uniquePlayerId) =0;
|
||||
|
||||
//refresh-Funktionen
|
||||
virtual void refreshSet() const=0;
|
||||
virtual void refreshCash() const=0;
|
||||
|
||||
@@ -47,9 +47,6 @@ void GuiWrapper::initGui(int speed) { myW->initGui(speed); }
|
||||
Session &GuiWrapper::getSession() { return myW->getSession(); }
|
||||
void GuiWrapper::setSession(boost::shared_ptr<Session> session) { myW->setSession(session); }
|
||||
|
||||
bool GuiWrapper::isNetworkServer() const { /* TODO hack */ return false; }
|
||||
void GuiWrapper::waitForNetworkAction(GameState state, unsigned uniquePlayerId) { /* TODO hack */ }
|
||||
|
||||
void GuiWrapper::refreshSet() const { myW->refreshSet(); }
|
||||
void GuiWrapper::refreshCash() const { myW->refreshCash(); }
|
||||
void GuiWrapper::refreshAction(int playerID, int playerAction) const { myW->refreshAction(playerID, playerAction); }
|
||||
|
||||
@@ -42,9 +42,6 @@ public:
|
||||
Session &getSession();
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
|
||||
bool isNetworkServer() const;
|
||||
void waitForNetworkAction(GameState state, unsigned uniquePlayerId);
|
||||
|
||||
void refreshSet() const;
|
||||
void refreshCash() const;
|
||||
void refreshAction(int =-1, int =-1) const;
|
||||
|
||||
@@ -318,6 +318,44 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
assert(playersTurn < curGame.getActualQuantityPlayers());
|
||||
|
||||
boost::shared_ptr<NetPacket> notification(new NetPacketPlayersTurn);
|
||||
NetPacketPlayersTurn::Data playersTurnData;
|
||||
playersTurnData.gameState = (GameState)curGame.getCurrentHand()->getActualRound();
|
||||
playersTurnData.playerId = curGame.getPlayerArray()[playersTurn]->getMyUniqueID();
|
||||
static_cast<NetPacketPlayersTurn *>(notification.get())->SetData(playersTurnData);
|
||||
|
||||
server.SendToAllPlayers(notification);
|
||||
|
||||
server.SetState(ServerRecvStateFinal::Instance());
|
||||
|
||||
|
||||
@@ -144,8 +144,6 @@ ServerRecvThread::NotificationLoop()
|
||||
case NOTIFY_GAME_START:
|
||||
InternalStartGame();
|
||||
break;
|
||||
case NOTIFY_WAIT_FOR_CLIENT_ACTION:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,16 +65,6 @@ ServerThread::StartGame()
|
||||
GetRecvThread().AddNotification(NOTIFY_GAME_START, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
ServerThread::WaitForClientAction(GameState state, unsigned uniquePlayerId)
|
||||
{
|
||||
if (!IsRunning())
|
||||
return; // TODO: throw exception
|
||||
|
||||
// Thread-safe notification.
|
||||
GetRecvThread().AddNotification(NOTIFY_WAIT_FOR_CLIENT_ACTION, state, uniquePlayerId);
|
||||
}
|
||||
|
||||
ServerCallback &
|
||||
ServerThread::GetCallback()
|
||||
{
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
// Notifications
|
||||
#define NOTIFY_GAME_START 1
|
||||
#define NOTIFY_WAIT_FOR_CLIENT_ACTION 2
|
||||
|
||||
class ServerRecvState;
|
||||
class SenderThread;
|
||||
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
void Init(unsigned serverPort, bool ipv6, const std::string &pwd,
|
||||
const GameData &gameData);
|
||||
void StartGame();
|
||||
void WaitForClientAction(GameState state, unsigned uniquePlayerId);
|
||||
|
||||
ServerCallback &GetCallback();
|
||||
GuiInterface &GetGui();
|
||||
|
||||
@@ -160,13 +160,6 @@ void Session::initiateNetworkServerGame()
|
||||
myNetServer->StartGame();
|
||||
}
|
||||
|
||||
void Session::waitForNetworkServerAction(GameState state, unsigned uniquePlayerId)
|
||||
{
|
||||
if (!myNetServer)
|
||||
return; // TODO: throw exception
|
||||
myNetServer->WaitForClientAction(state, uniquePlayerId);
|
||||
}
|
||||
|
||||
void Session::terminateNetworkServer()
|
||||
{
|
||||
if (!myNetServer)
|
||||
|
||||
@@ -49,7 +49,6 @@ public:
|
||||
|
||||
void startNetworkServer(const GameData &gameData);
|
||||
void initiateNetworkServerGame();
|
||||
void waitForNetworkServerAction(GameState state, unsigned uniquePlayerId);
|
||||
void terminateNetworkServer();
|
||||
|
||||
void setCurrentGameID(const int& theValue) { currentGameID = theValue; }
|
||||
|
||||
Reference in New Issue
Block a user