Exemple #1
0
 /// <summary>
 /// Gets an account from the servers.
 /// </summary>
 /// <param name="userId">The account ID of the user.</param>
 /// <returns>An account.</returns>
 public static Account Get(int userId) =>
 RobtopAnalyzer.DeserializeObject <Account>(WebRequestClient.SendRequest(new WebRequest
 {
     Url     = "http://boomlings.com/database/getGJUserInfo20.php",
     Content = new FormUrlEncodedContent(new Dictionary <string, string>
     {
         { "targetAccountID", userId.ToString() },
         { "secret", "Wmfd2893gb7" }
     })
 }));
Exemple #2
0
        /// <summary>
        /// A method to login to an account, creating a <see cref="UserAccount" /> object.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password</param>
        /// <returns>A user account, if successful.</returns>
        public static UserAccount Login(string username, string password)
        {
            var response = WebRequestClient.SendRequest(new WebRequest
            {
                Url     = @"http://boomlings.com/database/accounts/loginGJAccount.php",
                Content = new FormUrlEncodedContent(new Dictionary <string, string>
                {
                    { "userName", username },
                    { "password", password },
                    { "secret", "Wmfv3899gc9" },
                    { "udid", "GDNET" }
                }),
                Method = HttpMethod.Post
            });

            return(RobtopAnalyzer.DeserializeObject <UserAccount>(GetString(int.Parse(response.Split(',')[0]))));
        }
Exemple #3
0
        /// <summary>
        /// Gets an array of levels.
        /// </summary>
        /// <param name="search">A search query</param>
        /// <param name="options">Level search options.</param>
        /// <returns>The array.</returns>
        public static Level[] GetLevels(string search = "", LevelSearchOptions options = null)

        {
            if (options == null)
            {
                options = new LevelSearchOptions();
            }

            Dictionary <string, string> content = new Dictionary <string, string>();

            content = new Dictionary <string, string>
            {
                { "gameVersion", "21" },
                { "binaryVersion", "35" },

                { "type", ((int)options.SearchType).ToString() },
                { "str", search },

                { "len", (options.Length.Length > 0) ? options.Length.FormatEnum(",") : "-" },
                { "diff", (options.Difficulty.Length > 0) ? options.Difficulty.FormatEnum(",") : "-" },

                { "coins", Convert.ToInt32(options.HasCoins).ToString() },
                { "noStar", Convert.ToInt32(options.IsUnrated).ToString() },
                { "twoPlayer", Convert.ToInt32(options.TwoPlayer).ToString() },
                { "featured", Convert.ToInt32(options.Featured).ToString() },
                { "epic", Convert.ToInt32(options.Epic).ToString() },
                { "original", Convert.ToInt32(options.Original).ToString() },

                { "secret", "Wmfd2893gb7" }
            };

            // extraneous/optional params
            if (options.DemonType != DemonType.None)
            {
                content["diff"] = "-2";
                content.Add("demonFilter", ((int)options.DemonType).ToString());
            }

            if (options.CustomSongId > 0 && options.Song > 0)
            {
                throw new ArgumentException("You may not use NewGrounds Song ID's and In-game Song enums at once.");
            }

            if (options.CustomSongId > 0 || options.Song > 0)
            {
                if (options.CustomSongId > 0)
                {
                    content.Add("customSong", options.CustomSongId.ToString());
                }
                else if (options.Song > 0)
                {
                    content.Add("song", ((int)options.Song).ToString());
                }
            }

            string result = WebRequestClient.SendRequest(new WebRequest
            {
                Url     = "http://boomlings.com/database/getGJLevels21.php",
                Content = new FormUrlEncodedContent(content)
            });

            List <Level> levels = RobtopAnalyzer.DeserializeObjectList <Level>(result.Split("#")[0]);

            return(levels.ToArray());
        }