Exemplo n.º 1
0
        public static Defense FromAttributes(Dictionary <AttributeName, float> attributes)
        {
            var result = new Defense();

            foreach (var attr in attributes)
            {
                switch (attr.Key)
                {
                case AttributeName.Defense:
                    result.DefenseAttribute = (int)attr.Value;
                    break;

                case AttributeName.PhysicalDamageReduction:
                    result.AddDefense(DamageTypeName.Physical, attr.Value);
                    break;

                case AttributeName.ColdResistance:
                    result.AddDefense(DamageTypeName.Cold, attr.Value);
                    break;

                case AttributeName.LightningResistance:
                    result.AddDefense(DamageTypeName.Lightning, attr.Value);
                    break;

                case AttributeName.FireResistance:
                    result.AddDefense(DamageTypeName.Fire, attr.Value);
                    break;

                case AttributeName.NonPhysicalDamageReduction:
                    result.AddDefense(DamageTypeName.Cold, attr.Value);
                    result.AddDefense(DamageTypeName.Lightning, attr.Value);
                    result.AddDefense(DamageTypeName.Fire, attr.Value);
                    break;
                }
            }

            return(result);
        }