Пример #1
0
        private string getPlayerGuess()
        {
            bool     isValid;
            string   guess;
            Position positionOnBoard = new Position();

            printPlayersScore();
            Console.WriteLine("{0}Enter card Position :", Environment.NewLine);
            do
            {
                guess   = Console.ReadLine();
                isValid = GameRulesValidation.ValidateInput(guess);
                guess   = guess?.ToUpper();
                if (isValid)
                {
                    positionOnBoard = Position.Parse(guess);
                    isValid         = GameRulesValidation.ExceptionsCatch(
                        m_GameLogic.ValidateGuess(positionOnBoard));
                }
            }while (!isValid);

            Card card = m_GameLogic.GetCard(positionOnBoard);

            showCard(guess, card);

            return(guess);
        }
Пример #2
0
        private void chooseGameMode()
        {
            Console.WriteLine(
                @"Choose your game mode : 
1. Player vs Player.
2. Player vs PC.
");
            string modeNumber;

            do
            {
                modeNumber = Console.ReadLine();
            }while(!GameRulesValidation.ValidateGameMode(modeNumber));

            int result;

            int.TryParse(modeNumber, out result);
            m_GameMode = (MemoryGameLogic <Card> .eGameMode)result;

            if (m_GameMode == MemoryGameLogic <Card> .eGameMode.PlayerVsPlayer)
            {
                m_GameMode = MemoryGameLogic <Card> .eGameMode.PlayerVsPlayer;
                createPlayer();
            }
            else
            {
                m_GameMode = MemoryGameLogic <Card> .eGameMode.PlayerVsPc;
                r_Players[m_NumberOfPlayers] = new Player()
                {
                    UserName = "******"
                };
                m_NumberOfPlayers++;
            }
        }
Пример #3
0
        private void createBoard()
        {
            string boardSize;

            m_GameBoard = new Board();
            Console.WriteLine("Enter Row and Column : ");
            do
            {
                boardSize = Console.ReadLine();
            }while(!GameRulesValidation.ValidateBoardSize(boardSize));

            m_GameBoard.SetBoardSize(boardSize);
        }
Пример #4
0
        private void createPlayer()
        {
            string userName;

            Console.WriteLine("Enter Player {0} name : ", m_NumberOfPlayers + 1);
            do
            {
                userName = Console.ReadLine();
            }while (!GameRulesValidation.ValidateUser(userName));
            r_Players[m_NumberOfPlayers] = new Player()
            {
                UserName = userName
            };
            m_NumberOfPlayers++;
        }
Пример #5
0
        private void newGame()
        {
            Console.WriteLine("Would you like to play again Y/N ?");
            string input;

            do
            {
                input = Console.ReadLine();
            }while (!GameRulesValidation.ValidateNewGame(input));

            createBoard();
            initializeGameLogic();
            createDeckOfCards();
            m_GameLogic.NewGame();
            startGame();
        }