/// <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()); }
/// <summary> /// Gets a single level. /// </summary> /// <param name="search">A search query</param> /// <param name="options">Level search options.</param> /// <returns>A single level.</returns> public static Level GetLevel(string search = "", LevelSearchOptions options = null) => GetLevels(search, options)[0];