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 List <BonusRef> GetShieldAcBonus(GetBonusDto bonusDto) { var itemAcBonus = GetShieldAcBonusList(bonusDto); if (Item.Type == ItemType.Shield) { var currentEnchantmentBonus = itemAcBonus.FirstOrDefault(x => x.Bonues.Type == BonusType.EnhancementBonus); if (currentEnchantmentBonus != null) { currentEnchantmentBonus.Bonues.BonusValue.FixedValue += OwnerEnchamtmentBonues.GetValueOrDefault(); } else { itemAcBonus.Add(new BonusRef(Item, new Bonus { Type = BonusType.EnhancementBonus, BonusValue = new BonusToAdd { FixedValue = OwnerEnchamtmentBonues.GetValueOrDefault() } })); } } return(itemAcBonus); }
private int GetItemProficiencyPenelty(GetBonusDto bonusDto, OwnedItem equipedItem) { if (equipedItem == null || equipedItem.Item == null || equipedItem.Item.RequiresAbility == null || equipedItem.Item.RequiresAbility.Count == 0) { return(0); } if (equipedItem.Item.Type != ItemType.Weapon) { return(0); } var foundAbilities = bonusDto.Feats.Where( x => equipedItem.Item.RequiresAbility.Select(y => y.SpecialAbilityGuid).Contains(x.ID)) .ToList(); if (foundAbilities.Count != equipedItem.Item.RequiresAbility.Count) { return(-4); } if (foundAbilities.Any(x => !x.IsActive(bonusDto))) { return(-4); } return(0); }
public int GetRoundsLeft(GetBonusDto bonues, Guid parentAbilityId) { var abilityActiveFor = bonues.Round.ActivatedAbilities.Where(x => x.AbilityId == parentAbilityId && x.IsActive).Select(x => x.ActiveTime).SelectMany(x => x).ToList(); var numberOfRoundsActive = 0; foreach (var currentAbilityActiveFor in abilityActiveFor) { switch (currentAbilityActiveFor.Time) { case TimeLimitUnit.Attack: return(0); //break; case TimeLimitUnit.Round: numberOfRoundsActive++; break; case TimeLimitUnit.Encounter: numberOfRoundsActive += 600; break; case TimeLimitUnit.Day: numberOfRoundsActive += 10 * 60 * 24; break; } } var nOfRounds = Duration.GetNumberOfRounds(bonues.Abilities, bonues); return(nOfRounds - numberOfRoundsActive); }
public double GetQuadrupedCarryingCapacityMulitplier(GetBonusDto dto) { switch (GetCurrentSize(dto)) { case SizeCategory.Fine: return(0.25); case SizeCategory.Diminutive: return(0.5); case SizeCategory.Tiny: return(0.75); case SizeCategory.Small: return(1.0); case SizeCategory.Medium: return(1.5); case SizeCategory.Large: return(3.0); case SizeCategory.Huge: return(6.0); case SizeCategory.Gargantuan: return(12.0); case SizeCategory.Colossal: return(24.0); } throw new IndexOutOfRangeException("Size not handled"); }
public bool ChangeTime(TimeLimitUnit unit, GetBonusDto bonues, Guid parentAbilityId) { if (GetIsActive(bonues, parentAbilityId)) { var timeLeft = GetRoundsLeft(bonues, parentAbilityId); if (0 >= timeLeft) { if (unit == TimeLimitUnit.Attack) { if (Duration != null && Duration.Unit == DurationUnit.Attack) { return(true); } else { return(false); } } else { return(true); } } } return(false); }
public static List <Save> GetSaves(GetBonusDto bonusDto) { var characterSaves = new List <Save>(); //Adding saves and seeting base save foreach (var classLevel in bonusDto.Classes) { foreach (var saveRate in classLevel.Class.SaveBonusRate) { if (characterSaves.All(x => x.SaveType != saveRate.Save)) { characterSaves.Add(new Save { Description = saveRate.Save.Description, Name = saveRate.Save.Name, SaveType = saveRate.Save, ID = saveRate.Save.ID, SaveBonus = new CalculatedString() }); } var currentSave = characterSaves.First(x => x.SaveType == saveRate.Save); currentSave.AddBaseSave(classLevel.Class.Name, classLevel.Level, saveRate.Rate); } } //Adding bonuses foreach (var characterSave in characterSaves) { characterSave.SetBonuesToSave(bonusDto); } return(characterSaves.OrderBy(x => x.SaveType.Index).ToList()); }
private List <BonusRef> GetShieldAcBonusList(GetBonusDto bonusDto) { var armor = new List <BonusRef>(); if (Item.Type == ItemType.Shield) { armor.Add(new BonusRef(Item, new Bonus { BonusValue = new BonusToAdd { FixedValue = Item.AC.GetValueOrDefault(), }, Type = BonusType.ShieldBonus })); armor.Add(new BonusRef(Item, new Bonus { BonusValue = new BonusToAdd { FixedValue = Item.EnchanmentBonus.GetValueOrDefault(), }, Type = BonusType.EnhancementBonus })); } armor.AddRange(GetItemBonuses(bonusDto).Where(x => x.Type == BonusType.ShieldBonus && x.ShouldApplyToSubType(Configuration.ExtraAC)).MaxBonusRefList(bonusDto)); return(armor); }
public static int SubtractReduction(int dmg, DamageType type, GetBonusDto bonusDto) { var reduction = GetReductionOfType(type, bonusDto); var dmgAfterReduction = Math.Max(0, dmg - reduction); return(dmgAfterReduction); }
public bool UseChargeIfPossible(int charge, GetBonusDto bonues) { if (Limit != null) { if (!Limit.IsChargesPossible(charge, bonues, ID)) { return(false); } Limit.UseChagesIfPossible(charge, bonues, ID); if (ApplyConditionOnActivate != null) { bonues.Round.ApplyCondition(ApplyConditionOnActivate, ID); } //var bonuse = BonusFromCharges.Where(x => x.NumberOfChargesForBonus <= charge) // .OrderByDescending(x => x.NumberOfChargesForBonus) // .FirstOrDefault(); //if (bonuse != null) //{ // foreach (var bonus in Bonuses) // { // bonus.BonusValue.SetFixedBonus(bonuse.Bonus); // } //} } return(true); }
public static int MaxBonuesSum(this IEnumerable <BonusRef> bonues, GetBonusDto dto) { int value = 0; var grps = bonues.GroupBy(x => x.Type); foreach (var grp in grps) { var bonuesValues = grp.Select(x => x.GetBonus(dto)).ToList(); var stacks = DoesStack(grp.Key); if (stacks) { value = bonuesValues.Select(x => x.GetFixedAmount()).Sum(); } else { var min = bonuesValues.Select(x => x.GetFixedAmount()).Min(); var max = bonuesValues.Select(x => x.GetFixedAmount()).Max(); if (min < 0 && max > 0) { value += max + min; } else if (min < 0 && max < 0) { value += min; } else { value += max; } } } return(value); }
public void Heal(int amount, GetBonusDto bonusDto) { var maxHp = GetMaxHp(bonusDto).GetValueAsInt(); var currentHp = GetCurrentHp(bonusDto).GetValueAsInt(); var maxAmountToHeal = Math.Min(maxHp - currentHp, amount); var currentNonLethal = GetNonLethal().GetValueAsInt(); var maxAmountToHealNl = currentNonLethal - Math.Max(0, currentNonLethal - amount); if (maxAmountToHeal != 0) { Damage.Add(new DamageTaken { Amount = maxAmountToHeal }); } if (maxAmountToHealNl != 0) { NonLethalDamage.Add(new DamageTaken { Amount = -maxAmountToHealNl }); } }
private int GetSumedBonus(GetBonusDto bonusDto, IEnumerable <IGrouping <BonusType, T> > grouped) { var sum = 0; foreach (var grp in grouped) { if (!grp.Any()) { continue; } if (grp.Count() == 1) { sum += grp.First().GetBonus(bonusDto).GetFixedAmount(); } else { var orderBonuses = grp.OrderByDescending((x => x.GetBonus(bonusDto).GetFixedAmount())); var first = orderBonuses.First().GetBonus(bonusDto).GetFixedAmount(); var last = orderBonuses.Last().GetBonus(bonusDto).GetFixedAmount(); sum += first; //If both bonuses and penelties exist, apply also largest penelty. if (first > 0 && last < 0) { sum += last; } } } return(sum); }
public int GetAmount(GetBonusDto bonues, Guid parentAbilityId) { var totalAmount = 0; if (FixedAmount.HasValue) { totalAmount += FixedAmount.Value + (Ability == null ? 0 : bonues.Abilities.First(x => x.Ability.ID == Ability.ID).GetCurrentModifier(bonues)); } if (ClassProgression != null) { totalAmount += ClassProgression.Count(x => x.AtLevel <= bonues.Classes.First(y => y.Class.ID == x.ClassProgression.ID).Level); } if (TradeWith != null) { switch (TradeWith.ApplyTo.ApplyToType) { case BonusApplyToType.BaseAttack: totalAmount += bonues.Character.GetCurrentMaxBaseAttack(); break; default: throw new NotImplementedException("Trade not implementet"); } } return(totalAmount - bonues.Round.ActivatedAbilities.Where(x => x.AbilityId == parentAbilityId).Select(x => x.Charges).Sum()); }
public void TakeDamage(DamageType damageType, int amount, GetBonusDto bonus, bool ignorreDmgReduction) { var onHitFeats = bonus.Feats.Where(x => x.Limit != null && x.Limit.Amount != null && x.Limit.Amount.ActionRequired == RoundAction.AutoOnTakeDamage).ToList(); foreach (var specialAbility in onHitFeats) { specialAbility.UseChargeIfPossible(amount, bonus); } var realDamge = ignorreDmgReduction ? amount : DamageRecuction.SubtractReduction(amount, damageType, bonus); if (realDamge <= 0) { return; } if (Damage == null) { Damage = new List <DamageTaken>(); } Damage.Add(new DamageTaken { Amount = -realDamge }); }
public static int GetMediumLoad(GetBonusDto bonusDto) { var heavyLoad = GetHeavyLoad(bonusDto); var mediumLoad = (int)((double)heavyLoad / 3.0 * 2.0); return(mediumLoad); }
//TODO: add biped or quadped public static int GetLightLoad(GetBonusDto bonusDto) { var heavyLoad = GetHeavyLoad(bonusDto); var lightLoad = heavyLoad / 3; return(lightLoad); }
public int GetCasterLevel(GetBonusDto bonusDto) { if (!Class.IsCaster()) { return(0); } var casterLevelBase = Level; var casterLevelBonues = 0; if (Class.ArcaneCaster) { casterLevelBonues += bonusDto.Bonuses.Where(x => x.ShouldApplyToSubType(Configuration.ExistingCasterLevelArcaneId)) .Sum(x => x.GetBonus(bonusDto).GetFixedAmount()); } if (Class.DivineCaster) { casterLevelBonues += bonusDto.Bonuses.Where(x => x.ShouldApplyToSubType(Configuration.ExistingCasterLevelDivineId)) .Sum(x => x.GetBonus(bonusDto).GetFixedAmount()); } return(casterLevelBase + casterLevelBonues); }
public bool IsConditionMeet(GetBonusDto bonusDto) { if (SpecialAbillitiesForBonus == null && AbillitiesForBonus == null && TrapsBonus == null) { return(false); } if (TrapsBonus.HasValue) { return(TrapsBonus.Value); } if (AbillitiesForBonus != null) { var modifier = bonusDto.Abilities.First(x => x.Ability.ID == AbillitiesForBonus.ID).GetCurrent(bonusDto); switch (ConditionPretensForBonus) { case ConditionPretens.LargerThenZero: return(modifier.GetValueAsInt() > 0); default: throw new NotImplementedException(); } } return(true); }
public static int GetHeavyLoad(GetBonusDto bonusDto) { var str = bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiStrId).GetCurrent(bonusDto).GetValueAsInt(); var baseHeavyLoad = Math.Min(str, 10) * 10; if (str > 10) { baseHeavyLoad += Math.Min((str - 10), 2) * 15; } if (str > 12) { baseHeavyLoad += 20; } if (str > 13) { baseHeavyLoad += Math.Min((str - 13), 2) * 25; } if (str > 15) { baseHeavyLoad += Math.Min((str - 13), 2) * 30; } if (str > 17) { baseHeavyLoad += 40; } if (str > 18) { baseHeavyLoad += Math.Min((str - 18), 2) * 50; } if (str > 20) { baseHeavyLoad += Math.Min((str - 20), 2) * 60; } if (str > 22) { baseHeavyLoad += 80; } if (str > 23) { baseHeavyLoad += Math.Min((str - 23), 2) * 100; } if (str > 25) { baseHeavyLoad += Math.Min((str - 25), 2) * 120; } if (str > 27) { baseHeavyLoad += 160; } if (str > 29) { baseHeavyLoad += 200; } if (str > 30) { throw new NotImplementedException("Not supported carrying capacity"); } return((int)((double)baseHeavyLoad * bonusDto.Character.Race.GetBipedCarryingCapacityMulitplier(bonusDto))); }
public List <BonusRef> GetDamageReductionBonus(GetBonusDto bonusDto) { var bonuses = GetItemBonuses(bonusDto).Where(x => x.ShouldApplyTo(new GameId { ID = Configuration.DamageRecuctionId }, typeof(DamageRecuction))).ToList(); return(bonuses); }
public int GetCurrentSpeed(GetBonusDto bonusDto) { return(BaseSpeed + bonusDto.Bonuses.Where( x => x.ShouldApplyTo(this, typeof(Race)) && x.ShouldApplyToSubType(Configuration.SpeedId)) .Select(y => y.GetBonus(bonusDto).GetFixedAmount()) .Sum()); }
public void SetBonuesToSave(GetBonusDto bonusDto) { var abilityScore = bonusDto.Abilities.First(x => x.Ability.ID == SaveType.AbilityModifier.ID); SaveBonus.AddIfNotZero(abilityScore.Ability.Name, null, abilityScore.GetCurrentModifier(bonusDto)); var bonusToApplyToThis = bonusDto.Bonuses.Where(a => a.ShouldApplyTo(this) && a.ShouldApplyToSubType(null)).ToList(); SaveBonus.AddPartsByRef(bonusToApplyToThis, bonusDto); }
public void EnrichActiveBonusDto(GetBonusDto dto) { var abilities = Class.GetAbilitiesAtCurrentLevel(Level); foreach (var specialAbility in abilities) { specialAbility.EnrichActiveBonusDto(dto); } }
public static int GetInitiativBonus(GetBonusDto bonusDto) { var dex = bonusDto.Abilities.First(x => x.Ability.ID == Configuration.AbiDexId).GetCurrentModifier(bonusDto); var bonus = bonusDto.Bonuses.Where(x => x.ShouldApplyTo(new GameId { ID = Configuration.InitiativId }, typeof(Initiativ)) && x.ShouldApplyToSubType(null)).MaxBonuesSum(bonusDto); return(dex + bonus); }
public bool UseChagesIfPossible(int charges, GetBonusDto bonues, Guid parentAbilityId) { if (Amount.IsChargesPossible(charges, bonues, parentAbilityId)) { Amount.Use(charges, bonues, parentAbilityId); //SetIsActive(bonues.Abilities); return(true); } return(false); }
public int GetHideModifier(GetBonusDto bonusDto) { var currentSize = (int)GetCurrentSize(bonusDto); if (currentSize == 0) { return(0); } return(-4 * currentSize); }
public int GetSpecialAttackModifier(GetBonusDto bonusDto) { var currentSize = (int)GetCurrentSize(bonusDto); if (currentSize == 0) { return(0); } return(4 * currentSize); }
public void EnrichActiveBonusDto(GetBonusDto dto) { if (RacialAbilities != null) { foreach (var ability in RacialAbilities) { ability.EnrichActiveBonusDto(dto); } } }
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); }