Example #1
0
 private RawSkillData[] GetRawData()
 {
     if (rawData == null)
     {
         rawData = RawSkillData.ParseJsonString(base.RawData);
     }
     return(rawData);
 }
Example #2
0
        public RawSkillData Fetch(int skillId, string wikiPageArticle)
        {
            var basicName   = CreateBasicName(wikiPageArticle);
            var rawWikiPage = dataProvider.RequestData(basicName, true);


            var result = new RawSkillData
            {
                WikiLink  = dataProvider.CreateUrl(basicName, false),
                SkillId   = skillId,
                BasicName = basicName
            };

            if (string.IsNullOrEmpty(rawWikiPage))
            {
                logger.Log(GetType(),
                           string.Format("Wiki article not found. skillId: {0}, basicName: {1}",
                                         skillId,
                                         basicName),
                           LogSeverity.Warning);

                result.NotASkill = true;
                return(result);
            }

            result.IsRemoved = HasBeenRemoved(rawWikiPage);

            var pageData = ReplaceDifficultTemplate(rawWikiPage);

            var skillBox = GetSkillBoxContent(pageData);

            if (string.IsNullOrEmpty(skillBox))
            {
                var severity = Regex.Match(pageData, "skill infobox").Success ? LogSeverity.Error : LogSeverity.Warning;
                logger.Log(GetType(),
                           string.Format("No skill info box found. skillId: {0}, basicName: {1}",
                                         skillId,
                                         basicName),
                           severity);
                result.NotASkill = true;
                return(result);
            }


            var values = ExtractSkillBoxValues(skillBox);


            var id = values.GetIntegerValue("id");

            if (id.HasValue)
            {
                if (id.Value != skillId)
                {
                    logger.Log(GetType(),
                               string.Format(
                                   "Request skill id does no match skill from dataProvider. skillId: {0}, basicName: {1}, wikiId: {2}",
                                   skillId,
                                   basicName,
                                   values["id"]),
                               LogSeverity.Warning);
                }

                result.SecondarySkillId = id;
            }

            result.Name = values.GetTextValue("name");

            var description        = values.GetTextValue("description");
            var conciseDescription = values.GetTextValue("concise description");

            if (string.IsNullOrEmpty(description))
            {
                description = conciseDescription;
            }

            result.Description        = description;
            result.ConciseDescription = conciseDescription;
            result.Type           = values.GetTextValue("type");
            result.Campaign       = values.GetTextValue("campaign");
            result.Profession     = values.GetTextValue("profession");
            result.Attribute      = values.GetTextValue("attribute");
            result.IsElite        = values.GetBoolValue("elite");
            result.EnergyCost     = values.GetDoubleValue("energy");
            result.ActivationTime = values.GetActivationTime();
            result.RechargeTime   = values.GetDoubleValue("recharge");
            result.Upkeep         = values.GetDoubleValue("upkeep");
            result.Adrenaline     = values.GetDoubleValue("adrenaline");
            result.Sacrifice      = values.GetDoubleValue("sacrifice");
            result.Exhaustion     = values.GetBoolValue("exhaustion");
            result.Target         = values.GetTextValue("target");
            result.Range          = values.GetTextValue("range");
            result.SpecialType    = GetSpecialType(values, rawWikiPage);
            result.IsPvEOnly      = values.GetBoolValue("pve-only");
            result.HasPvP         = values.GetBoolValue("has-pvp");
            result.PvEVersion     = GetPvEVersion(rawWikiPage);
            result.IsPvPVersion   = values.GetBoolValue("is-pvp");
            result.Projectile     = values.GetTextValue("projectile");
            result.AreaOfEffect   = values.GetTextValue("aoe");

            result.Causes = values.GetInfoBoxValueArray(new[]
            {
                "causes1", "causes2", "causes3"
            });
            result.Removes = values.GetInfoBoxValueArray(new[]
            {
                "removes1", "removes2"
            });

            result.RelatedSkills = ExtractRelatedSkills(pageData);

            result.Progression = GetProgression(pageData);
            result.Categories  = GetCategories(pageData);


            var path = Path.Combine(imageStore, string.Format("{0}.jpg", skillId));

            if (!fileSystem.Exists(path))
            {
                var image = GetImage(basicName);

                if (image == null)
                {
                    logger.Log(GetType(),
                               string.Format("Skill image not found. skillId: {0}, basicName: {1}",
                                             skillId,
                                             basicName),
                               LogSeverity.Warning);
                }
                else
                {
                    fileSystem.Write(path, image);
                }
            }

            return(result);
        }