Example #1
0
        /// <summary>
        /// Processes the fired shot
        /// </summary>
        /// <returns>Shot is missed or hit</returns>
        /// <param name="coords">Coordinates</param>
        public ShotResult ProcessShot(BoardCorrdinates coords)
        {
            var panel = GameBoard.Panels.At(coords.Row, coords.Column);

            if (!panel.IsOccupied)
            {
                Console.WriteLine(" > \"You missed shot!\"");
                return(ShotResult.Miss);
            }
            var ship = ShipTypes.First(x => x.AttackerShipType == panel.AttackerShipType);

            ship.Hits++;
            Console.WriteLine(" > \"It's a Hit!\"");
            if (ship.IsSunk)
            {
                Console.WriteLine(" > \"You have sunk " + ship.Name + ".\"\n\n");
            }
            return(ShotResult.Hit);
        }