コード例 #1
0
 public SendOsuResult(int iD, string matchName, TeamInfo[] teams, BeatmapInfo[] beatmaps, PlayerInfo[] players, HighestRankingInfo highestScore, HighestRankingInfo highestAccuracy, int mVPPlayerID, DateTime timeStamp)
 {
     try
     {
         ID              = iD;
         MatchName       = matchName;
         Teams           = teams;
         Beatmaps        = beatmaps;
         Players         = players;
         HighestScore    = highestScore;
         HighestAccuracy = highestAccuracy;
         MVPPlayerID     = mVPPlayerID;
         TimeStamp       = $"{timeStamp.Hour}:{timeStamp.Minute}:{timeStamp.Second}";
     }
     catch (Exception ex)
     {
         Logger.Log(ex.ToString(), LogLevel.ERROR);
         throw ex;
     }
 }
コード例 #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;
            }
        }