Example #1
0
        public bool Play()
        {
            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.InputEvents input = a_view.GetInput();
            if (input == view.InputEvents.NewGame)
            {
                a_game.NewGame();
            }
            else if (input == view.InputEvents.Hit)
            {
                a_game.Hit();
            }
            else if (input == view.InputEvents.Stand)
            {
                a_game.Stand();
            }

            return(input != view.InputEvents.Quit);
        }
        public bool Play()
        {
            if (subcriberNeeded)
            {
                m_game.AddSubscriber(this);
                subcriberNeeded = false;
            }

            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.GameOption input = m_view.GetInput();

            if (input == view.GameOption.Play)
            {
                m_game.NewGame();
            }
            else if (input == view.GameOption.Hit)
            {
                m_game.Hit();
            }
            else if (input == view.GameOption.Stand)
            {
                m_game.Stand();
            }

            return(input != view.GameOption.Quit);
        }
Example #3
0
        public void CardRecieved()
        {
            Thread.Sleep(1000);
            view.DisplayWelcomeMessage();

            view.DisplayDealerHand(game.GetDealerHand(), game.GetDealerScore());
            view.DisplayPlayerHand(game.GetPlayerHand(), game.GetPlayerScore());
        }
        public bool Play(model.Game a_game, view.IView a_view)
        {
            m_view = a_view;
            m_game = a_game;

            m_view.DisplayWelcomeMessage();

            m_game.AddSubToPlayer(this);

            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.MenuOptions input = m_view.GetInput();

            if (view.MenuOptions.PLAY.Equals(input))
            {
                m_game.NewGame();
            }
            else if (view.MenuOptions.HIT.Equals(input))
            {
                m_game.Hit();
            }
            else if (view.MenuOptions.STAND.Equals(input))
            {
                m_game.Stand();
            }

            return(!view.MenuOptions.QUIT.Equals(input));
        }
Example #5
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());
        }
Example #6
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());
            }

            int input = a_view.GetInput();

            if (input == BlackJack.view.SwedishView.Play)
            {
                a_game.NewGame();
            }
            else if (input == BlackJack.view.SwedishView.Hit)
            {
                a_game.Hit();
            }
            else if (input == BlackJack.view.SwedishView.Stand)
            {
                a_game.Stand();
            }

            return(input != BlackJack.view.SwedishView.Quit);
        }
Example #7
0
        public void DisplayAllScreen()
        {
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
        }
Example #8
0
 public void DisplayGame()
 {
     PauseGame();
     a_view.DisplayWelcomeMessage();
     a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
     a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
 }
Example #9
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.Alternatives input = (view.Alternatives)m_view.GetInput();

            switch (input)
            {
            case view.Alternatives.play:
                m_game.NewGame();
                break;

            case view.Alternatives.hit:
                m_game.Hit();
                break;

            case view.Alternatives.stand:
                m_game.Stand();
                break;

            default:
                break;
            }
            return(input != view.Alternatives.quit);
        }
Example #10
0
 public PlayGame(model.Game g, view.IView v)
 {
     a_game = g;
     a_view = v;
     a_view.DisplayWelcomeMessage();
     a_game.Subscribe(this);
 }
Example #11
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());
            }

            BlackJack.view.MenuEvent.Event e;

            e = a_view.GetEvent();
            if (e == BlackJack.view.MenuEvent.Event.Quit)
            {
                return(false);
            }
            if (e == BlackJack.view.MenuEvent.Event.Start)
            {
                a_game.NewGame();
            }
            if (e == BlackJack.view.MenuEvent.Event.Hit)
            {
                a_game.Hit();
            }
            if (e == BlackJack.view.MenuEvent.Event.Stand)
            {
                a_game.Stand();
            }

            return(true);
        }
Example #12
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());
            }

            Event input = m_view.GetInput();

            switch (input)
            {
            case Event.Play:
                m_game.NewGame();
                break;

            case Event.Hit:
                m_game.Hit();
                break;

            case Event.Stand:
                m_game.Stand();
                break;
            }

            return(input != Event.Quit);
        }
Example #13
0
 public PlayGame(model.Game g, view.IView v)
 {
     a_game = g;
     a_view = v;
     a_view.DisplayWelcomeMessage();
     a_game.Subscribe(this);
 }
Example #14
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());
            }

            int input = a_view.GetInput();

            if (input == 'p')
            {
                a_game.NewGame();
            }
            else if (input == 'h')
            {
                a_game.Hit();
                Observer pause = new Observer();
                pause.PauseIt();
            }
            else if (input == 's')
            {
                a_game.Stand();
            }

            return(input != 'q');
        }
Example #15
0
 public void CardDrawn()
 {
     System.Threading.Thread.Sleep(500);
     a_view.DisplayWelcomeMessage();
     a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
     a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
 }
