public int UpgradeKarmaCost() { if (_character.Improvements.Any(x => ((x.ImproveType == Improvement.ImprovementType.SkillGroupDisable && x.ImprovedName == Name) || (x.ImproveType == Improvement.ImprovementType.SkillGroupCategoryDisable && GetRelevantSkillCategories.Contains(x.ImprovedName))) && x.Enabled)) { return(-1); } int rating = SkillList.Min(x => x.TotalBaseRating); int intReturn = 0; int intOptionsCost = 1; if (rating == 0) { intOptionsCost = Character.Options.KarmaNewSkillGroup; intReturn = intOptionsCost; } else if (RatingMaximum > rating) { intOptionsCost = Character.Options.KarmaImproveSkillGroup; intReturn = (rating + 1) * intOptionsCost; } else { return(-1); } List <string> lstRelevantCategories = GetRelevantSkillCategories.ToList(); decimal decMultiplier = 1.0m; int intExtra = 0; foreach (Improvement objLoopImprovement in _character.Improvements) { if ((objLoopImprovement.Maximum == 0 || rating <= objLoopImprovement.Maximum) && objLoopImprovement.Minimum <= rating && (string.IsNullOrEmpty(objLoopImprovement.Condition) || (objLoopImprovement.Condition == "career") == _character.Created || (objLoopImprovement.Condition == "create") != _character.Created) && objLoopImprovement.Enabled) { if (objLoopImprovement.ImprovedName == Name || string.IsNullOrEmpty(objLoopImprovement.ImprovedName)) { if (objLoopImprovement.ImproveType == Improvement.ImprovementType.SkillGroupKarmaCost) { intExtra += objLoopImprovement.Value; } else if (objLoopImprovement.ImproveType == Improvement.ImprovementType.SkillGroupKarmaCostMultiplier) { decMultiplier *= objLoopImprovement.Value / 100.0m; } } else if (lstRelevantCategories.Contains(objLoopImprovement.ImprovedName)) { if (objLoopImprovement.ImproveType == Improvement.ImprovementType.SkillGroupCategoryKarmaCost) { intExtra += objLoopImprovement.Value; } else if (objLoopImprovement.ImproveType == Improvement.ImprovementType.SkillGroupCategoryKarmaCostMultiplier) { decMultiplier *= objLoopImprovement.Value / 100.0m; } } } } if (decMultiplier != 1.0m) { intReturn = decimal.ToInt32(decimal.Ceiling(intReturn * decMultiplier)); } intReturn += intExtra; return(Math.Max(intReturn, Math.Min(1, intOptionsCost))); }