public StatEffect( StatName statName, string customDescription, byte level, FuncBonusAtLevel formulaValueBonus, FuncBonusAtLevel formulaPercentBonus, double valueBonus, double percentBonus) { this.StatName = statName; this.Level = level; this.Description = customDescription ?? statName.GetAttribute <DescriptionAttribute>()?.Description ?? throw new Exception("There is no [Description] attribute for stat " + statName); if (formulaValueBonus == null && formulaPercentBonus == null && valueBonus == 0 && percentBonus == 0) { throw new ArgumentNullException( $"Both provided formulas for stat effect \'{statName}\" are null and {nameof(valueBonus)} and {nameof(percentBonus)} are zero"); } this.FormulaValueBonus = formulaValueBonus; this.FormulaPercentBonus = formulaPercentBonus; this.ValueBonus = valueBonus; this.PercentBonus = percentBonus; }
public static string GetFullStatTitle(StatName statName) { var title = statName.GetDescription(); var attributeSkill = statName.GetAttribute <RelatedToSkillAttribute>(); var skillName = attributeSkill?.ProtoSkill?.Name; if (skillName is null) { return(title); } // ReSharper disable once CanExtractXamlLocalizableStringCSharp return($"({skillName}) {title}"); }