Beispiel #1
0
        public static string RenderToString(Board board, Board hints)
        {
            var drawstring = "";

            drawstring += "   ";
            for (var i = 0; i < board.Width; i++)
            {
                drawstring += Pos.ConvertPosToLetter(i) + " ";
            }
            drawstring += "\n";

            drawstring += "  ┌";
            for (var i = 0; i < board.Width - 1; i++)
            {
                drawstring += "─┬";
            }
            drawstring += "─┐\n";

            for (var y = 0; y < board.Height; y++)
            {
                drawstring += " " + y + "│";
                for (var x = 0; x < board.Width; x++)
                {
                    if (board.GetPiece(x, y) == ' ')
                    {
                        switch (hints.GetPiece(x, y))
                        {
                        case ' ':
                            drawstring += " │";
                            break;

                        case Constants.Hint:
                            drawstring += Constants.Hint + "│";
                            break;

                        default:
                            drawstring += hints.GetPiece(x, y) + "│";

                            break;
                        }
                    }
                    else
                    {
                        drawstring += board.GetPiece(x, y) + "│";
                    }
                }

                drawstring += "\n";

                if (y >= board.Height - 1)
                {
                    continue;
                }

                drawstring += "  ├";
                for (var i = 0; i < board.Width - 1; i++)
                {
                    drawstring += "─┼";
                }
                drawstring += "─┤\n";
            }

            drawstring += "  └";
            for (var i = 0; i < board.Width - 1; i++)
            {
                drawstring += "─┴";
            }
            drawstring += "─┘\n";

            return(drawstring);
        }