Exemplo n.º 1
0
        public Result ParseResult(string rawResponse)
        {
            ApiResult result = JsonConvert.DeserializeObject <ApiResult>(rawResponse);

            RuneMetricsError   error   = ParseError(result.Error);
            RuneMetricsProfile profile = null;

            if (error == RuneMetricsError.NoError)
            {
                string name = result.Name;

                int?       overallRank = result.Rank == null ? (int?)null : Int32.Parse(result.Rank.Replace(",", ""));
                SkillScore overall     = new SkillScore(HiScoresEntries.Overall, result.TotalXP, result.TotalSkill, overallRank);

                RuneMetricsProfile.CombatInfo combatInfo = new RuneMetricsProfile.CombatInfo(result.Magic, result.Ranged, result.Melee, result.CombatLevel);

                RuneMetricsProfile.QuestsInfo questsInfo = new RuneMetricsProfile.QuestsInfo(result.QuestsNotStarted, result.QuestsStarted, result.QuestsComplete);

                RuneMetricsSkillScores.Entry[] skillScoreEntries = new RuneMetricsSkillScores.Entry[result.SkillValues.Length + 1];
                skillScoreEntries[0] = new RuneMetricsSkillScores.Entry(HiScoresEntries.Overall.RuneMetricsId, overall.Level, overall.XP, overall.Rank);
                for (int i = 0; i < result.SkillValues.Length; i++)
                {
                    ApiSkillValueEntry entry = result.SkillValues[i];
                    long xp = entry.XP / 10;
                    skillScoreEntries[i + 1] = new RuneMetricsSkillScores.Entry(entry.Id, entry.Level, xp, entry.Rank);
                }
                RuneMetricsSkillScores skillScores = new RuneMetricsSkillScores(skillScoreEntries);

                AdventurersLogActivity[] activities = new AdventurersLogActivity[result.Activities.Length];
                for (int i = 0; i < result.Activities.Length; i++)
                {
                    ApiActivityEntry entry = result.Activities[i];
                    activities[i] = new AdventurersLogActivity(entry.Date, entry.Text, entry.Details);
                }

                profile = new RuneMetricsProfile(name, overall, combatInfo, questsInfo, skillScores, activities);
            }

            return(new Result(error, profile));
        }
Exemplo n.º 2
0
 public Result(RuneMetricsError error, RuneMetricsProfile profile)
 {
     Error   = error;
     Profile = profile;
 }