示例#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);
        }
示例#2
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);
        }
        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);
        }
示例#4
0
        public void CardRecieved()
        {
            Thread.Sleep(1000);
            view.DisplayWelcomeMessage();

            view.DisplayDealerHand(game.GetDealerHand(), game.GetDealerScore());
            view.DisplayPlayerHand(game.GetPlayerHand(), game.GetPlayerScore());
        }
示例#5
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());
 }
示例#6
0
        public void RenderGame()
        {
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
            m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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());
        }
示例#10
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());
 }
        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));
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            this.m_view = a_view;

            this.m_view.DisplayWelcomeMessage();

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

            if (a_game.IsGameOver())
            {
                this.m_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            int input = this.m_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);
        }
示例#15
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());
        }
示例#16
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));
        }
示例#17
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());
        }
示例#18
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());
            }

            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));
        }
示例#19
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);
        }
示例#20
0
文件: PlayGame.cs 项目: liha16/607w3
 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());
 }
示例#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());
            }

            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');
        }
示例#22
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();
 }
示例#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());
            }

            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);
        }
示例#24
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());
        }
示例#25
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());
        }
 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);
 }
示例#27
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());
        }
示例#28
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());
        }
示例#29
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());
            }
        }
示例#30
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();
        }