public EffectHitInfo(int hitValue, HitRoll hitRoll, HitType hitType) { this.hitValue = hitValue; this.isCrit = hitRoll.wasCrit; this.isHit = hitRoll.wasHit; this.hitType = hitType; }
public void four_when_four_needed_to_hit_is_hit() { HitRoll roll = new HitRoll(4, 4); Assert.IsTrue(roll.Hit); Assert.IsFalse(roll.Missed); }
public void ranged_attack_can_be_rolled_for_hit() { Target target = new(1); Shooter shooter = new(1); int weaponStrenght = 1; RangedAttack rangedAttack = new(target, shooter, weaponStrenght); HitRoll hitRoll = rangedAttack.RollHit(new Dice()); Assert.AreEqual(shooter.BalisticSkill, hitRoll.Expected); }
/// <summary> /// Applies the ability's effect on the target. /// </summary> /// <param name="target">The current target for the ability</param> private void UseAbility(ICharacter target) { int critChance = 0; //Get caster crit chance or ability crit chance for (int i = 0; i < effects.Length; i++) { EffectInfo effect = effects[i]; effect.effect.Initialize(effect.dice, effect.damageRollModifiers, effect.duration, effect.statusEffect); //Update check, so the first effect must either be guaranteed or will roll. if (i > 0 && !effect.UseOwnAttackRoll) { if (rollInfo.wasHit) { effect.effect.ApplyEffect(this, target); Debug.Log("Effect auto-confirmed, since the ability already hit"); } return; } rollInfo = CheckHit(target.GetAC(), critChance); if (guaranteedHit) { rollInfo.wasHit = true; } Debug.Log(caster.name + " used " + name + " (" + rollInfo.ToString() + ")"); if (rollInfo.wasHit) { // Debug.Log(name + "Was a hit"); effect.effect.ApplyEffect(this, target); } } }