Preparing network functions to let a player show his cards.
This commit is contained in:
@@ -78,6 +78,7 @@ public:
|
|||||||
void SendResetTimeout();
|
void SendResetTimeout();
|
||||||
void SendAskKickPlayer(unsigned playerId);
|
void SendAskKickPlayer(unsigned playerId);
|
||||||
void SendVoteKick(bool doKick);
|
void SendVoteKick(bool doKick);
|
||||||
|
void SendShowMyCards();
|
||||||
void SendInvitePlayerToCurrentGame(unsigned playerId);
|
void SendInvitePlayerToCurrentGame(unsigned playerId);
|
||||||
void SendRejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason);
|
void SendRejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason);
|
||||||
|
|
||||||
|
|||||||
@@ -310,6 +310,14 @@ ClientThread::SendVoteKick(bool doKick)
|
|||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientThread::SendShowMyCards()
|
||||||
|
{
|
||||||
|
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||||
|
packet->GetMsg()->present = PokerTHMessage_PR_showMyCardsRequestMessage;
|
||||||
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientThread::SendInvitePlayerToCurrentGame(unsigned playerId)
|
ClientThread::SendInvitePlayerToCurrentGame(unsigned playerId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -923,16 +923,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef POKERTH_TEST
|
server->SetState(ServerGameStateWaitNextHand::Instance());
|
||||||
server->GetStateTimer().expires_from_now(
|
|
||||||
boost::posix_time::seconds(0));
|
|
||||||
#else
|
|
||||||
server->GetStateTimer().expires_from_now(
|
|
||||||
boost::posix_time::seconds(server->GetGameData().delayBetweenHandsSec));
|
|
||||||
#endif
|
|
||||||
server->GetStateTimer().async_wait(
|
|
||||||
boost::bind(
|
|
||||||
&ServerGameStateHand::TimerNextHand, this, boost::asio::placeholders::error, server));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1289,6 +1280,74 @@ ServerGameStateWaitPlayerAction::TimerTimeout(const boost::system::error_code &e
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
ServerGameStateWaitNextHand ServerGameStateWaitNextHand::s_state;
|
||||||
|
|
||||||
|
ServerGameStateWaitNextHand &
|
||||||
|
ServerGameStateWaitNextHand::Instance()
|
||||||
|
{
|
||||||
|
return s_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerGameStateWaitNextHand::ServerGameStateWaitNextHand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerGameStateWaitNextHand::~ServerGameStateWaitNextHand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerGameStateWaitNextHand::Enter(boost::shared_ptr<ServerGame> server)
|
||||||
|
{
|
||||||
|
#ifdef SERVER_TEST
|
||||||
|
int timeoutSec = 0;
|
||||||
|
#else
|
||||||
|
int timeoutSec = server->GetGameData().delayBetweenHandsSec;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
server->GetStateTimer().expires_from_now(
|
||||||
|
boost::posix_time::seconds(timeoutSec));
|
||||||
|
|
||||||
|
server->GetStateTimer().async_wait(
|
||||||
|
boost::bind(
|
||||||
|
&ServerGameStateWaitNextHand::TimerTimeout, this, boost::asio::placeholders::error, server));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerGameStateWaitNextHand::Exit(boost::shared_ptr<ServerGame> server)
|
||||||
|
{
|
||||||
|
server->GetStateTimer().cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerGameStateWaitNextHand::HandleNewSession(boost::shared_ptr<ServerGame> server, SessionWrapper session)
|
||||||
|
{
|
||||||
|
// Do not accept new sessions in this state.
|
||||||
|
server->MoveSessionToLobby(session, NTF_NET_REMOVED_ALREADY_RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerGameStateWaitNextHand::InternalProcessPacket(boost::shared_ptr<ServerGame> server, SessionWrapper session, boost::shared_ptr<NetPacket> packet)
|
||||||
|
{
|
||||||
|
if (packet->GetMsg()->present == PokerTHMessage_PR_showMyCardsRequestMessage)
|
||||||
|
{
|
||||||
|
// TODO perform action.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerGameStateWaitNextHand::TimerTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server)
|
||||||
|
{
|
||||||
|
if (!ec && &server->GetState() == this)
|
||||||
|
{
|
||||||
|
ServerGameStateHand::StartNewHand(server);
|
||||||
|
server->SetState(ServerGameStateHand::Instance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ServerGameStateFinal ServerGameStateFinal::s_state;
|
ServerGameStateFinal ServerGameStateFinal::s_state;
|
||||||
|
|
||||||
ServerGameStateFinal &
|
ServerGameStateFinal &
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ friend class ServerGameStateWaitAck;
|
|||||||
friend class ServerGameStateStartGame;
|
friend class ServerGameStateStartGame;
|
||||||
friend class ServerGameStateHand;
|
friend class ServerGameStateHand;
|
||||||
friend class ServerGameStateWaitPlayerAction;
|
friend class ServerGameStateWaitPlayerAction;
|
||||||
|
friend class ServerGameStateWaitNextHand;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ private:
|
|||||||
static ServerGameStateHand s_state;
|
static ServerGameStateHand s_state;
|
||||||
|
|
||||||
friend class ServerGameStateStartGame;
|
friend class ServerGameStateStartGame;
|
||||||
|
friend class ServerGameStateWaitNextHand;
|
||||||
};
|
};
|
||||||
|
|
||||||
// State: Wait for a player action.
|
// State: Wait for a player action.
|
||||||
@@ -178,6 +179,29 @@ private:
|
|||||||
static ServerGameStateWaitPlayerAction s_state;
|
static ServerGameStateWaitPlayerAction s_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// State: Wait for the next hand.
|
||||||
|
class ServerGameStateWaitNextHand : public AbstractServerGameStateReceiving
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static ServerGameStateWaitNextHand &Instance();
|
||||||
|
virtual void Enter(boost::shared_ptr<ServerGame> server);
|
||||||
|
virtual void Exit(boost::shared_ptr<ServerGame> server);
|
||||||
|
|
||||||
|
virtual ~ServerGameStateWaitNextHand();
|
||||||
|
|
||||||
|
virtual void NotifyGameAdminChanged(boost::shared_ptr<ServerGame> /*server*/) {}
|
||||||
|
virtual void HandleNewSession(boost::shared_ptr<ServerGame> server, SessionWrapper session);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ServerGameStateWaitNextHand();
|
||||||
|
|
||||||
|
virtual void InternalProcessPacket(boost::shared_ptr<ServerGame> server, SessionWrapper session, boost::shared_ptr<NetPacket> packet);
|
||||||
|
void TimerTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static ServerGameStateWaitNextHand s_state;
|
||||||
|
};
|
||||||
|
|
||||||
class ServerGameStateFinal : public ServerGameState
|
class ServerGameStateFinal : public ServerGameState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -459,6 +459,13 @@ void Session::voteKick(bool doKick)
|
|||||||
myNetClient->SendVoteKick(doKick);
|
myNetClient->SendVoteKick(doKick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::showMyCards()
|
||||||
|
{
|
||||||
|
if (!myNetClient)
|
||||||
|
return; // only act if client is running.
|
||||||
|
myNetClient->SendShowMyCards();
|
||||||
|
}
|
||||||
|
|
||||||
bool Session::isNetworkClientRunning() const
|
bool Session::isNetworkClientRunning() const
|
||||||
{
|
{
|
||||||
// This, and every place which calls this, is a HACK.
|
// This, and every place which calls this, is a HACK.
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public:
|
|||||||
void kickPlayer(const std::string &playerName);
|
void kickPlayer(const std::string &playerName);
|
||||||
void startVoteKickPlayer(unsigned playerId);
|
void startVoteKickPlayer(unsigned playerId);
|
||||||
void voteKick(bool doKick);
|
void voteKick(bool doKick);
|
||||||
|
void showMyCards();
|
||||||
void selectServer(unsigned serverId);
|
void selectServer(unsigned serverId);
|
||||||
void setLogin(const std::string &userName, const std::string &password, bool isGuest);
|
void setLogin(const std::string &userName, const std::string &password, bool isGuest);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user