Ejemplo n.º 1
0
        public static ProgressionStar ConvertStar(ProgressionMap map, Star oldStar)
        {
            ProgressionStar newStar = ConvertStarOnly(map, oldStar);

            IDictionary <string, Planet> oldPlanets = oldStar.GetPlanets();

            if (oldPlanets != null)
            {
                foreach (Planet oldPlanet in oldPlanets.Values)
                {
                    ProgressionPlanet newPlanet = ConvertPlanet(map, oldPlanet);
                    newStar.Add(newPlanet);
                }
            }

            IDictionary <string, DwarfPlanet> oldDwarfs = oldStar.GetDwarfPlanets();

            if (oldDwarfs != null)
            {
                foreach (DwarfPlanet oldDwarf in oldDwarfs.Values)
                {
                    // Default handling is that if the DwarfPlanet has satellites convert
                    // it to an Planet otherwise convert to an Asteroid
                    if (oldDwarf.Satellites != null)
                    {
                        ProgressionPlanet newPlanet = ConvertDwarfPlanetasPlanet(map, oldDwarf);
                        newStar.Add(newPlanet);
                    }
                    else
                    {
                        Asteroid newAsteroid = ConvertDwarfPlanetasAsteroid(map, oldDwarf);
                        newStar.Add(newAsteroid);
                    }
                }
            }

            IDictionary <string, Asteroid> oldAsteroids = oldStar.GetAsteroids();

            if (oldAsteroids != null)
            {
                foreach (Asteroid oldAsteroid in oldAsteroids.Values)
                {
                    Asteroid newAsteroid = ConvertAsteroid(map, oldAsteroid);
                    newStar.Add(newAsteroid);
                }
            }

            IDictionary <string, Comet> oldComets = oldStar.GetComets();

            if (oldComets != null)
            {
                foreach (Comet oldComet in oldComets.Values)
                {
                    Comet newComet = ConvertComet(map, oldComet);
                    newStar.Add(newComet);
                }
            }

            return(newStar);
        }
Ejemplo n.º 2
0
        public void GetBridgeDistances()
        {
            ProgressionMap map = new ProgressionMap("Local Sector");
            LocalSectorMap c   = new LocalSectorMap(map);

            c.CreateLocalSector();

            var bridges = map.Bridges.Values.Where(b => b.BridgeType == ProgressionConstants.BridgeTypes.StarSystem);

            string bridgeFile = Path.Combine(TestingUtilities.Config["DataPath"], "bridges.txt");

            if (File.Exists(bridgeFile))
            {
                File.Delete(bridgeFile);
            }

            using (StreamWriter sw = new StreamWriter(bridgeFile))
            {
                foreach (ERBridge bridge in bridges)
                {
                    if (double.TryParse(bridge.BasicProperties[StellarMap.Core.Types.Constants.PropertyNames.Distance], out var distance))
                    {
                        distance = distance * 3.261633;
                        sw.Write(bridge.Name);
                        sw.Write(":");
                        sw.WriteLine(distance.ToString());
                    }
                }
            }
        }
        public void ERBridgeEqualTest()
        {
            ProgressionMap map = new ProgressionMap("Local Sector");
            LocalSectorMap c   = new LocalSectorMap(map);

            c.CreateLocalSector();

            ERBridge bridge1 = map.Bridges.Values.First();

            StarSystem system1 = map.Get <StarSystem>(bridge1.Portals[0].StarIdentifier);
            StarSystem system2 = map.Get <StarSystem>(bridge1.Portals[1].StarIdentifier);
            ERBridge   bridge2 = new ERBridge(bridge1.BridgeType, system1, system2);

            // ok force them equal because of identifiers lol
            bridge2.ParentIdentifier = bridge1.ParentIdentifier;
            bridge2.Identifier       = bridge1.Identifier;
            bridge2.Portals[0].ERBridgeIdentifier = bridge1.Portals[0].ERBridgeIdentifier;
            bridge2.Portals[1].ERBridgeIdentifier = bridge1.Portals[1].ERBridgeIdentifier;

            if (bridge1.BasicProperties.ContainsKey(Constants.PropertyNames.Distance))
            {
                bridge2.BasicProperties.Add(Constants.PropertyNames.Distance, bridge1.BasicProperties[Constants.PropertyNames.Distance]);
            }

            Assert.IsTrue(ERBridgeEqualityComparer.Comparer.Equals(bridge1, bridge2));
        }
