/// <summary> /// parse a move order from user /// </summary> /// <param name="input">string input as symbol x y</param> private void ParseMove(string input) { //separate string, perform integrity test on resulting partial strings string[] parsed = input.Trim('<', '>').Split(" "); if (parsed.Length != 3) { boardView.Display("Please enter your move as <symbole x y> please !"); return; } string symb = parsed[0]; if (parsed[0].Length > 1 || symb[0] != currentPlayer.Symbol) { boardView.Display($"The symbol is incorrect ! Expected : {currentPlayer.Symbol}, you proposed {symb}"); return; } try { int x = int.Parse(parsed[1]), y = int.Parse(parsed[2]); //can fail parsing here if (board.Play(x, y, currentPlayer)) { //move OK boardView.DisplayBoard(board); if (board.IsFinished()) { //end game board.Winner()?.IncScore(); boardView.DisplayScore(player1, player2); Console.WriteLine("Press [Y] to play again, [R] to change player, [stop] to end"); state = State.end; } else { //switch player currentPlayer = (currentPlayer == player1 ? player2 : player1); boardView.Display($"turn : {currentPlayer}"); } } else { //move failed boardView.Display($"You cannot do this move !"); return; } } catch { boardView.Display($"Impossible to read your coordinates"); return; } }