示例#1
0
        public bool Play()
        {
            DisplayWelcomeMessageAndHands();

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

            ViewAction action = m_view.GetAction();

            if (action == ViewAction.Newgame)
            {
                m_game.NewGame();
            }
            else if (action == ViewAction.Hit)
            {
                m_game.Hit();
            }
            else if (action == ViewAction.Stand)
            {
                m_game.Stand();
            }

            return(action != ViewAction.Quit);
        }
示例#2
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            m_game = a_game;
            m_view = a_view;
            m_game.RegisterNewObserver(this);

            update();

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

            int input = m_view.GetInput();

            if (input == view.SwedishView.NewGame_c)
            {
                a_game.NewGame();
            }
            else if (input == view.SwedishView.Hit_c)
            {
                a_game.Hit();
            }
            else if (input == view.SwedishView.Stand_c)
            {
                a_game.Stand();
            }

            return(input != view.SwedishView.Quit_c);
        }
示例#3
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);
        }
示例#4
0
        public bool Play()
        {
            m_game.Subscribe(this);

            DealtCard();

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

            Input input = m_view.GetInput();

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

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

            case Input.Stand:
                m_game.Stand();
                break;
            }
            return(input != Input.Quit);;
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
0
        public bool Play()
        {
            RenderGame();

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

            switch (m_view.GetMenuChoice())
            {
            case MenuChoices.PlayGame:
                m_game.NewGame();
                break;

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

            case MenuChoices.Stay:
                m_game.Stand();
                break;

            case MenuChoices.Quit:
                return(false);
            }

            return(true);
        }
示例#9
0
        public bool Play()
        {
            GetPlayBoard();

            if (_game.IsGameOver())
            {
                _view.DisplayGameOver(_game.IsDealerWinner());
            }

            view.PlayerAction input = _view.GetMenuOption();

            if (input == view.PlayerAction.DoPlay)
            {
                _game.NewGame();
            }
            else if (input == view.PlayerAction.DoHit)
            {
                _game.Hit();
            }
            else if (input == view.PlayerAction.DoStand)
            {
                _game.Stand();
            }

            return(input != view.PlayerAction.DoQuit);
        }
示例#10
0
        public bool Play()
        {
            UpdateCards();

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

            view.MenuOptions input = a_view.GetInput();

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

            return(input != view.MenuOptions.Quit);
        }
示例#11
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);
        }
示例#12
0
        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);
        }
示例#13
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);
        }
示例#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());
            }

            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);
        }
示例#15
0
文件: PlayGame.cs 项目: liha16/607w3
        public bool Play()
        {
            if (game.IsGameOver())
            {
                view.DisplayGameOver(game.IsDealerWinner());
            }

            view.SetInputOption();

            if (view.doesUserWantToPlay())
            {
                game.NewGame();
            }
            else if (view.doesUserWantToHit())
            {
                game.Hit();
            }
            else if (view.doesUserWantToStand())
            {
                game.Stand();
            }
            else if (view.doesUserWantToQuit())
            {
                return(false);
            }
            return(true);
        }
示例#16
0
        public bool Play()
        {
            DisplayGame();

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

            EnumChoice.GameChoice input = a_view.GetInput();

            if (input == EnumChoice.GameChoice.Play)
            {
                a_game.m_player.RegisterSubscriber(this);
                a_game.m_dealer.RegisterSubscriber(this);
                a_game.NewGame();
            }
            else if (input == EnumChoice.GameChoice.Hit)
            {
                a_game.Hit();
            }
            else if (input == EnumChoice.GameChoice.Stand)
            {
                a_game.Stand();
            }
            //
            return(input != EnumChoice.GameChoice.Quit);
        }
示例#17
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            a_game.RegisterNewCardDealer(this);

            this.game = a_game;
            this.view = a_view;
            CardDisplayer();

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

            int input = a_view.GetInput();

            switch (input)
            {
            case 1: { a_game.NewGame(); break; }

            case 2: { a_game.Hit(); break; }

            case 3: { a_game.Stand(); break; }

            case 4: { return(input != 4); }
            }
            return(input != 4);
        }
示例#18
0
        public bool Play()
        {
            DisplayAllScreen();

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

            m_view.GetInput();

            if (m_view.WantsNewGame())
            {
                m_game.NewGame();
            }
            else if (m_view.WantsToHit())
            {
                m_game.Hit();
            }
            else if (m_view.WantsToStand())
            {
                m_game.Stand();
            }

            return(!m_view.WantsToQuit());
        }
示例#19
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));
        }
示例#20
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());
        }
示例#21
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);
        }
        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));
        }
示例#23
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);
        }
示例#24
0
        public bool Play()
        {
            this.DisplayCards();

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

            char input = m_view.GetInput();

            if (input == m_inputLetter.getPlay())
            {
                m_game.NewGame();
            }
            else if (input == m_inputLetter.getHit())
            {
                m_game.Hit();
            }
            else if (input == m_inputLetter.getStand())
            {
                m_game.Stand();
            }

            return(input != m_inputLetter.getQuit());
        }
示例#25
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));
        }
示例#26
0
        public bool Play()
        {
            view.DisplayWelcomeMessage();

            view.DisplayDealerHand(game.GetDealerHand(), game.GetDealerScore());
            view.DisplayPlayerHand(game.GetPlayerHand(), game.GetPlayerScore());

            if (game.IsGameOver())
            {
                game.m_player.ClearSubscriber();
                game.m_dealer.ClearSubscriber();
                view.DisplayGameOver(game.IsDealerWinner());
            }

            input = view.GetInput();

            if (input == 'p')
            {
                game.m_player.AddSubscriber(this);
                game.m_dealer.AddSubscriber(this);
                game.NewGame();
            }
            else if (input == 'h')
            {
                game.Hit();
            }
            else if (input == 's')
            {
                game.Stand();
            }

            return(input != 'q');
        }
示例#27
0
        public bool Play()
        {
            DisplayInfo();

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

            Event input = m_view.GetInput();

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

            return(input != Event.Quit);
        }
示例#28
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');
        }
示例#29
0
        public bool Play()
        {
            if (a_game.IsGameOver())
            {
                CardDrawn();
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            var input = a_view.GetInput();

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

            case view.Event.Hit:
                a_game.Hit();
                break;

            case view.Event.Stand:
                a_game.Stand();
                break;

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

            case view.Event.None:
                return(true);
            }

            return(true);
        }
示例#30
0
        public bool Play(model.Game a_game)
        {
            m_game = a_game;


            CardDealt();
            //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.Event e;
            e = a_view.GetEvent();

            if (e == view.Event.Play)
            {
                a_game.NewGame();
            }
            else if (e == view.Event.Hit)
            {
                a_game.Hit();
            }
            else if (e == view.Event.Stand)
            {
                a_game.Stand();
            }

            return(e != view.Event.Quit);
        }