Fixed GUI refresh. Added calls to setHighestSet.
This commit is contained in:
@@ -56,11 +56,11 @@ public:
|
||||
void setMyCash(int theValue) { myCash = theValue; }
|
||||
int getMyCash() const { return myCash; }
|
||||
|
||||
void setMySet(int theValue) { myLastRelativeSet = theValue; mySet += theValue; myCash -= theValue; }
|
||||
void setMySetAbsolute(int theValue) { mySet = theValue; }
|
||||
void setMySetNull() { mySet = 0; }
|
||||
int getMySet() const { return mySet;}
|
||||
int getMyLastRelativeSet() const { return myLastRelativeSet; }
|
||||
void setMySet(int theValue) { myLastRelativeSet = theValue; mySet += theValue; myCash -= theValue; }
|
||||
void setMySetAbsolute(int theValue) { mySet = theValue; }
|
||||
void setMySetNull() { mySet = 0; }
|
||||
int getMySet() const { return mySet;}
|
||||
int getMyLastRelativeSet() const { return myLastRelativeSet; }
|
||||
|
||||
void setMyAction(int theValue) { myAction = theValue; }
|
||||
int getMyAction() const { return myAction; }
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
class ClientThread;
|
||||
class ClientCallback;
|
||||
class ResolverThread;
|
||||
class Game;
|
||||
|
||||
class ClientState
|
||||
{
|
||||
@@ -235,6 +236,11 @@ protected:
|
||||
|
||||
// Protected constructor - this is a singleton.
|
||||
ClientStateRunHand();
|
||||
|
||||
static int GetHighestSet(Game &curGame);
|
||||
static void SetHighestSet(Game &curGame, int highestSet);
|
||||
static int GetPlayersTurn(Game &curGame);
|
||||
static void SetPlayersTurn(Game &curGame, int playersTurn);
|
||||
};
|
||||
|
||||
// State: Final (TODO).
|
||||
|
||||
+115
-19
@@ -573,9 +573,19 @@ ClientStateRunHand::Process(ClientThread &client)
|
||||
tmpPlayer->setMyCash(actionDoneData.playerMoney);
|
||||
curGame->getCurrentHand()->getBoard()->setPot(actionDoneData.potSize);
|
||||
curGame->getCurrentHand()->getBoard()->setSets(actionDoneData.curHandBets);
|
||||
|
||||
// Update highest set
|
||||
if (tmpPlayer->getMySet() > GetHighestSet(*curGame))
|
||||
SetHighestSet(*curGame, tmpPlayer->getMySet());
|
||||
|
||||
// Unmark last player in GUI.
|
||||
client.GetGui().refreshGroupbox(tmpPlayer->getMyID(), 3);
|
||||
|
||||
// Refresh GUI
|
||||
client.GetGui().refreshSet();
|
||||
client.GetGui().refreshPot();
|
||||
client.GetGui().refreshAction();
|
||||
client.GetGui().refreshCash();
|
||||
}
|
||||
else if (tmpPacket->ToNetPacketPlayersTurn())
|
||||
{
|
||||
@@ -588,26 +598,15 @@ ClientStateRunHand::Process(ClientThread &client)
|
||||
curGame->getCurrentHand()->setActualRound(turnData.gameState);
|
||||
|
||||
// Next player's turn.
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(turnData.gameState) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
curGame->getCurrentHand()->getPreflop()->setPlayersTurn(tmpPlayer->getMyID());
|
||||
} break;
|
||||
case GAME_STATE_FLOP: {
|
||||
curGame->getCurrentHand()->getFlop()->setPlayersTurn(tmpPlayer->getMyID());
|
||||
} break;
|
||||
case GAME_STATE_TURN: {
|
||||
curGame->getCurrentHand()->getTurn()->setPlayersTurn(tmpPlayer->getMyID());
|
||||
} break;
|
||||
case GAME_STATE_RIVER: {
|
||||
curGame->getCurrentHand()->getRiver()->setPlayersTurn(tmpPlayer->getMyID());
|
||||
} break;
|
||||
default: {
|
||||
//
|
||||
}
|
||||
}
|
||||
SetPlayersTurn(*curGame, tmpPlayer->getMyID());
|
||||
|
||||
client.GetGui().nextPlayerAnimation();
|
||||
// Mark current player in GUI.
|
||||
int guiStatus = 2;
|
||||
if (!tmpPlayer->getMyActiveStatus())
|
||||
guiStatus = 0;
|
||||
else if (tmpPlayer->getMyAction() == PLAYER_ACTION_FOLD)
|
||||
guiStatus = 1;
|
||||
client.GetGui().refreshGroupbox(tmpPlayer->getMyID(), guiStatus);
|
||||
|
||||
if (tmpPlayer->getMyID() == 0) // Is this the GUI player?
|
||||
client.GetGui().meInAction();
|
||||
@@ -617,6 +616,103 @@ ClientStateRunHand::Process(ClientThread &client)
|
||||
return MSG_SOCK_INTERNAL_PENDING;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ClientStateRunHand::GetHighestSet(Game &curGame)
|
||||
{
|
||||
int highestSet = 0;
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
highestSet = curGame.getCurrentHand()->getPreflop()->getHighestSet();
|
||||
} break;
|
||||
case GAME_STATE_FLOP: {
|
||||
highestSet = curGame.getCurrentHand()->getFlop()->getHighestSet();
|
||||
} break;
|
||||
case GAME_STATE_TURN: {
|
||||
highestSet = curGame.getCurrentHand()->getTurn()->getHighestSet();
|
||||
} break;
|
||||
case GAME_STATE_RIVER: {
|
||||
highestSet = curGame.getCurrentHand()->getRiver()->getHighestSet();
|
||||
} break;
|
||||
default: {
|
||||
//
|
||||
}
|
||||
}
|
||||
return highestSet;
|
||||
}
|
||||
|
||||
void
|
||||
ClientStateRunHand::SetHighestSet(Game &curGame, int highestSet)
|
||||
{
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
curGame.getCurrentHand()->getPreflop()->setHighestSet(highestSet);
|
||||
} break;
|
||||
case GAME_STATE_FLOP: {
|
||||
curGame.getCurrentHand()->getFlop()->setHighestSet(highestSet);
|
||||
} break;
|
||||
case GAME_STATE_TURN: {
|
||||
curGame.getCurrentHand()->getTurn()->setHighestSet(highestSet);
|
||||
} break;
|
||||
case GAME_STATE_RIVER: {
|
||||
curGame.getCurrentHand()->getRiver()->setHighestSet(highestSet);
|
||||
} break;
|
||||
default: {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ClientStateRunHand::GetPlayersTurn(Game &curGame)
|
||||
{
|
||||
int playersTurn = 0;
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
playersTurn = curGame.getCurrentHand()->getPreflop()->getPlayersTurn();
|
||||
} break;
|
||||
case GAME_STATE_FLOP: {
|
||||
playersTurn = curGame.getCurrentHand()->getFlop()->getPlayersTurn();
|
||||
} break;
|
||||
case GAME_STATE_TURN: {
|
||||
playersTurn = curGame.getCurrentHand()->getTurn()->getPlayersTurn();
|
||||
} break;
|
||||
case GAME_STATE_RIVER: {
|
||||
playersTurn = curGame.getCurrentHand()->getRiver()->getPlayersTurn();
|
||||
} break;
|
||||
default: {
|
||||
//
|
||||
}
|
||||
}
|
||||
return playersTurn;
|
||||
}
|
||||
|
||||
void
|
||||
ClientStateRunHand::SetPlayersTurn(Game &curGame, int playersTurn)
|
||||
{
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
curGame.getCurrentHand()->getPreflop()->setPlayersTurn(playersTurn);
|
||||
} break;
|
||||
case GAME_STATE_FLOP: {
|
||||
curGame.getCurrentHand()->getFlop()->setPlayersTurn(playersTurn);
|
||||
} break;
|
||||
case GAME_STATE_TURN: {
|
||||
curGame.getCurrentHand()->getTurn()->setPlayersTurn(playersTurn);
|
||||
} break;
|
||||
case GAME_STATE_RIVER: {
|
||||
curGame.getCurrentHand()->getRiver()->setPlayersTurn(playersTurn);
|
||||
} break;
|
||||
default: {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ClientStateFinal &
|
||||
|
||||
@@ -500,6 +500,9 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
|
||||
tmpPlayer->setMyAction(actionData.playerAction);
|
||||
tmpPlayer->setMySet(actionData.playerBet);
|
||||
|
||||
if (tmpPlayer->getMySet() > GetHighestSet(curGame))
|
||||
SetHighestSet(curGame, tmpPlayer->getMySet());
|
||||
|
||||
boost::shared_ptr<NetPacket> notifyActionDone(new NetPacketPlayersActionDone);
|
||||
NetPacketPlayersActionDone::Data actionDoneData;
|
||||
actionDoneData.gameState = static_cast<GameState>(curGame.getCurrentHand()->getActualRound());
|
||||
@@ -521,6 +524,54 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int
|
||||
ServerRecvStateWaitPlayerAction::GetHighestSet(Game &curGame)
|
||||
{
|
||||
int highestSet = 0;
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
highestSet = curGame.getCurrentHand()->getPreflop()->getHighestSet();
|
||||
} break;
|
||||
case GAME_STATE_FLOP: {
|
||||
highestSet = curGame.getCurrentHand()->getFlop()->getHighestSet();
|
||||
} break;
|
||||
case GAME_STATE_TURN: {
|
||||
highestSet = curGame.getCurrentHand()->getTurn()->getHighestSet();
|
||||
} break;
|
||||
case GAME_STATE_RIVER: {
|
||||
highestSet = curGame.getCurrentHand()->getRiver()->getHighestSet();
|
||||
} break;
|
||||
default: {
|
||||
//
|
||||
}
|
||||
}
|
||||
return highestSet;
|
||||
}
|
||||
|
||||
void
|
||||
ServerRecvStateWaitPlayerAction::SetHighestSet(Game &curGame, int highestSet)
|
||||
{
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
curGame.getCurrentHand()->getPreflop()->setHighestSet(highestSet);
|
||||
} break;
|
||||
case GAME_STATE_FLOP: {
|
||||
curGame.getCurrentHand()->getFlop()->setHighestSet(highestSet);
|
||||
} break;
|
||||
case GAME_STATE_TURN: {
|
||||
curGame.getCurrentHand()->getTurn()->setHighestSet(highestSet);
|
||||
} break;
|
||||
case GAME_STATE_RIVER: {
|
||||
curGame.getCurrentHand()->getRiver()->setHighestSet(highestSet);
|
||||
} break;
|
||||
default: {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ServerRecvStateFinal &
|
||||
|
||||
@@ -135,8 +135,8 @@ protected:
|
||||
// Protected constructor - this is a singleton.
|
||||
ServerRecvStateStartRound();
|
||||
|
||||
void GameRun(Game &curGame, int state);
|
||||
PlayerInterface *GetCurrentPlayer(Game &curGame);
|
||||
static void GameRun(Game &curGame, int state);
|
||||
static PlayerInterface *GetCurrentPlayer(Game &curGame);
|
||||
};
|
||||
|
||||
// State: Wait for a player action.
|
||||
@@ -155,6 +155,9 @@ protected:
|
||||
|
||||
// Protected constructor - this is a singleton.
|
||||
ServerRecvStateWaitPlayerAction();
|
||||
|
||||
static int GetHighestSet(Game &curGame);
|
||||
static void SetHighestSet(Game &curGame, int highestSet);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user