Beispiel #1
0
        public void ProcessShotResult(BotCoordinates coords, GameStatus result)
        {
            var panel = FiringBoard.Panels.At(coords.Row, coords.Column);

            switch (result)
            {
            case GameStatus.Hit:
                panel.OccupationType = OccupationType.Hit;
                break;

            default:
                panel.OccupationType = OccupationType.Miss;
                break;
            }
        }
Beispiel #2
0
        public GameStatus ProcessShot(BotCoordinates coords)
        {
            var panel = GameBoard.Panels.At(coords.Row, coords.Column);

            if (!panel.IsOccupied)
            {
                Console.WriteLine(Name + " says: \"Miss!\"");
                return(GameStatus.Miss);
            }
            var ship = Ships.First(x => x.OccupationType == panel.OccupationType);

            ship.Hits++;
            Console.WriteLine(Name + " says: \"Hit!\"");
            if (ship.IsSunk)
            {
                Console.WriteLine(Name + " says: \"You sunk my " + ship.Name + "!\"");
            }
            return(GameStatus.Hit);
        }
Beispiel #3
0
        public List <BotPanels> GetNeighbors(BotCoordinates coordinates)
        {
            int row    = coordinates.Row;
            int column = coordinates.Column;
            List <BotPanels> panels = new List <BotPanels>();

            if (column > 1)
            {
                panels.Add(Panels.At(row, column - 1));
            }
            if (row > 1)
            {
                panels.Add(Panels.At(row - 1, column));
            }
            if (row < 10)
            {
                panels.Add(Panels.At(row + 1, column));
            }
            if (column < 10)
            {
                panels.Add(Panels.At(row, column + 1));
            }
            return(panels);
        }
Beispiel #4
0
 public BotPanels(int row, int column)
 {
     Coordinates    = new BotCoordinates(row, column);
     OccupationType = OccupationType.Empty;
 }