/// <inheritdoc /> public Armor Convert(ItemDTO value, object state) { var entity = new Leggings(); this.Merge(entity, value, state); return(entity); }
private void CreateLeggings() { Leggings newLeggings = new Leggings(); newLeggings.name = "Nothing"; newLeggings.description = ":flushed:"; newLeggings.defense = 0; leggingList.Add(newLeggings); // newLeggings = new Leggings(); newLeggings.name = "Taffy's Husky Jeans"; newLeggings.description = "Big pants for a big boy"; newLeggings.defense = 40; leggingList.Add(newLeggings); // newLeggings = new Leggings(); newLeggings.name = "Bean bag pants"; newLeggings.description = "Pants and a bean bag at the same time! Now try getting out these"; newLeggings.defense = -3; leggingList.Add(newLeggings); }
// Implement this method in a buddy class to set properties that are specific to 'Leggings' (if any) partial void Merge(Leggings entity, ItemDTO dto, object state);
public override string GenerateJson(bool topLevel) { var b = new StringBuilder(base.GenerateJson(topLevel)); if (!string.IsNullOrWhiteSpace(CustomName)) { b.AppendFormat("CustomName:\"{0}\",", CustomName.EscapeJsonString()); } if (!string.IsNullOrWhiteSpace(CustomName) && CustomNameVisible) { b.Append("CustomNameVisible:1b,"); } if (CanPickUpLoot) { b.Append("CanPickUpLoot:1b,"); } if (PersistanceRequired) { b.Append("PersistanceRequired:1b,"); } if (NoAi) { b.Append("NoAI:1b,"); } var holding = Holding.GenerateJson(false); var boots = Boots.GenerateJson(false); var leggings = Leggings.GenerateJson(false); var chest = Chestplate.GenerateJson(false); var helm = Helmet.GenerateJson(false); if (holding != string.Empty) { holding = holding.Remove(holding.Length - 1, 1); } if (boots != string.Empty) { boots = boots.Remove(boots.Length - 1, 1); } if (leggings != string.Empty) { leggings = leggings.Remove(leggings.Length - 1, 1); } if (chest != string.Empty) { chest = chest.Remove(chest.Length - 1, 1); } if (helm != string.Empty) { helm = helm.Remove(helm.Length - 1, 1); } if (holding != string.Empty || boots != string.Empty || leggings != string.Empty || chest != string.Empty || helm != string.Empty) { b.AppendFormat("Equipment:[0:{{{0}}},1:{{{1}}},2:{{{2}}},3:{{{3}}},4:{{{4}}}],", holding, boots, leggings, chest, helm); } if (DefaultHealth.HasValue && Health != DefaultHealth) { b.AppendFormat("HealF:{0}f,", Health); } StringBuilder aBuilder; if (PotionEffects.Count > 0) { aBuilder = new StringBuilder(); for (var i = 0; i < PotionEffects.Count; i++) { var attribute = PotionEffects[i]; var generateJson = attribute.GenerateJson(false); if (!string.IsNullOrWhiteSpace(generateJson)) { aBuilder.AppendFormat("{0}:{{{1}}},", i, generateJson); } } aBuilder.Remove(aBuilder.Length - 1, 1); if (aBuilder.Length > 0) { b.AppendFormat("ActiveEffects:[{0}],", aBuilder); } } if (Attributes.Count > 0) { aBuilder = new StringBuilder(); for (var i = 0; i < Attributes.Count; i++) { var attribute = Attributes[i]; var generateJson = attribute.GenerateJson(false); if (!string.IsNullOrWhiteSpace(generateJson)) { aBuilder.AppendFormat("{0}:{{{1}}},", i, generateJson); } } aBuilder.Remove(aBuilder.Length - 1, 1); if (aBuilder.Length > 0) { b.AppendFormat("Attributes:[{0}],", aBuilder); } } if (Math.Abs(DropChanceFloats[0].Value) > 0.001 || Math.Abs(DropChanceFloats[1].Value) > 0.001 || Math.Abs(DropChanceFloats[2].Value) > 0.001 || Math.Abs(DropChanceFloats[3].Value) > 0.001 || Math.Abs(DropChanceFloats[4].Value) > 0.001) { b.AppendFormat("DropChances:[0:{0:0.##}f,1:{1:0.##}f,2:{2:0.##}f,3:{3:0.##}f,4:{4:0.##}f],", DropChanceFloats[0].Value, DropChanceFloats[1].Value, DropChanceFloats[2].Value, DropChanceFloats[3].Value, DropChanceFloats[4].Value); } return(b.ToString()); }