private void getBoardSize(out int io_Rows, out int io_Columns) { string errorMsg; bool result; string rows; string columns = string.Empty; do { Console.WriteLine("Please enter board rows size and then columns size:"); rows = Console.ReadLine(); result = GameLogics.IsSizeBoardCorrect(rows, out errorMsg); if (result == true) { columns = Console.ReadLine(); result = GameLogics.IsSizeBoardCorrect(columns, out errorMsg); if (result == true) { result = GameLogics.IsBoardSizesValid(int.Parse(rows), int.Parse(columns), out errorMsg); } } if (result == false) { printErrorMsg(errorMsg); } }while (result == false); io_Rows = int.Parse(rows); io_Columns = int.Parse(columns); }
public void StartMemoryGame() { string firstPlayerName = getPlayerName(); Ex02.ConsoleUtils.Screen.Clear(); string secondPlayerName = string.Empty; chooseAndSetOpponent(); Ex02.ConsoleUtils.Screen.Clear(); if (GameLogics.s_Opponent == GameLogics.ePlayer.Player2) { secondPlayerName = chooseOpponentName(); Ex02.ConsoleUtils.Screen.Clear(); } m_Logic = new GameLogics(firstPlayerName, secondPlayerName); playGame(); }
private void chooseAndSetOpponent() { string errorMsg; bool result; string choiseString; do { Console.WriteLine("Choose your opponent: (1) for second player (2) for AI player"); choiseString = Console.ReadLine(); result = GameLogics.IsChoiseValid(choiseString, out errorMsg); if (result == false) { printErrorMsg(errorMsg); } }while (result == false); GameLogics.SetOpponentType(int.Parse(choiseString)); }
private string getPlayerName() { string errorMsg; bool result; string name; do { Console.WriteLine("Please enter first player name: "); name = Console.ReadLine(); result = GameLogics.IsPlayerNameValid(name, out errorMsg); if (result == false) { Ex02.ConsoleUtils.Screen.Clear(); Console.WriteLine(errorMsg); } }while (result == false); return(name); }