Fixed networking (LocalHand::getPreflop etc. now return the correct objects). Removed even more code which is no longer needed.

This commit is contained in:
lotodore
2007-08-07 21:17:11 +00:00
parent 03ecc5b9cb
commit 829f094ce8
3 changed files with 8 additions and 78 deletions
+4 -4
View File
@@ -41,10 +41,10 @@ public:
PlayerInterface** getPlayerArray() const { return playerArray; }
BoardInterface* getBoard() const { return myBoard; }
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[actualRound]; }
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[actualRound]; }
boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[actualRound]; }
boost::shared_ptr<BeRoInterface> getRiver() const { return myBeRo[actualRound]; }
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[GAME_STATE_TURN]; }
boost::shared_ptr<BeRoInterface> getRiver() const { return myBeRo[GAME_STATE_RIVER]; }
GuiInterface* getGuiInterface() const { return myGui; }
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const { return myBeRo[actualRound]; }
+4 -72
View File
@@ -47,25 +47,7 @@ using namespace std;
static PlayerInterface *GetCurrentPlayer(Game &curGame)
{
int curPlayerNum = 0;
// TODO: no switch needed here if game states are polymorphic
switch(curGame.getCurrentHand()->getActualRound()) {
case GAME_STATE_PREFLOP: {
curPlayerNum = curGame.getCurrentHand()->getPreflop()->getPlayersTurn();
} break;
case GAME_STATE_FLOP: {
curPlayerNum = curGame.getCurrentHand()->getFlop()->getPlayersTurn();
} break;
case GAME_STATE_TURN: {
curPlayerNum = curGame.getCurrentHand()->getTurn()->getPlayersTurn();
} break;
case GAME_STATE_RIVER: {
curPlayerNum = curGame.getCurrentHand()->getRiver()->getPlayersTurn();
} break;
default: {
//
}
}
int curPlayerNum = curGame.getCurrentHand()->getCurrentBeRo()->getPlayersTurn();
assert(curPlayerNum < curGame.getStartQuantityPlayers()); // TODO: throw exception
return curGame.getPlayerArray()[curPlayerNum];
}
@@ -771,7 +753,7 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
else if (GetTimer().elapsed().total_seconds() >= server.GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC)
{
// Player did not act fast enough. Act for him.
if (GetHighestSet(server.GetGame()) == tmpPlayer->getMySet())
if (server.GetGame().getCurrentHand()->getCurrentBeRo()->getHighestSet() == tmpPlayer->getMySet())
PerformPlayerAction(server, tmpPlayer, PLAYER_ACTION_CHECK, 0);
else
PerformPlayerAction(server, tmpPlayer, PLAYER_ACTION_FOLD, 0);
@@ -821,8 +803,8 @@ ServerRecvStateWaitPlayerAction::PerformPlayerAction(ServerRecvThread &server, P
{
player->setMySet(bet);
if (player->getMySet() > GetHighestSet(curGame))
SetHighestSet(curGame, player->getMySet());
if (player->getMySet() > curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet())
curGame.getCurrentHand()->getCurrentBeRo()->setHighestSet(player->getMySet());
// Update total sets.
curGame.getCurrentHand()->getBoard()->collectSets();
}
@@ -847,56 +829,6 @@ ServerRecvStateWaitPlayerAction::SendPlayerAction(ServerRecvThread &server, Play
server.SendToAllPlayers(notifyActionDone);
}
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: {
//
}
}
}
//-----------------------------------------------------------------------------
ServerRecvStateDealCardsDelay &
-2
View File
@@ -208,8 +208,6 @@ protected:
static void PerformPlayerAction(ServerRecvThread &server, PlayerInterface *player, PlayerAction action, int bet);
static void SendPlayerAction(ServerRecvThread &server, PlayerInterface *player);
static int GetHighestSet(Game &curGame);
static void SetHighestSet(Game &curGame, int highestSet);
};
// State: Delay after dealing cards