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(); } } }
protected override void ShowPlayerOpenInf(ILogic Logic) { Console.Write($"Player is opening the cards!\n"); ShowSetOfCards(Logic.GetCardsOfPlayer()); Console.WriteLine("Press Enter to continue."); }
public abstract void BeginInteractionWithLogic(ILogic Logic);
//-----------------------------------------------------------------------------Methods of UI Interaction with a Logic----------------- private void StartingRoundInteraction(ILogic Logic) { ClearScreen(); ShowSetOfCards(Logic.GetCardsOfPlayer()); }
protected abstract void ShowPlayerOpenInf(ILogic Logic);
protected abstract void ShowComputerOpenInf(ILogic Logic);
public void Start(ILogic TypeOfLogic, IUserInterface TypeOfUI) { SetStartingSettings(TypeOfLogic, TypeOfUI); UI.BeginInteractionWithLogic(Logic); }
private void SetupDeckSettings(ILogic TypeOfLogic) { TypeOfLogic.ConfigDeck(); }
private void SetStartingSettings(ILogic TypeOfLogic, IUserInterface TypeOfUI) { Logic = TypeOfLogic; UI = TypeOfUI; SetupDeckSettings(Logic); }