public override int GetHashCode()
        {
            int result = 17;

            result = 31 * result + nodeState.GetHashCode();
            result = 31 * result + coordinates.GetHashCode();
            result = 31 * result + GScore.GetHashCode();
            result = 31 * result + HScore.GetHashCode();
            return(result);
        }
示例#2
0
        /// <summary>
        /// Check, if beatmap is closed on setted percetange
        /// </summary>
        /// <param name="score">Gatari score</param>
        /// <param name="bm">Beatmap</param>
        /// <param name="percentage">Required percentage</param>
        /// <returns></returns>
        public double FailedScoreProgress(GScore score, Beatmap bm)
        {
            int total_hits    = score.count_50 + score.count_100 + score.count_300 + score.count_miss;
            int expected_hits = bm.count_circles + bm.count_sliders + bm.count_spinners;

            double progress = (double)total_hits / expected_hits;

            logger.LogDebug($"Failed progress: {progress}");

            return(progress);
        }
示例#3
0
        public async Task LastRecent(CommandContext commandContext,
            params string[] args)
        {
            ulong discordId = commandContext.Member.Id;

            if (wavMembers.GetMember(discordId) is null)
                wavMembers.CreateMember(discordId);

            string choosedServer = args.FirstOrDefault() ?? "-bancho";

            WAVMemberOsuProfileInfo userInfo = wavMembers.GetOsuProfileInfo(discordId, choosedServer);
            if (userInfo is null)
            {
                await commandContext.RespondAsync($"Не удалось найти ваш osu! профиль сервера `{choosedServer}`. Добавьте свой профиль через команду `osuset`");
                return;
            }

            switch (choosedServer)
            {
                case "-gatari":                    
                    GScore gscore = gapi.GetUserRecentScores(userInfo.Id, 0, 1, true).First();

                    GUser guser = null;
                    if (!gapi.TryGetUser(userInfo.Id, ref guser))
                    {
                        await commandContext.RespondAsync("Не удалось найти такого пользователя на Gatari.");
                        return;
                    }

                    DiscordEmbed gscoreEmbed = utils.GatariScoreToEmbed(gscore, guser);
                    await commandContext.RespondAsync(embed: gscoreEmbed);

                    break;

                case "-bancho":
                    Score score = api.GetUserRecentScores(userInfo.Id, true, 0, 1).First();

                    User user = null;
                    if (!api.TryGetUser(userInfo.Id, ref user))
                    {
                        await commandContext.RespondAsync("Не удалось найти такого пользователя на Gatari.");
                        return;
                    }

                    DiscordEmbed scoreEmbed = utils.BanchoScoreToEmbed(score, user);
                    await commandContext.RespondAsync(embed: scoreEmbed);
                    break;

                default:
                    await commandContext.RespondAsync($"Сервер `{choosedServer}` не поддерживается.");
                    break;
            }
        }
示例#4
0
        private int GetCost(int current)
        {
            // UNDONE
            int xDistance = (int)Math.Abs(Start % Width - current % Width);
            int yDistance = (int)Math.Abs(Start / Width - current / Width);

            if (!GScore.ContainsKey(current))
            {
                GScore.Add(current, (xDistance + yDistance) * 10);
            }

            return(GScore[current]);
        }
