public ClientApp(RequestSenderModule requestSender, IInputOutput inputOutputModule, IPhraseProvider phraseProvider, ISettingsProvider settingsProvider) { this.requestSender = requestSender; this.phraseProvider = phraseProvider; this.inputOutputModule = inputOutputModule; try { this.gameSettings = settingsProvider.GetGameSettings(); } catch (ArgumentException ex) { inputOutputModule.WriteOutput(ex.Message); this.gameSettings = null; return; } }
public Game (IPhraseProvider phraseProvider, IInputOutput ioModule, ISettingsProvider settingsProvider, IDoorsNumbersGenerator doorsNumbersGenerator) { this.phraseProvider = phraseProvider; this.ioModule = ioModule; try { this.gameSettings = settingsProvider.GetGameSettings(); } catch (ArgumentException ex) { ioModule.WriteOutput(ex.Message); this.gameSettings = null; return; } this.doorNumbersHolder = doorsNumbersGenerator.GenerateDoorsNumbers(this.gameSettings.DoorsAmount); this.userInputHolder = new Stack <int>(); }
public App(IPhraseProvider phraseProvider, IInputOutput inputOutputModule, ISettingsProvider settingsProvider, ClientsService clientsService, TradingService tradingService, ShowDbInfoService showDbInfoService) { this.phraseProvider = phraseProvider; this.inputOutputModule = inputOutputModule; this.clientsService = clientsService; this.tradingService = tradingService; this.showDbInfoService = showDbInfoService; try { this.gameSettings = settingsProvider.GetGameSettings(); } catch (ArgumentException ex) { inputOutputModule.WriteOutput(ex.Message); this.gameSettings = null; return; } }
public Game(IPhraseProvider phraseProvider, IInputOutput inputOutputModule, IDraw drawModule, ISettingsProvider settingsProvider, IBoard board) { this.phraseProvider = phraseProvider; this.inputOutputModule = inputOutputModule; this.drawModule = drawModule; this.board = board; try { this.gameSettings = settingsProvider.GetGameSettings(); } catch (ArgumentException ex) { inputOutputModule.WriteOutput(ex.Message); this.gameSettings = null; return; } this.board.BoardSizeY = this.gameSettings.BoardHeight; this.board.BoardSizeX = this.gameSettings.BoardWidth; }
/// <summary>Checks if entered number is integer, if not then number should be entered again.</summary> /// <returns></returns> private int InputCheck() { while (true) { if (!int.TryParse(io.ReadInput(), out int enteredNum)) { io.WriteOutput(phraseProvider.GetPhrase("Incorrect")); } else { return(selectedNum = enteredNum); } } }
private bool GeneralMenu() { string userInput; inputOutputModule.ClearMenu(); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.GeneralReg)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.GeneralTrade)); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.GeneralShow)); inputOutputModule.WriteOutput(gameSettings.ExitButton); inputOutputModule.WriteOutput(phraseProvider.GetPhrase(gameSettings.LangPackName, KeysForPhrases.ExitKey)); userInput = inputOutputModule.ReadInput(); if (userInput == "1") { Registration(); } if (userInput == "2") { Trading(); } if (userInput == "3") { for (bool i = true; i;) { i = ShowInfoMenu(); } } if (userInput == gameSettings.ExitButton) { return(false); } return(true); }
private bool TestLangPack() { try { foreach (KeysForPhrases phraseKey in Enum.GetValues(typeof(KeysForPhrases))) { phraseProvider.GetPhrase(phraseKey, gameSettings.LangPackName); } } catch (System.FormatException ex) { ioModule.WriteOutput(ex.Message); return(false); } return(true); }