예제 #1
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            this.a_game = a_game;
            this.a_view = a_view;
            a_view.SetGame(a_game);
            DisplayMessages(a_game, a_view);

            if (a_game.IsGameOver())
            {
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            int input = a_view.GetInput();

            if (input == a_view.WantToPlay())
            {
                a_game.NewGame();
            }
            else if (input == a_view.WantToHit())
            {
                a_game.Hit();
                //Escape early. If the player got over 21 then he lost, or atleast should initialize the gameover screen. Might want to work on this
                if (a_game.IsGameOver())
                {
                    a_view.DisplayGameOver(a_game.IsDealerWinner());
                    return(input != a_view.WantToQuit());
                }
            }
            else if (input == a_view.WantToStand())
            {
                a_game.Stand();
            }

            return(input != a_view.WantToQuit());
        }