static void Main(string[] args) { Board board = new Board(); board.Print(); Console.WriteLine("-------------------"); board.Move(board.Cells[0, 0].Piece, new Coordinates() { Row = 2, Column = 0 }); board.Print(); Console.WriteLine("-------------------"); board.Move(board.Cells[1, 0].Piece, new Coordinates() { Row = 3, Column = 0 }); board.Print(); Console.WriteLine("-------------------"); board.Move(board.Cells[6, 1].Piece, new Coordinates() { Row = 4, Column = 1 }); board.Print(); Console.WriteLine("-------------------"); board.Move(board.Cells[3, 0].Piece, new Coordinates() { Row = 4, Column = 1 }); board.Print(); }
public void Play(Board board) { Console.WriteLine("ShowMoves [position]; Move [initial_position] [destination_position]; IsThreatened [position]; EXIT"); Console.Write("->"); var instruction = Console.ReadLine().Split(' '); switch (instruction[0].ToLower()) { case "sm": var possibleMoves = board.GetPossiblePiecePositions(GetPositionInInstruction(instruction, 1)); _renderBoard(board, possibleMoves); Play(board); break; case "m": var fromPosition = GetPositionInInstruction(instruction, 1); var toPosition = GetPositionInInstruction(instruction, 2); if (!board.Move(this, fromPosition, toPosition)) { Play(board); } break; case "it": if (board.IsPositionThreatened(GetPositionInInstruction(instruction, 1), Color)) { Console.WriteLine("This Position is threatened"); } else { Console.WriteLine("This Position is not threatened"); } Play(board); break; case "exit": Environment.Exit(0); break; default: Play(board); break; } }