/// <summary> /// This method appends the inclusion of a figure. /// </summary> /// <remarks>A figure environment will be placed somewhere according to position settings. /// It is an floating environment.</remarks> /// <param name="position">>Where should the figure be placed.</param> /// <param name="caption">Text for figure caption.</param> /// <param name="label">Text for figure lable. Should start with fig:.</param> /// <param name="fileName">Relative path of graphic file to include.</param> /// <param name="landscape">Indicates whether the figure is in landscape environment or not.</param> /// <param name="converter">TEX converter.</param> internal static string IncludeFigure(FigurePositions position, string caption, string label, string fileName, bool landscape, ITeXConverter converter) { var tex = new StringBuilder(); tex.Append(Helper.Begin(Helper.Environments.figure)); tex.AppendFormat("[{0}]\n", position); tex.Append(Helper.NoIndent()); tex.Append(Helper.Centering()); var options = landscape ? $"max height={Helper.GetLengthInPercentageOfTextWidth(90)}, max width={Helper.GetLengthInPercentageOfTextHeight(100)}" : $"max height={Helper.GetLengthInPercentageOfTextHeight(90)}, max width={Helper.GetLengthInPercentageOfTextWidth(100)}"; options += ", keepaspectratio"; tex.Append(includeGraphics(options, fileName, converter)); tex.Append(Helper.Caption(caption)); tex.Append(Helper.Label(label)); tex.Append(Helper.End(Helper.Environments.figure)); return(tex.ToString()); }
//prints entire board public void PrintBoard(FigurePositions currentPosition) { System.Console.SetCursorPosition(37, 0); System.Console.BackgroundColor = System.ConsoleColor.Black; System.Console.WriteLine("STAR CHESS"); CursorCoordinates currentCursor = new CursorCoordinates(); currentCursor.X = 6; currentCursor.Y = 6; System.Console.BackgroundColor = System.ConsoleColor.White; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { FieldColorChanger(); System.Console.SetCursorPosition(currentCursor.X, currentCursor.Y); fullBoard[i, j] = new Field(); fullBoard[i, j].PrintField(currentCursor.X, currentCursor.Y, currentPosition.Position[i, j], System.Console.BackgroundColor); currentCursor.X += 9; } FieldColorChanger(); currentCursor.X = 6; currentCursor.Y += 5; } //Print board indicators System.Console.BackgroundColor = System.ConsoleColor.Black; System.Console.ForegroundColor = System.ConsoleColor.White; char[] arrayOfLetters = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' }; int counter = 0; for (int i = 10; i < 74; i += 9) { System.Console.SetCursorPosition(i, 4); System.Console.Write(arrayOfLetters[counter]); System.Console.SetCursorPosition(i, 47); System.Console.Write(arrayOfLetters[counter]); counter++; } counter = 8; for (int i = 8; i < 44; i += 5) { System.Console.SetCursorPosition(3, i); System.Console.Write(counter); System.Console.SetCursorPosition(81, i); System.Console.Write(counter); counter--; } //print board boarders o.O System.Console.BackgroundColor = System.ConsoleColor.DarkGray; for (int i = 2; i < 82; i++) { PrintBorders(i, 3); PrintBorders(i, 48); } for (int i = 4; i < 80; i++) { PrintBorders(i, 5); PrintBorders(i, 46); } for (int i = 3; i < 49; i++) { PrintBorders(1, i); PrintBorders(82, i); } for (int i = 5; i < 47; i++) { PrintBorders(4, i); PrintBorders(5, i); } for (int i = 5; i < 47; i++) { PrintBorders(79, i); PrintBorders(78, i); } }
public static bool ChessValidator(FigurePositions currentPositions) { bool hasCheck = false; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { Names currentFigureName = currentPositions.Position[i, j].Name; if (currentFigureName == Names.None) { continue; } Colors currentFigureColors = currentPositions.Position[i, j].Color; Player currentPlayer; if (currentFigureColors == Colors.White) { currentPlayer = StartProgram.WhitePlayer; } else { currentPlayer = StartProgram.BlackPlayer; } if (currentFigureName == Names.Pawn) { Pawn pawn = new Pawn(currentFigureColors, currentFigureName); hasCheck = pawn.MakesChess(i, j, currentPlayer, currentPositions); } else if (currentFigureName == Names.Bishop) { Bishop bishop = new Bishop(currentFigureColors, currentFigureName); hasCheck = bishop.MakesChess(i, j, currentPlayer, currentPositions); } else if (currentFigureName == Names.Rook) { Rook rook = new Rook(currentFigureColors, currentFigureName); hasCheck = rook.MakesChess(i, j, currentPlayer, currentPositions); } else if (currentFigureName == Names.Queen) { Queen queen = new Queen(currentFigureColors, currentFigureName); hasCheck = queen.MakesChess(i, j, currentPlayer, currentPositions); } else if (currentFigureName == Names.King) { King king = new King(currentFigureColors, currentFigureName); hasCheck = king.MakesChess(i, j, currentPlayer, currentPositions); } else if (currentFigureName == Names.Knight) { Knight knight = new Knight(currentFigureColors, currentFigureName); hasCheck = knight.MakesChess(i, j, currentPlayer, currentPositions); } if (hasCheck) { return(hasCheck); } } } return(hasCheck); }
public void PrintBoard(FigurePositions currentPosition) //prints entire board { System.Console.SetCursorPosition(37, 0); System.Console.BackgroundColor = System.ConsoleColor.Black; System.Console.WriteLine("STAR CHESS"); CursorCoordinates currentCursor = new CursorCoordinates(); currentCursor.X = 6; currentCursor.Y = 6; System.Console.BackgroundColor = System.ConsoleColor.White; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { FieldColorChanger(); System.Console.SetCursorPosition(currentCursor.X, currentCursor.Y); fullBoard[i, j] = new Field(); fullBoard[i, j].PrintField(currentCursor.X, currentCursor.Y, currentPosition.Position[i, j], System.Console.BackgroundColor); currentCursor.X += 9; } FieldColorChanger(); currentCursor.X = 6; currentCursor.Y += 5; } //Print board indicators System.Console.BackgroundColor = System.ConsoleColor.Black; System.Console.ForegroundColor = System.ConsoleColor.White; char[] arrayOfLetters = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' }; int counter = 0; for (int i = 10; i < 74; i += 9) { System.Console.SetCursorPosition(i, 4); System.Console.Write(arrayOfLetters[counter]); System.Console.SetCursorPosition(i, 47); System.Console.Write(arrayOfLetters[counter]); counter++; } counter = 8; for (int i = 8; i < 44; i += 5) { System.Console.SetCursorPosition(3, i); System.Console.Write(counter); System.Console.SetCursorPosition(81, i); System.Console.Write(counter); counter--; } //print board boarders o.O System.Console.BackgroundColor = System.ConsoleColor.DarkGray; for (int i = 2; i < 82; i++) { PrintBorders(i, 3); PrintBorders(i, 48); } for (int i = 4; i < 80; i++) { PrintBorders(i, 5); PrintBorders(i, 46); } for (int i = 3; i < 49; i++) { PrintBorders(1, i); PrintBorders(82, i); } for (int i = 5; i < 47; i++) { PrintBorders(4, i); PrintBorders(5, i); } for (int i = 5; i < 47; i++) { PrintBorders(79, i); PrintBorders(78, i); } }