public PokemonGeneratorRunnerTests()
        {
            _contentDir = Directory.GetCurrentDirectory();
            _outputDir  = Path.Combine(_contentDir, $"Test-{Guid.NewGuid()}");
            _opts       = new PersistentConfig
            {
                Options = new ProgramOptions
                {
                    PlayerOne = new PlayerOptions
                    {
                        GameVersion        = PokemonGame.Gold.ToString(),
                        InputSaveLocation  = Path.Combine(_contentDir, "gold.sav"),
                        OutputSaveLocation = Path.Combine(_outputDir, "out1.sav"),
                        Name = "Test1"
                    },
                    PlayerTwo = new PlayerOptions
                    {
                        GameVersion        = PokemonGame.Gold.ToString(),
                        InputSaveLocation  = Path.Combine(_contentDir, "gold.sav"),
                        OutputSaveLocation = Path.Combine(_outputDir, "out2.sav"),
                        Name = "Test2"
                    },
                    Level = 100
                }
            };

            AppDomain.CurrentDomain.SetData("DataDirectory", _contentDir);
            var options = DependencyInjector.Get <IOptions <PersistentConfig> >();

            options.Value.Options = _opts.Options;
            _manager      = DependencyInjector.Get <IGeneratorManager>();
            _deserializer = DependencyInjector.Get <ISaveFileRepository>();
        }
示例#2
0
 private void SaveSettings()
 {
     if (!string.IsNullOrWhiteSpace(GuiState.GitHubToken))
     {
         PersistentConfig.SetConfigData("GitHubToken", GuiState.GitHubToken);
     }
 }
        public ComponentInfo Build(MethodInfo componentMethod, ComponentDescriptionImpl componentDescription)
        {
            PersistentConfig config  = (PersistentConfig)componentMethod.GetCustomAttributes(typeof(PersistentConfig), false)[0];
            string           keyName = config.value;

            if (keyName.Length == 0)
            {
                keyName = componentDescription.FieldName;
            }
            return(new ConfigComponentInfo(keyName, config.configOptional));
        }
        public PokemonProviderTests()
        {
            var config = new PersistentConfig
            {
                Configuration = new GeneratorConfig
                {
                    LegendaryPokemon  = new List <int>(),
                    DisabledPokemon   = new List <int>(),
                    SpecialPokemon    = new List <int>(),
                    PairedMoves       = new Dictionary <int, int[]>(),
                    DependantMoves    = new Dictionary <int, int[]>(),
                    HMBank            = new List <int>(),
                    TeamSize          = 6,
                    MoveEffectFilters = new Dictionary <string, double>(),
                    PokemonLiklihood  = new PokemonLiklihood
                    {
                        Ignored   = 0,
                        Legendary = 0.1,
                        Special   = 0.3,
                        Standard  = 1
                    },
                    Mean = 0.5D,
                    Skew = 0.3D,
                    StandardDeviation  = 0.1D,
                    SameTypeModifier   = 1.5D,
                    DamageModifier     = 200D,
                    DamageTypeModifier = Likeliness.Low,
                    AlreadyPickedMoveEffectsModifier = Likeliness.Medium_Low,
                    AlreadyPickedMoveModifier        = Likeliness.Extremely_Low,
                    PairedModifier     = 2D,
                    DamageTypeDelta    = 15,
                    RandomMoveMinPower = 40,
                    RandomMoveMaxPower = 100,
                    AllowDuplicates    = false,
                    RandomBagMinCount  = 10
                }
            };

            _config = Options.Create(config);
            _mockProbabilityUtility = new Mock <IProbabilityUtility>(MockBehavior.Strict);
            _mockPokemonRepository  = new Mock <IPokemonRepository>(MockBehavior.Strict);
        }
示例#5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            config = new PersistentConfig();
            config.Load();

            openFileDialog1.Filter          = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
            openFileDialog1.CheckFileExists = true;

            if (!string.IsNullOrEmpty(config.ParsingPath))
            {
                openFileDialog1.FileName         = config.ParsingPath;
                openFileDialog1.InitialDirectory = System.IO.Path.GetDirectoryName(config.ParsingPath);
            }

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                LoadParsing(openFileDialog1.FileName);
            }
            else
            {
                Close();
            }
        }
示例#6
0
        private void Form1_Load( object sender, EventArgs e )
        {
            config = new PersistentConfig();
               config.Load();

               openFileDialog1.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
               openFileDialog1.CheckFileExists = true;

               if( !string.IsNullOrEmpty( config.ParsingPath ) )
               {
            openFileDialog1.FileName = config.ParsingPath;
            openFileDialog1.InitialDirectory = System.IO.Path.GetDirectoryName( config.ParsingPath );
               }

               if( openFileDialog1.ShowDialog() == DialogResult.OK )
               {
            LoadParsing( openFileDialog1.FileName );
               }
               else
               {
            Close();
               }
        }
示例#7
0
        public MainWindowViewModel()
        {
            GuiState = new GuiModel
            {
                GitHubToken = PersistentConfig.GetConfigData("GitHubToken")
            };

            GuiState.WhenAnyValue(p => p.RepositoryFolderFullUrl)
            .Throttle(TimeSpan.FromMilliseconds(250))
            .Subscribe(_ => ValidateAndExecuteURL(_));

            _gitHubDownloader = new GitHubDownloader(GuiState)
            {
                Finished = url =>
                {
                    Trace.WriteLine($"Finished {url}.", "Info");
                    DispatcherHelper.DispatchAction(() => GuiState.HasStarted = false);
                }
            };

            StartCommand      = ReactiveCommand.Create(() => StartDownload(), CanStartDownloadExecute);
            StopCommand       = ReactiveCommand.Create(() => StopDownload());
            OpenFolderCommand = ReactiveCommand.Create(() => GetSaveFolder());
        }
示例#8
0
        protected static void BuildConfiguration(ContainerBuilder builder)
        {
            var options  = new PersistentConfig();
            var iOptions = Options.Create(options);

            // When in winforms designer, this directory is unset and we should not configure anything
            if (string.IsNullOrWhiteSpace(AppDomain.CurrentDomain.GetData("DataDirectory") as string))
            {
                builder.Register <IOptions <PersistentConfig> >(context => iOptions).InstancePerLifetimeScope();
                builder.Register <IConfiguration>(context => new ConfigurationBuilder().Build()).InstancePerLifetimeScope();
                return;
            }

            Configuration = new ConfigurationBuilder()
                            .SetBasePath((string)AppDomain.CurrentDomain.GetData("DataDirectory"))
                            .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                            .AddJsonFile(ConfigRepository.ConfigFileName, optional: true, reloadOnChange: true)
                            .Build();

            Configuration.GetSection("Options").Bind(iOptions.Value.Options);
            Configuration.GetSection("Configuration").Bind(iOptions.Value.Configuration);
            builder.Register <IOptions <PersistentConfig> >(context => iOptions).InstancePerLifetimeScope();
            builder.Register <IConfiguration>(context => Configuration).InstancePerLifetimeScope();
        }