Ejemplo n.º 4
0
        public static ProgressionStar ConvertStarOnly(ProgressionMap map, Star oldStar)
        {
            ProgressionStar newStar = new ProgressionStar(oldStar.Name);

            newStar.Properties = oldStar.Properties;
            map.Add(newStar);
            return(newStar);
        }
Ejemplo n.º 5
0
        public static Comet ConvertComet(ProgressionMap map, Comet oldComet)
        {
            Comet newComet = new Comet(oldComet.Name);

            newComet.Properties = oldComet.Properties;
            map.Add(newComet);
            return(newComet);
        }
Ejemplo n.º 6
0
        public static Asteroid ConvertAsteroid(ProgressionMap map, Asteroid oldAsteroid)
        {
            Asteroid newAsteroid = new Asteroid(oldAsteroid.Name);

            newAsteroid.Properties = oldAsteroid.Properties;
            map.Add(newAsteroid);
            return(newAsteroid);
        }
Ejemplo n.º 7
0
        public static Satellite ConvertSatellite(ProgressionMap map, Satellite oldSatellite)
        {
            Satellite newSatellite = new Satellite(oldSatellite.Name);

            newSatellite.Properties = oldSatellite.Properties;
            map.Add(newSatellite);
            return(newSatellite);
        }
Ejemplo n.º 8
0
        public static Asteroid ConvertDwarfPlanetasAsteroid(ProgressionMap map, DwarfPlanet oldDwarfPlanet)
        {
            Asteroid newAsteroid = new Asteroid(oldDwarfPlanet.Name);

            newAsteroid.Properties = oldDwarfPlanet.Properties;
            map.Add(newAsteroid);
            return(newAsteroid);
        }
Ejemplo n.º 9
0
        public static ProgressionPlanet ConvertPlanetOnly(ProgressionMap map, Planet oldPlanet)
        {
            ProgressionPlanet newPlanet = new ProgressionPlanet(oldPlanet.Name);

            newPlanet.Properties = oldPlanet.Properties;
            map.Add(newPlanet);
            return(newPlanet);
        }
Ejemplo n.º 10
0
        public ProgressionMap DeSerializeMap(StreamReader reader)
        {
            string json = string.Empty;

            json = reader.ReadToEnd();

            ProgressionMap map = JsonConvert.DeserializeObject <ProgressionMap>(json);

            map.SetMap();

            return(map);
        }
Ejemplo n.º 11
0
        public void LocalSectorEqualTest()
        {
            ProgressionMap map = new ProgressionMap("Local Sector");
            LocalSectorMap c   = new LocalSectorMap(map);

            c.CreateLocalSector();

            ProgressionMap map2 = new ProgressionMap("Local Sector");
            LocalSectorMap c2   = new LocalSectorMap(map2);

            c2.CreateLocalSector();

            Assert.IsTrue(ProgressionMapEqualityComparer.Comparer.Equals(map, map2));
        }
Ejemplo n.º 12
0
        public static ProgressionPlanet ConvertPlanet(ProgressionMap map, Planet oldPlanet)
        {
            ProgressionPlanet newPlanet = ConvertPlanetOnly(map, oldPlanet);

            IDictionary <string, Satellite> oldSatellites = oldPlanet.GetSatellites();

            if (oldSatellites != null)
            {
                foreach (Satellite oldSatellite in oldSatellites.Values)
                {
                    Satellite newSatellite = ConvertSatellite(map, oldSatellite);
                    newPlanet.Add(newSatellite);
                }
            }

            return(newPlanet);
        }
Ejemplo n.º 13
0
        public void SerializeFileSolCluster()
        {
            ProgressionMap map = new ProgressionMap("Sol Cluster");
            LocalSectorMap c   = new LocalSectorMap(map);

            c.CreateSolCluster();

            string filename = Path.Combine(TestingUtilities.Config["DataPath"], "SolCluster.json");

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            using StreamWriter writer = new StreamWriter(filename);
            SerializeMap(map, writer);
        }
Ejemplo n.º 14
0
        public void LocalSectorNotEqualTest()
        {
            ProgressionMap map = new ProgressionMap("Local Sector");
            LocalSectorMap c   = new LocalSectorMap(map);

            c.CreateLocalSector();

            ProgressionMap map2 = new ProgressionMap("Local Sector");
            LocalSectorMap c2   = new LocalSectorMap(map2);

            c2.CreateLocalSector();
            var solCluster = map2.Clusters.Values.Where(x => x.Name == "Sol Cluster").First();

            Assert.IsNotNull(solCluster);
            solCluster.Name = "New Sol";

            Assert.IsFalse(ProgressionMapEqualityComparer.Comparer.Equals(map, map2));
        }
