Exemplo n.º 1
0
        /// <summary>
        /// This function will receive a Universe and a StarDefaultSettings object and create Stars from the data
        /// provided
        /// </summary>
        /// <param name="universe"></param>
        /// <param name="starDefaultSettings"></param>
        /// <param name="starData"></param>
        /// <param name="nameGeneration"></param>
        /// <returns>
        /// A newly modified Universe
        /// </returns>
        public Universe AddStars(Universe universe, StarDefaultSettings starDefaultSettings, StarData starData,
                                 NameGeneration nameGeneration)
        {
            // Check if the Stars have been initialized prior
            universe.Stars ??= new List <Star>();

            // Set the number of stars to create. The default is 1d10+20
            var starLen   = starData.Stars.Count;
            var starCount = starDefaultSettings.StarCount < 0
                ? Rand.Next(0, 10) + 20
                : starDefaultSettings.StarCount;

            var sCount = 0;

            while (sCount < starCount)
            {
                var star = new Star();

                // Generate the unique ID for the Star
                IdGen.GenerateId(star);

                // Set Grid Location of the Star
                var zone = universe.Zones[Rand.Next(0, universe.Zones.Count)];
                if (zone.StarId == null)
                {
                    zone.StarId = star.Id;
                }
                else
                {
                    continue;
                }

                // If that ID exists roll a new one
                if (universe.Stars.Exists(a => a.Id == star.Id))
                {
                    continue;
                }

                // Pick a random Name for the Star
                star.Name = Rand.Next(0, 4) == 2
                    ? nameGeneration.GenerateName()
                    : starData.Stars[Rand.Next(0, starLen - 1)];

                // If that Name exists roll a new one
                if (universe.Stars.Exists(a => a.Name == star.Name))
                {
                    continue;
                }

                // Set the type of Star
                star.StarType = starData.StarTypes[Rand.Next(0, 8) + Rand.Next(0, 8) + Rand.Next(0, 8)];

                // Add the Star to the Universe
                universe.Stars.Add(star);

                sCount++;
            }

            return(universe);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function receives a Universe and a PlanetDefaultSettings to create planets based on
        /// specified information
        /// </summary>
        /// <param name="universe"></param>
        /// <param name="planetDefaultSettings"></param>
        /// <param name="worldInfo"></param>
        /// <param name="starData"></param>
        /// <param name="societyData"></param>
        /// <param name="nameGeneration"></param>
        /// <returns>
        /// The newly updated Universe
        /// </returns>
        public Universe AddPlanets(Universe universe, PlanetDefaultSettings planetDefaultSettings, WorldInfo worldInfo,
                                   StarData starData, SocietyData societyData, NameGeneration nameGeneration)
        {
            // Get the number of Planet Names from starData
            var planLen = starData.Planets.Count;

            // Iterate through each star and
            foreach (Star star in universe.Stars)
            {
                // Set the random number of Planets that will be created for a given Star
                var pMax = planetDefaultSettings.PlanetRange == null || planetDefaultSettings.PlanetRange.Length == 0 ||
                           planetDefaultSettings.PlanetRange[0] == 0 ||
                           planetDefaultSettings.PlanetRange[1] == 0
                    ? Rand.Next(1, 3) // Default Planet count is up-to 3
                    : Rand.Next(planetDefaultSettings.PlanetRange[0],
                                planetDefaultSettings.PlanetRange[1] + 1);

                var pCount = 0;

                while (pCount < pMax)
                {
                    var planet = new Planet
                    {
                        Society = new Society(), Ruler = new Ruler(), Ruled = new Ruled(), Flavor = new Flavor()
                    };

                    // Generate the ID for the Planet
                    IdGen.GenerateId(planet);

                    // If that ID exists somewhere then re-roll it
                    if (universe.Planets.Exists(a => a.Id == planet.Id))
                    {
                        continue;
                    }

                    // Pick a random name out of the list of Planets
                    planet.Name = Rand.Next(0, 4) == 2
                        ? nameGeneration.GenerateName()
                        : starData.Planets[Rand.Next(0, planLen)];

                    // No planets can share a name
                    if (universe.Planets.Exists(a => a.Name == planet.Name))
                    {
                        continue;
                    }

                    // Set the Planet information from either a randomized value or specified information
                    planet.StarId = star.Id;
                    universe.Zones.Single(a => a.StarId == star.Id).Planets.Add(planet.Id);
                    planet.FirstWorldTag  = worldInfo.WorldTags[Rand.Next(0, 100)].Type;
                    planet.SecondWorldTag = worldInfo.WorldTags[Rand.Next(0, 100)].Type;
                    planet.Atmosphere     = worldInfo.Atmospheres[Rand.Next(0, 6) + Rand.Next(0, 6)].Type;
                    planet.Temperature    = worldInfo.Temperatures[Rand.Next(0, 6) + Rand.Next(0, 6)].Type;
                    planet.Biosphere      = worldInfo.Biospheres[Rand.Next(0, 6) + Rand.Next(0, 6)].Type;
                    planet.Population     = worldInfo.Populations[Rand.Next(0, 6) + Rand.Next(0, 6)].Type;
                    planet.TechLevel      = worldInfo.TechLevels[Rand.Next(0, 6) + Rand.Next(0, 6)].Type;

                    if (societyData != null)
                    {
                        // Set the Planet's society information
                        planet.Society.PriorCulture      = societyData.Societies.PriorCultures[Rand.Next(0, 6)];
                        planet.Society.OtherSociety      = societyData.Societies.OtherSocieties[Rand.Next(0, 8)];
                        planet.Society.MainRemnant       = societyData.Societies.MainRemnants[Rand.Next(0, 10)];
                        planet.Society.SocietyAge        = societyData.Societies.SocietyAges[Rand.Next(0, 4)];
                        planet.Society.ImportantResource = societyData.Societies.ImportantResources[Rand.Next(0, 12)];
                        planet.Society.FoundingReason    = societyData.Societies.FoundingReasons[Rand.Next(0, 20)];

                        // Set the Planet's Ruler
                        planet.Ruler.GeneralSecurity   = societyData.Rulers.GeneralSecurities[Rand.Next(0, 6)];
                        planet.Ruler.LegitimacySource  = societyData.Rulers.LegitimacySources[Rand.Next(0, 8)];
                        planet.Ruler.MainRulerConflict = societyData.Rulers.MainRulerConflicts[Rand.Next(0, 10)];
                        planet.Ruler.RuleCompletion    = societyData.Rulers.RuleCompletions[Rand.Next(0, 4)];
                        planet.Ruler.RuleForm          = societyData.Rulers.RuleForms[Rand.Next(0, 12)];
                        planet.Ruler.MainPopConflict   = societyData.Rulers.MainPopConflicts[Rand.Next(0, 20)];

                        // Set the Planet's Ruled
                        planet.Ruled.Contentment     = societyData.Ruled.Contentments[Rand.Next(0, 6)];
                        planet.Ruled.LastMajorThreat = societyData.Ruled.LastMajorThreats[Rand.Next(0, 8)];
                        planet.Ruled.Power           = societyData.Ruled.Powers[Rand.Next(0, 10)];
                        planet.Ruled.Uniformity      = societyData.Ruled.Uniformities[Rand.Next(0, 4)];
                        planet.Ruled.MainConflict    = societyData.Ruled.MainConflicts[Rand.Next(0, 12)];
                        planet.Ruled.Trends          = societyData.Ruled.Trends[Rand.Next(0, 20)];

                        // Set the Planet's Flavor
                        planet.Flavor.BasicFlavor       = societyData.Flavors.BasicFlavors[Rand.Next(0, 12)];
                        planet.Flavor.OutsiderTreatment = societyData.Flavors.OutsiderTreatments[Rand.Next(0, 6)];
                        planet.Flavor.PrimaryVirtue     = societyData.Flavors.PrimaryVirtues[Rand.Next(0, 8)];
                        planet.Flavor.PrimaryVice       = societyData.Flavors.PrimaryVices[Rand.Next(0, 10)];
                        planet.Flavor.XenophiliaDegree  = societyData.Flavors.XenophiliaDegrees[Rand.Next(0, 4)];
                        planet.Flavor.PossiblePatron    = societyData.Flavors.PossiblePatrons[Rand.Next(0, 12)];
                        planet.Flavor.Customs           = societyData.Flavors.Customs[Rand.Next(0, 20)];
                    }

                    // Set primary world
                    if (pCount == 0)
                    {
                        planet.IsPrimary = true;
                    }
                    else
                    {
                        // Non-primary world information
                        planet.Origin       = worldInfo.OwOrigins[Rand.Next(0, 8)];
                        planet.Relationship = worldInfo.OwRelationships[Rand.Next(0, 8)];
                        planet.Contact      = worldInfo.OwContacts[Rand.Next(0, 8)];
                        planet.IsPrimary    = false;
                    }

                    // Add the Planet to the current Universe
                    universe.Planets.Add(planet);
                    pCount++;
                }
            }

            return(universe);
        }