Ejemplo n.º 1
0
        private static List <Message> HandleJoinGameMessage(JoinGameMessage joinGameMessage, string userId)
        {
            var result = new List <Message>();

            Player player = (Player)AbstractPlayers.FirstOrDefault(p => p.Id == userId);

            if (player == null)
            {
                Logger.Write($"Cannot find player with id {userId} in connected players", LogLevel.Error);
            }
            else
            {
                GameManager.JoinGame(joinGameMessage.GameId, player);
                var message = new JoinGameMessage(joinGameMessage.GameId, player.Name,
                                                  GameManager.RecieveGame(joinGameMessage.GameId).Players.Select(p => p.Id).ToList());
                result.Add(message);
            }

            return(result);
        }