Ejemplo n.º 15
0
        public void HabitatNotEqualTest()
        {
            ProgressionMap map = new ProgressionMap("Local Sector");
            LocalSectorMap c   = new LocalSectorMap(map);

            c.CreateLocalSector();

            Habitat habitat1 = map.Habitats.Values.First();

            Habitat habitat2 = new Habitat();

            habitat2.BodyType         = ProgressionConstants.BodyType.Cluster;
            habitat2.Identifier       = habitat1.Identifier;
            habitat2.Name             = habitat1.Name;
            habitat2.ParentIdentifier = habitat1.ParentIdentifier;
            //habitat2.Properties = habitat1.Properties;

            Assert.IsFalse(StellarBodyEqualityComparer.Comparer.Equals(habitat1, habitat2));
        }
Ejemplo n.º 16
0
        public void ZipStoreLocalSector()
        {
            ProgressionMap localsector = new ProgressionMap("Local Sector");

            LocalSectorMap create = new LocalSectorMap(localsector);

            create.CreateLocalSector();

            IMapStorage store = MapStorageFactory.GetStorage(MapStorageFactory.ZipStorage);

            string filename = Path.Combine(TestingUtilities.Config["DataPath"], "LocalSector.zip");

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            using StreamWriter writer = new StreamWriter(filename);
            store.Store(localsector, writer);
        }
Ejemplo n.º 17
0
        public static void JsonGenerateLocalSector()
        {
            ProgressionMap localsector = new ProgressionMap("Local Sector");

            LocalSectorMap create = new LocalSectorMap(localsector);

            create.CreateLocalSector();

            IMapStorage store = MapStorageFactory.GetStorage(MapStorageFactory.JsonStorage);

            string filename = Path.Combine(dataDir, "LocalSector.json");

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            using StreamWriter writer = new StreamWriter(filename);
            store.Store(localsector, writer);
        }
Ejemplo n.º 18
0
        public PreDiasporaMap(ProgressionMap map)
        {
            Map = map;

            map.MetaData.Add("Basic", "Author", "Ergodic Mage");
            map.MetaData.Add("Basic", "Version", "0.1");
            map.MetaData.Add("Basic", "Date", "11/29/2019");

            using (StringWriter writer = new StringWriter())
            {
                writer.WriteLine("This is the map of the default Progression system at year 100DE.");
                writer.WriteLine("At this point in time, humans have started spreading through the Sol Cluster.");
                writer.WriteLine("The Pre-Diaspora Era is documented at https://github.com/ErgodicMage/StellarMap/blob/master/src/StellarSystems/Progression/DefaultSettingMaps/PreDiaspora.md");
                writer.Flush();

                map.MetaData.Add("Basic", "Description", writer.ToString());
            }
            map.MetaData.Add("Basic", "Diagram", "https://drive.google.com/file/d/1oQhyRB6X-ckqjOw_A0sMtgq8gt3He8_U/view?usp=sharing");
            map.MetaData.Add("Basic", "Rules", "https://github.com/ErgodicMage/StellarMap/blob/master/src/StellarSystems/Progression/Rules.md");
        }
Ejemplo n.º 19
0
        public void ERBridgeNotEqualTest()
        {
            ProgressionMap map = new ProgressionMap("Local Sector");
            LocalSectorMap c   = new LocalSectorMap(map);

            c.CreateLocalSector();

            ERBridge bridge1 = map.Bridges.Values.First();

            StarSystem system1 = map.Get <StarSystem>(bridge1.Portals[0].StarIdentifier);
            StarSystem system2 = map.Get <StarSystem>(bridge1.Portals[1].StarIdentifier);
            ERBridge   bridge2 = new ERBridge(bridge1.BridgeType, system1, system2);

            // ok force them equal because of identifiers lol
            bridge2.ParentIdentifier = bridge1.ParentIdentifier;
            bridge2.Identifier       = bridge1.Identifier;
            bridge2.Portals[0].ERBridgeIdentifier = bridge1.Portals[0].ERBridgeIdentifier;
            // except Portal 2 bridge identifier
            //bridge2.Portals[1].ERBridgeIdentifier = bridge1.Portals[1].ERBridgeIdentifier;

            Assert.IsFalse(ERBridgeEqualityComparer.Comparer.Equals(bridge1, bridge2));
        }
Ejemplo n.º 20
0
        public void SerializeMap(ProgressionMap map, StreamWriter writer)
        {
            string json = JsonConvert.SerializeObject(map, Newtonsoft.Json.Formatting.Indented);

            writer.Write(json);
        }