예제 #1
0
        private void OpeningCardsInteraction(ILogic Logic)
        {
            if (Logic.IsPlayerWinner())
            {
                ShowPlayerWin();
            }
            else
            {
                ShowComputerWin();
            }

            WaitKey();
            ClearScreen();
            Logic.ClearSets();
            MenuState.Back();
        }
예제 #2
0
        private void GettingCardInteraction(ILogic Logic)
        {
            Logic.GetCardToPlayerSet();

            ShowPlayerTookInf(Logic.GetCardsOfPlayer().Last());
            WaitKey();

            if (!Logic.CheckValidSum(Logic.GetCardsOfPlayer()))
            {
                ShowComputerWin();
                WaitKey();
                Logic.ClearSets();
                ClearScreen();
                MenuState.Back();
                return;
            }
            if (!Logic.CheckValidSum(Logic.GetCardsOfComputer()))
            {
                ShowPlayerWin();
                WaitKey();
                Logic.ClearSets();
                ClearScreen();
                MenuState.Back();
                return;
            }

            if (Logic.ComputerTakingCard())
            {
                ShowComputerTookInf();
                WaitKey();
            }
            else
            {
                ShowComputerOpenInf(Logic);
                WaitKey();
                OpeningCardsInteraction(Logic);
            }

            ClearScreen();
            ShowSetOfCards(Logic.GetCardsOfPlayer());
        }
예제 #3
0
        public override void BeginInteractionWithLogic(ILogic Logic)
        {
            ShowGreeting();
            WaitKey();
            ClearScreen();

            Logic.GenerateStartingSetsOfCards();

            MenuState StartingMenu = null; MenuState PlayingMenu = null;

            StartingMenu = new MenuState
            {
                Name    = "------------------------------------------Starting Menu-------------------------",
                Buttons = new List <Button>
                {
                    new Button {
                        Text = "Start the round;", OnSelect = () =>
                        {
                            StartingRoundInteraction(Logic);
                            MenuState.SetMenu(PlayingMenu);
                        }
                    },
                    new Button {
                        Text = "Exit;", OnSelect = () =>
                        {
                            ClearScreen();
                            ShowParting();
                            WaitKey();
                            Environment.Exit(0);
                        }
                    }
                }
            };
            PlayingMenu = new MenuState
            {
                Name    = "\n------------------------------------------Playing Menu--------------------------",
                Buttons = new List <Button>
                {
                    new Button {
                        Text = "Open cards;", OnSelect = () =>
                        {
                            ShowPlayerOpenInf(Logic);
                            WaitKey();
                            ShowComputerOpenInf(Logic);
                            WaitKey();
                            OpeningCardsInteraction(Logic);
                        }
                    },
                    new Button {
                        Text = "Get card;", OnSelect = () => GettingCardInteraction(Logic)
                    },
                    new Button {
                        Text = "Leave the game;", OnSelect = () =>
                        {
                            ClearScreen();
                            MenuState.Back();
                        }
                    }
                }
            };

            MenuState.SetMenu(StartingMenu);

            byte choice = 0;

            while (true)
            {
                MenuState currentMenu = MenuState.GetCurrent();
                DrawMenu(currentMenu);
                choice = ReadAndSaveCode();
                if (choice <= currentMenu.Buttons.Count())
                {
                    currentMenu.Buttons[choice - 1].OnSelect();
                }
            }
        }
예제 #4
0
 protected override void ShowPlayerOpenInf(ILogic Logic)
 {
     Console.Write($"Player is opening the cards!\n");
     ShowSetOfCards(Logic.GetCardsOfPlayer());
     Console.WriteLine("Press Enter to continue.");
 }
예제 #5
0
 public abstract void BeginInteractionWithLogic(ILogic Logic);
예제 #6
0
 //-----------------------------------------------------------------------------Methods of UI Interaction with a Logic-----------------
 private void StartingRoundInteraction(ILogic Logic)
 {
     ClearScreen();
     ShowSetOfCards(Logic.GetCardsOfPlayer());
 }
예제 #7
0
 protected abstract void ShowPlayerOpenInf(ILogic Logic);
예제 #8
0
 protected abstract void ShowComputerOpenInf(ILogic Logic);
예제 #9
0
        public void Start(ILogic TypeOfLogic, IUserInterface TypeOfUI)
        {
            SetStartingSettings(TypeOfLogic, TypeOfUI);

            UI.BeginInteractionWithLogic(Logic);
        }
예제 #10
0
 private void SetupDeckSettings(ILogic TypeOfLogic)
 {
     TypeOfLogic.ConfigDeck();
 }
예제 #11
0
 private void SetStartingSettings(ILogic TypeOfLogic, IUserInterface TypeOfUI)
 {
     Logic = TypeOfLogic;
     UI    = TypeOfUI;
     SetupDeckSettings(Logic);
 }