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; } }
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); }
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); }
public BotPanels(int row, int column) { Coordinates = new BotCoordinates(row, column); OccupationType = OccupationType.Empty; }