public void Execute(LivingEntity actor, LivingEntity target) { string actorName = (actor is Player) ? "You" : $"The {actor.Name.ToLower()}"; string targetName = (target is Player) ? "you" : $"the {target.Name.ToLower()}"; if (CombatService.AttackSucceeded(actor, target)) { int manaLost = _manaCost; actor.LoseMana(manaLost); if (CombatService.CriticalHit(actor, target)) { int damage = 2 * RandomNumberGenerator.NumberBetween(_minimumDamage, _maximumDamage); target.TakeDamage(damage); ReportResult($"{actorName} hit {targetName} with a critial hit, dealing {damage} point{(damage > 1 ? "s" : "")}."); } else { int damage = RandomNumberGenerator.NumberBetween(_minimumDamage, _maximumDamage); ReportResult($"{actorName} hit {targetName} for {damage} point{(damage > 1 ? "s" : "")}."); target.TakeDamage(damage); } } else { int manaLost = _manaCost; actor.LoseMana(manaLost); ReportResult($"{actorName} missed {targetName}."); } }
public void Execute(LivingEntity actor, LivingEntity target) { var actorName = actor is Player ? "You" : $"The {actor.Name.ToLower()}"; var targetName = target is Player ? "you" : $"the {target.Name.ToLower()}"; if (CombatService.AttackSucceeded(actor, target)) { var damage = RandomNumberGenerator.NumberBetween(_minimumDamage, _maximumDamage); ReportResult($"{actorName} hit {targetName} for {damage} point{(damage > 1 ? "s" : "")}"); target.TakeDamage(damage); } else { ReportResult($"{actorName} missed {targetName}"); } }
public void Execute(LivingEntity actor, LivingEntity target) { string actorName = (actor is Player) ? "You" : $"The {actor.Name.ToLower()}"; string targetName = (target is Player) ? "you" : $"the {target.Name.ToLower()}"; if (CombatService.AttackSucceeded(actor, target)) { int damage = DiceService.Instance.Roll(_damageDice).Value; ReportResult($"{actorName} hit {targetName} for {damage} point{(damage > 1 ? "s" : "")}."); target.TakeDamage(damage); } else { ReportResult($"{actorName} missed {targetName}."); } }