Example #1
0
 public static JsonWeapon FromWeapon(Weapon w)
 {
     if (w == null)
     {
         return(null);
     }
     else
     {
         JsonWeapon res = new JsonWeapon(w.DamageMin, w.DamageMax, w.Speed, w.TwoHanded, Weapon.TypeToString(w.Type), w.Id, w.Name, Attributes.ToStringDic(w.Attributes), ClassicCraft.Enchantment.FromEnchantment(w.Enchantment), ClassicCraft.Enchantment.FromEnchantment(w.Buff), SchoolToString(w.School));
         if (res.Stats != null)
         {
             if (res.Stats.ContainsKey("Crit"))
             {
                 res.Stats["Crit"] *= 100;
             }
             if (res.Stats.ContainsKey("Hit"))
             {
                 res.Stats["Hit"] *= 100;
             }
             if (res.Stats.ContainsKey("AS"))
             {
                 res.Stats["AS"] *= 100;
             }
             if (res.Stats.ContainsKey("SpellHit"))
             {
                 res.Stats["SpellHit"] *= 100;
             }
             if (res.Stats.ContainsKey("SpellCrit"))
             {
                 res.Stats["SpellCrit"] *= 100;
             }
         }
         if (res.Enchantment != null)
         {
             if (res.Enchantment.Stats.ContainsKey("Crit"))
             {
                 res.Enchantment.Stats["Crit"] *= 100;
             }
             if (res.Enchantment.Stats.ContainsKey("Hit"))
             {
                 res.Enchantment.Stats["Hit"] *= 100;
             }
             if (res.Enchantment.Stats.ContainsKey("AS"))
             {
                 res.Enchantment.Stats["AS"] *= 100;
             }
             if (res.Enchantment.Stats.ContainsKey("SpellHit"))
             {
                 res.Enchantment.Stats["SpellHit"] *= 100;
             }
             if (res.Enchantment.Stats.ContainsKey("SpellCrit"))
             {
                 res.Enchantment.Stats["SpellCrit"] *= 100;
             }
         }
         if (res.Buff != null)
         {
             if (res.Buff.Stats.ContainsKey("Crit"))
             {
                 res.Buff.Stats["Crit"] *= 100;
             }
             if (res.Buff.Stats.ContainsKey("Hit"))
             {
                 res.Buff.Stats["Hit"] *= 100;
             }
             if (res.Buff.Stats.ContainsKey("AS"))
             {
                 res.Buff.Stats["AS"] *= 100;
             }
             if (res.Buff.Stats.ContainsKey("SpellHit"))
             {
                 res.Buff.Stats["SpellHit"] *= 100;
             }
             if (res.Buff.Stats.ContainsKey("SpellCrit"))
             {
                 res.Buff.Stats["SpellCrit"] *= 100;
             }
         }
         return(res);
     }
 }
Example #2
0
        public static Dictionary <Player.Slot, Item> ToEquipment(JsonWeapon mh, JsonWeapon oh, JsonWeapon ranged, Dictionary <string, JsonItem> je)
        {
            Dictionary <Player.Slot, Item> res = new Dictionary <Player.Slot, Item>();

            foreach (Player.Slot slot in (Player.Slot[])Enum.GetValues(typeof(Player.Slot)))
            {
                if (slot == Player.Slot.MH)
                {
                    res.Add(slot, JsonWeapon.ToWeapon(mh));
                }
                else if (slot == Player.Slot.OH)
                {
                    res.Add(slot, JsonWeapon.ToWeapon(oh));
                }
                else if (slot == Player.Slot.Ranged)
                {
                    res.Add(slot, JsonWeapon.ToWeapon(ranged));
                }
                else
                {
                    Item   i = null;
                    string s = Player.FromSlot(slot);

                    if (je.ContainsKey(s))
                    {
                        i = JsonItem.ToItem(je[s]);
                    }

                    res.Add(slot, JsonItem.ToItem(je[Player.FromSlot(slot)]));
                }
            }

            return(res);
        }