Exemple #1
0
        public void StartGame(GameConfig config, IInterfaceService interfaceService)
        {
            var outputService = new OutputService(interfaceService, config);

            var solution = EntryGenerator.Generate(config.NumbersInSolution, config.MaxNumber);

            _board = new Board(solution);

            outputService.WriteNewGame();

            for (var guessNumber = 1; guessNumber <= config.NumberOfGuesses; guessNumber++)
            {
                outputService.WriteGuessNumber(guessNumber);
                var userGuesses = outputService.GetGuesses();
                if (EndgameChecker.UserHasWon(userGuesses, solution))
                {
                    outputService.WriteUserWins();
                    return;
                }

                var response = userGuesses.Select((guess, i) => _board.GetResultForGuess(guess, i));
                outputService.WriteResponse(response);
            }
            outputService.WriteUserLoses();
            outputService.WriteSolution(solution);
        }
 public InterfaceController(IInterfaceService interfaceService, IMapper mapper, IConfiguration configuration)
 {
     _interfaceService = interfaceService;
     _mapper           = mapper;
     _configuration    = configuration;
     _token            = _configuration.GetValue <string>("Token");
 }
Exemple #3
0
 public ChangeUserCommand(IReaderService readerService, IWriterService writerService, IInterfaceService interfaceService, IUserService userService)
 {
     this.readerService    = readerService;
     this.writerService    = writerService;
     this.interfaceService = interfaceService;
     this.userService      = userService;
 }
Exemple #4
0
 public UserService(IInterfaceService interfaceService, IReaderService reader, IWriterService writer, IUserSessionService userSessionService, IPlayerRepository playerRepository)
 {
     this.interfaceService   = interfaceService;
     this.reader             = reader;
     this.writer             = writer;
     this.userSessionService = userSessionService;
     this.playerRepository   = playerRepository;
 }
Exemple #5
0
 public ExitGameCommand(IUserSessionService userSessionService, IInterfaceService interfaceService, IWriterService writerService, IReaderService readerService, IUserService userService)
 {
     this.userSessionService = userSessionService;
     this.interfaceService   = interfaceService;
     this.writerService      = writerService;
     this.readerService      = readerService;
     this.userService        = userService;
 }
Exemple #6
0
 public ConsoleMenuPagination(IReaderService reader, IWriterService writer, IInterfaceService interfaceService, IMenuNavigation menuNavigation, IMenuNavigationStrategyFactory menuNavigationStrategyFactory)
 {
     this.reader           = reader;
     this.writer           = writer;
     this.interfaceService = interfaceService;
     this.menuNavigation   = menuNavigation;
     this.menuNavigationStrategyFactory = menuNavigationStrategyFactory;
 }
 public CheckGameCommand(IUserSessionService userSessionService, ISudokuGridSolver sudokuGridSolver, IUserService userService, IWriterService writerService, IInterfaceService interfaceService, IReaderService readerService)
 {
     this.userSessionService = userSessionService;
     this.sudokuGridSolver   = sudokuGridSolver;
     this.userService        = userService;
     this.writerService      = writerService;
     this.interfaceService   = interfaceService;
     this.readerService      = readerService;
 }
Exemple #8
0
 public Engine(IUnityContainer unityContainer, IInterfaceService interfaceService, IUserService userService, IMenuService menuService, IUserSessionService userSessionService, ICommandFactory commandFactory)
 {
     this.unityContainer     = unityContainer;
     this.interfaceService   = interfaceService;
     this.userService        = userService;
     this.menuService        = menuService;
     this.userSessionService = userSessionService;
     this.commandFactory     = commandFactory;
 }
Exemple #9
0
 public SolutionGameCommand(IUserSessionService userSessionService, ISudokuGridSolver sudokuGridSolver, IInterfaceService interfaceService, IReaderService readerService, IWriterService writerService, IUserService userService, IGameSetUpFasade gameSetUpFasade)
 {
     this.userSessionService = userSessionService;
     this.sudokuGridSolver   = sudokuGridSolver;
     this.interfaceService   = interfaceService;
     this.readerService      = readerService;
     this.writerService      = writerService;
     this.userService        = userService;
     this.gameSetUpFasade    = gameSetUpFasade;
 }
 public GameSetUpFasade(IUserService userService, IUserSessionService userSessionService, IGameFactory gameFactory, IInterfaceService interfaceService, IWriterService writerService, IAsciiFactoriesFactory asciiFactoriesFactory, IFieldFactory fieldFactory, IButtonFactory buttonFactory)
 {
     this.userSessionService    = userSessionService;
     this.userService           = userService;
     this.gameFactory           = gameFactory;
     this.interfaceService      = interfaceService;
     this.writerService         = writerService;
     this.asciiFactoriesFactory = asciiFactoriesFactory;
     this.fieldFactory          = fieldFactory;
     this.buttonFactory         = buttonFactory;
 }
Exemple #11
0
 public GamePlayFasade(IReaderService readerService, IWriterService writerService, IInterfaceService interfaceService, IUserSessionService userSessionService, INavigationService navigationService, IGameNavigationStrategyFactory gameNavigationStrategyFactory, IAsciiFactoriesFactory asciiFactoriesFactory, IInGameValueStrategyFactory gameValueStrategyFactory, IInGameCommandFactory inGameCommandFactory)
 {
     this.readerService                 = readerService;
     this.writerService                 = writerService;
     this.interfaceService              = interfaceService;
     this.userSessionService            = userSessionService;
     this.navigationService             = navigationService;
     this.gameNavigationStrategyFactory = gameNavigationStrategyFactory;
     this.asciiFactoriesFactory         = asciiFactoriesFactory;
     this.gameValueStrategyFactory      = gameValueStrategyFactory;
     this.inGameCommandFactory          = inGameCommandFactory;
 }
        public void Setup()
        {
            answerToGuess  = "ABC";
            settings       = Substitute.For <IGameSettings>();
            mastermindGame = Substitute.For <IMastermindGame>();
            mastermindGame.Settings.Returns(settings);
            gameInterface      = Substitute.For <IInterfaceService>();
            _serviceUnderTests = new MastermindGameplayService(gameInterface);

            wrongAnswerCheck.IsCorrect.Returns(false);
            correctAnswerCheck.IsCorrect.Returns(true);
            mastermindGame.PlayRound(wrongAnswer).Returns(wrongAnswerCheck);
            mastermindGame.PlayRound(answerToGuess).Returns(correctAnswerCheck);
        }
Exemple #13
0
 public OutputService(IInterfaceService interfaceService, GameConfig config)
 {
     _interfaceService = interfaceService;
     _config           = config;
 }
Exemple #14
0
 public ExitCommand(IReaderService readerService, IWriterService writerService, IInterfaceService interfaceService)
 {
     this.readerService    = readerService;
     this.writerService    = writerService;
     this.interfaceService = interfaceService;
 }
Exemple #15
0
 public MastermindGameplayService(IInterfaceService gameInterface)
 {
     _interface = gameInterface;
 }