private BoardContent GetBoard(string board) { var result = new BoardContent(); for (var i = 0; i < 100; i++) { result[new BoardIndex(i)] = BoardContentJsonConverter.CharToSquareContent(board[i]); } return(result); }
public ActionResult <BoardIndex[]> GetShots([FromBody] ShotRequest[] shotRequests) { // Create a helper variable that will receive our calculated // shots for each shot request. var shots = new BoardIndex[shotRequests.Length]; Parallel.For(0, shotRequests.Length, index => { var board = new BoardContent(shotRequests[index].Board.Select(d => (byte)BoardContentJsonConverter.CharToSquareContent(d))); #if DEBUG Console.WriteLine(board); Console.WriteLine(board.ToShortString()); #endif shots[index] = BattleshipHelper.GetNextShot(board); #if DEBUG Console.WriteLine($"Next shot:{(string)shots[index]}"); ////Thread.Sleep(500); #endif }); return(shots); }