Пример #1
0
        /// <summary>
        ///     使用一定的格式构造一个字符串
        /// </summary>
        /// <param name="format"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        public string ToString(string format, IFormatProvider formatProvider)
        {
            var b = new StringBuilder(format);

            b.Replace("Artist", Artist);
            b.Replace("artist", Artist);
            b.Replace("bpm", Bpm.ToString(CultureInfo.CurrentCulture));
            b.Replace("stars", Stars.ToString(CultureInfo.CurrentCulture));
            b.Replace("mode", Mode.ToString());
            b.Replace("cs", CircleSize.ToString(CultureInfo.CurrentCulture));
            b.Replace("ar", ApproachRate.ToString(CultureInfo.CurrentCulture));
            b.Replace("hp", HpDrain.ToString(CultureInfo.CurrentCulture));
            b.Replace("od", OverallDifficulty.ToString(CultureInfo.CurrentCulture));
            b.Replace("circles", HitCircle.ToString());
            b.Replace("sliders", Slider.ToString());
            b.Replace("spiners", Spinner.ToString());
            b.Replace("creator", Creator);
            b.Replace("Title", Title);
            b.Replace("title", Title);
            b.Replace("Tags", Tags);
            b.Replace("tags", Tags);
            b.Replace("setid", BeatmapSetId.ToString());
            b.Replace("maxcombo", MaxCombo.ToString());
            b.Replace("approved", Approved.ToString());
            var total = TimeSpan.FromSeconds(TotalTime);
            var hit   = TimeSpan.FromSeconds(DrainTime);

            b.Replace("length", $"{total.TotalMinutes}:{total.Seconds}");
            b.Replace("hitlength", $"{hit.TotalMinutes}:{hit.Seconds}");
            b.Replace("version", Version);
            b.Replace("md5", Md5);
            b.Replace("id", BeatmapId.ToString());
            return(b.ToString());
        }
Пример #2
0
        /// <summary>
        /// Retrieve general beatmap set information.
        /// </summary>
        /// <param name="beatmapSetId">Specify a beatmap set id.</param>
        /// <returns>Fetched beatmaps.</returns>
        public OsuBeatmapSet GetBeatmapSet(
            BeatmapSetId beatmapSetId)
        {
            var maps = GetBeatmaps(beatmapSetId);

            return(new OsuBeatmapSet(maps));
        }
Пример #3
0
        /// <summary>
        /// Retrieve general beatmap information.
        /// </summary>
        /// <param name="beatmapSetId">Specify a beatmap set id.</param>
        /// <param name="gameMode">Specify the game mode.</param>
        /// <param name="limitCount">Amount of results (1 - 500). Default value is 500.</param>
        /// <returns>Fetched beatmaps.</returns>
        public OsuBeatmap[] GetBeatmaps(
            BeatmapSetId beatmapSetId,
            ConvertibleGameMode gameMode = null,
            int?limitCount = null)
        {
            var sb = new StringBuilder(Key.CreateBeatmapLink());

            sb.Append($"&s={beatmapSetId}");

            if (gameMode != null)
            {
                AppendConvertibleGameMode(gameMode, sb);
            }
            if (limitCount != null)
            {
                AppendLimit(limitCount, sb);
            }

            string json = GetJson(sb);
            var    obj  = JsonConvert.DeserializeObject <OsuBeatmap[]>(json);

            return(obj);
        }
Пример #4
0
 public OsuBeatmap[] GetBeatmapsBySid(BeatmapSetId setId)
 {
     return(_client.GetBeatmaps(setId));
 }