public static DiscordColor MapColor(BeatmapState state) { return(state switch { BeatmapState.Graveyard => DiscordColor.Black, BeatmapState.WorkInProgress => DiscordColor.Black, BeatmapState.Pending => DiscordColor.Black, BeatmapState.Ranked => DiscordColor.Cyan, BeatmapState.Approved => DiscordColor.SpringGreen, BeatmapState.Qualified => DiscordColor.SpringGreen, BeatmapState.Loved => DiscordColor.HotPink, _ => DiscordColor.Red });
// To do, find a way to load a file on Android without making said object a TextAsset /* Tried list * Application.persistantDataPath -> useful for when we want players to write & save, however, not so much at this point * Application.dataPath does not point to the right location on android * */ private IEnumerator LoadFile(string filename) { state = BeatmapState.Loading; WWW beatmapWWW = new WWW("file://" + filename); yield return(beatmapWWW); // Load beatmap string file = beatmapWWW.text; beatmapSplitText = file.Split('\n').ToList(); bool successfulLoad = beatmapSplitText.Count > 0 ? true : false; if (!successfulLoad) { Debug.LogWarning("Failed to load beatmap file"); yield return(false); } else { for (int i = 0; i < beatmapSplitText.Count; i++) { beatmapSplitText[i] = beatmapSplitText[i].Trim(); } state = BeatmapState.Loaded; ParseBeatmap(); yield return(LoadAudio(beatmapDirectory)); if (song != null) { LevelManager.instance.ChangeLevel(LevelEnum.PLAYGROUND); } else { Debug.LogWarning("Failed to load audio"); } } }
public static async Task LinkParserMethod(SocketMessage s, ShardedCommandContext context) { User user = await DatabaseQueries.GetOrCreateUserAsync(context.User.Id); Server server = await DatabaseQueries.GetOrCreateServerAsync(context.Guild.Id); var embed = new KaguyaEmbedBuilder(); user.ActiveRateLimit++; if (user.IsBlacklisted) { return; } string link = $"{s}"; string mapId = link.Split('/').Last(); //Gets the map's ID from the link. if (mapId.Contains('?')) { mapId = mapId.Replace("?m=0", ""); } Beatmap mapData = await Client.GetBeatmapByIdAsync((long)mapId.AsUlong()); string status = ""; BeatmapState state = mapData.State; DateTimeOffset?approvedDate = mapData.ApprovedDate; status = state switch { // ReSharper disable PossibleInvalidOperationException BeatmapState.Graveyard | BeatmapState.WorkInProgress | BeatmapState.Pending => $"Last updated on {mapData.LastUpdate.Value.LocalDateTime.ToShortDateString()}", BeatmapState.Ranked => $"Ranked on {approvedDate.Value.LocalDateTime.ToShortDateString()}", BeatmapState.Approved => $"Approved on {approvedDate.Value.LocalDateTime.ToShortDateString()}", BeatmapState.Qualified => $"Qualified on {approvedDate.Value.LocalDateTime.ToShortDateString()}", BeatmapState.Loved => $"Loved 💙 on {approvedDate.Value.LocalDateTime.ToShortDateString()}", // ReSharper restore PossibleInvalidOperationException _ => status }; string lengthValue = mapData.TotalLength.ToString(@"mm\:ss"); PerformanceData pp95 = await mapData.GetPPAsync(95f); PerformanceData pp98 = await mapData.GetPPAsync(98f); PerformanceData pp99 = await mapData.GetPPAsync(99f); PerformanceData pp100 = await mapData.GetPPAsync(100f); embed.WithAuthor(author => { author.Name = $"{mapData.Title} by {mapData.Author}"; author.Url = $"https://osu.ppy.sh/b/{mapId}"; author.IconUrl = $"https://a.ppy.sh/{mapData.AuthorId}"; }); embed.WithDescription( $"**{mapData.Title} [{mapData.Difficulty}]** by **{mapData.Artist}**" + $"\n" + $"\n<:total_length:630131957598126120> **Total Length:** {lengthValue} <:bpm:630131958046785563> **BPM:** {mapData.Bpm:N1}" + $"\n**Star Rating:** `{mapData.StarRating:N2} ☆` **Maximum Combo:** `{mapData.MaxCombo:N0}x`" + $"\n**Download:** [[Beatmap]]({mapData.BeatmapUri}/download)" + $"[(without video)](https://osu.ppy.sh/d/{mapData.BeatmapUri}n)" + $"\n" + $"\n**CS:** `{mapData.CircleSize:N2} ` **AR:** `{mapData.ApproachRate:N2}` " + $"**OD:** `{mapData.OverallDifficulty:N2}` **HP:** `{mapData.HpDrain:N2}`" + $"\n" + $"\n**95% FC:** `{pp95.Pp:N0}pp` **98% FC:** `{pp98.Pp:N0}pp`" + $"\n**99% FC:** `{pp99.Pp:N0}pp` **100% FC (SS):** `{pp100.Pp:N0}pp`"); embed.WithFooter($"Status: {status} | 💙 Amount: {mapData.FavoriteCount:N0}"); await context.Channel.SendEmbedAsync(embed); await ConsoleLogger.LogAsync( $"osu! beatmap automatically parsed in guild {server.ServerId} by user {user.UserId}", LogLvl.DEBUG); user.OsuBeatmapsLinked++; await DatabaseQueries.UpdateAsync(user); } }
public static bool HasLeaderboard(BeatmapState state) => state == BeatmapState.Ranked || state == BeatmapState.Loved || state == BeatmapState.Approved;