Exemplo 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));
        }
Exemplo n.º 2
0
        public void Apply(IBonusConfiguration config, ItemConfiguration itemConfiguration, NameBuilder name)
        {
            var equipableConfig = (EquipableItemConfiguration)itemConfiguration;

            var bonusType = (EquipableBonusType)Enum.Parse(typeof(EquipableBonusType), config.Values[KeyBonusType]);

            var min   = int.Parse(config.Values[KeyMin]);
            var max   = int.Parse(config.Values[KeyMax]);
            var bonus = RandomHelper.GetRandomValue(min, max);

            if (bonus == 0)
            {
                return;
            }

            if (!equipableConfig.Bonuses.ContainsKey(bonusType))
            {
                equipableConfig.Bonuses.Add(bonusType, 0);
            }
            equipableConfig.Bonuses[bonusType] += bonus;

            var bonusCode = GetBonusCode(bonusType);

            name.AddNamePostfix(bonusCode, GetNamePostfix(bonusType));
            name.AddDescription(bonusCode, GetBonusText(bonusType));
        }
Exemplo n.º 3
0
        public void Apply(IBonusConfiguration config, ItemConfiguration itemConfiguration, NameBuilder name)
        {
            var weightDecrease = int.Parse(config.Values[KeyWeightDecrease]);

            itemConfiguration.Weight = (int)Math.Round(itemConfiguration.Weight * (100 - weightDecrease) / 100f);

            name.AddNamePrefix(BonusCode, NamePrefix);
            name.AddDescription(BonusCode, "It weights less than similar items.");
        }
Exemplo n.º 4
0
        private void ApplyBonus(ItemConfiguration item, NameBuilder name, IBonusConfiguration bonusConfig)
        {
            if (!BonusAppliers.ContainsKey(bonusConfig.Type))
            {
                throw new ApplicationException($"Bonus applier not found for bonus type: {bonusConfig.Type}");
            }

            var applier = BonusAppliers[bonusConfig.Type];

            applier.Apply(bonusConfig, item, name);
        }
Exemplo n.º 5
0
        public void Apply(IBonusConfiguration config, ItemConfiguration itemConfiguration, NameBuilder name)
        {
            var possiblePower = GetPossibleLightPower(config);
            var power         = RandomHelper.GetRandomElement(possiblePower);

            var equipableConfig = (EquipableItemConfiguration)itemConfiguration;

            equipableConfig.LightPower = power;

            name.AddNamePrefix(BonusCode, NamePrefix);
            name.AddDescription(BonusCode, "It emits some light.");
        }
Exemplo n.º 6
0
        public void Apply(IBonusConfiguration config, ItemConfiguration itemConfiguration, NameBuilder name)
        {
            if (!(itemConfiguration is DurableItemConfiguration item))
            {
                throw new ApplicationException(
                          $"{nameof(DurabilityBonusApplier)} cannot be applied to item configuration {itemConfiguration.GetType().Name}");
            }

            var min   = int.Parse(config.Values[KeyMin]);
            var max   = int.Parse(config.Values[KeyMax]);
            var bonus = RandomHelper.GetRandomValue(min, max);

            if (bonus == 0)
            {
                return;
            }

            item.MaxDurability = (int)Math.Round(item.MaxDurability * (1 + bonus / 100d));

            name.AddNamePrefix(BonusCode, "Durable");
            name.AddDescription(BonusCode, "This item looks more durable.");
        }
Exemplo n.º 7
0
        public void Apply(IBonusConfiguration config, ItemConfiguration itemConfiguration, NameBuilder name)
        {
            if (!(itemConfiguration is WeaponItemConfiguration item))
            {
                throw new ApplicationException(
                          $"{nameof(AccuracyBonusApplier)} cannot be applied to item configuration {itemConfiguration.GetType().Name}");
            }

            var min   = int.Parse(config.Values[KeyMin]);
            var max   = int.Parse(config.Values[KeyMax]);
            var bonus = RandomHelper.GetRandomValue(min, max);

            if (bonus == 0)
            {
                return;
            }

            item.HitChance = Math.Min(100, (int)Math.Round(item.HitChance * (1 + bonus / 100d)));

            name.AddNamePrefix(BonusCode, "Balanced");
            name.AddDescription(BonusCode, GetDescription());
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
        private LightLevel[] GetPossibleLightPower(IBonusConfiguration config)
        {
            var powerStrings = config.Values[KeyPower].Replace(" ", "").Split(',');

            return(powerStrings.Select(powerString => Enum.Parse(typeof(LightLevel), powerString)).Cast <LightLevel>().ToArray());
        }