public override SkillForecast ComputeForecast(ICombatant attacker, ICombatant defender) { var hitChance = new HitChance(attacker, defender); var critChance = new CritChance(attacker, defender); var glanceChance = new GlanceChance(attacker, defender); var chances = new SkillChances { CritChance = critChance.Value, HitChance = hitChance.Value, GlanceChance = glanceChance.Value }; var attackCount = new AttackCount(attacker, defender); var hit = new SkillHit { BaseDamage = DamageUtils.ComputeMeleeDamage(attacker, defender), HitCount = attackCount.Value }; return(new SkillForecast { Type = Type, Hit = hit, Chances = chances, Attacker = attacker, Defender = defender }); }
public static WeaponHit ComputeHit(ICombatant attacker, ICombatant defender, IRandomizer random) { var hitChance = new HitChance(attacker, defender); var glanceChance = new GlanceChance(attacker, defender); var critChance = new CritChance(attacker, defender); if (random.GetNextRandom() > (100 - hitChance.Value)) { var baseDamage = ComputeMeleeDamage(attacker, defender); if (random.GetNextRandom() > (100 - critChance.Value)) { baseDamage *= 2; } else if (random.GetNextRandom() > (100 - glanceChance.Value)) { baseDamage /= 2; } return(new WeaponHit(baseDamage)); } return(new Miss(MissReason.Miss)); }