public void Move() { Figure userSelection; int targetX; int targetY; do { Console.WriteLine("\n{0}: which figure would you like to move?", this.Name); Console.Write("X = "); validInputX = int.TryParse(Console.ReadLine(), out targetX); Console.Write("Y = "); validInputY = int.TryParse(Console.ReadLine(), out targetY); validChoice = InputValidator.CheckTargetSelection(this, targetX, targetY); } while (!validInputX || !validInputY || !validChoice); userSelection = Chessboard.chessBoard[targetX, targetY]; userSelection.Move(userSelection, targetX, targetY); Chessboard.chessBoard[targetX, targetY] = new Blank(); }
public override void Move(Figure figure, int targetX, int targetY) { Chessboard.ShowChessBoard(targetX, targetY); do { Console.WriteLine("Where would you like to move the Tower?"); Console.Write("X = "); validDestinationX = int.TryParse(Console.ReadLine(), out destinationX); Console.Write("Y = "); validDestinationY = int.TryParse(Console.ReadLine(), out destinationY); if (!validDestinationX || !validDestinationY) { Console.WriteLine("\nInvalid move. Try again\n"); continue; } validChoice = InputValidator.CheckFigureDestination(figure, targetX, targetY, destinationX, destinationY); } while (!validChoice || !validDestinationX || !validDestinationY); Chessboard.chessBoard[destinationX, destinationY] = figure; //moves the figure to the destination selected by the user. //Console.ReadKey(); }
public override void Move(Figure figure, int targetX, int targetY) { //gets the figure to move from Player.Move() Chessboard.ShowChessBoard(targetX, targetY); //displays the current selection do { Console.WriteLine("Where would you like to move the pawn?"); Console.Write("X = "); validDestinationX = int.TryParse(Console.ReadLine(), out destinationX); Console.Write("Y = {0}", targetY); if (!validDestinationX) { Console.WriteLine("\nInvalid X. Try again\n"); continue; } validChoice = InputValidator.CheckFigureDestination(figure, targetX, targetY, destinationX, 0); } while (!validChoice || !validDestinationX); Chessboard.chessBoard[destinationX, targetY] = figure; //moves the figure to the destination selected by the user. //Console.ReadKey(); }