Exemplo n.º 1
0
        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}.");
            }
        }