예제 #1
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);
         }
     }
 }
예제 #2
0
        public void JsonMod_UnknownTags()
        {
            var unexpectedTags = (
                from mod in _mods.Values
                where mod.Domain != ModDomain.Area && mod.Domain != ModDomain.Atlas
                from spawnWeight in mod.SpawnWeights
                let tag = spawnWeight.Tag
                          where !tag.EndsWith("_shaper") && !tag.EndsWith("_elder") &&
                          !TagsExtensions.TryParse(tag, out var _) &&
                          !UnknownTags.Contains(tag)
                          select tag
                ).ToHashSet();

            Assert.AreEqual(0, unexpectedTags.Count, string.Join(", ", unexpectedTags));
        }
예제 #3
0
        private void ParseTags()
        {
            var unknownTags = new HashSet <string>();

            foreach (var s in _json["tags"].Values <string>())
            {
                if (TagsExtensions.TryParse(s, out var tag))
                {
                    _xml.Tags |= tag;
                }
                else
                {
                    unknownTags.Add(s);
                }
            }

            UnknownTags = unknownTags.ToList();
        }
예제 #4
0
 /// <param name="id">the id of this mod</param>
 /// <param name="jsonMod">the <see cref="JsonMod"/> to encapsulate</param>
 /// <param name="jsonBenchOptions">the master crafting options with which this mod can be crafted</param>
 public Mod(string id, JsonMod jsonMod, IEnumerable <JsonCraftingBenchOption> jsonBenchOptions)
 {
     Id = id;
     foreach (var jsonMasterMod in jsonBenchOptions)
     {
         foreach (var itemClass in jsonMasterMod.ItemClasses)
         {
             if (ItemClassEx.TryParse(itemClass, out ItemClass enumClass))
             {
                 _itemClasses.Add(enumClass);
             }
         }
     }
     foreach (var spawnWeight in jsonMod.SpawnWeights)
     {
         if (TagsExtensions.TryParse(spawnWeight.Tag, out Tags tag))
         {
             _spawnTags.Add(Tuple.Create(tag, spawnWeight.CanSpawn));
         }
     }
     JsonMod = jsonMod;
     Stats   = jsonMod.Stats.Select(s => new Stat(s)).ToList();
 }