public static void PrintFreeSpots(this TicTacToeBoard board) { for (int i = 0; i < board.FreeSpots.Count; i++) { Console.WriteLine(i + 1 + " " + board.FreeSpots[i]); } }
private static void Testing() { TicTacToeBoard board = new TicTacToeBoard(); UI.PrintBoard(board.Board); Player player01 = new Player("Julia", true); Player player02 = new Player("Julia2", false); //AIPlayer player02 = new AIPlayer(false); //Console.WriteLine(player01); while (board.GameOverCheck(board) == false) { int userChoice; UI.PrintFreeSpots(board); userChoice = UI.InputChoise("Pick a spot, player 1", board); player01.TakeTurn(board, board.FreeSpots[userChoice - 1]); UI.PrintBoard(board.Board); if (board.GameOverCheck(board) == true) { continue; } UI.PrintFreeSpots(board); userChoice = UI.InputChoise("Pick a spot, player 2", board); player02.TakeTurn(board, board.FreeSpots[userChoice - 1]); //Console.WriteLine("Player 2:"); //player02.TakeTurn(board); UI.PrintBoard(board.Board); } }
public static void GameLoop() { TicTacToeBoard board = new TicTacToeBoard(); while (true) { UI.PrintBoard(board.Board); } }
public static int InputChoise(string message, TicTacToeBoard board) { int[] choices = new int[board.FreeSpots.Count]; for (int i = 0; i < choices.Length; i++) { choices[i] = i + 1; } start: Console.CursorVisible = true; bool choiceMade = false; int userInput = -1; int wrongUserInput = -1; string errorText = " is not valid input. "; int[] rightAnswers = choices; Console.WriteLine(message); do { try { Console.Write("\n Your input -> "); userInput = Convert.ToInt32(Console.ReadLine()); wrongUserInput = userInput; errorText = wrongUserInput + errorText; if (Array.Exists(rightAnswers, element => element == userInput)) { return(userInput); } else { Console.WriteLine(errorText); } } catch (Exception) { Console.WriteLine("This " + errorText); goto start; } } while (choiceMade == false); return(choices[0]); }
public void TakeTurn(TicTacToeBoard board) { //Piece newPiece = new Piece(typeOfPiecesIAmPlayingWith); //board.AddPiece(newPiece) }
public override void TakeTurn(TicTacToeBoard board, (int, int) spot)