Ejemplo n.º 1
0
        public (string, RunResults) RunGames()
        {
            if (_settings.GameCount <= 0)
            {
                return(ErrorMessages.GamesCount, null);
            }

            var diceService = DiceFactory.CreateDiceService();
            var gameService = GameFactory.CreateGameService(diceService);

            var results = new List <int>();

            for (int i = 0; i < _settings.GameCount; i++)
            {
                gameService.Initialize(_settings);
                gameService.PlayGame();
                results.Add(gameService.GameData.TurnNumber);
            }

            try
            {
                return(null, new RunResults
                {
                    Minimum = results.Min(),
                    Maximum = results.Max(),
                    Average = results.Average()
                });
            }
            catch
            {
                return(gameService.Error, null);
            }
        }
Ejemplo n.º 2
0
        public void BasicSettings_Game_GeneratesTurnsCount()
        {
            var settings = new GameSettings
            {
                ChipsPerPlayer = 1,
                PlayerCount    = 3
            };
            var diceService = DiceFactory.CreateDiceService();
            var basicGame   = GameFactory.CreateGameService(diceService);

            basicGame.Initialize(settings);
            basicGame.PlayGame();
            Assert.NotEqual(0, basicGame.GameData.TurnNumber);
        }