public AttackRollResult(Attack atk) { _Attack = atk; _Name = atk.Name; Rolls = new List <SingleAttackRoll>(); if (atk.Weapon != null) { _Name = atk.Weapon.Name; } int totalAttacks = atk.Count * atk.Bonus.Count; for (int atkcount = 0; atkcount < atk.Count; atkcount++) { foreach (int mod in atk.Bonus) { SingleAttackRoll sr = new SingleAttackRoll(); DieRoll roll = new DieRoll(1, 20, mod); sr.Result = roll.Roll(); sr.Damage = atk.Damage.Roll(); if (atk.Plus != null) { Regex plusRegex = new Regex("(?<die>[0-9]+d[0-9]+((\\+|-)[0-9]+)?) (?<type>[a-zA-Z]+)"); Match dm = plusRegex.Match(atk.Plus); if (dm.Success) { DieRoll bonusRoll = DieRoll.FromString(dm.Groups["die"].Value); BonusDamage bd = new BonusDamage(); bd.Damage = bonusRoll.Roll(); bd.DamageType = dm.Groups["type"].Value; sr.BonusDamage.Add(bd); } } if (sr.Result.Rolls[0].Result >= atk.CritRange) { sr.CritResult = roll.Roll(); sr.CritDamage = new RollResult(); for (int i = 1; i < atk.CritMultiplier; i++) { RollResult crit = atk.Damage.Roll(); sr.CritDamage = crit + sr.CritDamage; } } Rolls.Add(sr); } } }
internal AttackBonus() { damage = new BonusDamage(); arpen = new BonusArpen(); }