/// <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> /// <param name="spawnWeightsReplacement">replacement spawn weights if this mod can only be spawned by different /// means, e.g. as a master signature mod</param> public Mod(string id, JsonMod jsonMod, IEnumerable <JsonCraftingBenchOption> jsonBenchOptions, IEnumerable <JsonSpawnWeight> spawnWeightsReplacement) { Id = id; foreach (var jsonMasterMod in jsonBenchOptions) { foreach (var itemClass in jsonMasterMod.ItemClasses) { if (ItemClassEx.TryParse(itemClass, out ItemClass enumClass)) { _itemClasses.Add(enumClass); } } } var spawnWeights = spawnWeightsReplacement ?? jsonMod.SpawnWeights; foreach (var spawnWeight in spawnWeights) { if (TagsEx.TryParse(spawnWeight.Tag, out Tags tag)) { _spawnTags.Add(Tuple.Create(tag, spawnWeight.CanSpawn)); } } JsonMod = jsonMod; Stats = jsonMod.Stats.Select(s => new Stat(s)).ToList(); }
private XmlItemBase PrintoutsToBase(ItemClass itemClass, JToken printouts) { // name, requirements and implicts; same for all categories var implicits = PluralValue <string>(printouts, RdfImplicits).ToArray(); var item = new XmlItemBase { Level = SingularValue <int>(printouts, RdfLvlReq), Dexterity = SingularValue(printouts, RdfBaseDexReq, 0), Intelligence = SingularValue(printouts, RdfBaseIntReq, 0), Strength = SingularValue(printouts, RdfBaseStrReq, 0), Name = SingularValue <string>(printouts, RdfName), DropDisabled = !SingularBool(printouts, RdfDropEnabled, true), InventoryHeight = SingularValue(printouts, RdfInventoryHeight, 1), InventoryWidth = SingularValue(printouts, RdfInventoryWidth, 1), MetadataId = SingularValue <string>(printouts, RdfMetadataId), Implicit = implicits, ItemClass = itemClass, }; // tags and properties foreach (var s in PluralValue <string>(printouts, RdfTags)) { Tags tag; if (TagsEx.TryParse(s, out tag)) { item.Tags |= tag; } else { _unknownTags.Add(s); } } // properties; tag specific var propBuilder = new PropertyBuilder(printouts); if (item.Tags.HasFlag(Tags.Weapon)) { propBuilder.Add("Physical Damage: {0}-{1}", RdfBasePhysMin, RdfBasePhysMax); propBuilder.Add("Critical Strike Chance: {0}%", RdfBaseCritChance); propBuilder.Add("Attacks per Second: {0}", RdfBaseAttackSpeed); propBuilder.Add("Weapon Range: {0}", RdfBaseWeaponRange); } if (item.Tags.HasFlag(Tags.Armour)) { propBuilder.Add("Chance to Block: {0}%", RdfBaseBlock); propBuilder.Add("Armour: {0}", RdfBaseArmour); propBuilder.Add("Evasion Rating: {0}", RdfBaseEvasion); propBuilder.Add("Energy Shield: {0}", RdfBaseEnergyShield); } item.Properties = propBuilder.ToArray(); return(item); }
public async Task JsonSignatureMod_UnknownTags() { await _initialization; foreach (var mod in _npcMasters.Values.Select(n => n.SignatureMod)) { foreach (var spawnWeight in mod.SpawnWeights) { Tags tag; if (!TagsEx.TryParse(spawnWeight.Tag, out tag)) { Assert.IsTrue(UnknownTags.Contains(spawnWeight.Tag), spawnWeight.Tag + " unknown"); } } } }
public async Task JsonMod_UnknownTags() { await _initialization; 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") && !TagsEx.TryParse(tag, out var _) && !UnknownTags.Contains(tag) select tag ).ToHashSet(); Assert.AreEqual(0, unexpectedTags.Count, string.Join(", ", unexpectedTags)); }
public async Task JsonMod_UnknownTags() { await _initialization; foreach (var mod in _mods.Values) { foreach (var spawnWeight in mod.SpawnWeights) { Tags tag; if (!TagsEx.TryParse(spawnWeight.Tag, out tag)) { Assert.IsTrue(UnknownTags.Contains(spawnWeight.Tag), spawnWeight.Tag + " unknown"); } } } }
private void ParseTags() { var unknownTags = new HashSet <string>(); foreach (var s in _json["tags"].Values <string>()) { if (TagsEx.TryParse(s, out var tag)) { _xml.Tags |= tag; } else { unknownTags.Add(s); } } UnknownTags = unknownTags.ToList(); }