Added packet type to start a "Hand". Added generic gui for the server.
This commit is contained in:
+14
-3
@@ -111,6 +111,17 @@ Server Notification: Game Start
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Message Type = 5 | Message Length = 8 |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Reserved |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
|
||||
Server Notification: Hand Start
|
||||
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Message Type = 6 | Message Length = 8 |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Your 1st Card | Your 2nd Card |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
@@ -123,7 +134,7 @@ Server Request/Notification: Player's Turn
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Message Type = 6 | Message Length = 8 |
|
||||
| Message Type = 7 | Message Length = 8 |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Game State | Player ID |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
@@ -140,7 +151,7 @@ Client Reply/Request: Player's Action
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Message Type = 7 | Message Length = 12 |
|
||||
| Message Type = 8 | Message Length = 12 |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Game State | Player Action |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
@@ -165,7 +176,7 @@ Server Reply: Player's Action Rejected
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Message Type = 8 | Message Length = 16 |
|
||||
| Message Type = 9 | Message Length = 16 |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Game State | Player Action |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
+24
-20
@@ -40,15 +40,15 @@ DEPENDPATH += . \
|
||||
src/engine/local_engine \
|
||||
src/gui/qt \
|
||||
src/net/common \
|
||||
src/gui/qt/mainwindow \
|
||||
src/gui/qt/mainwindow/startsplash \
|
||||
src/gui/qt/mainwindow \
|
||||
src/gui/qt/mainwindow/startsplash \
|
||||
src/gui/qt/aboutpokerth \
|
||||
src/gui/qt/connecttoserverdialog \
|
||||
src/gui/qt/createnetworkgamedialog \
|
||||
src/gui/qt/joinnetworkgamedialog \
|
||||
src/gui/qt/log \
|
||||
src/gui/qt/qttools \
|
||||
src/gui/qt/qttools/qthelper \
|
||||
src/gui/qt/qttools \
|
||||
src/gui/qt/qttools/qthelper \
|
||||
src/gui/qt/newlocalgamedialog \
|
||||
src/gui/qt/settingsdialog \
|
||||
src/gui/qt/startnetworkgamedialog \
|
||||
@@ -95,9 +95,9 @@ HEADERS += src/game.h \
|
||||
src/engine/local_engine/localriver.h \
|
||||
src/engine/local_engine/localturn.h \
|
||||
src/engine/local_engine/tools.h \
|
||||
src/gui/qt/mainwindow/mainwindowimpl.h \
|
||||
src/gui/qt/mainwindow/mainwindowimpl.h \
|
||||
src/gui/qt/mainwindow/mycardspixmaplabel.h \
|
||||
src/gui/qt/mainwindow/startsplash/startsplash.h \
|
||||
src/gui/qt/mainwindow/startsplash/startsplash.h \
|
||||
src/gui/qt/guiwrapper.h \
|
||||
src/gui/qt/aboutpokerth/aboutpokerthimpl.h \
|
||||
src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.h \
|
||||
@@ -108,11 +108,13 @@ HEADERS += src/game.h \
|
||||
src/gui/qt/settingsdialog/settingsdialogimpl.h \
|
||||
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h \
|
||||
src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.h \
|
||||
src/gui/qttoolsinterface.h \
|
||||
src/gui/qt/qttools/qttoolswrapper.h \
|
||||
src/gui/qt/qttools/qthelper/qthelper.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
|
||||
FORMS += src/gui/qt/mainwindow.ui \
|
||||
src/gui/qt/aboutpokerth.ui \
|
||||
src/gui/qt/aboutpokerth.ui \
|
||||
src/gui/qt/connecttoserverdialog.ui \
|
||||
src/gui/qt/createnetworkgamedialog.ui \
|
||||
src/gui/qt/joinnetworkgamedialog.ui \
|
||||
@@ -171,9 +173,9 @@ SOURCES += src/game.cpp \
|
||||
src/net/common/netexception.cpp \
|
||||
src/net/common/receiverhelper.cpp \
|
||||
src/gui/qt/guiwrapper.cpp \
|
||||
src/gui/qt/mainwindow/mainwindowimpl.cpp \
|
||||
src/gui/qt/mainwindow/mainwindowimpl.cpp \
|
||||
src/gui/qt/mainwindow/mycardspixmaplabel.cpp \
|
||||
src/gui/qt/mainwindow/startsplash/startsplash.cpp \
|
||||
src/gui/qt/mainwindow/startsplash/startsplash.cpp \
|
||||
src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp \
|
||||
src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.cpp \
|
||||
src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp \
|
||||
@@ -184,17 +186,19 @@ SOURCES += src/game.cpp \
|
||||
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp \
|
||||
src/gui/qt/waitforservertostartgamedialog/waitforservertostartgamedialogimpl.cpp \
|
||||
src/gui/qttoolsinterface.cpp \
|
||||
src/gui/qt/qttools/qttoolswrapper.cpp \
|
||||
src/gui/qt/qttools/qthelper/qthelper.cpp
|
||||
src/gui/qt/qttools/qttoolswrapper.cpp \
|
||||
src/gui/qt/qttools/qthelper/qthelper.cpp \
|
||||
src/gui/generic/serverguiwrapper.cpp \
|
||||
src/gui/generic/genericservergui.cpp
|
||||
RESOURCES += src/gui/qt/resources.qrc
|
||||
TRANSLATIONS = ts/pokerth_de.ts \
|
||||
ts/pokerth_es.ts \
|
||||
ts/pokerth_it.ts \
|
||||
ts/pokerth_it.ts \
|
||||
ts/pokerth_fr.ts \
|
||||
ts/pokerth_se.ts \
|
||||
ts/pokerth_pt.ts \
|
||||
ts/pokerth_tr.ts \
|
||||
ts/pokerth_nl.ts
|
||||
ts/pokerth_se.ts \
|
||||
ts/pokerth_pt.ts \
|
||||
ts/pokerth_tr.ts \
|
||||
ts/pokerth_nl.ts
|
||||
CODECFORSRC = UTF-8
|
||||
|
||||
TEMPLATE = vcapp
|
||||
@@ -214,7 +218,7 @@ win32{
|
||||
DEPENDPATH += src/net/linux/ src/core/linux
|
||||
SOURCES += src/core/linux/rand.cpp \
|
||||
src/net/linux/socket_helper.cpp \
|
||||
src/net/linux/socket_startup.cpp
|
||||
src/net/linux/socket_startup.cpp
|
||||
}
|
||||
|
||||
unix{
|
||||
|
||||
+35
-35
@@ -1,40 +1,40 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by FThauer FHammer *
|
||||
* f.thauer@web.de *
|
||||
* *
|
||||
* 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 GAME_DEFS_H
|
||||
#define GAME_DEFS_H
|
||||
|
||||
#define MAX_NUMBER_OF_PLAYERS 7
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by FThauer FHammer *
|
||||
* f.thauer@web.de *
|
||||
* *
|
||||
* 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 GAME_DEFS_H
|
||||
#define GAME_DEFS_H
|
||||
|
||||
#define MAX_NUMBER_OF_PLAYERS 7
|
||||
|
||||
enum GameState {
|
||||
GAME_STATE_PREFLOP = 0,
|
||||
GAME_STATE_FLOP,
|
||||
GAME_STATE_TURN,
|
||||
GAME_STATE_RIVER };
|
||||
|
||||
enum PlayerAction {
|
||||
PLAYER_ACTION_NONE = 0,
|
||||
PLAYER_ACTION_FOLD,
|
||||
PLAYER_ACTION_CHECK,
|
||||
PLAYER_ACTION_CALL,
|
||||
PLAYER_ACTION_BET,
|
||||
PLAYER_ACTION_RAISE,
|
||||
PLAYER_ACTION_ALLIN };
|
||||
|
||||
#endif
|
||||
|
||||
enum PlayerAction {
|
||||
PLAYER_ACTION_NONE = 0,
|
||||
PLAYER_ACTION_FOLD,
|
||||
PLAYER_ACTION_CHECK,
|
||||
PLAYER_ACTION_CALL,
|
||||
PLAYER_ACTION_BET,
|
||||
PLAYER_ACTION_RAISE,
|
||||
PLAYER_ACTION_ALLIN };
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* 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"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
GenericServerGui::GenericServerGui(ConfigFile *config)
|
||||
: myConfig(config)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GenericServerGui::~GenericServerGui()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericServerGui::initGui(int speed)
|
||||
{
|
||||
}
|
||||
|
||||
Session &GenericServerGui::getSession()
|
||||
{
|
||||
return *mySession;
|
||||
}
|
||||
|
||||
void GenericServerGui::setSession(boost::shared_ptr<Session> session)
|
||||
{
|
||||
mySession = session;
|
||||
}
|
||||
|
||||
void GenericServerGui::waitForNetworkAction(GameState state, unsigned uniquePlayerId)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
* 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);
|
||||
|
||||
private:
|
||||
|
||||
boost::shared_ptr<Session> mySession;
|
||||
ConfigFile *myConfig;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,122 @@
|
||||
/***************************************************************************
|
||||
* 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 "serverguiwrapper.h"
|
||||
#include "genericservergui.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ServerGuiWrapper::ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb)
|
||||
: myClientcb(clientcb), myServercb(servercb)
|
||||
{
|
||||
myGui.reset(new GenericServerGui(config));
|
||||
}
|
||||
|
||||
ServerGuiWrapper::~ServerGuiWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::initGui(int speed) {}
|
||||
|
||||
Session &ServerGuiWrapper::getSession()
|
||||
{
|
||||
return myGui->getSession();
|
||||
}
|
||||
|
||||
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 */
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::refreshSet() const {}
|
||||
|
||||
void ServerGuiWrapper::refreshCash() const {}
|
||||
|
||||
void ServerGuiWrapper::refreshAction(int playerID, int playerAction) const {}
|
||||
|
||||
void ServerGuiWrapper::refreshChangePlayer() const {}
|
||||
|
||||
void ServerGuiWrapper::refreshAll() const {}
|
||||
|
||||
void ServerGuiWrapper::refreshPot() const {}
|
||||
void ServerGuiWrapper::refreshGroupbox(int playerID, int status) const {}
|
||||
void ServerGuiWrapper::refreshPlayerName() const {}
|
||||
|
||||
void ServerGuiWrapper::dealHoleCards() const {}
|
||||
void ServerGuiWrapper::dealFlopCards() const {}
|
||||
void ServerGuiWrapper::dealTurnCard() const {}
|
||||
void ServerGuiWrapper::dealRiverCard() const {}
|
||||
|
||||
void ServerGuiWrapper::highlightRoundLabel(string round) const {}
|
||||
|
||||
|
||||
void ServerGuiWrapper::nextPlayerAnimation() const {}
|
||||
|
||||
void ServerGuiWrapper::preflopAnimation1() const {}
|
||||
void ServerGuiWrapper::preflopAnimation2() const {}
|
||||
|
||||
void ServerGuiWrapper::flopAnimation1() const {}
|
||||
void ServerGuiWrapper::flopAnimation2() const {}
|
||||
|
||||
void ServerGuiWrapper::turnAnimation1() const {}
|
||||
void ServerGuiWrapper::turnAnimation2() const {}
|
||||
|
||||
void ServerGuiWrapper::riverAnimation1() const {}
|
||||
void ServerGuiWrapper::riverAnimation2() const {}
|
||||
|
||||
void ServerGuiWrapper::postRiverAnimation1() const {}
|
||||
void ServerGuiWrapper::postRiverRunAnimation1() const {}
|
||||
|
||||
void ServerGuiWrapper::flipHolecardsAllIn() const {}
|
||||
|
||||
void ServerGuiWrapper::nextRoundCleanGui() const {}
|
||||
|
||||
void ServerGuiWrapper::meInAction() const {}
|
||||
|
||||
void ServerGuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) {}
|
||||
void ServerGuiWrapper::logNewGameHandMsg(int gameID, int handID) {}
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); }
|
||||
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); }
|
||||
void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerJoined(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerName); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerLeft(const string &playerName) { if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerName); }
|
||||
void ServerGuiWrapper::SignalNetClientGameStart(const GameData &gameData) { if (myClientcb) myClientcb->SignalNetClientGameStart(gameData); }
|
||||
|
||||
void ServerGuiWrapper::SignalNetServerSuccess(int actionID) { if (myServercb) myServercb->SignalNetServerSuccess(actionID); }
|
||||
void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID) { if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID); }
|
||||
void ServerGuiWrapper::SignalNetServerPlayerJoined(const string &playerName) { if (myServercb) myServercb->SignalNetServerPlayerJoined(playerName); }
|
||||
void ServerGuiWrapper::SignalNetServerPlayerLeft(const string &playerName) { if (myServercb) myServercb->SignalNetServerPlayerLeft(playerName); }
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
* 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 SERVERGUIWRAPPER_H
|
||||
#define SERVERGUIWRAPPER_H
|
||||
|
||||
#include <guiinterface.h>
|
||||
|
||||
class ConfigFile;
|
||||
class GenericServerGui;
|
||||
|
||||
class ServerGuiWrapper : public GuiInterface
|
||||
{
|
||||
public:
|
||||
ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb);
|
||||
~ServerGuiWrapper();
|
||||
|
||||
void initGui(int speed);
|
||||
|
||||
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;
|
||||
void refreshChangePlayer() const;
|
||||
void refreshPot() const;
|
||||
void refreshGroupbox(int =-1, int =-1) const;
|
||||
void refreshAll() const;
|
||||
void refreshPlayerName() const;
|
||||
|
||||
void dealHoleCards() const;
|
||||
void dealFlopCards() const;
|
||||
void dealTurnCard() const;
|
||||
void dealRiverCard() const;
|
||||
|
||||
void highlightRoundLabel(std::string round) const;
|
||||
|
||||
void nextPlayerAnimation() const;
|
||||
|
||||
void preflopAnimation1() const;
|
||||
void preflopAnimation2() const;
|
||||
|
||||
void flopAnimation1() const;
|
||||
void flopAnimation2() const;
|
||||
|
||||
void turnAnimation1() const;
|
||||
void turnAnimation2() const;
|
||||
|
||||
void riverAnimation1() const;
|
||||
void riverAnimation2() const;
|
||||
|
||||
void postRiverAnimation1() const;
|
||||
void postRiverRunAnimation1() const;
|
||||
|
||||
void flipHolecardsAllIn() const;
|
||||
|
||||
void nextRoundCleanGui() const;
|
||||
|
||||
void meInAction() const;
|
||||
|
||||
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
|
||||
void logNewGameHandMsg(int gameID, int handID) ;
|
||||
|
||||
void SignalNetClientConnect(int actionID);
|
||||
void SignalNetClientGameInfo(int actionID);
|
||||
void SignalNetClientError(int errorID, int osErrorID);
|
||||
void SignalNetClientPlayerJoined(const std::string &playerName);
|
||||
void SignalNetClientPlayerLeft(const std::string &playerName);
|
||||
|
||||
void SignalNetClientGameStart(const GameData &gameData);
|
||||
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
void SignalNetServerError(int errorID, int osErrorID);
|
||||
void SignalNetServerPlayerJoined(const std::string &playerName);
|
||||
void SignalNetServerPlayerLeft(const std::string &playerName);
|
||||
|
||||
private:
|
||||
|
||||
boost::shared_ptr<GenericServerGui> myGui;
|
||||
ClientCallback *myClientcb;
|
||||
ServerCallback *myServercb;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
#include "guiwrapper.h"
|
||||
#include "session.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "mainwindowimpl.h"
|
||||
#include "configfile.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -22,15 +22,13 @@
|
||||
|
||||
#include <guiinterface.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "mainwindowimpl.h"
|
||||
#include "connecttoserverdialogimpl.h"
|
||||
#include "configfile.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
class Session;
|
||||
class mainWindowImpl;
|
||||
class Log;
|
||||
class ConfigFile;
|
||||
|
||||
class GuiWrapper : public GuiInterface
|
||||
{
|
||||
@@ -102,8 +100,8 @@ public:
|
||||
void SignalNetServerPlayerJoined(const std::string &playerName);
|
||||
void SignalNetServerPlayerLeft(const std::string &playerName);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
|
||||
Log *myLog;
|
||||
mainWindowImpl *myW;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
@@ -32,9 +32,10 @@ using namespace std;
|
||||
#define NET_TYPE_PLAYER_JOINED 0x0003
|
||||
#define NET_TYPE_PLAYER_LEFT 0x0004
|
||||
#define NET_TYPE_GAME_START 0x0005
|
||||
#define NET_TYPE_PLAYERS_TURN 0x0006
|
||||
#define NET_TYPE_PLAYERS_ACTION 0x0007
|
||||
#define NET_TYPE_PLAYERS_ACTION_REJECTED 0x0008
|
||||
#define NET_TYPE_HAND_START 0x0006
|
||||
#define NET_TYPE_PLAYERS_TURN 0x0007
|
||||
#define NET_TYPE_PLAYERS_ACTION 0x0008
|
||||
#define NET_TYPE_PLAYERS_ACTION_REJECTED 0x0009
|
||||
|
||||
#define NET_TYPE_ERROR 0x0400
|
||||
|
||||
@@ -112,6 +113,12 @@ struct NetPacketPlayerLeftData
|
||||
};
|
||||
|
||||
struct NetPacketGameStartData
|
||||
{
|
||||
NetPacketHeader head;
|
||||
u_int32_t reserved;
|
||||
};
|
||||
|
||||
struct NetPacketHandStartData
|
||||
{
|
||||
NetPacketHeader head;
|
||||
u_int16_t yourCards[2];
|
||||
@@ -192,6 +199,9 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
||||
case NET_TYPE_GAME_START:
|
||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketGameStart);
|
||||
break;
|
||||
case NET_TYPE_HAND_START:
|
||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketHandStart);
|
||||
break;
|
||||
case NET_TYPE_PLAYERS_TURN:
|
||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketPlayersTurn);
|
||||
break;
|
||||
@@ -315,6 +325,12 @@ NetPacket::ToNetPacketGameStart() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const NetPacketHandStart *
|
||||
NetPacket::ToNetPacketHandStart() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const NetPacketPlayersTurn *
|
||||
NetPacket::ToNetPacketPlayersTurn() const
|
||||
{
|
||||
@@ -744,8 +760,7 @@ NetPacketGameStart::SetData(const NetPacketGameStart::Data &inData)
|
||||
NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData();
|
||||
assert(tmpData);
|
||||
|
||||
tmpData->yourCards[0] = htons(inData.yourCards[0]);
|
||||
tmpData->yourCards[1] = htons(inData.yourCards[1]);
|
||||
tmpData->reserved = htonl(inData.reserved);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -754,8 +769,7 @@ NetPacketGameStart::GetData(NetPacketGameStart::Data &outData) const
|
||||
NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData();
|
||||
assert(tmpData);
|
||||
|
||||
outData.yourCards[0] = ntohs(tmpData->yourCards[0]);
|
||||
outData.yourCards[1] = ntohs(tmpData->yourCards[1]);
|
||||
outData.reserved = ntohl(tmpData->reserved);
|
||||
}
|
||||
|
||||
const NetPacketGameStart *
|
||||
@@ -774,8 +788,71 @@ NetPacketGameStart::Check(const NetPacketHeader* data) const
|
||||
{
|
||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
||||
}
|
||||
}
|
||||
|
||||
NetPacketGameStartData *tmpData = (NetPacketGameStartData *)GetRawData();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NetPacketHandStart::NetPacketHandStart()
|
||||
: NetPacket(NET_TYPE_GAME_START, sizeof(NetPacketGameStartData))
|
||||
{
|
||||
}
|
||||
|
||||
NetPacketHandStart::~NetPacketHandStart()
|
||||
{
|
||||
}
|
||||
|
||||
boost::shared_ptr<NetPacket>
|
||||
NetPacketHandStart::Clone() const
|
||||
{
|
||||
boost::shared_ptr<NetPacket> newPacket(new NetPacketHandStart);
|
||||
try
|
||||
{
|
||||
newPacket->SetRawData(GetRawData());
|
||||
} catch (const NetException &)
|
||||
{
|
||||
// Need to return the new packet anyway.
|
||||
}
|
||||
return newPacket;
|
||||
}
|
||||
|
||||
void
|
||||
NetPacketHandStart::SetData(const NetPacketHandStart::Data &inData)
|
||||
{
|
||||
NetPacketHandStartData *tmpData = (NetPacketHandStartData *)GetRawData();
|
||||
assert(tmpData);
|
||||
|
||||
tmpData->yourCards[0] = htons(inData.yourCards[0]);
|
||||
tmpData->yourCards[1] = htons(inData.yourCards[1]);
|
||||
}
|
||||
|
||||
void
|
||||
NetPacketHandStart::GetData(NetPacketHandStart::Data &outData) const
|
||||
{
|
||||
NetPacketHandStartData *tmpData = (NetPacketHandStartData *)GetRawData();
|
||||
assert(tmpData);
|
||||
|
||||
outData.yourCards[0] = ntohs(tmpData->yourCards[0]);
|
||||
outData.yourCards[1] = ntohs(tmpData->yourCards[1]);
|
||||
}
|
||||
|
||||
const NetPacketHandStart *
|
||||
NetPacketHandStart::ToNetPacketHandStart() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void
|
||||
NetPacketHandStart::Check(const NetPacketHeader* data) const
|
||||
{
|
||||
assert(data);
|
||||
|
||||
u_int16_t dataLen = ntohs(data->length);
|
||||
if (dataLen < sizeof(NetPacketHandStartData))
|
||||
{
|
||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
||||
}
|
||||
|
||||
NetPacketHandStartData *tmpData = (NetPacketHandStartData *)GetRawData();
|
||||
if (ntohs(tmpData->yourCards[0]) > 51 || ntohs(tmpData->yourCards[1]) > 51)
|
||||
{
|
||||
throw NetException(ERR_SOCK_INVALID_PACKET, 0);
|
||||
|
||||
+26
-1
@@ -42,6 +42,7 @@ class NetPacketJoinGameAck;
|
||||
class NetPacketPlayerJoined;
|
||||
class NetPacketPlayerLeft;
|
||||
class NetPacketGameStart;
|
||||
class NetPacketHandStart;
|
||||
class NetPacketPlayersTurn;
|
||||
class NetPacketPlayersAction;
|
||||
class NetPacketPlayersActionRejected;
|
||||
@@ -69,6 +70,7 @@ public:
|
||||
virtual const NetPacketPlayerJoined *ToNetPacketPlayerJoined() const;
|
||||
virtual const NetPacketPlayerLeft *ToNetPacketPlayerLeft() const;
|
||||
virtual const NetPacketGameStart *ToNetPacketGameStart() const;
|
||||
virtual const NetPacketHandStart *ToNetPacketHandStart() const;
|
||||
virtual const NetPacketPlayersTurn *ToNetPacketPlayersTurn() const;
|
||||
virtual const NetPacketPlayersAction *ToNetPacketPlayersAction() const;
|
||||
virtual const NetPacketPlayersActionRejected *ToNetPacketPlayersActionRejected() const;
|
||||
@@ -192,7 +194,7 @@ class NetPacketGameStart : public NetPacket
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
u_int16_t yourCards[2];
|
||||
u_int32_t reserved;
|
||||
};
|
||||
|
||||
NetPacketGameStart();
|
||||
@@ -210,6 +212,29 @@ protected:
|
||||
virtual void Check(const NetPacketHeader* data) const;
|
||||
};
|
||||
|
||||
class NetPacketHandStart : public NetPacket
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
u_int16_t yourCards[2];
|
||||
};
|
||||
|
||||
NetPacketHandStart();
|
||||
virtual ~NetPacketHandStart();
|
||||
|
||||
virtual boost::shared_ptr<NetPacket> Clone() const;
|
||||
|
||||
void SetData(const Data &inData);
|
||||
void GetData(Data &outData) const;
|
||||
|
||||
virtual const NetPacketHandStart *ToNetPacketHandStart() const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void Check(const NetPacketHeader* data) const;
|
||||
};
|
||||
|
||||
class NetPacketPlayersTurn : public NetPacket
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
#include "configfile.h"
|
||||
#include <net/socket_startup.h>
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtCore>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user