Exemplo n.º 1
0
        public void CargoDefinitionsLibrary_When_AskedIfSomethingIsAMineral_Should_CorrectlyRespond()
        {
            var minerals           = new List <MineralSD>();
            var mineralCargoTypeId = Guid.NewGuid();

            var otherJunk        = new List <ICargoable>();
            var otherCargoTypeId = Guid.NewGuid();

            var theDice = new Random();

            var diceRollMinerals = theDice.Next(15, 20);

            for (var i = 0; i < diceRollMinerals; i++)
            {
                var randomMineral = new MineralSD()
                {
                    ID          = Guid.NewGuid(),
                    CargoTypeID = mineralCargoTypeId,
                    Mass        = 1000,
                    Name        = "RandomMineral_" + i.ToString(),
                    Description = "A random mineral."
                };
                minerals.Add(randomMineral);
            }

            var diceRoll = theDice.Next(15, 20);

            for (var i = 0; i < diceRoll; i++)
            {
                var randomCargoThing = new JustSomeCargoThing()
                {
                    ID          = Guid.NewGuid(),
                    CargoTypeID = otherCargoTypeId,
                    Mass        = 1000,
                    Name        = "AThing_" + i.ToString()
                };
                otherJunk.Add(randomCargoThing);
            }

            var library = new CargoDefinitionsLibrary();

            library.LoadMineralDefinitions(minerals);
            library.LoadOtherDefinitions(otherJunk);

            for (var i = 0; i < diceRollMinerals; i++)
            {
                Assert.IsTrue(library.IsMineral(minerals[i].ID));
            }
            for (var i = 0; i < diceRoll; i++)
            {
                Assert.IsFalse(library.IsMineral(otherJunk[i].ID));
            }
        }
Exemplo n.º 2
0
        private void Initialise()
        {
            var minerals = systemBodyInfo.Minerals;

            _mineralDeposits.Clear();
            foreach (var kvp in minerals)
            {
                MineralSD mineral = _staticData.Minerals[kvp.Key];
                if (!_mineralDeposits.ContainsKey(kvp.Key))
                {
                    _mineralDeposits.Add(kvp.Key, new PlanetMineralInfoVM(mineral.Name, kvp.Value));
                }
            }
            OnPropertyChanged(nameof(MineralDeposits));
        }
