// neighbouring function to get all boards in this specific direction public List <JSFBoard> getAllBoardInDirection(JSFBoardDirection bd) { List <JSFBoard> list = new List <JSFBoard>(); JSFBoard chain = boardEnumToReference(bd); while (chain != null) // recursively add the boards in the specified direction { list.Add(chain); chain = chain.boardEnumToReference(bd); } return(list); // returns the list of boards in the direction }
// neighbouring function to get a board in this specific direction and distance public JSFBoard getBoardFromDirection(JSFBoardDirection bd, int distance) { JSFBoard target = boardEnumToReference(bd); // initial for (int x = 1; x < distance; x++) // recursively find the board in the specified direction { if (target == null) { break; // no board here... do not continue... } target = target.boardEnumToReference(bd); } return(target); }