Trying to bring life to the server.

This commit is contained in:
lotodore
2007-05-14 12:40:42 +00:00
parent 7540ea17bd
commit 2d894c6a2c
16 changed files with 279 additions and 102 deletions
+66
View File
@@ -19,6 +19,7 @@
#include "genericservergui.h"
#include <session.h>
#include <game.h>
using namespace std;
@@ -53,3 +54,68 @@ void GenericServerGui::waitForNetworkAction(GameState state, unsigned uniquePlay
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()
{
}
+24
View File
@@ -39,6 +39,30 @@ public:
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;
+18 -18
View File
@@ -74,36 +74,36 @@ 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::dealHoleCards() { myGui->dealHoleCards(); }
void ServerGuiWrapper::dealFlopCards() { myGui->dealFlopCards(); }
void ServerGuiWrapper::dealTurnCard() { myGui->dealTurnCard(); }
void ServerGuiWrapper::dealRiverCard() { myGui->dealRiverCard(); }
void ServerGuiWrapper::highlightRoundLabel(string round) const {}
void ServerGuiWrapper::nextPlayerAnimation() const {}
void ServerGuiWrapper::nextPlayerAnimation() { myGui->nextPlayerAnimation(); }
void ServerGuiWrapper::preflopAnimation1() const {}
void ServerGuiWrapper::preflopAnimation2() const {}
void ServerGuiWrapper::preflopAnimation1() { myGui->preflopAnimation1(); }
void ServerGuiWrapper::preflopAnimation2() { myGui->preflopAnimation2(); }
void ServerGuiWrapper::flopAnimation1() const {}
void ServerGuiWrapper::flopAnimation2() const {}
void ServerGuiWrapper::flopAnimation1() { myGui->flopAnimation1(); }
void ServerGuiWrapper::flopAnimation2() { myGui->flopAnimation2(); }
void ServerGuiWrapper::turnAnimation1() const {}
void ServerGuiWrapper::turnAnimation2() const {}
void ServerGuiWrapper::turnAnimation1() { myGui->turnAnimation1(); }
void ServerGuiWrapper::turnAnimation2() { myGui->turnAnimation2(); }
void ServerGuiWrapper::riverAnimation1() const {}
void ServerGuiWrapper::riverAnimation2() const {}
void ServerGuiWrapper::riverAnimation1() { myGui->riverAnimation1(); }
void ServerGuiWrapper::riverAnimation2() { myGui->riverAnimation2(); }
void ServerGuiWrapper::postRiverAnimation1() const {}
void ServerGuiWrapper::postRiverRunAnimation1() const {}
void ServerGuiWrapper::postRiverAnimation1() { myGui->postRiverAnimation1(); }
void ServerGuiWrapper::postRiverRunAnimation1() { myGui->postRiverRunAnimation1(); }
void ServerGuiWrapper::flipHolecardsAllIn() const {}
void ServerGuiWrapper::flipHolecardsAllIn() { myGui->flipHolecardsAllIn(); }
void ServerGuiWrapper::nextRoundCleanGui() const {}
void ServerGuiWrapper::nextRoundCleanGui() {}
void ServerGuiWrapper::meInAction() const {}
void ServerGuiWrapper::meInAction() {}
void ServerGuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) {}
void ServerGuiWrapper::logNewGameHandMsg(int gameID, int handID) {}
+18 -18
View File
@@ -47,35 +47,35 @@ public:
void refreshAll() const;
void refreshPlayerName() const;
void dealHoleCards() const;
void dealFlopCards() const;
void dealTurnCard() const;
void dealRiverCard() const;
void dealHoleCards();
void dealFlopCards();
void dealTurnCard();
void dealRiverCard();
void highlightRoundLabel(std::string round) const;
void nextPlayerAnimation() const;
void nextPlayerAnimation();
void preflopAnimation1() const;
void preflopAnimation2() const;
void preflopAnimation1();
void preflopAnimation2();
void flopAnimation1() const;
void flopAnimation2() const;
void flopAnimation1();
void flopAnimation2();
void turnAnimation1() const;
void turnAnimation2() const;
void turnAnimation1();
void turnAnimation2();
void riverAnimation1() const;
void riverAnimation2() const;
void riverAnimation1();
void riverAnimation2();
void postRiverAnimation1() const;
void postRiverRunAnimation1() const;
void postRiverAnimation1();
void postRiverRunAnimation1();
void flipHolecardsAllIn() const;
void flipHolecardsAllIn();
void nextRoundCleanGui() const;
void nextRoundCleanGui();
void meInAction() const;
void meInAction();
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ;
+19 -19
View File
@@ -58,40 +58,40 @@ public:
// virtual void refreshCash() const=0;
// // Karten-Funktionen
virtual void dealHoleCards() const=0;
virtual void dealFlopCards() const=0;
virtual void dealTurnCard() const=0;
virtual void dealRiverCard() const=0;
virtual void dealHoleCards()=0;
virtual void dealFlopCards()=0;
virtual void dealTurnCard()=0;
virtual void dealRiverCard()=0;
virtual void highlightRoundLabel(std::string) const=0;
virtual void nextPlayerAnimation() const=0;
virtual void nextPlayerAnimation()=0;
virtual void preflopAnimation1() const=0;
virtual void preflopAnimation2() const=0;
virtual void preflopAnimation1()=0;
virtual void preflopAnimation2()=0;
virtual void flopAnimation1() const=0;
virtual void flopAnimation2() const=0;
virtual void flopAnimation1()=0;
virtual void flopAnimation2()=0;
virtual void turnAnimation1() const=0;
virtual void turnAnimation2() const=0;
virtual void turnAnimation1()=0;
virtual void turnAnimation2()=0;
virtual void riverAnimation1() const=0;
virtual void riverAnimation2() const=0;
virtual void riverAnimation1()=0;
virtual void riverAnimation2()=0;
virtual void postRiverAnimation1() const=0;
virtual void postRiverRunAnimation1() const=0;
// virtual void postRiverAnimation2() const=0;
virtual void flipHolecardsAllIn() const=0;
virtual void postRiverAnimation1()=0;
virtual void postRiverRunAnimation1()=0;
// virtual void postRiverAnimation2()=0;
virtual void flipHolecardsAllIn()=0;
// virtual void handSwitchRounds() const=0;
//
// virtual void startNewHand() const=0;
virtual void nextRoundCleanGui() const=0;
virtual void nextRoundCleanGui()=0;
//
// virtual void userWidgetsBackgroudColor() const=0;
// virtual void timerBlockerFalse() const=0;
virtual void meInAction() const=0;
virtual void meInAction()=0;
//log.cpp
+18 -18
View File
@@ -59,36 +59,36 @@ void GuiWrapper::refreshPot() const { myW->refreshPot(); }
void GuiWrapper::refreshGroupbox(int playerID, int status) const { myW->refreshGroupbox(playerID, status); }
void GuiWrapper::refreshPlayerName() const { myW->refreshPlayerName(); }
void GuiWrapper::dealHoleCards() const { myW->dealHoleCards(); }
void GuiWrapper::dealFlopCards() const { myW->dealFlopCards0(); }
void GuiWrapper::dealTurnCard() const { myW->dealTurnCards0(); }
void GuiWrapper::dealRiverCard() const { myW->dealRiverCards0(); }
void GuiWrapper::dealHoleCards() { myW->dealHoleCards(); }
void GuiWrapper::dealFlopCards() { myW->dealFlopCards0(); }
void GuiWrapper::dealTurnCard() { myW->dealTurnCards0(); }
void GuiWrapper::dealRiverCard() { myW->dealRiverCards0(); }
void GuiWrapper::highlightRoundLabel(string round) const { myW->highlightRoundLabel(round); }
void GuiWrapper::nextPlayerAnimation() const { myW->nextPlayerAnimation(); }
void GuiWrapper::nextPlayerAnimation() { myW->nextPlayerAnimation(); }
void GuiWrapper::preflopAnimation1() const { myW->preflopAnimation1(); }
void GuiWrapper::preflopAnimation2() const { myW->preflopAnimation2(); }
void GuiWrapper::preflopAnimation1() { myW->preflopAnimation1(); }
void GuiWrapper::preflopAnimation2() { myW->preflopAnimation2(); }
void GuiWrapper::flopAnimation1() const { myW->flopAnimation1(); }
void GuiWrapper::flopAnimation2() const { myW->flopAnimation2(); }
void GuiWrapper::flopAnimation1() { myW->flopAnimation1(); }
void GuiWrapper::flopAnimation2() { myW->flopAnimation2(); }
void GuiWrapper::turnAnimation1() const { myW->turnAnimation1(); }
void GuiWrapper::turnAnimation2() const { myW->turnAnimation2(); }
void GuiWrapper::turnAnimation1() { myW->turnAnimation1(); }
void GuiWrapper::turnAnimation2() { myW->turnAnimation2(); }
void GuiWrapper::riverAnimation1() const { myW->riverAnimation1(); }
void GuiWrapper::riverAnimation2() const { myW->riverAnimation2(); }
void GuiWrapper::riverAnimation1() { myW->riverAnimation1(); }
void GuiWrapper::riverAnimation2() { myW->riverAnimation2(); }
void GuiWrapper::postRiverAnimation1() const { myW->postRiverAnimation1(); }
void GuiWrapper::postRiverRunAnimation1() const { myW->postRiverRunAnimation1(); }
void GuiWrapper::postRiverAnimation1() { myW->postRiverAnimation1(); }
void GuiWrapper::postRiverRunAnimation1() { myW->postRiverRunAnimation1(); }
void GuiWrapper::flipHolecardsAllIn() const { myW->flipHolecardsAllIn(); }
void GuiWrapper::flipHolecardsAllIn() { myW->flipHolecardsAllIn(); }
void GuiWrapper::nextRoundCleanGui() const { myW->nextRoundCleanGui(); }
void GuiWrapper::nextRoundCleanGui() { myW->nextRoundCleanGui(); }
void GuiWrapper::meInAction() const { myW->meInAction(); }
void GuiWrapper::meInAction() { myW->meInAction(); }
void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->logPlayerActionMsg(playerName, action, setValue); }
void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->logNewGameHandMsg(gameID, handID); }
+18 -18
View File
@@ -54,35 +54,35 @@ public:
void refreshAll() const;
void refreshPlayerName() const;
void dealHoleCards() const;
void dealFlopCards() const;
void dealTurnCard() const;
void dealRiverCard() const;
void dealHoleCards();
void dealFlopCards();
void dealTurnCard();
void dealRiverCard();
void highlightRoundLabel(std::string round) const;
void nextPlayerAnimation() const;
void nextPlayerAnimation();
void preflopAnimation1() const;
void preflopAnimation2() const;
void preflopAnimation1();
void preflopAnimation2();
void flopAnimation1() const;
void flopAnimation2() const;
void flopAnimation1();
void flopAnimation2();
void turnAnimation1() const;
void turnAnimation2() const;
void turnAnimation1();
void turnAnimation2();
void riverAnimation1() const;
void riverAnimation2() const;
void riverAnimation1();
void riverAnimation2();
void postRiverAnimation1() const;
void postRiverRunAnimation1() const;
void postRiverAnimation1();
void postRiverRunAnimation1();
void flipHolecardsAllIn() const;
void flipHolecardsAllIn();
void nextRoundCleanGui() const;
void nextRoundCleanGui();
void meInAction() const;
void meInAction();
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
void logNewGameHandMsg(int gameID, int handID) ;
+21 -7
View File
@@ -40,6 +40,7 @@
#include "log.h"
#include "configfile.h"
#include <generic/serverguiwrapper.h>
#include <net/socket_msg.h>
@@ -594,7 +595,8 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) {
// Start new local game - terminate existing network game.
mySession->terminateNetworkClient();
mySession->terminateNetworkServer();
if (myServerGuiInterface.get())
myServerGuiInterface->getSession().terminateNetworkServer();
//get values from local game dialog
GameData gameData;
@@ -630,8 +632,19 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
//
if (myCreateNetworkGameDialog->result() == QDialog::Accepted ) {
if (!myServerGuiInterface.get())
{
// Create pseudo Gui Wrapper for the server.
myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui()));
{
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
myServerGuiInterface->setSession(session);
}
}
// Terminate existing network games.
mySession->terminateNetworkClient();
mySession->terminateNetworkServer();
myServerGuiInterface->getSession().terminateNetworkServer();
GameData gameData;
gameData.numberOfPlayers = myCreateNetworkGameDialog->spinBox_quantityPlayers->value();
@@ -641,8 +654,8 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value();
myStartNetworkGameDialog->treeWidget->clear();
mySession->startNetworkServer(gameData);
myServerGuiInterface->getSession().startNetworkServer(gameData);
mySession->startNetworkClientForLocalServer();
myStartNetworkGameDialog->exec();
@@ -650,11 +663,11 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
if (myStartNetworkGameDialog->result() == QDialog::Accepted ) {
mySession->initiateNetworkServerGame();
myServerGuiInterface->getSession().initiateNetworkServerGame();
}
else {
mySession->terminateNetworkClient();
mySession->terminateNetworkServer();
myServerGuiInterface->getSession().terminateNetworkServer();
}
}
@@ -667,7 +680,8 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
if (myJoinNetworkGameDialog->result() == QDialog::Accepted ) {
mySession->terminateNetworkClient();
mySession->terminateNetworkServer();
if (myServerGuiInterface.get())
myServerGuiInterface->getSession().terminateNetworkServer();
myWaitingForServerGameDialog->treeWidget->clear();
// Maybe use QUrl::toPunycode.
+3 -1
View File
@@ -35,6 +35,7 @@ class Log;
class ConfigFile;
class Session;
class GuiInterface;
class BoardInterface;
// class HandInterface;
class PlayerInterface;
@@ -199,7 +200,8 @@ public slots:
void networkStart(int, int, int, int);
private:
boost::shared_ptr<GuiInterface> myServerGuiInterface;
boost::shared_ptr<Session> mySession;
Log *myLog;
ConfigFile *myConfig;
+42 -1
View File
@@ -28,6 +28,7 @@
#include <gamedata.h>
#include <game.h>
#include <playerinterface.h>
#include <handinterface.h>
using namespace std;
@@ -258,10 +259,12 @@ ServerRecvStateStartHand::Process(ServerRecvThread &server)
{
boost::shared_ptr<NetPacket> answer(new NetPacketHandStart);
// Initialize hand.
Game &curGame = server.GetGame();
curGame.initHand();
PlayerInterface **playerArray = curGame.getPlayerArray();
// Send cards to all players.
for (int i = 0; i < curGame.getActualQuantityPlayers(); i++)
{
if (playerArray[i]->getNetSessionData().get())
@@ -278,13 +281,51 @@ ServerRecvStateStartHand::Process(ServerRecvThread &server)
}
}
server.SetState(ServerRecvStateFinal::Instance());
// Start hand.
curGame.startHand();
server.SetState(ServerRecvStateStartRound::Instance());
return MSG_NET_GAME_SERVER_HAND;
}
//-----------------------------------------------------------------------------
ServerRecvStateStartRound &
ServerRecvStateStartRound::Instance()
{
static ServerRecvStateStartRound state;
return state;
}
ServerRecvStateStartRound::ServerRecvStateStartRound()
{
}
ServerRecvStateStartRound::~ServerRecvStateStartRound()
{
}
void
ServerRecvStateStartRound::HandleNewConnection(ServerRecvThread &server, boost::shared_ptr<ConnectData> connData)
{
// TODO: send error msg
}
int
ServerRecvStateStartRound::Process(ServerRecvThread &server)
{
Game &curGame = server.GetGame();
curGame.getCurrentHand()->switchRounds();
server.SetState(ServerRecvStateFinal::Instance());
return MSG_NET_GAME_SERVER_ROUND;
}
//-----------------------------------------------------------------------------
ServerRecvStateFinal &
ServerRecvStateFinal::Instance()
{
+21
View File
@@ -109,6 +109,27 @@ protected:
ServerRecvStateStartHand();
};
// State: Start new round.
class ServerRecvStateStartRound : public ServerRecvState
{
public:
// Access the state singleton.
static ServerRecvStateStartRound &Instance();
virtual ~ServerRecvStateStartRound();
//
virtual void HandleNewConnection(ServerRecvThread &server, boost::shared_ptr<ConnectData> data);
//
virtual int Process(ServerRecvThread &server);
protected:
// Protected constructor - this is a singleton.
ServerRecvStateStartRound();
};
// State: Final.
class ServerRecvStateFinal : public ServerRecvState
{
+1
View File
@@ -159,6 +159,7 @@ private:
friend class ServerRecvStateInit;
friend class ServerRecvStateStartGame;
friend class ServerRecvStateStartHand;
friend class ServerRecvStateStartRound;
};
#endif
+1
View File
@@ -65,6 +65,7 @@
#define MSG_NET_GAME_SERVER_START 6
#define MSG_NET_GAME_CLIENT_HAND 7
#define MSG_NET_GAME_SERVER_HAND 8
#define MSG_NET_GAME_SERVER_ROUND 10
#endif
+2 -2
View File
@@ -89,9 +89,9 @@ int main( int argc, char **argv )
a.installTranslator(&translator);
///////////////////////////////////////////////////
GuiInterface *myGuiInterface = new GuiWrapper(myConfig);
boost::shared_ptr<GuiInterface> myGuiInterface(new GuiWrapper(myConfig));
{
boost::shared_ptr<Session> session(new Session(myGuiInterface, myConfig));
boost::shared_ptr<Session> session(new Session(myGuiInterface.get(), myConfig));
myGuiInterface->setSession(session);
}
+5
View File
@@ -93,6 +93,11 @@ Game *Session::getCurrentGame()
return currentGame;
}
GuiInterface *Session::getGui()
{
return myGui;
}
void Session::startNetworkClient(const string &serverAddress, unsigned serverPort, bool ipv6, const string &pwd)
{
if (myNetClient || !myGui)
+2
View File
@@ -41,6 +41,8 @@ public:
Game *getCurrentGame();
GuiInterface *getGui();
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, const std::string &pwd);
void startNetworkClientForLocalServer();
void terminateNetworkClient();