Example #1
0
 private void ParseSimpleFields(ItemBaseDto xml)
 {
     xml.Name            = _json.Value <string>("name");
     xml.DropDisabled    = _json.Value <string>("release_state") != "released";
     xml.InventoryHeight = _json.Value <int>("inventory_height");
     xml.InventoryWidth  = _json.Value <int>("inventory_width");
     xml.MetadataId      = _metadataId;
 }
Example #2
0
 public ItemBaseDto Parse()
 {
     _xml = new ItemBaseDto();
     ParseSimpleFields();
     ParseItemClass();
     ParseImplicits();
     ParseRequirements();
     ParseTags();
     ParseProperties();
     return(_xml);
 }
Example #3
0
 private void ParseTags(ItemBaseDto xml)
 {
     foreach (var s in _json["tags"] !.Values <string>())
     {
         if (TagsExtensions.TryParse(s, out var tag))
         {
             xml.Tags |= tag;
         }
         else
         {
             _unknownTags.Add(s);
         }
     }
 }
Example #4
0
        private void ParseRequirements(ItemBaseDto xml)
        {
            var requirements = _json["requirements"] !;

            if (requirements.HasValues)
            {
                xml.Dexterity    = requirements.Value <int>("dexterity");
                xml.Strength     = requirements.Value <int>("strength");
                xml.Intelligence = requirements.Value <int>("intelligence");
                xml.Level        = requirements.Value <int>("level");
            }
            else
            {
                xml.Level = 1;
            }
        }
Example #5
0
        private void ParseProperties(ItemBaseDto xml)
        {
            var properties = _json["properties"] !;

            if (xml.Tags.HasFlag(Tags.Weapon))
            {
                xml.Properties = FormatToArray(ParseWeaponProperties(properties));
            }
            else if (xml.Tags.HasFlag(Tags.Armour))
            {
                xml.Properties = FormatToArray(ParseArmourProperties(properties));
            }
            else if (xml.Tags.HasFlag(Tags.Flask))
            {
                xml.Properties = FormatToArray(ParseFlaskProperties(properties));
            }
            else
            {
                xml.Properties = new string[0];
            }
        }
Example #6
0
        public ItemBase(ItemImageService itemImageService, ModDatabase modDatabase, ItemBaseDto xmlBase)
        {
            Level                = xmlBase.Level;
            RequiredStrength     = xmlBase.Strength;
            RequiredDexterity    = xmlBase.Dexterity;
            RequiredIntelligence = xmlBase.Intelligence;
            DropDisabled         = xmlBase.DropDisabled;
            InventoryHeight      = xmlBase.InventoryHeight;
            InventoryWidth       = xmlBase.InventoryWidth;

            Name       = xmlBase.Name;
            ItemClass  = xmlBase.ItemClass;
            Tags       = xmlBase.Tags;
            MetadataId = xmlBase.MetadataId;

            ImplicitMods   = xmlBase.Implicit.Select(id => modDatabase.Mods[id]).ToList();
            _properties    = xmlBase.Properties;
            CanHaveQuality = Tags.HasFlag(Tags.Weapon) || Tags.HasFlag(Tags.Armour);

            Image = new ItemImage(itemImageService, Name, ItemClass);

            MaximumNumberOfSockets = GetMaximumNumberOfSockets();
        }
Example #7
0
 private void ParseImplicits(ItemBaseDto xml)
 {
     xml.Implicit = _json["implicits"] !.Values <string>().ToArray();
 }
Example #8
0
 private void ParseItemClass(ItemBaseDto xml)
 {
     ItemClassEx.TryParse(_json.Value <string>("item_class"), out var itemClass);
     xml.ItemClass = itemClass;
 }