Esempio n. 1
0
        public IMapSearchResult FindBeatmap(IMapSearchArgs searchArgs, CancellationToken cancellationToken)
        {
            var      result  = new MapSearchResult(searchArgs);
            IBeatmap beatmap = null;

            if (!string.IsNullOrEmpty(searchArgs.MapHash))
            {
                beatmap = _databaseController.GetBeatmap(searchArgs.MapHash);
            }

            if (!IsValidBeatmap(beatmap) && searchArgs.MapId > 0)
            {
                beatmap = _databaseController.GetBeatmap(searchArgs.MapId);
            }

            if (!IsValidBeatmap(beatmap))
            {
                if (!(string.IsNullOrEmpty(searchArgs.Artist) && string.IsNullOrEmpty(searchArgs.Title)) || !string.IsNullOrEmpty(searchArgs.Raw))
                {
                    beatmap = _databaseController.GetBeatmap(searchArgs.Artist, searchArgs.Title, searchArgs.Diff, searchArgs.Raw);
                }
            }

            if (IsValidBeatmap(beatmap))
            {
                result.BeatmapsFound.Add(beatmap);
            }
            return(result);
        }