public virtual void Move(GridPos piece1, GridPos piece2, Player player) { }
public GamePiece GetPiece(GridPos pos) { return(grid[pos.x][pos.y]); }
static private Player StartTurn(Player player) { bool validMove = false; String userInput; int[] gridCords, targetCords; GridPos targetGrid = new GridPos(99, 99); while (!validMove) { Console.Clear(); Game.DrawBoard(); Console.Write("\n It's "); Console.ForegroundColor = player.GetColor(); Console.Write(player.GetName() + "'s "); Console.ForegroundColor = ConsoleColor.White; Console.Write("Turn!\n Select a piece to move:"); userInput = Console.ReadLine(); bool moveSelection = true; gridCords = Game.ParseGridPos(userInput); if (gridCords[0] >= 0 || gridCords[1] >= 0)//nullcheck the entered coordinates { List <GridPos> validMoves = ((Chessboard)Game).GetPossibleMoves(gridCords, player); if (validMoves.Count == 0) { Console.WriteLine("There are no possible moves for that piece try another one."); } else { moveSelection = true; while (moveSelection) { Console.Clear(); Game.HighLightGrids(validMoves.ToArray(), ConsoleColor.Green); Game.DrawBoard(); Game.HighLightGrids(validMoves.ToArray(), ConsoleColor.Black); Console.WriteLine("Make your move. Possible moves are highlighted in Green."); userInput = Console.ReadLine(); targetCords = Game.ParseGridPos(userInput); targetGrid = new GridPos(targetCords[0], targetCords[1]); validMoves.ForEach(x => { if (x == targetGrid) { moveSelection = false; } }); if (moveSelection == true) { Console.WriteLine("That is not a valid move, please try again!"); Thread.Sleep(500); } } Game.Move(new GridPos((byte)gridCords[0], (byte)gridCords[1]), targetGrid, player); validMove = true; Console.Clear(); } } else { Console.WriteLine("Invalid Input, please try again!"); } } if (player == player1) { return(player2); } if (player == player2) { return(player1); } return(null); }