예제 #1
0
    private static void MakeDeities()
    {
        MakeLanguage();

        var types = System.Reflection.Assembly
                    .GetExecutingAssembly()
                    .GetTypes();

        var archetypes = types
                         .Where(t => typeof(DeityArchetype).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
                         .Select(t => (DeityArchetype)Activator.CreateInstance(t))
                         .ToList();

        var domains = types
                      .Where(t => typeof(DeityDomain).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
                      .Select(t => (DeityDomain)Activator.CreateInstance(t))
                      .ToList();

        while (archetypes.Any() &&
               domains.Any() &&
               Deities.Count < 4)
        {
            var deity = new Deity {
                Name      = MakeDeityName(),
                Pronoun   = Globals.Random.NextDouble() < 0.5 ? "he" : "she",
                Archetype = archetypes[Random.Next(archetypes.Count)]
            };
            archetypes.Remove(deity.Archetype);
            deity.FavorPerTeam["player"] = 0;
            deity.FavorPerTeam["undead"] = 0;
            deity.FavorPerTeam["plants"] = 0;

            while (domains.Any() && deity.Domains.Count < deity.Archetype.NumberOfDomains)
            {
                var domain = domains[Random.Next(domains.Count)];
                domains.Remove(domain);
                deity.Domains.Add(domain);
            }

            Deities.Add(deity);
        }

        foreach (var deity in Deities)
        {
            deity.Finalize(Deities);

            foreach (var material in deity.GetPreferredMaterials())
            {
                deity.Likes.Add($"things made of {material}");
            }

            GD.Print(deity.GetFullTitle());
        }
    }