示例#1
0
        static string ChessToAscii(Chess chess)
        {
            StringBuilder sb = new StringBuilder();

            // рисуем рамку вокруг доски:
            sb.AppendLine("  +-----------------+"); // начало доски (горизонталь)
            for (int y = 7; y >= 0; y--)
            {
                sb.Append(y + 1);
                sb.Append(" | ");
                for (int x = 0; x < 8; x++)
                {
                    sb.Append(chess.GetFigureAt(x, y) + " ");
                }
                sb.AppendLine("|");
            }
            sb.AppendLine("  +-----------------+"); // конец доски (горизонталь)
            sb.AppendLine("    a b c d e f g h ");

            if (chess.IsCheck)
            {
                sb.AppendLine("IS CHECK");
            }
            if (chess.IsCheckmate)
            {
                sb.AppendLine("IS CHECKMATE");
            }
            if (chess.IsStalemate)
            {
                sb.AppendLine("IS STALEMATE");
            }

            return(sb.ToString());
        }
示例#2
0
        static string ChessToAscii2(Chess chess)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("    a b c d e f g h  ");
            sb.AppendLine("  +-----------------+");
            for (int y = 7; y >= 0; y--)
            {
                sb.Append(y + 1);
                sb.Append(" | ");
                for (int x = 0; x < 8; x++)
                {
                    sb.Append(chess.GetFigureAt(x, y) + " ");
                }
                sb.AppendLine("| " + (y + 1));
            }
            sb.AppendLine("  +-----------------+");
            sb.AppendLine("    A B C D E F G H  ");

            if (chess.IsCheck)
            {
                sb.AppendLine("IS CHECK");
            }
            if (chess.IsCheckmate)
            {
                sb.AppendLine("IS CHECKMATE");
            }
            if (chess.IsStalemate)
            {
                sb.AppendLine("IS STALEMATE");
            }
            return(sb.ToString());
        }
示例#3
0
        static string ChessToASCII(Chess chess)
        {
            string text = "  +-----------------+\n";

            for (int y = 7; y >= 0; y--)
            {
                text += y + 1;
                text += " | ";
                for (int x = 0; x < 8; x++)
                {
                    text += chess.GetFigureAt(x, y) + " ";
                }
                text += "|\n";
            }
            text += "  +-----------------+\n";
            text += "    a b c d e f g h\n";
            return(text);
        }
示例#4
0
        static string ChessToAscii(Chess chess)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("  +-----------------+");
            for (int y = 7; y >= 0; y--)
            {
                sb.Append(y + 1);
                sb.Append(" | ");
                for (int x = 0; x < 8; x++)
                {
                    sb.Append(chess.GetFigureAt(x, y) + " ");
                }
                sb.AppendLine("|");
            }
            sb.AppendLine("  +-----------------+");
            sb.AppendLine("    a b c d e f g h  ");
            return(sb.ToString());
        }
示例#5
0
        static string ChessToAscii(Chess chess)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(" +--------------+");
            for (int y = 7; y >= 0; y--)
            {
                sb.Append(y + 1);
                sb.Append("|");
                for (int x = 0; x < 8; x++)
                {
                    sb.Append(chess.GetFigureAt(x, y) + " ");
                }
                sb.AppendLine();
            }
            sb.AppendLine(" +---------------+");
            sb.AppendLine("  a b c d e f g h  ");
            if (chess.IsCheck)
            {
                sb.AppendLine("IS CHECK");
            }
            if (chess.IsCheckMate)
            {
                sb.AppendLine("IS CHECKMATE");
            }
            if (chess.IsStaleMate)
            {
                sb.AppendLine("IS STALEMATE");
            }
            if (chess.IsDraw)
            {
                sb.AppendLine("IS DRAW");
            }
            sb.AppendLine($"Now Color IS:" + chess.NowColor);
            return(sb.ToString());
        }