Exemple #1
0
        public ShotResult RegisterShot(string location)
        {
            HitLocations.Add(location);
            if (!BattleShips.Any(battleShip => battleShip.Fields.Contains(location)))
            {
                return(ShotResult.Miss);
            }

            var ship = BattleShips.Single(battleShip => battleShip.Fields.Contains(location));

            return(ship.Fields.All(field => HitLocations.Contains(field)) ? ShotResult.Sunk : ShotResult.Hit);
        }