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