private void OpeningCardsInteraction(ILogic Logic) { if (Logic.IsPlayerWinner()) { ShowPlayerWin(); } else { ShowComputerWin(); } WaitKey(); ClearScreen(); Logic.ClearSets(); MenuState.Back(); }
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()); }
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(); } } }