Exemplo n.º 1
0
        // gameSession: a single game session progress
        private eRunState gameSession(out ushort o_StepsTaken)
        {
            eRunState runState      = eRunState.Continue; // current game run state
            ushort    guessesAmount = getGuessesAmount();

            m_Logic.UserGuessesAmount = guessesAmount; // set guessAmount
            m_Logic.InitiateGame();
            o_StepsTaken = 0;

            for (int i = 1; i < m_Logic.Board.Length && runState == eRunState.Continue; i++)
            {
                Screen.Clear();
                PrintUtils.PrintCurrentBoardStatus(m_Logic.Board);
                runState = handleGuessInput(i);
                ++o_StepsTaken;
            }

            // check if user had too many steps
            if (runState == eRunState.Continue && o_StepsTaken == m_Logic.UserGuessesAmount)
            {
                runState = eRunState.Lost;
            }

            return(runState);
        }
Exemplo n.º 2
0
        public void Run()
        {
            eRunState runState;   // current game's runState
            ushort    stepsTaken; // amount of steps taken in session

            // game loop
            do
            {
                Screen.Clear();
                runState = this.gameSession(out stepsTaken); // start a new game session
                Screen.Clear();
                PrintUtils.PrintCurrentBoardStatus(m_Logic.Board);
                handleEndSession(ref runState, stepsTaken);
            }while (runState != eRunState.EndGame);
        }