Ejemplo n.º 1
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

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

            view.InputType input = a_view.GetInput();

            if (input == view.InputType.Play)
            {
                a_game.NewGame();
            }
            else if (input == view.InputType.Hit)
            {
                a_game.Hit();
            }
            else if (input == view.InputType.Stand)
            {
                a_game.Stand();
            }
            return(input != view.InputType.Quit);
        }
Ejemplo n.º 2
0
 public void CardDealt()
 {
     a_view.DisplayWelcomeMessage();
     a_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
     a_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
     a_view.PauseRedraw();
 }
Ejemplo n.º 3
0
        public void DisplayMessages(model.Game a_game, view.IView a_view)
        {
            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
        }
Ejemplo n.º 4
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            a_game.AddSubscriberToPlayer(this);
            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

            if (a_game.IsGameOver())
            {
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }
            model.MenuChoice choice = a_view.GetMenuChoice();

            if (choice == model.MenuChoice.NewGame)
            {
                a_game.NewGame();
            }
            else if (choice == model.MenuChoice.Hit)
            {
                a_game.Hit();
            }
            else if (choice == model.MenuChoice.Stand)
            {
                a_game.Stand();
            }

            return(choice != model.MenuChoice.Quit);
        }
Ejemplo n.º 5
0
        public void HandleEvent(object sender, EventArgs args)
        {
            System.Threading.Thread.Sleep(1000);
            Console.Clear();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
        }
Ejemplo n.º 6
0
        public void DealtCard()
        {
            Thread.Sleep(2000); //Wait for two seconds
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
        }
 public void CardDealt()
 {
     m_view.Pause(1000);
     m_view.DisplayWelcomeMessage();
     m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
     m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
     m_view.Pause(1000);
 }
Ejemplo n.º 8
0
        public void DisplayCards()
        {
            System.Threading.Thread.Sleep(1000);

            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
        }
Ejemplo n.º 9
0
        public void UpdateCards()
        {
            Thread.Sleep(1000);

            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
        }
Ejemplo n.º 10
0
        private void Display()
        {
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());

            if (m_game.IsGameOver())
            {
                m_view.DisplayGameOver(m_game.IsDealerWinner());
            }
        }
Ejemplo n.º 11
0
        public void RenderGame()
        {
            c_view.DisplayWelcomeMessage();

            c_view.DisplayDealerHand(c_game.GetDealerHand(), c_game.GetDealerScore());
            c_view.DisplayPlayerHand(c_game.GetPlayerHand(), c_game.GetPlayerScore());

            if (c_game.IsGameOver())
            {
                c_view.DisplayGameOver(c_game.IsDealerWinner());
            }
        }
Ejemplo n.º 12
0
        public void NotifyAboutDealtCard()
        {
            m_view.DisplayWelcomeMessage();
            m_view.DisplayDealerHand(
                m_game.GetDealerHand(), m_game.GetDealerScore()
                );
            m_view.DisplayPlayerHand(
                m_game.GetPlayerHand(), m_game.GetPlayerScore()
                );

            m_view.PauseDramatically();
        }
Ejemplo n.º 13
0
        public void CardDealt()
        {
            m_view.DisplayWelcomeMessage();
            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());

            if (m_game.IsGameOver())
            {
                m_view.DisplayGameOver(m_game.IsDealerWinner());
            }

            System.Threading.Thread.Sleep(1000);
        }
Ejemplo n.º 14
0
        public bool Play()
        {
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());

            if (m_game.IsGameOver())
            {
                m_view.DisplayGameOver(m_game.IsDealerWinner());
            }

            view.GameAction gameAction = m_view.GetAction();

            switch (gameAction)
            {
            case view.GameAction.Play:
                m_game.NewGame();
                return(true);

            case view.GameAction.Hit:
                m_game.Hit();
                return(true);

            case view.GameAction.Stand:
                m_game.Stand();
                return(true);

            case view.GameAction.Quit:
                return(false);

            case view.GameAction.Invalid:
                return(true);

            default:
                throw new Exception("GameAction can not be handled.");
            }
        }
Ejemplo n.º 15
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

            if (a_game.IsGameOver())
            {
                foreach (model.Player obs in a_game.getPlayers())
                {
                    obs.removeObserver(this);
                }
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            switch (a_view.GetInput())
            {
            case view.MenuOptions.play:
                foreach (model.Player obs in a_game.getPlayers())
                {
                    obs.addObserver(this);
                }
                a_game.NewGame();
                break;

            case view.MenuOptions.hit:
                a_game.Hit();
                break;

            case view.MenuOptions.stand:
                a_game.Stand();
                break;

            case view.MenuOptions.quit:
                return(false);

            default:
                return(true);
            }

            return(true);
        }
Ejemplo n.º 16
0
 public void PrintView()
 {
     m_view.DisplayWelcomeMessage();
     m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
     m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
 }
Ejemplo n.º 17
0
 private void Render(model.Game a_game)
 {
     a_view.DisplayWelcomeMessage();
     a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
     a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
 }
Ejemplo n.º 18
0
 private void GetPlayBoard()
 {
     _view.DisplayWelcomeMessage();
     _view.DisplayDealerHand(_game.GetDealerHand(), _game.GetDealerScore());
     _view.DisplayPlayerHand(_game.GetPlayerHand(), _game.GetPlayerScore());
 }