private Coordinates DamagedShipShot() { Random rand = new Random(Guid.NewGuid().GetHashCode()); var hitNeighbors = EnemyBoard.GetHitNeighbors(); var neighborID = rand.Next(hitNeighbors.Count); return(hitNeighbors[neighborID]); }
private Coordinates RandomShot() { var availableFields = EnemyBoard.GetOpenRandomFields(); Random rand = new Random(Guid.NewGuid().GetHashCode()); var fieldID = rand.Next(availableFields.Count); return(availableFields[fieldID]); }
public Player(string name) { Name = name; Ships = new List <Ship>() { new Destroyer(), new Destroyer(), new Battleship(), }; GameBoard = new Board(); EnemyBoard = new EnemyBoard(); }
public Coordinates FireShot() { var hitNeighbors = EnemyBoard.GetHitNeighbors(); Coordinates coords; if (hitNeighbors.Any()) { coords = DamagedShipShot(); } else { coords = RandomShot(); } return(coords); }