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)); }
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."); }
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."); }
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."); }
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()); }