public Beatmap(Input input) { if (input.BeatmapId == null) { throw new Exception("No beatmap link provided"); } Task <BeatmapData[]> beatmapRequest = OsuApi.Beatmap(input.BeatmapId, input.ModRequestNumber ?? 0, input.Gamemode); Task <ScoreData[]> leaderboardRequest = OsuApi.Leaderboard(input.BeatmapId, input.Gamemode); Task.WhenAll( beatmapRequest, leaderboardRequest ).Wait(); beatmap = beatmapRequest.Result[0]; leaderboard = leaderboardRequest.Result; CountLeaderboardFullCombo(); difficultyCalculator = new DifficultyCalculator(input.BeatmapId, input.Gamemode, input.ModNumber); difficulty = difficultyCalculator.Calculate(); Embed = CreateEmbed(); }
public async Task <DiscordEmbedBuilder> CreateScoreEmbed() { int requestnumber = OsuHelper.GetModRequestNumber(score.EnabledMods); Task <UserData> userRequest = OsuApi.User(input); Task <BeatmapData[]> beatmapRequest = OsuApi.Beatmap(score.BeatmapId ?? input.BeatmapId, requestnumber, input.Gamemode); Task <ScoreData[]> leaderboardRequest = OsuApi.Leaderboard(score.BeatmapId, input.Gamemode); Task.WhenAll( userRequest, beatmapRequest, leaderboardRequest ).Wait(); user = userRequest.Result; beatmap = beatmapRequest.Result[0]; leaderboard = leaderboardRequest.Result; DiscordEmbedBuilder embed = CreateBaseEmbed(); Dictionary <string, string> data = GetModeData(score, beatmap); string emoji = GetRankEmoji(score); string mods = OsuHelper.ParseMods(score.EnabledMods); ppData pp = new PerformanceCalculator(score, beatmap, input.Gamemode).Calculate(); string achievedPp; if (score.Rank.Equals("F") || beatmap.Approved == 4) { achievedPp = $"~~{Math.Round(score.PP > 0 && !input.IsDeltaT ? score.PP : pp.AchievedPp)}pp~~"; } else { achievedPp = Math.Round(score.PP > 0 && !input.IsDeltaT ? score.PP : pp.AchievedPp).ToString() + "pp"; } var totalTimeSpan = TimeSpan.FromSeconds(beatmap.TotalLength); var hitTimeSpan = TimeSpan.FromSeconds(beatmap.HitLength); string totalLength = string.Format("{0:D2}:{1:D2}", totalTimeSpan.Minutes, totalTimeSpan.Seconds); string hitLength = string.Format("{0:D2}:{1:D2}", hitTimeSpan.Minutes, hitTimeSpan.Seconds); int retryCount = GetRetryCount(); if (retryCount > 0) { embed.Author.Name += $" | Try #{retryCount}"; } embed.WithDescription($"[{beatmap.Artist} - {beatmap.Title} [{beatmap.Version}]](https://osu.ppy.sh/b/{beatmap.BeatmapId})\n" + $"{mods} **{achievedPp}**"); int leaderboardPosition = GetLeaderboardPosition(); if (leaderboardPosition > 0) { embed.Description += $" BM#{leaderboardPosition}"; } embed.AddField("**Score**", $"{emoji} {score.Score.ToString("#,##0")}", true); embed.AddField("**Combo**", data["combo"], true); embed.AddField("**Accuracy**", data["accuracy"], true); embed.AddField("**Hits**", data["hits"], true); if (pp.FullComboPp != 0) { embed.AddField("**PP if FC**", Math.Round(pp.FullComboPp) + "pp", true); } if (pp.ssPp != 0) { embed.AddField("**PP if SS**", Math.Round(pp.ssPp) + "pp", true); } embed.AddField("**Beatmap Values**", $"★{Math.Round(beatmap.DifficultyRating, 2)} **Length**: {totalLength} ({hitLength}) **BPM** {beatmap.bpm}\n" + data["stats"]); embed.WithFooter($"Beatmap by: {beatmap.Creator} | Played on {score.Date}"); Database.SetLastMap(input.DiscordChannelId, beatmap.BeatmapId); return(embed); }