コード例 #1
0
        public static SendOsuResult CreateTestResult()
        {
            TeamInfo[] teams = new TeamInfo[]
            {
                new TeamInfo(3, (short)TeamColor.Blue, "blue"),
                new TeamInfo(2, (short)TeamColor.Red, "red")
            };

            BeatmapInfo[] maps = new BeatmapInfo[]
            {
                new BeatmapInfo(1, 10, 6.5, "Artist", "title", "version", "creator"),
                new BeatmapInfo(2, 11, 7.58, "Artist2", "title2", "version2", "creator2"),
            };

            PlayerInfo[] players = new PlayerInfo[]
            {
                new PlayerInfo(1, "user1", 30.05f, 99.34568f, 99.34f),
                new PlayerInfo(2, "user2", 30.05f, 99.34568f, 99.34f),
            };

            ScoreInfo[] scores = new ScoreInfo[]
            {
                new ScoreInfo(1, 1, (short)TeamColor.Blue, 99.0f, new string[] { "ez", "hr" }, 500, 5, 0, 50.0f, 1, DateTime.UtcNow, 30, 20, 10, 5),
                new ScoreInfo(2, 1, (short)TeamColor.Blue, 99.0f, new string[] { "ez", "hr" }, 500, 5, 0, 50.0f, 1, DateTime.UtcNow, 30, 20, 10, 5),
                new ScoreInfo(1, 1, (short)TeamColor.Blue, 99.0f, new string[] { "ez", "hr" }, 500, 5, 0, 50.0f, 1, DateTime.UtcNow, 30, 20, 10, 5),
                new ScoreInfo(1, 1, (short)TeamColor.Blue, 99.0f, new string[] { "ez", "hr" }, 500, 5, 0, 50.0f, 1, DateTime.UtcNow, 30, 20, 10, 5),
            };

            SendOsuResult r = new SendOsuResult(1, "GAF:(blue) vs (red)", teams, maps, players, new HighestRankingInfo(1, scores[0], scores[0].PlayerID), new HighestRankingInfo(2, scores[1], scores[1].PlayerID), 1, DateTime.UtcNow);

            return(r);
        }
コード例 #2
0
        public static SendOsuResult ConvertSendOsuResult(Osu.results.AnalyzerResult ar)
        {
            try
            {
                BeatmapInfo[] maps = new BeatmapInfo[ar.Beatmaps.Length];

                for (int i = 0; i < ar.Beatmaps.Length; i++)
                {
                    maps[i] = new BeatmapInfo(ar.Beatmaps[i].id ?? -1, ar.Beatmaps[i].beatmapset.id ?? -1, ar.Beatmaps[i].difficulty_rating,
                                              ar.Beatmaps[i].beatmapset.artist ?? "null", ar.Beatmaps[i].beatmapset.title ?? "null", ar.Beatmaps[i].version ?? "null", ar.Beatmaps[i].beatmapset.creator ?? "null");
                }

                List <ScoreInfo> scoresL = new List <ScoreInfo>();
                PlayerInfo[]     players = new PlayerInfo[ar.Ranks.Length];
                ScoreInfo        hScore  = new ScoreInfo()
                {
                    Score = -1
                };
                ScoreInfo hAcc = new ScoreInfo()
                {
                    Accuracy = -1.0f
                };
                PlayerInfo mvp = new PlayerInfo(0, "", -1, 0.0f, 0.0f);
                //RankingInfo[] rankings = new RankingInfo[ar.Ranks.Length];

                ScoreInfo sI;
                for (int i = 0; i < ar.Ranks.Length; i++)
                {
                    var rank = ar.Ranks[i];

                    players[i] = new PlayerInfo(rank.Player.UserId, rank.Player.UserName, rank.Player.MVPScore,
                                                rank.Player.AverageAccuracy, rank.Player.AverageAccuracyRounded);

                    if (players[i].MVPScore > mvp.MVPScore)
                    {
                        mvp = players[i];
                    }

                    //rankings[i] = new RankingInfo(rank.Player.UserId, (short)rank.Place);

                    for (int x = 0; x < rank.Player.Scores.Length; x++)
                    {
                        var   score = rank.Player.Scores[x];
                        short slot  = score.multiplayer == null ? (short)-1 : !score.multiplayer.slot.HasValue ? (short)-1 : (short)score.multiplayer.slot.Value;
                        short team  = score.multiplayer.team.Equals("red", StringComparison.CurrentCultureIgnoreCase) ? (short)1 : (short)2;

                        sI = new ScoreInfo(score.user_id ?? 0, slot, team, (score.accuracy ?? 0.0f) * 100.0f, score.mods?.ToArray() ?? new string[] { }, score.score ?? 0,
                                           score.max_combo ?? 0, (short)(score.perfect ?? 0), score.pp ?? 0, score.rank ?? 0, score.created_at ?? DateTime.MinValue, score.statistics?.count_300 ?? 0,
                                           score.statistics?.count_100 ?? 0, score.statistics?.count_50 ?? 0, score.statistics?.count_miss ?? 0);

                        scoresL.Add(sI);

                        if (hScore.Score < sI.Score)
                        {
                            hScore = sI;
                        }

                        if (hAcc.Accuracy < sI.Accuracy)
                        {
                            hAcc = sI;
                        }
                    }
                }


                HighestRankingInfo highestScore = new HighestRankingInfo(ar.HighestScoreBeatmap.id.Value, hScore, ar.HighestScore.user_id.Value);

                HighestRankingInfo highestAccuracy = new HighestRankingInfo(ar.HighestAccuracyBeatmap.id.Value, hAcc, ar.HighestAccuracyScore.user_id.Value);

                ScoreInfo[] scores = new ScoreInfo[scoresL.Count];
                scoresL.CopyTo(scores);

                TeamInfo[] teamInfos = new TeamInfo[2];

                if (ar.WinningTeamColor == Osu.TeamColor.Red)
                {
                    teamInfos[0] = new TeamInfo((short)ar.WinningTeamWins, (short)TeamColor.Red, ar.WinningTeam);
                    teamInfos[1] = new TeamInfo((short)ar.LosingTeamWins, (short)TeamColor.Blue, ar.LosingTeam);
                }
                else
                {
                    teamInfos[0] = new TeamInfo((short)ar.LosingTeamWins, (short)TeamColor.Red, ar.LosingTeam);
                    teamInfos[1] = new TeamInfo((short)ar.WinningTeamWins, (short)TeamColor.Blue, ar.WinningTeam);
                }

                SendOsuResult result = new SendOsuResult(ar.MatchId, ar.MatchName, teamInfos, maps, players, highestScore,
                                                         highestAccuracy, mvp.ID, ar.TimeStamp);

                List <BanInfo> bans = new List <BanInfo>();

                foreach (Osu.results.BanInfo ban in ar.Bans)
                {
                    bans.Add(new BanInfo(ban.Artist, ban.Title, ban.Version, ban.BannedBy));
                }

                result.Bans  = bans.ToArray();
                result.Stage = ar.Stage;

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString(), LogLevel.ERROR);
                throw ex;
            }
        }