Exemple #1
0
        public void PrintGameDurationEstimatesToConsole()
        {
            var moqEnv = new Moq.Mock <IWebHostEnvironment>();

            moqEnv.Setup(env => env.EnvironmentName).Returns("Microsoft.Extensions.Hosting.EnvironmentName.Production");
            InMemoryConfiguration inMemoryConfig = new InMemoryConfiguration(moqEnv.Object);

            inMemoryConfig.UpdateConfiguration();

            foreach (GameModeMetadataHolder holder in inMemoryConfig.GameModes)
            {
                GameModeMetadata metadata = holder.GameModeMetadata;
                var defaultParams         = metadata.Options.Select(option =>
                {
                    var optionRequest = new ConfigureLobbyRequest.GameModeOptionRequest
                    {
                        Value = option.DefaultValue.ToString()
                    };
                    optionRequest.ParseValue(option, out string err);
                    return(optionRequest);
                }).ToList();

                Console.WriteLine($"GameMode: {metadata.GameIdString}");
                for (int i = metadata.MinPlayers.Value; i < 40; i++)
                {
                    var estimates = metadata.GetGameDurationEstimates(i, defaultParams);
                    Console.WriteLine($"Players:{i} \ts:{estimates[GameDuration.Short].TotalMinutes},\t m:{estimates[GameDuration.Normal].TotalMinutes},\t l:{estimates[GameDuration.Extended].TotalMinutes}");
                }
            }
        }