Example #1
0
 public static JsonItem FromItem(Item i)
 {
     if (i == null)
     {
         return(null);
     }
     else
     {
         JsonItem res = new JsonItem(i.Id, i.Name, SlotUtil.ToString(i.Slot), Attributes.ToStringDic(i.Attributes), ClassicCraft.Enchantment.FromEnchantment(i.Enchantment));
         if (res.Stats != null)
         {
             if (res.Stats.ContainsKey("CritChance"))
             {
                 res.Stats["CritChance"] *= 100;
             }
             if (res.Stats.ContainsKey("HitChance"))
             {
                 res.Stats["HitChance"] *= 100;
             }
             if (res.Stats.ContainsKey("AS"))
             {
                 res.Stats["AS"] *= 100;
             }
         }
         if (res.Enchantment != null)
         {
             if (res.Enchantment.Stats.ContainsKey("CritChance"))
             {
                 res.Enchantment.Stats["CritChance"] *= 100;
             }
             if (res.Enchantment.Stats.ContainsKey("HitChance"))
             {
                 res.Enchantment.Stats["HitChance"] *= 100;
             }
             if (res.Enchantment.Stats.ContainsKey("AS"))
             {
                 res.Enchantment.Stats["AS"] *= 100;
             }
         }
         return(res);
     }
 }