Let the server send cards on request of the corresponding user.
This commit is contained in:
@@ -60,12 +60,13 @@ public:
|
||||
virtual void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg) = 0;
|
||||
virtual void SignalNetClientMsgBox(const std::string &msg) = 0;
|
||||
virtual void SignalNetClientWaitDialog() = 0;
|
||||
|
||||
|
||||
virtual void SignalNetClientServerListAdd(unsigned serverId) = 0;
|
||||
virtual void SignalNetClientServerListClear() = 0;
|
||||
virtual void SignalNetClientServerListShow() = 0;
|
||||
|
||||
virtual void SignalNetClientLoginShow() = 0;
|
||||
virtual void SignalNetClientPostRiverShowCards(unsigned playerId) = 0;
|
||||
|
||||
virtual void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName) = 0;
|
||||
virtual void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) = 0;
|
||||
|
||||
@@ -1718,6 +1718,29 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
||||
client->SetState(ClientStateWaitGame::Instance());
|
||||
}
|
||||
}
|
||||
else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_afterHandShowCardsMessage)
|
||||
{
|
||||
AfterHandShowCardsMessage_t *showCards = &tmpPacket->GetMsg()->choice.afterHandShowCardsMessage;
|
||||
PlayerResult_t *r = &showCards->playerResult;
|
||||
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = client->GetGame()->getPlayerByUniqueId(r->playerId);
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
|
||||
int tmpCards[2];
|
||||
int bestHandPos[5];
|
||||
tmpCards[0] = static_cast<int>(r->resultCard1);
|
||||
tmpCards[1] = static_cast<int>(r->resultCard2);
|
||||
tmpPlayer->setMyCards(tmpCards);
|
||||
for (int num = 0; num < 5; num++)
|
||||
bestHandPos[num] = *r->bestHandPosition.list.array[num];
|
||||
tmpPlayer->setMyCardsValueInt(r->cardsValue);
|
||||
tmpPlayer->setMyBestHandPosition(bestHandPos);
|
||||
tmpPlayer->setMyCash(r->playerMoney);
|
||||
tmpPlayer->setLastMoneyWon(r->moneyWon);
|
||||
|
||||
client->GetCallback().SignalNetClientPostRiverShowCards(r->playerId);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -134,6 +134,12 @@ ServerGame::SendToAllPlayers(boost::shared_ptr<NetPacket> packet, SessionData::S
|
||||
GetSessionManager().SendToAllSessions(GetLobbyThread().GetSender(), packet, state);
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::SendToAllButOnePlayers(boost::shared_ptr<NetPacket> packet, SessionId except, SessionData::State state)
|
||||
{
|
||||
GetSessionManager().SendToAllButOneSessions(GetLobbyThread().GetSender(), packet, except, state);
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::RemoveAllSessions()
|
||||
{
|
||||
|
||||
@@ -170,6 +170,28 @@ static void PerformPlayerAction(ServerGame &server, boost::shared_ptr<PlayerInte
|
||||
SendPlayerAction(server, player);
|
||||
}
|
||||
|
||||
static void
|
||||
SetPlayerResult(PlayerResult_t &playerResult, boost::shared_ptr<PlayerInterface> tmpPlayer)
|
||||
{
|
||||
playerResult.playerId = tmpPlayer->getMyUniqueID();
|
||||
int tmpCards[2];
|
||||
int bestHandPos[5];
|
||||
tmpPlayer->getMyCards(tmpCards);
|
||||
playerResult.resultCard1 = tmpCards[0];
|
||||
playerResult.resultCard2 = tmpCards[1];
|
||||
tmpPlayer->getMyBestHandPosition(bestHandPos);
|
||||
for (int num = 0; num < 5; num++)
|
||||
{
|
||||
long *handPos = (long *)calloc(1, sizeof(long));
|
||||
*handPos = bestHandPos[num];
|
||||
ASN_SEQUENCE_ADD(&playerResult.bestHandPosition.list, handPos);
|
||||
}
|
||||
|
||||
playerResult.cardsValue = tmpPlayer->getMyCardsValueInt();
|
||||
playerResult.moneyWon = tmpPlayer->getLastMoneyWon();
|
||||
playerResult.playerMoney = tmpPlayer->getMyCash();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ServerGameState::~ServerGameState()
|
||||
@@ -876,23 +898,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
||||
while (i != end)
|
||||
{
|
||||
PlayerResult_t *playerResult = (PlayerResult_t *)calloc(1, sizeof(PlayerResult_t));
|
||||
playerResult->playerId = (*i)->getMyUniqueID();
|
||||
int tmpCards[2];
|
||||
int bestHandPos[5];
|
||||
(*i)->getMyCards(tmpCards);
|
||||
playerResult->resultCard1 = tmpCards[0];
|
||||
playerResult->resultCard2 = tmpCards[1];
|
||||
(*i)->getMyBestHandPosition(bestHandPos);
|
||||
for (int num = 0; num < 5; num++)
|
||||
{
|
||||
long *handPos = (long *)calloc(1, sizeof(long));
|
||||
*handPos = bestHandPos[num];
|
||||
ASN_SEQUENCE_ADD(&playerResult->bestHandPosition.list, handPos);
|
||||
}
|
||||
|
||||
playerResult->cardsValue = (*i)->getMyCardsValueInt();
|
||||
playerResult->moneyWon = (*i)->getLastMoneyWon();
|
||||
playerResult->playerMoney = (*i)->getMyCash();
|
||||
SetPlayerResult(*playerResult, (*i));
|
||||
|
||||
ASN_SEQUENCE_ADD(&endHandShow->playerResults.list, playerResult);
|
||||
++i;
|
||||
@@ -1332,7 +1338,16 @@ ServerGameStateWaitNextHand::InternalProcessPacket(boost::shared_ptr<ServerGame>
|
||||
{
|
||||
if (packet->GetMsg()->present == PokerTHMessage_PR_showMyCardsRequestMessage)
|
||||
{
|
||||
// TODO perform action.
|
||||
Game &curGame = server->GetGame();
|
||||
boost::shared_ptr<NetPacket> show(new NetPacket(NetPacket::Alloc));
|
||||
show->GetMsg()->present = PokerTHMessage_PR_afterHandShowCardsMessage;
|
||||
|
||||
AfterHandShowCardsMessage_t *netShowCards = &packet->GetMsg()->choice.afterHandShowCardsMessage;
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer(curGame.getPlayerByUniqueId(session.playerData->GetUniqueId()));
|
||||
if (tmpPlayer)
|
||||
SetPlayerResult(netShowCards->playerResult, tmpPlayer);
|
||||
|
||||
server->SendToAllButOnePlayers(show, session.sessionData->GetId(), SessionData::Game);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ public:
|
||||
GameState GetCurRound() const;
|
||||
|
||||
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet, SessionData::State state);
|
||||
void RemoveAllSessions();
|
||||
void SendToAllButOnePlayers(boost::shared_ptr<NetPacket> packet, SessionId except, SessionData::State state);
|
||||
void RemoveAllSessions();
|
||||
|
||||
bool IsPasswordProtected() const;
|
||||
bool CheckPassword(const std::string &password) const;
|
||||
|
||||
Reference in New Issue
Block a user