Esempio n. 1
0
        public Game(int i_BoardSize, GameType.eGameType i_GameType)
        {
            r_Board      = new Board(i_BoardSize);
            m_BlackScore = k_StartingScore;
            m_WhiteScore = k_StartingScore;
            r_GameType   = i_GameType;

            if (GameType.IsPlayerVsPc(r_GameType))
            {
                r_PcPlayer = new PcPlayer();
            }
        }
Esempio n. 2
0
        // handling the Guesses of the players
        internal static string Guess(string i_name)
        {
            string cell = string.Empty;

            // if user chose to play againt computer, we use the Guess function at PcPlayer
            if (i_name == "computer")
            {
                System.Console.WriteLine("Computer's turn");
                System.Threading.Thread.Sleep(1200);
                cell = PcPlayer.Guess(m_memoryGame.BoardHeight, m_memoryGame.BoardWidth, m_gameBoard);
            }
            else
            {
                System.Console.WriteLine(i_name + " ,please guess a cell");
                cell = System.Console.ReadLine();

                // check if the guess is valid
                int[] validity = IsValidCell(cell);
                while (validity[0] == 1 || validity[1] == 1)
                {
                    if (validity[1] == 1)
                    {
                        System.Console.WriteLine("The input is illegal, please try again");
                        cell     = System.Console.ReadLine();
                        validity = IsValidCell(cell);
                        continue;
                    }

                    if (validity[0] == 1)
                    {
                        System.Console.WriteLine("The input is out of board's bounds");
                        cell = System.Console.ReadLine();
                    }

                    validity = IsValidCell(cell);
                }
            }

            m_gameBoard.GuessedCells.Add(cell);
            return(cell);
        }
Esempio n. 3
0
        internal GameFlow(bool i_isFirstGame)
        {
            // init the game
            m_memoryGame = new GameInit(i_isFirstGame);
            m_gameBoard  = new Board(m_memoryGame.BoardHeight, m_memoryGame.BoardWidth);
            m_playerOne  = new Player(m_memoryGame.PlayerOne);
            m_scoreLimit = (m_memoryGame.BoardHeight * m_memoryGame.BoardWidth) / 2;
            m_totalScore = 0;

            // Setting rival according to game mode
            if (m_memoryGame.Mode == "player")
            {
                m_playerTwo = new Player(m_memoryGame.PlayerTwo);
            }
            else
            {
                m_pcPlayer = new PcPlayer();
            }

            m_running = true;

            // start game
            StartGame();
        }