public void TestRooksMove() { ChessBoard board = new ChessBoard(); DefaultInfo.SetDefaultValues(); // board.SetDefaultChessBoard(); board['a', 1] = (sbyte)DefaultPieces.WhiteRook; board['h', 1] = (sbyte)DefaultPieces.WhiteRook; board['c', 2] = (sbyte)DefaultPieces.WhiteKing; board['a', 8] = (sbyte)DefaultPieces.BlackRook; board['h', 8] = (sbyte)DefaultPieces.BlackRook; board['c', 7] = (sbyte)DefaultPieces.BlackKing; board = FIDEnotation.PerformWhiteMove(board, "Rae1"); Assert.IsFalse(DefaultInfo.WhiteAsideRookIsUnMoved); board = FIDEnotation.PerformBlackMove(board, "Rhe8"); Assert.IsFalse(DefaultInfo.BlackHsideRookIsUnMoved); board = FIDEnotation.PerformWhiteMove(board, "Rhf1"); Assert.IsFalse(DefaultInfo.WhiteHsideRookIsUnMoved); board = FIDEnotation.PerformBlackMove(board, "Rab8"); Assert.IsFalse(DefaultInfo.BlackAsideRookIsUnMoved); board.DebugConsoleSimpleDraw(); board = FIDEnotation.PerformWhiteMove(board, "Rf6"); board = FIDEnotation.PerformWhiteMove(board, "Rfe6"); board = FIDEnotation.PerformWhiteMove(board, "R6e3"); }
public void TestSetDefaultValues() { DefaultInfo.SetDefaultValues(); Assert.IsTrue(DefaultInfo.IsWhiteMove); Assert.IsFalse(DefaultInfo.WhiteWin); Assert.IsFalse(DefaultInfo.BlackWin); Assert.IsTrue(DefaultInfo.WhiteAsideRookIsUnMoved); Assert.IsTrue(DefaultInfo.WhiteKingIsUnMoved); Assert.IsTrue(DefaultInfo.WhiteHsideRookIsUnMoved); Assert.IsTrue(DefaultInfo.BlackKingIsUnMoved); Assert.IsTrue(DefaultInfo.BlackAsideRookIsUnMoved); Assert.IsTrue(DefaultInfo.BlackHsideRookIsUnMoved); Assert.IsFalse(DefaultInfo.WhiteEnPassantEndangered); Assert.IsFalse(DefaultInfo.BlackEnPassantEndangered); }
//TO DO drawns static void Main(string[] args) { ChessBoard gameboard = new ChessBoard(); gameboard.SetDefaultChessBoard(); DefaultInfo.SetDefaultValues(); string notation = ""; List <string> gamestory = new List <string>(); string move = ""; // Code Review: Назва локальної змінної повинна починатися з малої літери. int NumberOfMoves = 1; int rows = 20; int rowwidth = 20; //Draw.DrawChessBoard(gameboard); Console.Title = "Dan's True Chess Game"; do { DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth); if (DefaultInfo.IsWhiteMove) { if (!FIDEnotation.CheckIfArePossibleMoves(gameboard, true)) { if (!WhiteKing.IsSafe(gameboard)) { DefaultInfo.BlackWin = true; } break; } WhiteMove(ref gameboard, ref notation, ref move); } else { if (!FIDEnotation.CheckIfArePossibleMoves(gameboard, false)) { if (!BlackKing.IsSafe(gameboard)) { DefaultInfo.WhiteWin = true; } break; } BlackMove(ref gameboard, ref notation, gamestory, ref move, ref NumberOfMoves); } }while (true); if (DefaultInfo.WhiteWin) { gamestory[gamestory.Count] += "+"; move = " "; DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth); Console.WriteLine("White win!"); } if (DefaultInfo.BlackWin) { gamestory[gamestory.Count - 1] += "+"; move = " "; DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth); Console.WriteLine("Black win!"); } else { gamestory[gamestory.Count] += "="; move = " "; DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth); Console.WriteLine("Draw"); } }