コード例 #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());
            }

            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);
        }
コード例 #2
0
ファイル: PlayGame.cs プロジェクト: sk222sw/blackjack
 public PlayGame(model.Game g, view.IView v)
 {
     a_game = g;
     a_view = v;
     a_view.DisplayWelcomeMessage();
     a_game.Subscribe(this);
 }
コード例 #3
0
ファイル: PlayGame.cs プロジェクト: la222tc/blackjack_csharp
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            m_game = a_game;
            m_view = a_view;

            m_game.AddObserver(this);
        }
コード例 #4
0
ファイル: PlayGame.cs プロジェクト: CCHolmgren/Portfolio
        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());
        }
コード例 #5
0
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            m_game = a_game;
            m_view = a_view;

            m_game.AddObserver(this);
        }
コード例 #6
0
ファイル: PlayGame.cs プロジェクト: liha16/607w3
 public void StartGame(model.Game a_game, view.IView a_view)
 {
     game = a_game;
     view = a_view;
     view.DisplayWelcomeMessage();
     subscribeToHandCard();
 }
コード例 #7
0
ファイル: PlayGame.cs プロジェクト: MarkusGirdland/BlackJack
        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');
        }
コード例 #8
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            m_view = a_view;
            m_game = a_game;
            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.Events input = (BlackJack.view.Events)a_view.GetInput();

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

            return input != view.Events.Quit;
        }
コード例 #9
0
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            _game = a_game;
            _view = a_view;

            _game.SetObserver(this);
        }
コード例 #10
0
ファイル: PlayGame.cs プロジェクト: sk222sw/blackjack
 public PlayGame(model.Game g, view.IView v)
 {
     a_game = g;
     a_view = v;
     a_view.DisplayWelcomeMessage();
     a_game.Subscribe(this);
 }
コード例 #11
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);
        }
コード例 #12
0
ファイル: PlayGame.cs プロジェクト: ad222kr/1dv607
 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);
 }
コード例 #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());
            }

            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));
        }
コード例 #14
0
ファイル: PlayGame.cs プロジェクト: sh222td/Portfolio
        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);
        }
コード例 #15
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);
        }
コード例 #16
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            //Initialize fields
            m_view = a_view;
            m_game = a_game;

            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.Input input = a_view.GetInput();

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

            return input != view.Input.Quit;
        }
コード例 #17
0
ファイル: PlayGame.cs プロジェクト: jt222ic/Blackjack_jt22ic
 public PlayGame(model.Game A_game,
     view.IView A_view)
 {
     a_game = A_game;
       a_view = A_view;
       a_game.addSub(this);
 }
コード例 #18
0
ファイル: PlayGame.cs プロジェクト: AndreasAnemyrLNU/1dv607
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            this.a_game = a_game;
            this.m_view = a_view;

            a_game.AddSubscriber(this);
        }
コード例 #19
0
 public Farkle(view.IView a_IView, model.env.exit.IEnvironmentExit a_envExit)
 {
     m_IView         = a_IView;
     m_playerFactory = new PlayerFactory();
     m_asyncDelay    = new model.task.delay.AsyncDelay();
     m_envExit       = a_envExit;
 }
コード例 #20
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);
        }
コード例 #21
0
ファイル: PlayGame.cs プロジェクト: CCHolmgren/Portfolio
        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());
        }
コード例 #22
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);
        }
コード例 #23
0
        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));
        }
コード例 #24
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);
        }
コード例 #25
0
ファイル: PlayGame.cs プロジェクト: Lendzin/1dv607
        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);
        }
コード例 #26
0
        public PlayGame(model.Game a_game, view.IView a_view, view.InputLetter a_inputLetter)
        {
            m_view        = a_view;
            m_inputLetter = a_inputLetter;
            m_game        = a_game;

            a_game.AddObservers(this);
        }
コード例 #27
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();
 }
コード例 #28
0
ファイル: PlayGame.cs プロジェクト: Elmona/Blackjack
        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();
        }
コード例 #29
0
        public PlayGame(view.IView a_view, model.Game a_game)
        {
            m_view = a_view;
            m_game = a_game;

            // Subscribe to observer
            m_game.AddSubscribtionToCards(this);
        }
コード例 #30
0
ファイル: PlayGame.cs プロジェクト: LindaOtt/Workshop_3
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            this.a_game = a_game;
            this.a_view = a_view;

            a_game.AddObserver(this);

            //this.a_game.AddSubscribers(this);
        }
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            m_game = a_game;
            m_view = a_view;

            //subscribe to game events
            m_game.AddSubscriber(this);

            UpdateView();
        }
コード例 #32
0
 public FarkleViewTest()
 {
     fake_dice = new Mock <model.Dice>();
     fake_dice_setup();
     mock_player = new Mock <model.IPlayer>();
     mock_player_setup();
     mock_console_readline = new Mock <model.console.readline.IConsoleReadline>();
     mock_console_readline_setup();
     sut            = new view.FarkleView(mock_console_readline.Object);
     sut_farkleview = new view.FarkleView(mock_console_readline.Object);
 }
コード例 #33
0
        public PlayGame()
        {
            // create a setup controller
            SetupGame setup = new SetupGame();

            // create a game with config delivered from the setup controller
            m_game = new model.Game(setup.GetWinnerAtDrawRules(), setup.GetDealer17Rules(), setup.GetGameRules());
            // Let setup controller create the game view depending on language
            m_view = setup.GetLanguageView();

            m_game.AddSubscriber(this);
        }
