コード例 #1
0
ファイル: HitPoints.cs プロジェクト: tvbirch/pen_and_paper
        /*
         *
         * 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));
        }
コード例 #2
0
ファイル: AbilityScore.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }
コード例 #3
0
ファイル: OwnedItem.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }
コード例 #4
0
        //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);
        }
コード例 #5
0
ファイル: OwnedItem.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }
コード例 #6
0
ファイル: AbilityScore.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }
コード例 #7
0
ファイル: HitPoints.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }
コード例 #8
0
ファイル: HitPoints.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }
コード例 #9
0
ファイル: OwnedItem.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }
コード例 #10
0
ファイル: OwnedItem.cs プロジェクト: tvbirch/pen_and_paper
        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);
        }