Protocol changes for big blind / small blind. GUI Player is now stored in Game.

This commit is contained in:
lotodore
2007-05-20 22:49:07 +00:00
parent 63b278a88e
commit e4039695c0
10 changed files with 40 additions and 27 deletions
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
-2
View File
@@ -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;
+2 -5
View File
@@ -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();
}
}
+4 -4
View File
@@ -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 *
+2 -2
View File
@@ -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);
-2
View File
@@ -120,8 +120,6 @@ public:
struct Data
{
u_int32_t sessionId;
u_int16_t playerId;
u_int16_t playerNumber;
GameData gameData;
};