Exemplo n.º 1
0
        private void initGame()
        {
            string player1Name = m_IO.GetPlayerName();
            string player2Name;
            int    sizeOfBoard;

            m_Player1 = new Player(player1Name, Player.ePlayerType.Player, Player.eColor.Black);
            UI.eModeGame oponentOption = m_IO.GetGameMode();

            if (oponentOption == UI.eModeGame.PlayerVsComputer)
            {
                player2Name = "Computer";
                m_Player2   = new Player(player2Name, Player.ePlayerType.Computer, Player.eColor.White);
            }
            else
            {
                player2Name = m_IO.GetPlayerName();
                m_Player2   = new Player(player1Name, Player.ePlayerType.Player, Player.eColor.White);
            }

            sizeOfBoard = m_IO.GetSizeOfBoard();

            Move.s_Height = sizeOfBoard;
            Move.s_Width  = sizeOfBoard;
        }
Exemplo n.º 2
0
        public UI.eModeGame GetGameMode()
        {
            bool inputIsNotValid = true;

            UI.eModeGame chosenGameMode = UI.eModeGame.Invalid;

            while (inputIsNotValid)
            {
                string enteredGameMode = m_UIhandler.GetModeGameFromUser();
                inputIsNotValid = !m_Valdator.GameModeIsValid(enteredGameMode, out chosenGameMode);
            }

            return(chosenGameMode);
        }
Exemplo n.º 3
0
        public bool GameModeIsValid(string i_GameModeOption, out UI.eModeGame o_GameMode)
        {
            bool v_GameModeIsLegal;
            bool v_InputIsNumber;
            int  v_Option;

            o_GameMode = UI.eModeGame.Invalid;

            v_InputIsNumber = Int32.TryParse(i_GameModeOption, out v_Option);
            if (v_InputIsNumber)
            {
                v_GameModeIsLegal = v_Option == c_SelectOption1 || v_Option == c_SelectOption2;
                if (v_GameModeIsLegal)
                {
                    o_GameMode = getModeGameFromNumber(v_Option);
                }
            }
            else
            {
                v_GameModeIsLegal = false;
            }

            return(v_GameModeIsLegal);
        }