Exemplo n.º 3
0
        public void TestExport()
        {
            WeightedList <AtmosphericGasSD> atmoGases = new WeightedList <AtmosphericGasSD>();
            AtmosphericGasSD gas = new AtmosphericGasSD();

            gas.BoilingPoint   = 100;
            gas.MeltingPoint   = 0;
            gas.ChemicalSymbol = "H20";
            gas.Name           = "Water";
            gas.IsToxic        = false;

            atmoGases.Add(1.0, gas);

            gas.BoilingPoint   = 100;
            gas.MeltingPoint   = 0;
            gas.ChemicalSymbol = "H2O";
            gas.Name           = "Water Second take";
            gas.IsToxic        = false;

            atmoGases.Add(1.0, gas);

            StaticDataManager.ExportStaticData(atmoGases, "AtmoGasesExportTest.json");

            List <CommanderNameThemeSD> nameThemes = new List <CommanderNameThemeSD>();
            CommanderNameThemeSD        nameTheme  = new CommanderNameThemeSD();

            nameTheme.NameList  = new List <CommanderNameSD>();
            nameTheme.ThemeName = "The Creators";

            CommanderNameSD name = new CommanderNameSD();

            name.First    = "Greg";
            name.Last     = "Nott";
            name.IsFemale = false;

            nameTheme.NameList.Add(name);

            name.First    = "Rod";
            name.Last     = "Serling";
            name.IsFemale = false;

            nameTheme.NameList.Add(name);

            nameThemes.Add(nameTheme);

            StaticDataManager.ExportStaticData(nameThemes, "CommanderNameThemeExportTest.json");

            StaticDataManager.ExportStaticData(VersionInfo.PulsarVersionInfo, "VersionInfoExportTest.vinfo");

            List <MineralSD> minList = new List <MineralSD>();
            MineralSD        min     = new MineralSD();

            min.Abundance = new Dictionary <BodyType, double>();
            min.Abundance.Add(BodyType.Asteroid, 0.01);
            min.Abundance.Add(BodyType.Comet, 0.05);
            min.Abundance.Add(BodyType.DwarfPlanet, 0.075);
            min.Abundance.Add(BodyType.GasDwarf, 0.1);
            min.Abundance.Add(BodyType.GasGiant, 1.0);
            min.Abundance.Add(BodyType.IceGiant, 0.5);
            min.Abundance.Add(BodyType.Moon, 0.5);
            min.Abundance.Add(BodyType.Terrestrial, 1.0);
            min.ID          = Guid.NewGuid();
            min.Name        = "Sorium";
            min.Description = "des";
            minList.Add(min);

            StaticDataManager.ExportStaticData(minList, "MineralsExportTest.json");

            //Dictionary<ID, TechSD> techs = Tech();
            //TechSD tech1 = new TechSD();
            //tech1.Name = "Trans-Newtonian Technology";
            //tech1.Requirements = new Dictionary<ID, int>();
            //tech1.Description = "Unlocks almost all other technology.";
            //tech1.Cost = 1000;
            //tech1.Category = ResearchCategories.ConstructionProduction;
            //tech1.ID = ID.NewGuid();

            //TechSD tech2 = new TechSD();
            //tech2.Name = "Construction Rate";
            //tech2.Requirements = new Dictionary<ID, int>();
            //tech2.Requirements.Add(tech1.ID, 0);
            //tech2.Description = "Boosts Construction Rate by 12 BP";
            //tech2.Cost = 3000;
            //tech2.Category = ResearchCategories.ConstructionProduction;
            //tech2.ID = ID.NewGuid();

            //techs.Add(tech1.ID, tech1);
            //techs.Add(tech2.ID, tech2);



            //StaticDataManager.ExportStaticData(techs, "./TechnologyDataExportTest.json");

            //InstallationSD install = new InstallationSD();
            //install.Name = "Mine";
            //install.Description = "Employs population to mine transnewtonian resources.";
            //install.PopulationRequired = 1;
            //install.CargoSize = 1;
            //install.BaseAbilityAmounts = new Dictionary<AbilityType, int>();
            //install.BaseAbilityAmounts.Add(AbilityType.Mine, 1);
            //install.TechRequirements = new List<ID>();
            //install.TechRequirements.Add(tech1.ID); //use trans-newtonian techology you just added to the tech list
            //install.ResourceCosts = new Dictionary<ID, int>();
            //install.ResourceCosts.Add(min.ID,60); //use Sorium that you just added to the mineral list
            //install.WealthCost = 120;
            //install.BuildPoints = 120;

            //installations.Add(install);



            //ComponentAbilitySD launchAbility = new ComponentAbilitySD();
            //launchAbility.Ability = AbilityType.LaunchMissileSize;
            //launchAbility.AbilityAmount = new List<float>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
            //launchAbility.CrewAmount = new List<float>() { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30};
            ////launchAbility.ID = ID.NewGuid();
            //launchAbility.Name = "Missile Launcher Size";
            //launchAbility.Description = "Can fire a missile of this size or smaller";
            //launchAbility.WeightAmount = new List<float>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            //launchAbility.TechRequirements = new List<ID>() { };

            //ComponentAbilitySD reloadAbility = new ComponentAbilitySD();
            //reloadAbility.Name = "Missile Launcher Reload Rate";
            //reloadAbility.Description = "Speed at which this launcher can reload from a magazine";
            ////reloadAbility.ID = ID.NewGuid();
            //reloadAbility.Ability = AbilityType.ReloadRateFromMag;
            //reloadAbility.AbilityAmount = new List<float>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            //reloadAbility.CrewAmount = new List<float>() { };

            //ComponentSD missileLauncher = new ComponentSD();
            //missileLauncher.ComponentAbilitySDs = new List<ComponentAbilitySD>() { launchAbility, reloadAbility};
            //missileLauncher.Name = "MissileLauncher";
            //missileLauncher.Description = "Can launch Missiles and be reloaded via a magazine";
            //missileLauncher.ID = ID.NewGuid();

            ////StaticDataManager.ExportStaticData(launchAbility, "./launcherabilitytest.json");
            ////StaticDataManager.ExportStaticData(reloadAbility, "./launcherabilitytest.json");
            //Dictionary<ID, ComponentSD> components = new Dictionary<ID, ComponentSD>();
            //components.Add(missileLauncher.ID, missileLauncher);
            //StaticDataManager.ExportStaticData(components, "./Componentstest.json");

            // test export of galaxy settings:
            GalaxyFactory gf = new GalaxyFactory(true, 1);

            StaticDataManager.ExportStaticData(gf.Settings, "SystemGenSettings.json");
        }