Пример #1
0
        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;
            }
        }
Пример #2
0
 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>();
 }
Пример #3
0
        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;
            }
        }
Пример #4
0
        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;
        }
Пример #5
0
 /// <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);
         }
     }
 }
Пример #6
0
        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);
        }
Пример #7
0
 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);
 }