示例#5
0
        /// <summary>
        /// Get embed from gatari score and user information
        /// </summary>
        /// <param name="score">Gatari score</param>
        /// <param name="user">Gatari user</param>
        /// <param name="mapLen">Map's length</param>
        /// <returns></returns>
        public DiscordEmbed GatariScoreToEmbed(GScore score, GUser user)
        {
            DiscordEmoji rankEmoji = osuEmoji.RankingEmoji(score.ranking);
            Random       rnd       = new Random();

            DiscordEmbedBuilder embed = new DiscordEmbedBuilder();

            embed.WithAuthor(user.username, $"https://osu.gatari.pw/u/{user.id}", $"https://a.gatari.pw/{user.id}?{rnd.Next(1000, 9999)}")
            .WithThumbnail($"https://b.ppy.sh/thumb/{score.beatmap.beatmapset_id}.jpg");

            TimeSpan mapLen = TimeSpan.FromSeconds(score.beatmap.hit_length);

            StringBuilder embedMessage = new StringBuilder();

            embedMessage.AppendLine($"[{osuEmoji.RankStatusEmoji(score.beatmap.ranked)} {score.beatmap.song_name} by {score.beatmap.creator}](https://osu.gatari.pw/s/{score.beatmap.beatmapset_id}#osu/{score.beatmap.beatmap_id})");
            embedMessage.AppendLine($"▸ **Difficulty**: {score.beatmap.difficulty:##0.00}★ ▸ **Length**: {mapLen.Minutes}:{string.Format("{0:00}", mapLen.Seconds)} ▸ **BPM**: {score.beatmap.bpm} ▸ **Mods**: {ModsToString(score.mods)}");
            embedMessage.AppendLine($"▸ {rankEmoji} ▸ **{score.accuracy:##0.00}%** ▸ **{$"{(double)score.pp:##0.00}"}** {osuEmoji.PPEmoji()} ▸ **{score.max_combo}x/{score.beatmap.fc}x**");


            // mania
            if (score.play_mode == 3)
            {
                embedMessage.AppendLine($"▸ {score.score} [{score.count_300} {osuEmoji.Hit300Emoji()}, {score.count_katu} {osuEmoji.Hit200Emoji()}, {score.count_100} {osuEmoji.Hit100Emoji()}, {score.count_50} {osuEmoji.Hit50Emoji()}, {score.count_miss} {osuEmoji.MissEmoji()}]");
                embed.AddField($"New recent score osu!mania", embedMessage.ToString());
            }

            // ctb
            if (score.play_mode == 2)
            {
                embedMessage.AppendLine($"▸ {score.score} [{score.count_300} {osuEmoji.Hit300Emoji()}, {score.count_katu} {osuEmoji.Hit200Emoji()}, {score.count_100} {osuEmoji.Hit100Emoji()}, {score.count_50} {osuEmoji.Hit50Emoji()}, {score.count_miss} {osuEmoji.MissEmoji()}]");
                embed.AddField($"New recent score osu!ctb", embedMessage.ToString());
            }

            // taiko
            if (score.play_mode == 1)
            {
                embedMessage.AppendLine($"▸ {score.score} [{score.count_300} {osuEmoji.Hit300Emoji()}, {score.count_katu} {osuEmoji.Hit200Emoji()}, {score.count_100} {osuEmoji.Hit100Emoji()}, {score.count_50} {osuEmoji.Hit50Emoji()}, {score.count_miss} {osuEmoji.MissEmoji()}]");
                embed.AddField($"New recent score osu!taiko", embedMessage.ToString());
            }

            //std
            if (score.play_mode == 0)
            {
                embedMessage.AppendLine($"▸ {score.score} [{score.count_300} {osuEmoji.Hit300Emoji()}, {score.count_100} {osuEmoji.Hit100Emoji()}, {score.count_50} {osuEmoji.Hit50Emoji()}, {score.count_miss} {osuEmoji.MissEmoji()}]");
                embed.AddField($"New recent score osu!standard", embedMessage.ToString());
            }

            embed.WithFooter($"Played at: {score.time}");

            return(embed.Build());
        }
示例#6
0
        public DiscordEmbed UserToEmbed(GUser user, GStatistics stats, List <GScore> scores = null)
        {
            DiscordEmbedBuilder embedBuilder = new DiscordEmbedBuilder();

            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"**Server:** gatari");
            sb.AppendLine($"**Rank:** `{stats.rank}` ({user.country} `#{stats.country_rank}`)");
            sb.AppendLine($"**Level:** `{stats.level}` + `{stats.level_progress}%`");
            sb.AppendLine($"**PP:** `{stats.pp} PP` **Acc**: `{Math.Round(stats.avg_accuracy, 2)}%`");
            sb.AppendLine($"**Playcount:** `{stats.playcount}` (`{(Math.Round((double)stats.playtime / 3600))}` hrs)");
            sb.AppendLine($"**Ranks**: {osuEmoji.RankingEmoji("XH")}`{stats.xh_count}` {osuEmoji.RankingEmoji("X")}`{stats.x_count}` {osuEmoji.RankingEmoji("SH")}`{stats.sh_count}` {osuEmoji.RankingEmoji("S")}`{stats.s_count}` {osuEmoji.RankingEmoji("A")}`{stats.a_count}`\n");
            //sb.AppendLine($"**Playstyle:** {user.play string.Join(", ", user.playstyle)}\n");
            sb.AppendLine("Top 5 scores:");

            if (scores != null && scores?.Count != 0)
            {
                double avg_pp = 0;
                for (int i = 0; i < scores.Count; i++)
                {
                    GScore s = scores[i];

                    string mods = string.Join(' ', s.mods);
                    if (string.IsNullOrEmpty(mods))
                    {
                        mods = "NM";
                    }

                    sb.AppendLine($"{i + 1}: __[{s.beatmap.song_name}](https://osu.gatari.pw/b/{s.beatmap.beatmap_id})__ **{mods}** - {s.beatmap.difficulty}★");
                    sb.AppendLine($"▸ {osuEmoji.RankingEmoji(s.ranking)} ▸ `{s.pp} PP` ▸ **[{s.count_300}/{s.count_100}/{s.count_50}]**");

                    avg_pp += s.pp ?? 0;
                }
                sb.AppendLine($"\nAvg: `{Math.Round(avg_pp / 5, 2)} PP`");
            }
            embedBuilder.WithTitle(user.username)
            .WithUrl($"https://osu.gatari.pw/u/{user.id}")
            .WithThumbnail($"https://a.gatari.pw/{user.id}?{new Random().Next(1000, 9999)}")
            .WithDescription(sb.ToString());

            return(embedBuilder.Build());;
        }
示例#7
0
 public override int GetHashCode()
 {
     return(Location.GetHashCode() + GScore.GetHashCode() + HScore.GetHashCode());
 }