Exemple #1
0
        private static GameMessage.eValidationMessageType checkIfTileValid(StringBuilder i_StringToValidate,
                                                                           char[,] i_VisualBoardMatrix)
        {
            GameMessage.eValidationMessageType messageType = GameMessage.eValidationMessageType.InvalidTile;

            if (checkIfTileFormatValid(i_StringToValidate))
            {
                if (checkIfTileNumbersAreInRangeOfBoard(i_StringToValidate, i_VisualBoardMatrix))
                {
                    if (checkIfTileIsHidden(i_StringToValidate, i_VisualBoardMatrix))
                    {
                        messageType = GameMessage.eValidationMessageType.Valid;
                    }
                    else
                    {
                        messageType = GameMessage.eValidationMessageType.TileAlreadyShown;
                    }
                }
                else
                {
                    messageType = GameMessage.eValidationMessageType.InvalidTileOutOfBounds;
                }
            }
            else if (CheckIfPressedQuit(i_StringToValidate))
            {
                messageType = GameMessage.eValidationMessageType.Valid;
            }

            return(messageType);
        }
Exemple #2
0
        public static GameMessage.eValidationMessageType ValidateInput(eValidationType i_CurrentValidationType,
                                                                       StringBuilder i_UserInput,
                                                                       char[,] i_VisualBoardMatrix)
        {
            GameMessage.eValidationMessageType messageType = GameMessage.eValidationMessageType.Invalid;

            switch (i_CurrentValidationType)
            {
            case eValidationType.ValidatePlayerName:
                messageType = checkIfPlayerNameValid(i_UserInput);
                break;

            case eValidationType.ValidateGameMode:
                messageType = checkIfGameModeValid(i_UserInput);
                break;

            case eValidationType.ValidateBoardDimensions:
                messageType = checkIfBoardDimensionsValid(i_UserInput);
                break;

            case eValidationType.ValidateTile:
                messageType = checkIfTileValid(i_UserInput, i_VisualBoardMatrix);
                break;

            case eValidationType.ValidateIsPlayingAgain:
                messageType = checkIfPlayAgainValid(i_UserInput);
                break;
            }

            return(messageType);
        }
Exemple #3
0
        private static GameMessage.eValidationMessageType checkIfPlayerNameValid(StringBuilder i_StringToValidate)
        {
            GameMessage.eValidationMessageType messageType = GameMessage.eValidationMessageType.Invalid;

            if (!(string.IsNullOrEmpty(i_StringToValidate.ToString())))
            {
                messageType = GameMessage.eValidationMessageType.Valid;
            }

            return(messageType);
        }
Exemple #4
0
        private static GameMessage.eValidationMessageType checkIfTileLocationCorrect(StringBuilder i_TileStringLocation, Coordinate i_BoardSize)
        {
            GameMessage.eValidationMessageType messageType = GameMessage.eValidationMessageType.InvalidTileOutOfBounds;
            Coordinate tileLocation = Coordinate.ConvertTileCoordinateInputToCoordinate(i_TileStringLocation);

            if (tileLocation.X < i_BoardSize.X && tileLocation.Y < i_BoardSize.Y)
            {
                messageType = GameMessage.eValidationMessageType.Valid;
            }

            return(messageType);
        }
Exemple #5
0
        private static GameMessage.eValidationMessageType checkIfBoardDimensionsValid(StringBuilder i_StringToValidate)
        {
            GameMessage.eValidationMessageType messageType = GameMessage.eValidationMessageType.InvalidDimensions;

            if (checkIfBoardDimensionInFormat(i_StringToValidate))
            {
                if (isBoardSizeValid(i_StringToValidate))
                {
                    messageType = GameMessage.eValidationMessageType.Valid;
                }
            }

            return(messageType);
        }
Exemple #6
0
        public GameMessage.eValidationMessageType CheckIfValid(InputValidator.eValidationType i_CurrentValidationType,
                                                               StringBuilder i_UserInput)
        {
            GameMessage.eValidationMessageType validationType = GameMessage.eValidationMessageType.Invalid;
            char[,]                             visualMatrix = null;

            if (i_CurrentValidationType == InputValidator.eValidationType.ValidateTile)
            {
                visualMatrix = m_VisualBoard.Matrix;
            }

            validationType = InputValidator.ValidateInput(i_CurrentValidationType, i_UserInput, visualMatrix);

            return(validationType);
        }
Exemple #7
0
        private static GameMessage.eValidationMessageType checkIfGameModeValid(StringBuilder i_StringToValidate)
        {
            GameMessage.eValidationMessageType messageType = GameMessage.eValidationMessageType.InvalidGameMode;
            int gameModeNumber = -1;

            if (int.TryParse(i_StringToValidate.ToString(), out gameModeNumber))
            {
                if (gameModeNumber >= 1 && gameModeNumber <= 2)
                {
                    messageType = GameMessage.eValidationMessageType.Valid;
                }
            }

            return(messageType);
        }
Exemple #8
0
        private static GameMessage.eValidationMessageType checkIfPlayAgainValid(StringBuilder i_PlayAgainInput)
        {
            GameMessage.eValidationMessageType messageType = GameMessage.eValidationMessageType.Invalid;
            int playAgainNumber = -1;

            if (int.TryParse(i_PlayAgainInput.ToString(), out playAgainNumber))
            {
                if (playAgainNumber == 1 || playAgainNumber == 2)
                {
                    messageType = GameMessage.eValidationMessageType.Valid;
                }
            }

            return(messageType);
        }
Exemple #9
0
        private StringBuilder getValidInput(InputValidator.eValidationType i_ValidateType)
        {
            StringBuilder userInput = null;

            GameMessage.eValidationMessageType validationMessage = GameMessage.eValidationMessageType.Invalid;

            while (validationMessage != GameMessage.eValidationMessageType.Valid)
            {
                userInput         = m_CurrentViewManager.GetUserInput();
                validationMessage = m_CurrentDataManager.CheckIfValid(i_ValidateType, userInput);
                m_CurrentViewManager.ShowValidationMessage(validationMessage);
            }

            return(userInput);
        }
Exemple #10
0
 public void ShowValidationMessage(GameMessage.eValidationMessageType i_MessageType)
 {
     GameMessage.PrintValidationMessage(i_MessageType);
 }