Example #16
0
 public void m_dealer_HandCardCompleted(object sender, EventArgs e)
 {
     Thread.Sleep(2000);
     view.DisplayWelcomeMessage();
     view.DisplayDealerHand(game.GetDealerHand(), game.GetDealerScore());
     view.DisplayPlayerHand(game.GetPlayerHand(), game.GetPlayerScore());
 }
Example #17
0
 public void StartGame(model.Game a_game, view.IView a_view)
 {
     game = a_game;
     view = a_view;
     view.DisplayWelcomeMessage();
     subscribeToHandCard();
 }
Example #18
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            m_game = a_game;
            m_view = 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());
            }

            int input = a_view.GetInput();

            if (input == (int)GameAlternative.Play)
            {
                a_game.NewGame();
            }
            else if (input == (int)GameAlternative.Hit)
            {
                a_game.Hit();
            }
            else if (input == (int)GameAlternative.Stand)
            {
                a_game.Stand();
            }

            return(input != (int)GameAlternative.Quit);
        }
Example #19
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);
        }
Example #20
0
        public bool Play()
        {
            bool keepPlaying = true;

            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());
            }


            Enum input = a_view.GetInput();

            if (input != null)
            {
                switch (input)
                {
                case ViewEnums.Play: a_game.NewGame(); break;

                case ViewEnums.Hit: a_game.Hit(); break;

                case ViewEnums.Stand: a_game.Stand(); break;

                case ViewEnums.Quit: keepPlaying = false; break;

                default: break;
                }
            }

            return(keepPlaying);
        }
Example #21
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.MenuSelection input = a_view.GetInput();

            if (input == view.MenuSelection.Play)
            {
                a_game.NewGame();
            }
            else if (input == view.MenuSelection.Hit)
            {
                a_game.Hit();
            }
            else if (input == view.MenuSelection.Stand)
            {
                a_game.Stand();
            }

            return(input != view.MenuSelection.Quit);
        }
Example #22
0
        private void DisplayInfo()
        {
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
        }
Example #23
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());
            }

            int input = a_view.GetInput();

            if (a_view.PlayerWantsToPlay(input))
            {
                a_game.NewGame();
            }
            else if (a_view.PlayerWantsToHit(input))
            {
                a_game.Hit();
            }
            else if (a_view.PlayerWantsToStand(input))
            {
                a_game.Stand();
            }

            return(a_view.PlayerWantsToQuit(input));
        }
Example #24
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();
 }
        public bool Play()
        {
            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());
            }

            int input = a_view.GetInput();

            if (a_view.IsPlay(input))
            {
                a_game.NewGame();
            }
            else if (a_view.IsHit(input))
            {
                a_game.Hit();
            }
            else if (a_view.IsStand(input))
            {
                a_game.Stand();
            }

            return(!a_view.IsQuit(input));
        }
Example #26
0
        public bool Play(model.Game a_game, view.IView a_view, DealtCardObserver observer)
        {
            a_game.RegisterObserver(observer);

            if (!GameStarted)
            {
                a_view.DisplayWelcomeMessage();
            }

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

            UserWish userWish = a_view.GetUserWish();

            if (userWish == UserWish.Play)
            {
                GameStarted = true;
                a_game.NewGame();
            }

            if (userWish == UserWish.Hit)
            {
                a_game.Hit();
            }

            if (userWish == UserWish.Stand)
            {
                a_game.Stand();
            }

            return(userWish != UserWish.Quit);
        }
Example #27
0
 public PlayGame(model.Game a_game, view.IView a_view)
 {
     m_game = a_game;
     m_view = a_view;
     m_view.DisplayWelcomeMessage();
     m_game.Subsribe(this);
 }
 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);
 }
Example #29
0
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            this.a_game = a_game;
            this.a_view = a_view;

            this.a_game.AddSubscriber(this);
            a_view.DisplayWelcomeMessage();
        }
Example #30
0
        public void update()
        {
            Thread.Sleep(1200);
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(this.m_game.GetDealerHand(), this.m_game.GetDealerScore());
            m_view.DisplayPlayerHand(this.m_game.GetPlayerHand(), this.m_game.GetPlayerScore());
        }
Example #31
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());
        }
Example #32
0
 public PlayGame(model.Game a_game, view.IView a_view)
 {
     m_game = a_game;
     m_view = a_view;
     m_game.AddPlayerSubscriber(this);
     m_game.AddDealerSubscriber(this);
     m_view.DisplayWelcomeMessage();
 }
Example #33
0
 public PlayGame(view.IView a_view)
 {
     m_view = a_view;
     m_view.DisplayWelcomeMessage();
 }