public ActionResult New(StarForm form)
        {
            Debug.WriteLine($"POST: Star Controller: New - starsystemID={form.StarsystemID}");
            var game = GameState.Game;

            DB_stars star = new DB_stars();

            star.game_id       = game.ID;
            star.starsystem_id = form.StarsystemID;

            star.star_age_id        = (form.SelectedStarAge == -1) ? null : form.SelectedStarAge;
            star.star_type_id       = (form.SelectedStarType == -1) ? null : form.SelectedStarType;
            star.radiation_level_id = (form.SelectedRadiationLevel == -1) ? null : form.SelectedRadiationLevel;

            star.name    = form.Name;
            star.gmnotes = form.GMNotes;
            Database.Session.Save(star);

            Database.Session.Flush();
            return(RedirectToRoute("StarMap"));
        }
Exemple #2
0
        private void SaveSector(Game game, DB_sectors dbSector, Fotiv_Automator.Models.StarMapGenerator.Models.StarSector sector)
        {
            Debug.WriteLine($"Star Map Controller: Saving Sector to DB");

            foreach (var column in sector.Sector)
            {
                foreach (var starsystem in column)
                {
                    DB_starsystems dbStarSystem = new DB_starsystems();
                    dbStarSystem.game_id   = game.ID;
                    dbStarSystem.sector_id = dbSector.id;
                    dbStarSystem.hex_x     = starsystem.Coordinate.X;
                    dbStarSystem.hex_y     = starsystem.Coordinate.Y;
                    Database.Session.Save(dbStarSystem);

                    foreach (var star in starsystem.Stars)
                    {
                        DB_stars dbStar = new DB_stars();
                        dbStar.game_id            = game.ID;
                        dbStar.starsystem_id      = dbStarSystem.id;
                        dbStar.star_type_id       = RetrieveStarType(star.Classification.ToString().SpaceUppercaseLetters()).id;
                        dbStar.star_age_id        = RetrieveStarAge(star.Age.ToString().SpaceUppercaseLetters()).id;
                        dbStar.radiation_level_id = RetrieveRadiationLevel(star.Radiation.ToString().SpaceUppercaseLetters()).id;
                        dbStar.name = star.Classification.ToString().SpaceUppercaseLetters();
                        Database.Session.Save(dbStar);

                        foreach (var celestialBody in star.CelestialBodies)
                        {
                            // Create the Planet
                            DB_planets dbPlanet = new DB_planets();
                            dbPlanet.game_id           = game.ID;
                            dbPlanet.star_id           = dbStar.id;
                            dbPlanet.planet_tier_id    = RetrievePlanetaryTier(celestialBody.TerraformingTier.ToString().SpaceUppercaseLetters()).id;
                            dbPlanet.planet_type_id    = RetrievePlanetType(celestialBody.CelestialType.ToString().SpaceUppercaseLetters()).id;
                            dbPlanet.stage_of_life_id  = RetrieveStageOfLife(celestialBody.StageOfLife.ToString().SpaceUppercaseLetters()).id;
                            dbPlanet.resources         = celestialBody.ResourceValue;
                            dbPlanet.supports_colonies = celestialBody.SupportsColonies;
                            dbPlanet.name = celestialBody.CelestialType.ToString().SpaceUppercaseLetters();
                            Database.Session.Save(dbPlanet);

                            foreach (var species in celestialBody.Sentients)
                            {
                                CreateSpeciesAndCivilization(game, dbPlanet, dbStarSystem, species);
                            }

                            // And set up the satellites
                            foreach (var satellite in celestialBody.OrbitingSatellites)
                            {
                                DB_planets dbSatellite = new DB_planets();
                                dbSatellite.game_id            = game.ID;
                                dbSatellite.star_id            = dbStar.id;
                                dbSatellite.orbiting_planet_id = dbPlanet.id;
                                dbSatellite.planet_tier_id     = RetrievePlanetaryTier(satellite.TerraformingTier.ToString().SpaceUppercaseLetters()).id;
                                dbSatellite.planet_type_id     = RetrievePlanetType(satellite.CelestialType.ToString().SpaceUppercaseLetters()).id;
                                dbSatellite.stage_of_life_id   = RetrieveStageOfLife(satellite.StageOfLife.ToString().SpaceUppercaseLetters()).id;
                                dbSatellite.resources          = satellite.ResourceValue;
                                dbSatellite.supports_colonies  = satellite.SupportsColonies;
                                dbSatellite.name = satellite.CelestialType.ToString().SpaceUppercaseLetters();
                                Database.Session.Save(dbSatellite);

                                foreach (var species in satellite.Sentients)
                                {
                                    CreateSpeciesAndCivilization(game, dbSatellite, dbStarSystem, species);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
 public Star(DB_stars star)
 {
     Info = star;
 }