Esempio n. 1
0
        private void OpeningCardsInteraction(ILogic Logic)
        {
            if (Logic.IsPlayerWinner())
            {
                ShowPlayerWin();
            }
            else
            {
                ShowComputerWin();
            }

            WaitKey();
            ClearScreen();
            Logic.ClearSets();
            MenuState.Back();
        }
Esempio n. 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());
        }
Esempio n. 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();
                }
            }
        }
Esempio n. 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.");
 }
Esempio n. 5
0
 public abstract void BeginInteractionWithLogic(ILogic Logic);
Esempio n. 6
0
 //-----------------------------------------------------------------------------Methods of UI Interaction with a Logic-----------------
 private void StartingRoundInteraction(ILogic Logic)
 {
     ClearScreen();
     ShowSetOfCards(Logic.GetCardsOfPlayer());
 }
Esempio n. 7
0
 protected abstract void ShowPlayerOpenInf(ILogic Logic);
Esempio n. 8
0
 protected abstract void ShowComputerOpenInf(ILogic Logic);
Esempio n. 9
0
        public void Start(ILogic TypeOfLogic, IUserInterface TypeOfUI)
        {
            SetStartingSettings(TypeOfLogic, TypeOfUI);

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