private void HandleDamageFor(IShip shipToReceiveDamage, IShip shipToInflictDamage, double chance)
        {
            if (!ShouldHandle(chance))
            {
                Console.WriteLine($"'{shipToInflictDamage.Name}' did not damage '{shipToReceiveDamage.Name}' this round!");
                return;
            }

            var expectedBullets = 5 * (new Random().Next(5) + 1);
            var actualBullets   = shipToInflictDamage.Shoot(expectedBullets);

            Console.WriteLine($"'{shipToInflictDamage.Name}' damaged '{shipToReceiveDamage.Name}' with {actualBullets} bullets!");
            shipToReceiveDamage.Damage(actualBullets);
        }
Exemple #2
0
        public virtual bool Damage(CoOrdinates coordinates)
        {
            IShip ship = this.GetShip(coordinates);

            if (ship == null)
            {
                return(false);
            }

            bool hit = ship.Damage(coordinates);

            // Update the coordinates
            //
            return(hit);
        }