/// <summary> /// Starts the game with given game parameters. /// </summary> /// <param name="param">Incomplete parameters of the game (missing player order information).</param> public void StartGame(GameParameters parameters) { // Change the state CurrentState = ServerState.IN_GAME; StateChanged.Invoke(CurrentState); // If resuming, game execution is already in progress if (_Loaded) { Socket.SendToAll(new ServerResponse() { Type = ServerResponseType.GAME_HISTORY }); foreach (var rsp in _LoadedResponses) { Socket.SendToAll(rsp); } Socket.SendToAll(new ServerResponse() { Type = ServerResponseType.GAME_RESUME }); // Start the file writer if (_History != null) { _History._PlayerNames = parameters.PlayerOrder.Select(x => PlayersNames[x]).ToArray(); _History.Start(); } return; } lock (MessageHandlerThread) { // Make random order Random rnd = new Random(); parameters.PlayerOrder = PlayersInGame.Keys.OrderBy(a => rnd.Next()).ToArray(); // Start the file writer if (_History != null) { _History._PlayerNames = parameters.PlayerOrder.Select(x => PlayersNames[x]).ToArray(); _History.Start(); } // Start the game Executor.CurrentGameState = new GameState(); Executor.StartGame(parameters); } }