Esempio n. 1
0
        public void Apply(IBonusConfiguration config, ItemConfiguration itemConfiguration, NameBuilder name)
        {
            var weaponConfig = (WeaponItemConfiguration)itemConfiguration;

            var element    = ItemGeneratorHelper.GetRandomDamageElement();
            var min        = int.Parse(config.Values[KeyMin]);
            var max        = int.Parse(config.Values[KeyMax]);
            var difference = int.Parse(config.Values[KeyDifference]);

            var maxValue = RandomHelper.GetRandomValue(min, max);
            var minValue = Math.Max(0, maxValue - difference);

            if (maxValue == 0)
            {
                return;
            }

            if (weaponConfig.MaxDamage.ContainsKey(element))
            {
                weaponConfig.MaxDamage[element] += maxValue;
                weaponConfig.MinDamage[element] += minValue;
            }
            else
            {
                weaponConfig.MaxDamage.Add(element, maxValue);
                weaponConfig.MinDamage.Add(element, minValue);
            }

            var bonusCode = GetBonusCode(element);

            name.AddNamePrefix(bonusCode, GetElementPrefix(element));
            name.AddDescription(bonusCode, GetBonusDescription(element));
        }
Esempio n. 2
0
        public void Apply(IBonusConfiguration config, ItemConfiguration itemConfiguration, NameBuilder name)
        {
            var armorConfig = (ArmorItemConfiguration)itemConfiguration;

            var element = ItemGeneratorHelper.GetRandomDamageElement();
            var min     = int.Parse(config.Values[KeyMin]);
            var max     = int.Parse(config.Values[KeyMax]);

            var protection = RandomHelper.GetRandomValue(min, max);

            if (armorConfig.Protection.ContainsKey(element))
            {
                armorConfig.Protection[element] += protection;
            }
            else
            {
                armorConfig.Protection.Add(element, protection);
            }

            var bonusCode = GetBonusCode(element);

            name.AddNamePostfix(bonusCode, string.Format(NamePostfixTemplate, TextHelper.GetElementName(element)));
            name.AddDescription(bonusCode, GetBonusDescription(element));
        }