/* * public int GetScore(GetBonusDto bonusDto) * { * if (BaseValue.HasValue && !Bonus.Any()) * { * return BaseValue.Value; * } * else if (BaseValue.HasValue) * { * var localBonus = new MaxBonusList<Bonus>(); * localBonus.AddRange(Bonus.Where(x => !x.IsTemporary())); * * return BaseValue.Value + localBonus.GetMaxValue(bonusDto); * } * return 0; * } * * public int GetCurrent(GetBonusDto bonusDto) * { * return (GetScore(bonusDto) - 10) / 2; * } * public int? GetTempScore(GetBonusDto bonusDto) * { * if (Bonus.Any(x => x.IsTemporary() && x.IsActive())) * { * return (GetScore(bonusDto) + Bonus.Where(x => x.IsTemporary()).Sum(x => x.GetBonus(bonusDto))); * } * return null; * } * * public int? GetTempModifier(GetBonusDto bonusDto) * { * var tempScore = GetTempScore(bonusDto); * if (!tempScore.HasValue) * { * return null; * } * return (tempScore.Value - 10) / 2; * } * * public bool ChangeTime(List<SpecialAbility> currentSpecialAbilities, TimeLimitUnit unit, List<AbilityScore> abilities) * { * Bonus.ChangeTime(currentSpecialAbilities, unit, abilities); * return false; * } * * public void AddBonues(List<Bonus> bonues) * { * foreach (var bonus in bonues) * { * if (bonus.ShouldApplyTo(Ability)) * { * Bonus.Add(bonus); * } * } * } * * public void RemoveBonues(List<Bonus> bonues) * { * if (bonues == null) * { * return; * } * foreach (var bonus in bonues) * { * Bonus.RemoveAll(x => x.ID == bonus.ID); * } * } * * public int GetCurrentModifier(GetBonusDto bonusDto) * { * var tempBonus = GetTempModifier(bonusDto); * if (tempBonus.HasValue) * { * return tempBonus.Value; * } * return GetCurrent(bonusDto); * } * public int GetScoreValue(GetBonusDto bonusDto) * { * var tempValue = GetTempScore(bonusDto); * if (tempValue.HasValue) * { * return tempValue.Value; * } * return GetScore(bonusDto); * }*/ public CalculatedString GetCurrent(GetBonusDto bonusDto) { var activeBonuses = Tools.GetBonusesApplyingTo(Ability.ID, BonusApplyToType.Ability, bonusDto.ActiveBonus.ToList()); var passiveBonuses = Tools.GetBonusesApplyingTo(Ability.ID, BonusApplyToType.Ability, bonusDto.PassiveBonus.ToList()); var calcStr = new CalculatedString(); calcStr.AddIfNotZero(Ability.Name, null, BaseValue.GetValueOrDefault()); calcStr.AddPartsByRef(passiveBonuses, bonusDto); calcStr.AddPartsByRef(activeBonuses, bonusDto); return(calcStr); }
public int GetCurrentModifier(GetBonusDto bonusDto) { var activeBonuses = Tools.GetBonusesApplyingTo(Ability.ID, BonusApplyToType.Ability, bonusDto.ActiveBonus.ToList()); var passiveBonuses = Tools.GetBonusesApplyingTo(Ability.ID, BonusApplyToType.Ability, bonusDto.PassiveBonus.ToList()); //var activeBonusValue = activeBonuses.Sum(x => x.GetBonus(bonusDto).GetFixedAmount()); //var passiveBonusValue = passiveBonuses.Sum(x => x.GetBonus(bonusDto).GetFixedAmount()); var calcStr = new CalculatedString(); calcStr.AddIfNotZero("Base", null, BaseValue.GetValueOrDefault()); calcStr.AddPartsByRef(activeBonuses, bonusDto); calcStr.AddPartsByRef(passiveBonuses, bonusDto); var newBase = calcStr.GetValueAsInt(); return((newBase - 10) / 2); }
public string GetCriticalRange(GetBonusDto bonusDto) { var critRange = 0; if (Item.CritRange.HasValue) { critRange += Item.CritRange.GetValueOrDefault(); } var calcStr = new CalculatedString(); calcStr.AddPartsByRef(GetItemBonuses(bonusDto).Where(x => x.ShouldApplyToSubType(Configuration.CritRange)).ToList(), bonusDto); if (calcStr.GetValueAsInt() != 0) { critRange *= calcStr.GetValueAsInt(); } string critStr = null; if (critRange == 0) { critStr = "20"; } else { critStr = (20 - critRange).ToString() + " - 20"; } if (Item.CriticalMultiplier.HasValue) { critStr += " x" + Item.CriticalMultiplier; } return(critStr); }
public double GetWeight(GetBonusDto bonusDto) { var weightBonus = GetItemBonuses(bonusDto).Where(x => x.ShouldApplyToSubType(Configuration.WeightReductionInProcentage)).MaxBonusRefList(bonusDto); var calcStr = new CalculatedString(); calcStr.AddPartsByRef(weightBonus, bonusDto); var procentReduction = calcStr.GetValueAsInt(); return(Item.Weight.Lb / 100.0 * (100 - procentReduction)); }
public CalculatedString GetMaxDexBonus(GetBonusDto bonusDto) { var calcStr = new CalculatedString(); if (!Item.MaxDexBonus.HasValue) { return(null); } calcStr.AddIfNotZero("Base", null, Item.MaxDexBonus.Value); calcStr.AddPartsByRef(GetItemBonuses(bonusDto).Where(x => x.ShouldApplyToSubType(Configuration.MaxDexBonus)).ToList(), bonusDto); return(calcStr); }
public static CalculatedString GetDamageReduction(GetBonusDto bonusDto) { //TODO: support different types of dmg reduction. var damageReductionBonues = GetDamageReductionBonues(bonusDto); var max = damageReductionBonues.OrderByDescending(x => x.GetBonus(bonusDto).GetFixedAmount()).ToList(); var calcStr = new CalculatedString(); if (max.Count != 0) { damageReductionBonues = new List <BonusRef>(); damageReductionBonues.Add(max.First()); calcStr.AddPartsByRef(damageReductionBonues, bonusDto); } //TODO: Crystals til våben og armor. return(calcStr); }
public CalculatedString GetAttackBonus(GetBonusDto bonusDto, int currentEquipmentPenelty, int?currentBaseAttackWithItem, int proficiencyPenelty, int shieldPenelty) { var totalEnchantmentBonues = GetEnchantmentBonus(); var masterWorkedBonues = IsMasterWorked() && Item.Type == ItemType.Weapon ? 1 : 0; var abilityBonues = 0; if (Item.UseItemsOwnAbilistyScore.HasValue) { abilityBonues = Item.UseItemsOwnAbilistyScore.Value; } else { if (Item.IsRanged) { abilityBonues = bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiDexId) .GetCurrentModifier(bonusDto); } else { abilityBonues = bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiStrId) .GetCurrentModifier(bonusDto); } } var size = bonusDto.Character.Race.GetAttackAndAcModifier(bonusDto); var calcStr = new CalculatedString(); calcStr.AddIfNotZero("Base Attack", null, currentBaseAttackWithItem.GetValueOrDefault()); calcStr.AddIfNotZero(Item.IsRanged ? "Dexterity" : "Strength", null, abilityBonues); if (totalEnchantmentBonues == 0) { calcStr.AddIfNotZero("Masterworked", null, masterWorkedBonues); } calcStr.AddIfNotZero("Enchantment Bonus", null, totalEnchantmentBonues); calcStr.AddIfNotZero("Equipment Penelty", null, currentEquipmentPenelty); calcStr.AddIfNotZero("Base Attack trade", null, Tools.GetBonusesApplyingTo(Configuration.BabId, BonusApplyToType.BaseAttack, bonusDto.Bonuses).MaxBonuesSum(bonusDto)); calcStr.AddIfNotZero("Proficiency Penelty", null, proficiencyPenelty); calcStr.AddIfNotZero("Shield Penelty", null, shieldPenelty); calcStr.AddIfNotZero("Size", null, size); calcStr.AddPartsByRef(GetItemBonuses(bonusDto).Where(x => x.ShouldApplyToSubType(Configuration.AttackBonues)).ToList(), bonusDto); return(calcStr); }
public CalculatedString GetArmorCheckPenelty(GetBonusDto bonusDto) { var calcStr = new CalculatedString(); calcStr.AddIfNotZero("Base", null, -Item.ArmorCheckPenelty.GetValueOrDefault()); if (IsMasterWorked() && (Item.Type == ItemType.Armor || Item.Type == ItemType.Shield)) { calcStr.AddIfNotZero("Masterworked", null, 1); } var bonuses = GetItemBonuses(bonusDto) .Where(x => x.ShouldApplyToSubType(Configuration.ArmorCheckPeneltyReduction)) .MaxBonusRefList(bonusDto); calcStr.AddPartsByRef(bonuses, bonusDto); return(calcStr); }
//public MaxBonusList<Bonus> Bonuses { get; private set; } //private AbilityScore _str; //private Size _size; //private Classes _classes; public static CalculatedString GetGrappleBonus(GetBonusDto bonusDto) { var calcStr = new CalculatedString(); var str = bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiStrId).GetCurrentModifier(bonusDto); var size = bonusDto.Character.Race.GetSpecialAttackModifier(bonusDto); var baseattack = bonusDto.Character.GetBaseAttack().First(); var bonus = bonusDto.Bonuses.Where(x => x.ShouldApplyTo(new GameId { ID = Configuration.GrappleId }, typeof(Grapple)) && x.ShouldApplyToSubType(null)).MaxBonusRefList(bonusDto); //return str + size + baseattack + bonus; calcStr.AddIfNotZero("Strength", null, str); calcStr.AddIfNotZero("Size", null, size); calcStr.AddIfNotZero("Base attack", null, baseattack); calcStr.AddPartsByRef(bonus, bonusDto); return(calcStr); }
public string GetRange(GetBonusDto bonusDto) { //SetCorrectMaterial(bonusDto); var range = 0; if (Item.RangeIncrement.HasValue) { range += Item.RangeIncrement.GetValueOrDefault(); } var calcStr = new CalculatedString(); calcStr.AddPartsByRef(GetItemBonuses(bonusDto).Where(x => x.ShouldApplyToSubType(Configuration.RangeIncrement)).ToList(), bonusDto); if (calcStr.GetValueAsInt() != 0) { range += calcStr.GetValueAsInt(); } if (range == 0) { return(""); } return(range + "ft"); }