Exemplo n.º 1
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();
                }
            }
        }