Exemplo n.º 1
0
            /// <summary>
            ///     使用指定的模式搜索谱面,可指定包含与不包含
            /// </summary>
            /// <param name="mode"></param>
            /// <param name="option"></param>
            /// <returns></returns>
            public BeatmapCollection Find(OsuGameMode mode, BeatmapFindOption option = BeatmapFindOption.Contains)
            {
                var bc = new BeatmapCollection();

                foreach (var b in _beatmaps)
                {
                    if (option == BeatmapFindOption.Contains)
                    {
                        if (b.Mode == mode)
                        {
                            if (!bc.Contains(b))
                            {
                                bc.Add(b);
                            }
                        }
                    }
                    if (option == BeatmapFindOption.NotContains)
                    {
                        if (b.Mode != mode)
                        {
                            if (!bc.Contains(b))
                            {
                                bc.Add(b);
                            }
                        }
                    }
                }

                return(bc);
            }
Exemplo n.º 2
0
            /* public BeatmapCollection FindEx(string artist = null, string title = null, string creator = null, string version = null, string tag = null, string source = null)
             * {
             *   BeatmapCollection result = new BeatmapCollection();
             *
             *   return result;
             * }*/
            /// <summary>
            ///     使用关键词搜索谱面,可指定包括与不包括
            /// </summary>
            /// <param name="keyWord"></param>
            /// <param name="option"></param>
            /// <returns></returns>
            public BeatmapCollection Find(string keyWord, BeatmapFindOption option = BeatmapFindOption.Contains)
            {
                var b       = new BeatmapCollection();
                var keyword = keyWord.ToUpper();

                foreach (var beatmap in _beatmaps)
                {
                    var allinfo = beatmap.ToString().ToUpper() + " " + beatmap.Source.ToUpper() + " " +
                                  beatmap.Tags.ToUpper() + " " + beatmap.Creator.ToUpper() + " " +
                                  beatmap.Maker.ToUpper();

                    if (option == BeatmapFindOption.Contains)
                    {
                        if (keyword.StartsWith("${") && keyword.EndsWith("}"))
                        {
                            var newkeyword = keyword.Trim('$', '}', '{');
                            if (beatmap.Title.ToUpper() == newkeyword || beatmap.TitleUnicode.ToUpper() == newkeyword ||
                                beatmap.Artist.ToUpper() == newkeyword ||
                                beatmap.ArtistUnicode.ToUpper() == newkeyword ||
                                beatmap.Maker.ToUpper() == newkeyword || beatmap.Creator.ToUpper() == newkeyword ||
                                beatmap.Tags.ToUpper() == newkeyword || beatmap.Source.ToUpper() == newkeyword ||
                                beatmap.Difficulty.ToUpper() == newkeyword)
                            {
                                if (!b.Contains(beatmap))
                                {
                                    b.Add(beatmap);
                                }
                            }
                        }
                        else if (allinfo.Contains(keyword))
                        {
                            b.Add(beatmap);
                        }
                    }

                    if (option == BeatmapFindOption.NotContains)
                    {
                        if (keyword.StartsWith("${") && keyword.EndsWith("}"))
                        {
                            var newkeyw = keyword.Trim('$', '}', '{');
                            if (beatmap.Title.ToUpper() != newkeyw && beatmap.TitleUnicode.ToUpper() != newkeyw &&
                                beatmap.Artist.ToUpper() != newkeyw && beatmap.ArtistUnicode.ToUpper() != newkeyw &&
                                beatmap.Maker.ToUpper() != newkeyw && beatmap.Creator.ToUpper() != newkeyw &&
                                beatmap.Tags.ToUpper() != newkeyw && beatmap.Source.ToUpper() != newkeyw &&
                                beatmap.Difficulty.ToUpper() != newkeyw)
                            {
                                if (!b.Contains(beatmap))
                                {
                                    b.Add(beatmap);
                                }
                            }
                        }
                        else if (!allinfo.Contains(keyword))
                        {
                            b.Add(beatmap);
                        }
                    }
                }

                if (b.Beatmaps.Count == 0)
                {
                    throw new BeatmapNotFoundException("找不到指定的谱面");
                }
                return(b);
            }