public bool DebugPutShip(Square.Mark type, bool isShipHorizontal, int[] position) { int positionX = position[1]; int positionY = position[0]; int initx = positionX; int inity = positionY; int size = Square.GetOccupiedSquares(type); var startX = positionX; if (startX > 0) { startX--; } var startY = positionY; if (startY > 0) { startY--; } var endX = positionX; var endY = positionY; if (!isShipHorizontal) { endY += size - 1; } else { endX += size - 1; } // if end point is not the last coordinate check one past it. if (endY < 9) { endY++; } if (endX < 9) { endX++; } if (!IsInsideBoard(9, startX, startY, endX, endY)) { return(false); } for (int cy = startY; cy <= endY; cy++) { for (int cx = startX; cx <= endX; cx++) { if (!Board[cx, cy].IsAvailable()) { return(false); } } } if (isShipHorizontal) { for (int cx = initx; cx < size + initx; cx++) { Board[cx, inity].SetMark(type); } } else { for (int cy = inity; cy < size + inity; cy++) { Board[initx, cy].SetMark(type); } } return(true); }