Ejemplo n.º 1
0
        public string KouCalConstant([KouPluginArgument(Name = "定数/歌曲名[+难度类型]")] string nameOrConstant,
                                     [KouPluginArgument(Name = "分数")] int score,
                                     [KouPluginArgument(Name = "歌曲ptt反推定数")] double?ptt = null)
        {
            if (score < 0 || score > 11000000)
            {
                return("这个分数怎么有点奇怪呢");
            }
            string songName = nameOrConstant;

            if (ptt != null)
            {
                return($"{score}分的谱面ptt={ptt}时,谱面定数约为{ArcaeaData.CalSongChartConstant(ptt.Value, score):F3}");
            }

            Song.RatingClass ratingClass = Song.RatingClass.Future;
            if (songName.MatchOnceThenReplace(@"[,,]?(ftr|pst|prs|byd|byn|future|past|present|beyond)",
                                              out songName, out var matched, RegexOptions.IgnoreCase | RegexOptions.RightToLeft))
            {
                KouStringTool.TryToEnum(matched[1].Value, out ratingClass);
            }

            if (songName.IsNullOrWhiteSpace())
            {
                return("你在说哪首歌呢");
            }

            var satisfiedSongs = Song.Find(s =>
                                           s.SongTitle.Contains(songName,
                                                                StringComparison.OrdinalIgnoreCase) ||
                                           s.Aliases?.Any(alias => alias.Alias == songName) ==
                                           true);

            if (satisfiedSongs.Count > 1)
            {
                return($"具体是以下哪一首歌呢(暂时不支持选择id):\n{satisfiedSongs.ToSetString()}");
            }
            if (satisfiedSongs.Count == 0)
            {
                if (KouStringTool.TryToDouble(nameOrConstant, out double constant))
                {
                    return($"定数{constant}时,{score}分的ptt为{ArcaeaData.CalSongScorePtt(constant, score):F3}");
                }
                return($"找不到哪个歌叫{songName}哦...");
            }
            var song         = satisfiedSongs[0];
            var songConstant = song.MoreInfo.FirstOrDefault(p => p.ChartRatingClass == ratingClass)?.ChartConstant;

            if (songConstant == null)
            {
                return($"{song.SongTitle}还没有{ratingClass}的定数信息呢...");
            }
            return($"{song.SongTitle}[{ratingClass}{songConstant.Value:0.#}]{score}分的ptt为{ArcaeaData.CalSongScorePtt(songConstant.Value, score):F3}");
        }
Ejemplo n.º 2
0
        public string KouCalConstant([KouPluginArgument(Name = "定数/歌曲名[+难度类型]")] string nameOrConstant,
                                     [KouPluginArgument(Name = "分数")] int score,
                                     [KouPluginArgument(Name = "歌曲ptt反推定数")] double?ptt = null)
        {
            if (score < 0 || score > 11000000)
            {
                return("这个分数怎么有点奇怪呢");
            }
            if (ptt != null)
            {
                return($"{score}分的谱面ptt={ptt}时,谱面定数约为{ArcaeaData.CalSongChartConstant(ptt.Value, score):F3}");
            }
            if (KouStringTool.TryToDouble(nameOrConstant, out double constant))
            {
                return($"定数{constant}时,{score}分的ptt为{ArcaeaData.CalSongScorePtt(constant, score):F3}");
            }
            KouArcaeaInfo kouArcaeaInfo = new KouArcaeaInfo
            {
                SongName = nameOrConstant
            };
            var    songs  = kouArcaeaInfo.GetSatisfiedSong(ratingClass: PluginArcaeaSong.RatingClass.Future);
            string result = "";

            if (songs.Count == 0)
            {
                return($"找不到是哪个歌");
            }
            else if (songs.Count > 4)
            {
                result = $"具体是指下面哪个歌呢?\n{songs.ToSetString()}";
            }
            else
            {
                foreach (var song in songs)
                {
                    if (song.ChartConstant == null)
                    {
                        continue;
                    }
                    double con = song.ChartConstant.Value;
                    result += $"{song.ToString(FormatType.Brief)} {score}分的ptt为{ArcaeaData.CalSongScorePtt(con, score):F3}\n";
                }
            }
            return(result.Trim());
        }