Ejemplo n.º 1
0
        // RETURNS FALSE WHEN GAMER ROUND IS FINISHED
        private bool GamerPlaysRound()
        {
            if (m_game.IsGamerNext() && m_game.Status == GameStatus.InProgress)
            {
                int rollsLeft = m_game.GetRollsLeft();

                // First roll completes automatically for gamer
                if (rollsLeft == m_game.RollsPerRound)
                {
                    m_game.GamerRolls();
                }

                string gameJson = JsonConvert.SerializeObject(m_game, Formatting.Indented);

                m_view.DisplayGameDetails(
                    gameJson, m_game.CurrentPlayerIndex, m_game.CurrentRound, m_game.GetRollsLeft());
                m_view.DisplayGameMenu(rollsLeft);

                var input = m_view.GetGameInput(rollsLeft);

                switch (input)
                {
                case GameMenuInput.HoldDie1:
                    m_game.GamerHoldsDie(0);
                    return(true);

                case GameMenuInput.HoldDie2:
                    m_game.GamerHoldsDie(1);
                    return(true);

                case GameMenuInput.HoldDie3:
                    m_game.GamerHoldsDie(2);
                    return(true);

                case GameMenuInput.HoldDie4:
                    m_game.GamerHoldsDie(3);
                    return(true);

                case GameMenuInput.HoldDie5:
                    m_game.GamerHoldsDie(4);
                    return(true);

                case GameMenuInput.Roll:
                    m_game.GamerRolls();
                    return(true);

                case GameMenuInput.ChooseCat:
                    return(GamerSelectsCat(gameJson) ? false : true);

                case GameMenuInput.Quit:
                    // m_view.DisplaySaveOption()
                    // var input = m_view.GetSaveDecision();

                    // QUIT GAME - WITH SAVE
                    // if (input == SaveMenuInput.Save)
                    // {
                    m_game.Status = GameStatus.Unfinished;
                    SaveUnfinishedGame();
                    // }
                    // QUIT GAME / WITHOUT SAVE
                    // else (input == SaveMenuInput.NoSave)
                    // {
                    //     m_game.Status == GameStatus.Discarded;
                    // }

                    return(false);

                default:
                    m_view.TextToConsole("\nERROR: menu input not recognised");
                    return(true);
                }
            }

            return(false);
        }