Restructured network server.
This commit is contained in:
@@ -318,6 +318,44 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server)
|
||||
Game &curGame = server.GetGame();
|
||||
|
||||
curGame.getCurrentHand()->switchRounds();
|
||||
int playersTurn = 0;
|
||||
|
||||
// TODO: no switch needed here if game states are polymorphic
|
||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
||||
case 0: {
|
||||
// Preflop starten
|
||||
curGame.getCurrentHand()->getPreflop()->preflopRun();
|
||||
playersTurn = curGame.getCurrentHand()->getPreflop()->getPlayersTurn();
|
||||
} break;
|
||||
case 1: {
|
||||
// Flop starten
|
||||
curGame.getCurrentHand()->getFlop()->flopRun();
|
||||
playersTurn = curGame.getCurrentHand()->getFlop()->getPlayersTurn();
|
||||
} break;
|
||||
case 2: {
|
||||
// Turn starten
|
||||
curGame.getCurrentHand()->getTurn()->turnRun();
|
||||
playersTurn = curGame.getCurrentHand()->getTurn()->getPlayersTurn();
|
||||
} break;
|
||||
case 3: {
|
||||
// River starten
|
||||
curGame.getCurrentHand()->getRiver()->riverRun();
|
||||
playersTurn = curGame.getCurrentHand()->getRiver()->getPlayersTurn();
|
||||
} break;
|
||||
default: {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
assert(playersTurn < curGame.getActualQuantityPlayers());
|
||||
|
||||
boost::shared_ptr<NetPacket> notification(new NetPacketPlayersTurn);
|
||||
NetPacketPlayersTurn::Data playersTurnData;
|
||||
playersTurnData.gameState = (GameState)curGame.getCurrentHand()->getActualRound();
|
||||
playersTurnData.playerId = curGame.getPlayerArray()[playersTurn]->getMyUniqueID();
|
||||
static_cast<NetPacketPlayersTurn *>(notification.get())->SetData(playersTurnData);
|
||||
|
||||
server.SendToAllPlayers(notification);
|
||||
|
||||
server.SetState(ServerRecvStateFinal::Instance());
|
||||
|
||||
|
||||
@@ -144,8 +144,6 @@ ServerRecvThread::NotificationLoop()
|
||||
case NOTIFY_GAME_START:
|
||||
InternalStartGame();
|
||||
break;
|
||||
case NOTIFY_WAIT_FOR_CLIENT_ACTION:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,16 +65,6 @@ ServerThread::StartGame()
|
||||
GetRecvThread().AddNotification(NOTIFY_GAME_START, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
ServerThread::WaitForClientAction(GameState state, unsigned uniquePlayerId)
|
||||
{
|
||||
if (!IsRunning())
|
||||
return; // TODO: throw exception
|
||||
|
||||
// Thread-safe notification.
|
||||
GetRecvThread().AddNotification(NOTIFY_WAIT_FOR_CLIENT_ACTION, state, uniquePlayerId);
|
||||
}
|
||||
|
||||
ServerCallback &
|
||||
ServerThread::GetCallback()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user