コード例 #34
0
ファイル: PlayGame.cs プロジェクト: ej222ru/1DV607_WS3
        public PlayGame()
        {
            // create a setup controller
            SetupGame setup = new SetupGame();

            // create a game with config delivered from the setup controller
            m_game = new model.Game(setup.GetWinnerAtDrawRules(), setup.GetDealer17Rules(), setup.GetGameRules());
            // Let setup controller create the game view depending on language
            m_view = setup.GetLanguageView();

            m_game.AddSubscriber(this);
        }
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            m_game = a_game;
            m_view = a_view;

            //subscribe to game events
            m_game.AddSubscriber(this);

            if (!(m_view is view.ModernView))
            {
                ClearView();
            }
        }
コード例 #36
0
ファイル: SetupGame.cs プロジェクト: ej222ru/1DV607_WS3
 public view.IView GetLanguageView()
 {
     view.Language selectLanguage = setup.GetLanguage();
     if (selectLanguage == view.Language.ENGLISH)
     {
         gameView = new view.SimpleView();
     }
     else if (selectLanguage == view.Language.SWEDISH)
     {
         gameView = new view.SwedishView();
     }
     else
     {
         gameView = new view.SimpleView();
     }
     return gameView;
 }
コード例 #37
0
 public view.IView GetLanguageView()
 {
     view.Language selectLanguage = setup.GetLanguage();
     if (selectLanguage == view.Language.ENGLISH)
     {
         gameView = new view.SimpleView();
     }
     else if (selectLanguage == view.Language.SWEDISH)
     {
         gameView = new view.SwedishView();
     }
     else
     {
         gameView = new view.SimpleView();
     }
     return(gameView);
 }
コード例 #38
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);
        }
コード例 #39
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            m_view = a_view;
            m_game = a_game;


            if (!isWelcomed)
            {
                isWelcomed = true;
                a_view.DisplayWelcomeMessage();
                m_view.DisplayRules(m_game.GetHitRule(), m_game.GetNewGameRule(), m_game.GetWinRule());
            }
            else { 
                a_view.DisplayResults(a_game.GetPlayerHand(), a_game.GetPlayerScore(), a_game.GetDealerHand(), a_game.GetDealerScore());
            }

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

            view.Action action = a_view.GetInput();

            switch (action)
            {
                case view.Action.NewGame:
                    a_game.NewGame();
                    break;
                case view.Action.Hit:
                    a_game.Hit();
                    break;
                case view.Action.Stand:
                    a_game.Stand();
                    break;
            }

            return action != view.Action.Quit;

        }
コード例 #40
0
ファイル: PlayGame.cs プロジェクト: fr222cy/IDV607-Black-Jack
 public PlayGame(view.IView v)
 {
     m_view = v;
 }
コード例 #41
0
 public PlayGame(model.Game a_game, view.IView a_view)
 {
     m_game = a_game;
     m_view = a_view;
     m_game.AddSubscribers(this);
 }
コード例 #42
0
ファイル: PlayGame.cs プロジェクト: henceee/1DV607
 public PlayGame(view.IView a_view)
 {
     m_view = a_view;
 }
コード例 #43
0
ファイル: PlayGame.cs プロジェクト: Marco30/1DV607-Workshops
 // / Konstruktor som sätter inparametrarna till sina privata objekt
 public PlayGame(model.Game a_game, IView a_view)
 {
     v_view = a_view;
     m_game = a_game;
 }
コード例 #44
0
ファイル: PlayGame.cs プロジェクト: DevRobDev/1DV407
 public PlayGame(view.IView a_view)
 {
     m_view = a_view;
     m_view.DisplayWelcomeMessage();
 }
コード例 #45
0
ファイル: PlayGame.cs プロジェクト: rn222cx/1dv607-OOP
 public PlayGame(Game a_game, view.IView a_view)
 {
     this.a_game = a_game;
     this.a_view = a_view;
 }
コード例 #46
0
ファイル: PlayGame.cs プロジェクト: ks222rt/1DV607
 public PlayGame(model.Game A_game, view.IView A_view)
 {
     a_game = A_game;
     a_view = A_view;
 }
コード例 #47
0
 public PlayGame(view.IView view, model.Game game)
 {
     a_view = view;
     a_game = game;
     a_game.AddObserver(this);
 }
コード例 #48
0
 public DealtCardObserver(model.Game a_game, view.IView a_view)
 {
     m_game = a_game;
     m_view = a_view;
 }
コード例 #49
0
 public PlayGame(model.Game a_game, view.IView a_view)
 {
     m_game = a_game;
     m_view = a_view;
 }
コード例 #50
0
 public PlayGame(model.Game a_game, view.IView a_view)
 {
     c_game = a_game;
     c_view = a_view;
 }
コード例 #51
0
ファイル: PlayGame.cs プロジェクト: MartinArvidsson/UML
 public PlayGame(model.Game a_Game, view.IView a_View)
 {
     a_game = a_Game;
     a_view = a_View;
     a_game.AddSub(this);
 }
コード例 #52
0
ファイル: PlayGame.cs プロジェクト: mw222rs/blackjack_csharp
 public PlayGame(view.IView a_view, model.Game a_game)
 {
     m_view = a_view;
     m_game = a_game;
 }