Example #1
0
        public static bool IsThereWinner()
        {
            var currentPlayerSymbol = Player.GetCurrentPlayerSymbol();

            var isThereWinner = FieldValidator.IsThereWinningColumn(currentPlayerSymbol) ||
                                FieldValidator.IsThereWinningRow(currentPlayerSymbol) ||
                                FieldValidator.IsThereWinningTopLeftBottomRightDiagonal(currentPlayerSymbol) ||
                                FieldValidator.IsThereWinningBottomLeftTopRightDiagonal(currentPlayerSymbol);

            if (isThereWinner)
            {
                DrawField();
                SysLogger.DisplayMessageToTheConsole("GameOver");
            }

            return(isThereWinner);
        }
Example #2
0
        public static Field CreateField(int inputSize = 0)
        {
            var size = inputSize;

            if (size == 0)
            {
                SysLogger.DisplayMessageToTheConsole("EnterFieldSize");
                var userSizeInput = Console.ReadLine();

                if (!FieldValidator.IsFieldSizeValid(userSizeInput))
                {
                    return(null);
                }
                size = int.Parse(userSizeInput);
            }

            return(new Field(size));
        }