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 CalculatedString GetBase(GetBonusDto bonusDto) { 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); return(calcStr); }
public Trait(string id, string name, string description, Color color) { Index = AllTraits.Count; ObjectID = EffectManager.SetID(this); ID = id; Name = name; Description = description; Color = color; AllTraits.Add(this); }
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 int GetBaseModifier(GetBonusDto bonusDto) { var passiveBonuses = Tools.GetBonusesApplyingTo(Ability.ID, BonusApplyToType.Ability, bonusDto.PassiveBonus.ToList()); //var passiveBonusValue = passiveBonuses.Sum(x => x.GetBonus(bonusDto).GetFixedAmount()); var calcStr = new CalculatedString(); calcStr.AddIfNotZero("Base", null, BaseValue.GetValueOrDefault()); calcStr.AddPartsByRef(passiveBonuses, bonusDto); var newBase = calcStr.GetValueAsInt(); return((newBase - 10) / 2); }
/* * * public string GetWounds() * { * var wounds = string.Empty; * foreach (var wound in wounds) * { * wounds += wound + ","; * } * if (!string.IsNullOrEmpty(wounds)) * { * wounds = wounds.Substring(0, wounds.Length - 1); * } * return wounds; * } * * * * public bool ChangeTime(List<SpecialAbility> currentSpecialAbilities, TimeLimitUnit unit, List<AbilityScore> abilities) * { * Bonuses.ChangeTime(currentSpecialAbilities,unit, abilities); * DamageRecuction.ChangeTime(currentSpecialAbilities,unit); * return false; * } * * public void AddBonues(List<Bonus> bonues) * { * foreach (var bonus in bonues) * { * if (bonus.ShouldApplyTo(this)) * { * Bonuses.Add(bonus); * } * } * DamageRecuction.AddBonues(bonues); * } * public void RemoveBonues(List<Bonus> bonues) * { * if (bonues == null) * { * return; * } * foreach (var bonus in bonues) * { * Bonuses.RemoveAll(x => x.ID == bonus.ID); * } * } * * public int GetDamageReduction(GetBonusDto bonusDto) * { * return DamageRecuction.Bonuses.GetMaxValue(bonusDto); * } * * public void Heal(int hp) * { * DamageTaken = Math.Max(0, DamageTaken - hp); * NonLethalDamageTaken = Math.Max(0, NonLethalDamageTaken - hp); * } * * public void TakeDamage(int dmg, DamageType type, GetBonusDto bonusDto) * { * DamageTaken += DamageRecuction.SubtractReduction(dmg, type, bonusDto); * } * * public void TakeNonLethalDamage(int dmg, DamageType type, GetBonusDto bonusDto) * { * NonLethalDamageTaken += DamageRecuction.SubtractReduction(dmg, type, bonusDto); * }*/ public CalculatedString GetMaxHp(GetBonusDto bonusDto) { var calcStr = new CalculatedString(); calcStr.AddIfNotZero("Base HP", null, BaseHp); var abi = bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiConId).GetCurrentModifier(bonusDto); var lvl = bonusDto.Classes.Sum(x => x.Level); calcStr.AddIfNotZero(string.Format("Constitution ({0}) * Level ({1})", abi, lvl), null, abi * lvl); return(calcStr); //return BaseHp + (bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiConId).GetCurrentModifier(bonusDto) * bonusDto.Classes.Sum(x => x.Level)); }
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 CalculatedString GetNonLethal() { if (NonLethalDamage == null) { NonLethalDamage = new List <DamageTaken>(); } var calcStr = new CalculatedString(); foreach (var damageTaken in NonLethalDamage) { if (damageTaken.Amount < 0) { calcStr.AddIfNotZero("DMG", null, damageTaken.Amount); } else { calcStr.AddIfNotZero("Heal", null, damageTaken.Amount); } } return(calcStr); //return NonLethalDamage.Sum(x => x.Amount); }
public CalculatedString GetCurrentHp(GetBonusDto bonusDto) { if (Damage == null) { Damage = new List <DamageTaken>(); } var calcStr = new CalculatedString(); calcStr.AddIfNotZero("HP", null, GetMaxHp(bonusDto).GetValueAsInt()); foreach (var damageTaken in Damage) { if (damageTaken.Amount < 0) { calcStr.AddIfNotZero("DMG", null, damageTaken.Amount); } else { calcStr.AddIfNotZero("Heal", null, damageTaken.Amount); } } return(calcStr); //return GetMaxHp(bonusDto).GetValueAsInt() - Damage.Sum(x => x.Amount); }
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"); }
public CalculatedString GetDamageString(GetBonusDto bonusDto) { //SetCorrectMaterial(bonusDto); var isTwoHanded = Item.RequiresSlots.Select(x => x.Requirement).Count(x => x == ItemSlotRequirement.WeaponHand) == 2; var damage = Item.Damage; if (damage == null || damage.Amount == null) { return(null); } var calcStr = new CalculatedString(); var bonusList = GetItemBonuses(bonusDto).Where(x => x.ShouldApplyToSubType(Configuration.Damage) || (Item.Type == ItemType.Armor && x.ShouldApplyToSubType(Configuration.DamageArmor)) || (Item.Type == ItemType.Shield && x.ShouldApplyToSubType(Configuration.DamageShield)) || (Item.Type == ItemType.Weapon && x.ShouldApplyToSubType(Configuration.DamageWeapon)) || (Item.Type == ItemType.Other && x.ShouldApplyToSubType(Configuration.DamageMisc)) || (Item.Type == ItemType.Unarmed && x.ShouldApplyToSubType(Configuration.DamageUnarmed)) ).ToList(); calcStr.AddIfNotZero(Item.Name, null, damage.Amount); var enchantmentBonus = GetEnchantmentBonus(); if (enchantmentBonus != 0) { calcStr.AddIfNotZero("Enchantment Bonus", null, new DiceRoll { FixedAmount = enchantmentBonus }); } if (Item.UseItemsOwnAbilistyScore.HasValue) { calcStr.AddIfNotZero("Item Ability Score", null, new DiceRoll { FixedAmount = Item.UseItemsOwnAbilistyScore }); } else { if (!Item.IsRanged) { var abiMod = bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiStrId) .GetCurrentModifier(bonusDto); if (Item.IsOneAndAHalfHanded && bonusDto.EquippedItems.Sum(x => x.Item.RequiresSlots.Count(y => y.Requirement == ItemSlotRequirement.WeaponHand)) == 1) { calcStr.AddIfNotZero("1.5 x Strength", null, new DiceRoll { FixedAmount = (int)((double)abiMod * 1.5) }); } else if (isTwoHanded) { calcStr.AddIfNotZero("1.5 x Strength", null, new DiceRoll { FixedAmount = (int)((double)abiMod * 1.5) }); } else { calcStr.AddIfNotZero("Strength", null, new DiceRoll { FixedAmount = abiMod }); } } } foreach (var bonus in bonusList) { if (bonus.Bonues != null && bonus.Bonues.ParentAbility != null && bonus.Bonues.ParentAbility.Limit != null && bonus.Bonues.ParentAbility.Limit.Amount.TradeDoubleIfThw && isTwoHanded) { var b = bonus.GetBonus(bonusDto); b.FixedAmount *= 2; calcStr.AddIfNotZero(bonus.Parent.Name, bonus.GetCondition(), b); } else { calcStr.AddIfNotZero(bonus.Parent.Name, bonus.GetCondition(), bonus.GetBonus(bonusDto)); } } return(calcStr); }