Protocol changes for big blind / small blind. GUI Player is now stored in Game.
This commit is contained in:
+22
-5
@@ -116,6 +116,9 @@ Server Notification: Game Start
|
||||
|
||||
[ Dealer Pos can be different for each game, therefore it is not
|
||||
transmitted in Join Game ACK. ]
|
||||
[ It is not necessary to transmit the Dealer Pos, because the server
|
||||
decides which player's turn it is. This is only for fast and simple
|
||||
GUI display. ]
|
||||
|
||||
|
||||
Server Notification: Hand Start
|
||||
@@ -143,10 +146,12 @@ Server Request/Notification: Player's Turn
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
Game State:
|
||||
0 - Preflop
|
||||
1 - Flop
|
||||
2 - Turn
|
||||
3 - River
|
||||
0xF0 - Preflop Small Blind (no action requested)
|
||||
0xF1 - Preflop Big Blind (no action requested)
|
||||
0x00 - Preflop
|
||||
0x01 - Flop
|
||||
0x02 - Turn
|
||||
0x03 - River
|
||||
|
||||
|
||||
Client Reply/Request: Player's Action
|
||||
@@ -173,13 +178,25 @@ Cash Value:
|
||||
0 - states fold, check, call, all in
|
||||
> 0 - states bet, raise
|
||||
|
||||
Server Reply/Notification: Player's Action Done
|
||||
|
||||
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 = 9 | Message Length = 12 |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Game State | Player Action |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Cash Value |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
|
||||
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 = 9 | Message Length = 16 |
|
||||
| Message Type = 10 | Message Length = 16 |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Game State | Player Action |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
startQuantityPlayers(gameData.numberOfPlayers),
|
||||
startCash(gameData.startCash), startSmallBlind(gameData.smallBlind),
|
||||
startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise),
|
||||
myGameID(gameId), actualQuantityPlayers(gameData.numberOfPlayers),
|
||||
myGameID(gameId), guiPlayerNum(gameData.guiPlayerNum), actualQuantityPlayers(gameData.numberOfPlayers),
|
||||
actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(startData.startDealerPos)
|
||||
{
|
||||
// cout << "Create Game Object" << "\n";
|
||||
|
||||
+3
-4
@@ -63,10 +63,8 @@ public:
|
||||
|
||||
int getDealerPosition() const { return dealerPosition; }
|
||||
|
||||
void setMyGameID(const int& theValue) { myGameID = theValue;}
|
||||
int getMyGameID() const { return myGameID; }
|
||||
|
||||
|
||||
int getGuiPlayerNum() const { return guiPlayerNum; }
|
||||
|
||||
//Zufgriff Laufvariablen
|
||||
void setActualQuantityPlayers(const int& theValue) { actualQuantityPlayers = theValue; }
|
||||
@@ -85,7 +83,7 @@ private:
|
||||
GuiInterface *myGui;
|
||||
HandInterface *actualHand;
|
||||
BoardInterface *actualBoard;
|
||||
PlayerInterface *playerArray[7];
|
||||
PlayerInterface *playerArray[MAX_NUMBER_OF_PLAYERS];
|
||||
|
||||
//Startvariablen
|
||||
int startQuantityPlayers;
|
||||
@@ -93,6 +91,7 @@ private:
|
||||
int startSmallBlind;
|
||||
int startHandsBeforeRaiseSmallBlind;
|
||||
int myGameID;
|
||||
int guiPlayerNum;
|
||||
|
||||
//Laufvariablen
|
||||
int actualQuantityPlayers;
|
||||
|
||||
+3
-1
@@ -26,7 +26,9 @@ enum GameState {
|
||||
GAME_STATE_PREFLOP = 0,
|
||||
GAME_STATE_FLOP,
|
||||
GAME_STATE_TURN,
|
||||
GAME_STATE_RIVER };
|
||||
GAME_STATE_RIVER,
|
||||
GAME_STATE_PREFLOP_SMALL_BLIND = 0xF0,
|
||||
GAME_STATE_PREFLOP_BIG_BLIND = 0xF1 };
|
||||
|
||||
enum PlayerAction {
|
||||
PLAYER_ACTION_NONE = 0,
|
||||
|
||||
+3
-1
@@ -26,12 +26,14 @@
|
||||
struct GameData
|
||||
{
|
||||
GameData() : numberOfPlayers(0), startCash(0), smallBlind(0),
|
||||
handsBeforeRaise(1), guiSpeed(4) {}
|
||||
handsBeforeRaise(1), guiSpeed(4), guiPlayerNum(0), guiPlayerUniqueId(0) {}
|
||||
int numberOfPlayers;
|
||||
int startCash;
|
||||
int smallBlind;
|
||||
int handsBeforeRaise;
|
||||
int guiSpeed;
|
||||
int guiPlayerNum;
|
||||
unsigned guiPlayerUniqueId;
|
||||
};
|
||||
|
||||
struct StartData
|
||||
|
||||
@@ -82,8 +82,6 @@ protected:
|
||||
void RemovePlayerData(unsigned playerId);
|
||||
const PlayerDataList &GetPlayerDataList() const;
|
||||
|
||||
int m_myPlayerNum; // TODO: Hack
|
||||
|
||||
private:
|
||||
|
||||
std::auto_ptr<ClientContext> m_context;
|
||||
|
||||
@@ -392,12 +392,9 @@ ClientStateWaitSession::Process(ClientThread &client)
|
||||
tmpPacket->ToNetPacketJoinGameAck()->GetData(joinGameAckData);
|
||||
client.SetGameData(joinGameAckData.gameData);
|
||||
|
||||
// TODO: Hack
|
||||
client.m_myPlayerNum = joinGameAckData.playerNumber;
|
||||
|
||||
// TODO: Type Human is fixed here.
|
||||
boost::shared_ptr<PlayerData> playerData(
|
||||
new PlayerData(joinGameAckData.playerId, joinGameAckData.playerNumber, PLAYER_TYPE_HUMAN));
|
||||
new PlayerData(joinGameAckData.gameData.guiPlayerUniqueId, joinGameAckData.gameData.guiPlayerNum, PLAYER_TYPE_HUMAN));
|
||||
playerData->SetName(context.GetPlayerName());
|
||||
client.AddPlayerData(playerData);
|
||||
|
||||
@@ -515,7 +512,7 @@ ClientStateWaitHand::Process(ClientThread &client)
|
||||
int myCards[2];
|
||||
myCards[0] = (int)tmpData.yourCards[0];
|
||||
myCards[1] = (int)tmpData.yourCards[1];
|
||||
client.GetGame()->getPlayerArray()[client.m_myPlayerNum]->setMyCards(myCards);
|
||||
client.GetGame()->getPlayerArray()[client.GetGame()->getGuiPlayerNum()]->setMyCards(myCards);
|
||||
client.GetGui().dealHoleCards();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,13 +528,13 @@ NetPacketJoinGameAck::SetData(const NetPacketJoinGameAck::Data &inData)
|
||||
assert(tmpData);
|
||||
|
||||
tmpData->sessionId = htonl(inData.sessionId);
|
||||
tmpData->playerId = htons(inData.playerId);
|
||||
tmpData->playerNumber = htons(inData.playerNumber);
|
||||
tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers);
|
||||
tmpData->smallBlind = htons(inData.gameData.smallBlind);
|
||||
tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise);
|
||||
tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed);
|
||||
tmpData->startCash = htonl(inData.gameData.startCash);
|
||||
tmpData->playerId = htons(inData.gameData.guiPlayerUniqueId);
|
||||
tmpData->playerNumber = htons(inData.gameData.guiPlayerNum);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -544,13 +544,13 @@ NetPacketJoinGameAck::GetData(NetPacketJoinGameAck::Data &outData) const
|
||||
assert(tmpData);
|
||||
|
||||
outData.sessionId = ntohl(tmpData->sessionId);
|
||||
outData.playerId = ntohs(tmpData->playerId);
|
||||
outData.playerNumber = ntohs(tmpData->playerNumber);
|
||||
outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers);
|
||||
outData.gameData.smallBlind = ntohs(tmpData->smallBlind);
|
||||
outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
|
||||
outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
|
||||
outData.gameData.startCash = ntohl(tmpData->startCash);
|
||||
outData.gameData.guiPlayerUniqueId = ntohs(tmpData->playerId);
|
||||
outData.gameData.guiPlayerNum = ntohs(tmpData->playerNumber);
|
||||
}
|
||||
|
||||
const NetPacketJoinGameAck *
|
||||
|
||||
@@ -153,10 +153,10 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
|
||||
// Send ACK to client.
|
||||
boost::shared_ptr<NetPacket> answer(new NetPacketJoinGameAck);
|
||||
NetPacketJoinGameAck::Data joinGameAckData;
|
||||
joinGameAckData.playerId = tmpPlayerData->GetUniqueId();
|
||||
joinGameAckData.playerNumber = tmpPlayerData->GetNumber();
|
||||
joinGameAckData.sessionId = session.sessionData->GetId(); // TODO: currently unused.
|
||||
joinGameAckData.gameData = server.GetGameData();
|
||||
joinGameAckData.gameData.guiPlayerUniqueId = tmpPlayerData->GetUniqueId();
|
||||
joinGameAckData.gameData.guiPlayerNum = tmpPlayerData->GetNumber();
|
||||
static_cast<NetPacketJoinGameAck *>(answer.get())->SetData(joinGameAckData);
|
||||
server.GetSender().Send(recvSock, answer);
|
||||
|
||||
|
||||
@@ -120,8 +120,6 @@ public:
|
||||
struct Data
|
||||
{
|
||||
u_int32_t sessionId;
|
||||
u_int16_t playerId;
|
||||
u_int16_t playerNumber;
|
||||
GameData gameData;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user