Esempio n. 1
0
        public HitResult TryHit(int x, int y)
        {
            Battleship destroyed = null;
            var        result    = HitResult.Missed;

            foreach (var bs in Battleships)
            {
                result = bs.TryToHit(x, y);
                if (result == HitResult.Destroyed)
                {
                    destroyed = bs;
                }
                if (result != HitResult.Missed)
                {
                    break;
                }
            }
            if (destroyed != null)
            {
                Battleships.Remove(destroyed);
            }
            return(result);
        }