Esempio n. 1
0
        private static Affix ConvertFomItemAffixJson(ItemAffixJson source)
        {
            if (source == null || source.Name == null)
            {
                return(null);
            }

            var name   = source.Name;
            var attack = new Attack("", 0);

            if (source.AttackData.ContainsKey("element"))
            {
                attack = attack.Brand((Element)Enum.Parse(typeof(Element), source.AttackData["element"].ToString()));
            }

            if (source.AttackData.ContainsKey("damageBonus"))
            {
                attack = attack.AddDamage((double)source.AttackData["damageBonus"]);
            }

            if (source.AttackData.ContainsKey("strikeBonus"))
            {
                attack = attack.AddStrike((double)source.AttackData["strikeBonus"]);
            }

            if (source.AttackData.ContainsKey("damageScale"))
            {
                attack = attack.MultiplyDamage((double)source.AttackData["damageScale"]);
            }


            var affix = new Affix(name, attack);

            return(affix);
        }