static void Main(string[] args) { var board = new gameBoard(3); Player[] p = new Player[2]; for (int i = 0; i < 2; i++) { Console.Write($"Player {i+1}, what is your name? "); string name = Console.ReadLine(); Console.Write("And what do you want your symbol to be? "); string symbol = Console.ReadLine(); p[i] = new Player(); p[i].name = name; p[i].symbol = symbol; } Console.WriteLine("How big of a game board do you want to use?"); Console.Write("Ex. [3]x3, [4]x4, [5]x5 etc: "); int boardSize = int.Parse(Console.ReadLine()); gameBoard thisGame = new gameBoard(boardSize); Console.Write(thisGame.spaces); thisGame.populateBoard(boardSize); var Play = new PlayGame(); Play.ChooseMove(p, thisGame, boardSize, 1); }
public void ChooseMove(Player[] p, gameBoard thisGame, int boardSize, int currentPlayer) { int currentMove = 0; while (currentMove == 0) { Console.Write($"{p[currentPlayer-1].name}, choose a space: "); currentMove = int.Parse(Console.ReadLine()); string errorMessage = ""; var currentSpace = thisGame.spaces[currentMove - 1]; if (currentMove < 0) { errorMessage = "Please enter a number value (ex: 5): "; } if (currentSpace == p[0].symbol || currentSpace == p[1].symbol) { errorMessage = "Please choose a space not used."; currentMove = 0; } Console.WriteLine(errorMessage); } thisGame.spaces[currentMove - 1] = p[currentPlayer - 1].symbol; thisGame.populateBoard(boardSize); if (currentPlayer == 1) { currentPlayer = 2; } else { currentPlayer = 1; } ChooseMove(p, thisGame, boardSize, currentPlayer); }