Ejemplo n.º 1
0
        public FireShotResponse FireShot(Coordinate coordinate)
        {
            FireShotResponse response = new FireShotResponse();

            // is this coordinate on the board?
            if (!IsValidCoordinate(coordinate))
            {
                response.ShotStatus = ShotStatus.Invalid;
                return(response);
            }

            // did they already try this position?
            if (ShotHistory.ContainsKey(coordinate))
            {
                response.ShotStatus = ShotStatus.Duplicate;
                return(response);
            }

            CheckShipsForHit(coordinate, response);
            CheckForVictory(response);

            return(response);
        }