Пример #1
0
        public int SortByBelievers(ReligionGroupParser x, ReligionGroupParser y)
        {
            if (x.Provinces.Count > y.Provinces.Count)
            {
                return(-1);
            }
            if (x.Provinces.Count < y.Provinces.Count)
            {
                return(1);
            }

            return(0);
        }
Пример #2
0
        public ReligionGroupParser AddReligionGroup(String name)
        {
            ScriptScope scope = new ScriptScope();
            scope.Name = name;
            
            script.Root.Add(scope);
            
            ReligionGroupParser r = new ReligionGroupParser(scope);

            r.Init();
            GroupMap[name] = r;
            AllReligionGroups.Add(r);
            return r;
        }
Пример #3
0
        public void AddTrigger(ReligionGroupParser group)
        {
            if (script == null)
            {
                return;
            }

            script.Root.Do($@"
                true_religion_group_{group.Name}_trigger = {{
	                true_religion_group = {group.Name}
                }}


");
        }
Пример #4
0
        public ReligionGroupParser AddReligionGroup(String name)
        {
            ScriptScope scope = new ScriptScope();

            scope.Name = name;

            script.Root.Add(scope);

            ReligionGroupParser r = new ReligionGroupParser(scope);

            r.Init();
            GroupMap[name] = r;
            AllReligionGroups.Add(r);
            return(r);
        }
Пример #5
0
        public ReligionGroupParser AddReligionGroup(String name)
        {
            ScriptScope scope = new ScriptScope
            {
                Name = name
            };

            script.Root.Add(scope);

            ReligionGroupParser r = new ReligionGroupParser(scope);

            r.Init();
            GroupMap[name] = r;
            AllReligionGroups.Add(r);

            ScripterTriggerManager.instance.AddTrigger(r);
            return(r);
        }
Пример #6
0
        public void Init()
        {
            LanguageManager.instance.Add("urtru", StarNames.Generate(Rand.Next(1000000)));

            Script s = new Script();

            script = s;
            s.Name = Globals.ModDir + "common\\religions\\00_religions.txt";
            s.Root = new ScriptScope();

            ReligionGroupParser r = AddReligionGroup("urtru");

            r.Init();

            var firstReligion = r.AddReligion("urtru");

            firstReligion.CreateNewReligion();

            AllReligionGroups.Add(r);
        }
Пример #7
0
        public void Init()
        {
            LanguageManager.instance.Add("norse", StarNames.Generate(Rand.Next(1000000)));
            LanguageManager.instance.Add("pagan", StarNames.Generate(Rand.Next(1000000)));
            LanguageManager.instance.Add("christian", StarNames.Generate(Rand.Next(1000000)));

            Script s = new Script();

            script = s;
            s.Name = Globals.ModDir + "common\\religions\\00_religions.txt";
            s.Root = new ScriptScope();
            ReligionGroupParser r = AddReligionGroup("pagan");

            r.Init();
            var pagan = r.AddReligion("pagan");

            pagan.CreateRandomReligion(null);

            AllReligionGroups.Add(r);
        }
Пример #8
0
        public void LoadVanilla()
        {
            SaveReligions = false;
            var files = ModManager.instance.GetFileKeys("common\\religions");

            foreach (var file in files)
            {
                Script s = ScriptLoader.instance.LoadKey(file);
                foreach (var rootChild in s.Root.Children)
                {
                    if ((rootChild as ScriptScope).Name == "secret_religion_visibility_trigger")
                    {
                        continue;
                    }

                    ReligionGroupParser p = new ReligionGroupParser(rootChild as ScriptScope);

                    AllReligionGroups.Add(p);
                    foreach (var scopeChild in p.Scope.Children)
                    {
                        if (scopeChild is ScriptScope)
                        {
                            var sc = scopeChild as ScriptScope;

                            if (sc.Name == "male_names" ||
                                sc.Name == "female_names")
                            {
                                continue;
                            }

                            ReligionParser r = new ReligionParser(sc);
                            AllReligions.Add(r);
                            ReligionMap[r.Name] = r;
                            p.Religions.Add(r);
                            r.Group        = p;
                            r.LanguageName = LanguageManager.instance.Get(r.Name);
                        }
                    }
                }
            }
        }
Пример #9
0
        public void CreateRandomReligion(ReligionGroupParser group)
        {
            String      culture = "";
            CulturalDna dna     = null;

            if (this.capital == null)
            {
                dna = CulturalDnaManager.instance.GetVanillaCulture((string)null);
            }
            else
            {
                culture = capital.Title.Holder.culture;
                dna     = CultureManager.instance.CultureMap[culture].dna;
            }
            RandomReligionProperties();
            //     Modern = true;
            int    r      = Rand.Next(255);
            int    g      = Rand.Next(255);
            int    b      = Rand.Next(255);
            string god    = dna.GetGodName();
            string devil  = dna.GetPlaceName();
            string priest = dna.GetPlaceName();

            this.priest   = priest;
            high_god_name = dna.GetGodName();
            string scripture_name = dna.GetPlaceName();
            string crusade_name   = dna.GetPlaceName();

            this.high_god_name = god;

            this.devil          = devil;
            this.priest         = priest;
            this.scripture_name = scripture_name;
            this.crusade_name   = crusade_name;
            if (Name == "sanappa")
            {
                int gfdgdf = 0;
            }
            DoReligionScope(god, devil, priest, scripture_name, crusade_name, dna, r, g, b);
        }
Пример #10
0
        public void CreateAssassinTemplate(ScriptScope parentSociety, ScriptScope parentScriptTrigger, String societyName, ReligionParser religion, ReligionGroupParser religiongroup = null)
        {
            if (religiongroup == null)
            {
                religiongroup = religion.Group;
            }

            parentSociety.Do($@"

{societyName} = {{
	primary_attribute = intrigue
	is_secret = yes
	devil_worshipper = no
	opinion_to_other_members = +10
	opinion_to_pretenders = -20			
	opinion_to_perceived_members = -20 
	opinion_per_rank_above = +10
	society_rank_up_decision = request_to_rank_up_within_society
	sound = assassins_interface
	society_ranks_gfx = generic_ranks
	
	active = {{
		has_dlc = ""Mystics""
	}}
	indestructible = yes

	can_join_society = {{
		hidden_trigger = {{
			NAND = {{
				ai = yes
				is_society_rank_full = {{ 
					society = {societyName}
					rank = 1
				}}
			}}
		}}
		has_{societyName}_prerequisites = yes
		hidden_trigger = {{
			NOT = {{ has_character_flag = society_join_block }}
		}}
	}}

	show_society = {{
		OR = {{
			religion = {religion.Name}
			secret_religion = {religion.Name}
		}}
		age = 16
		OR = {{
			is_female = no
			has_game_rule = {{
				name = gender
				value = all
			}}
		}}
	}}

	potential = {{
		OR = {{
			religion = {religion.Name}
			secret_religion = {religion.Name}
		}}
	}}

	society_rank = {{
		level = 1
		limit = 20 
		startup_limit = 10
		modifier = {{
			is_visible = {{
				OR = {{
					society_member_of = {societyName}
					FROM = {{ is_society_discovered = yes }}
				}}
			}}
			murder_plot_power_modifier = 0.1 # increased plotpower
		}}
		decisions = {{
			assassins_borrow_money
			assassins_donate
			assassins_drug_effect
		}}
	}}
	
	society_rank = {{
		level = 2
		limit = 15
		startup_limit = 6
		modifier = {{ 
			is_visible = {{
				OR = {{
					society_member_of = {societyName}
					FROM = {{ is_society_discovered = yes }}
				}}
			}}
			murder_plot_power_modifier = 0.2 # further increased plotpower
			defensive_plot_power_modifier = 0.1
			intrigue = 1 
			combat_rating = 1 # bonus to dueling
		}}
		decisions = {{
			assassins_scare_ruler #Available (targeted) Power: Can scare rulers to get a Favor (leave a dagger on their pillow, etc. 
		}}
	}}
	
	society_rank = {{
		level = 3
		limit = 5 
		startup_limit = 3
		modifier = {{
			is_visible = {{
				OR = {{
					society_member_of = {societyName}
					FROM = {{ is_society_discovered = yes }}
				}}
			}}
			murder_plot_power_modifier = 0.30 # further increased plotpower
			defensive_plot_power_modifier = 0.15
			intrigue = 2 # further increase
			combat_rating = 1 # bonus to dueling (left over)
			plot_discovery_chance = 0.1 # bonus to plot discovery chance
		}}
		decisions = {{
			assassins_raise_ships #Available Power: Can raise special fleet of Ships
		}}
	}}

	society_rank = {{
		level = 4
		limit = 1 
		startup_limit = 1
		modifier = {{
			is_visible = {{
				OR = {{
					society_member_of = {societyName}
					FROM = {{ is_society_discovered = yes }}
				}}
			}}
			murder_plot_power_modifier = 0.50 # further increased plotpower
			defensive_plot_power_modifier = 0.25
			intrigue = 3 # further increase
			combat_rating = 1 # bonus to dueling (left over)
			plot_discovery_chance = 0.2 # further bonus to plot discovery chance
		}}
		decisions = {{
			assassins_raise_troops
			assassins_mark_for_death 
		}}
		obedience_tooltip = obedience_tooltip 
		obedient = {{
			ROOT = {{
				always = yes
			}}
		}}
	}}

	monthly_currency_gain = {{
		name = currency_name_{societyName}
    
		per_attribute = {{
			name = intrigue 
			value = 0.5
		}}
		has_trait = {{
			trait = zealous
			value = 3
		}}
		has_trait = {{
			trait = erudite
			value = 3
		}}
		has_trait = {{
			trait = scholar
			value = 3
		}}
		has_trait = {{
			trait = theologian
			value = 3
		}}
		has_trait = {{
			trait = schemer
			value = 3
		}}
		has_trait = {{
			trait = strong
			value = 1
		}}
		has_trait = {{
			trait = robust
			value = 1
		}}
		has_trait = {{
			trait = genius
			value = 1
		}}
		has_trait = {{
			trait = quick
			value = 1
		}}
		has_trait = {{
			trait = shrewd
			value = 1
		}}
		has_trait = {{
			trait = diligent
			value = 1
		}}
		has_trait = {{
			trait = patient
			value = 1
		}}
		has_trait = {{
			trait = temperate
			value = 1
		}}
		has_trait = {{
			trait = charitable
			value = 1
		}}
		society_rank = {{
			rank = 4
			value = 10
		}}
	}}

	member_score_per_attribute = 3
	member_score_per_rank = 100

	member_score = {{
		value = 10


		modifier = {{
			trait = zealous
			factor = 1.3
		}}
		modifier = {{
			trait = erudite
			factor = 1.3
		}}
		modifier = {{
			trait = scholar
			factor = 1.3
		}}
		modifier = {{
			trait = theologian
			factor = 1.3
		}}
		modifier = {{
			trait = schemer
			factor = 1.3
		}}
		modifier = {{
			trait = strong
			factor = 1.1
		}}
		modifier = {{
			trait = robust
			factor = 1.1
		}}
		modifier = {{
			trait = genius
			factor = 1.1
		}}
		modifier = {{
			trait = quick
			factor = 1.1
		}}
		modifier = {{
			trait = shrewd
			factor = 1.1
		}}
		modifier = {{
			trait = diligent
			factor = 1.1
		}}
		modifier = {{
			trait = patient
			factor = 1.1
		}}
		modifier = {{
			trait = temperate
			factor = 1.1
		}}
		modifier = {{
			trait = charitable
			factor = 1.1
		}}	
	}}
	
	startup_populate = {{
	    trigger = {{
			ai = yes
	        controls_religion = no 
			religion = {religion.Name}
			age = 16
			OR = {{
				is_female = no
				has_game_rule = {{
					name = gender
					value = all
				}}
			}}
			NOT = {{ trait = decadent }}
			OR = {{
				trait = zealous
				trait = schemer
				trait = elusive_shadow
				trait = deceitful
				trait = ambitious
				intrigue = 18
			}}
			is_in_society = no
			NOT = {{ higher_tier_than = DUKE }}
			NOT = {{ mercenary = yes }}
		}}
	}}
}}
");

            parentScriptTrigger.Do($@"
            has_{societyName}_prerequisites = {{
                age = 16
	            true_religion_{religion.Name}_trigger = yes
	                OR = {{
		                is_female = no
		                has_game_rule = {{
			                name = gender
			                value = all
		                }}
	                }}
                }}
            ");


            secretSocieties.Add((parentSociety.Children[parentSociety.Children.Count - 1] as ScriptScope).Name);
        }
Пример #11
0
        public void CreateRandomReligion(ReligionGroupParser group)
        {
            String culture = "";
            CulturalDna dna = null;
            if (this.capital == null)
            {
                dna = CulturalDnaManager.instance.GetVanillaCulture((string) null);
            }
            else
            {
                culture = capital.Title.Holder.culture;
                dna = CultureManager.instance.CultureMap[culture].dna;
            }
            RandomReligionProperties();
      //     Modern = true;
            int r = Rand.Next(255);
            int g = Rand.Next(255);
            int b = Rand.Next(255);
            string god = dna.GetGodName();
            string devil = dna.GetPlaceName();
            string priest = dna.GetPlaceName();
            high_god_name = dna.GetGodName();
            string scripture_name = dna.GetPlaceName();
            string crusade_name = dna.GetPlaceName();

            this.high_god_name = god;
            
            this.devil = devil;
            this.priest = priest;
            this.scripture_name = scripture_name;
            this.crusade_name = crusade_name;

            DoReligionScope(god, devil, priest, scripture_name, crusade_name, dna, r, g, b);
        }
Пример #12
0
        public void CalculateCulturesProper()
        {
            foreach (var cultureGroupParser in AllCultureGroups)
            {
                if (cultureGroupParser.Name == "norse")
                {
                    continue;
                }
                if (cultureGroupParser.Provinces.Count == 0)
                {
                    continue;
                }

                var province = cultureGroupParser.Provinces[Rand.Next(cultureGroupParser.Provinces.Count)];

                List <ProvinceParser> target = new List <ProvinceParser>();
                target.Add(province);
                target.AddRange(province.Adjacent.Where(p => p.land == true && p.title != null));

                for (int x = 0; x < 8; x++)
                {
                    var toAdd = new List <ProvinceParser>();
                    target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null && !target.Contains(pp))));
                    target.AddRange(toAdd);
                }
                HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target);
                foreach (var provinceParser in toDo)
                {
                    provinceParser.Culture = cultureGroupParser.Cultures[0];
                    if (provinceParser.Culture.Group.ReligionGroup != null)
                    {
                        provinceParser.Religion = provinceParser.Culture.Group.ReligionGroup.Religions[0];
                    }
                    else
                    {
                        provinceParser.Religion = ReligionManager.instance.AllReligions[0];
                    }
                }
            }

            for (int index = 0; index < AllCultureGroups.Count; index++)
            {
                var cultureGroupParser = AllCultureGroups[index];

                if (cultureGroupParser.Provinces.Count < 20)
                {
                    bool possible = true;
                    while (cultureGroupParser.Provinces.Count > 0 && possible)
                    {
                        for (int i = 0; i < cultureGroupParser.Provinces.Count; i++)
                        {
                            var provinceParser = cultureGroupParser.Provinces[i];
                            var difcul         =
                                provinceParser.Adjacent.Where(
                                    p => p.Culture != provinceParser.Culture && p.Culture != null);
                            if (!difcul.Any())
                            {
                                if (i == cultureGroupParser.Provinces.Count - 1)
                                {
                                    possible = false;
                                }
                                continue;
                            }
                            var list = new List <ProvinceParser>(difcul);
                            provinceParser.Culture  = list[Rand.Next(list.Count)].Culture;
                            provinceParser.Religion = list[Rand.Next(list.Count)].Religion;
                            break;
                        }
                    }
                }

                if (cultureGroupParser.Provinces.Count == 0)
                {
                    AllCultureGroups.Remove(cultureGroupParser);
                    Script.Root.Remove(cultureGroupParser.Scope);
                    CultureMap.Remove(cultureGroupParser.Cultures[0].Name);
                    AllCultures.Remove(cultureGroupParser.Cultures[0]);
                    foreach (var characterParser in CharacterManager.instance.Characters)
                    {
                        if (characterParser.culture == cultureGroupParser.Cultures[0].Name)
                        {
                            characterParser.culture = AllCultures[AllCultures.Count - 1].Name;
                        }
                    }

                    foreach (var value in DynastyManager.instance.DynastyMap.Values)
                    {
                        if ((string)(value.Scope.Children[1] as ScriptCommand).Value == cultureGroupParser.Cultures[0].Name)
                        {
                            (value.Scope.Children[1] as ScriptCommand).Value = AllCultures[AllCultures.Count - 1].Name;
                        }
                    }
                    index--;
                }
            }
            allowMultiCultureGroups = true;
            for (int index = 0; index < AllCultureGroups.Count; index++)
            {
                var cultureGroupParser = AllCultureGroups[index];

                var provinces = new List <ProvinceParser>(cultureGroupParser.Provinces);
                // Now do the same for cultures...

                var mainCulture = cultureGroupParser.Cultures[0];

                int size = cultureGroupParser.Provinces.Count;
                if (size <= 4)
                {
                    size = 2;
                }
                else if (size < 12)
                {
                    size = 4;
                }
                else if (size < 24)
                {
                    size = 5;
                }
                else if (size < 32)
                {
                    size = 6;
                }
                else if (size < 40)
                {
                    size = 7;
                }
                else
                {
                    size = 8;
                }

                for (int c = 0; c < size; c++)
                {
                    if (provinces.Count == 0)
                    {
                        break;
                    }
                    var start = provinces[Rand.Next(provinces.Count)];

                    if (!CultureManager.instance.CultureMap.ContainsKey(mainCulture.Name))
                    {
                        mainCulture = cultureGroupParser.Cultures[cultureGroupParser.Cultures.Count - 1];
                    }
                    if (!CultureMap.ContainsKey(mainCulture.Name))
                    {
                        CultureMap[mainCulture.Name] = mainCulture;
                    }

                    start.Culture = BranchCulture(mainCulture.Name);
                    var newC = start.Culture;
                    List <ProvinceParser> target = new List <ProvinceParser>();
                    target.Add(start);
                    target.AddRange(start.Adjacent.Where(p => provinces.Contains(p)));
                    int s = 1;
                    if (size > 8)
                    {
                        s = 2;
                    }
                    if (size > 15)
                    {
                        s = 3;
                    }

                    for (int x = 0; x < s; x++)
                    {
                        var toAdd = new List <ProvinceParser>();
                        target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null)));
                        target.AddRange(toAdd);
                    }
                    HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target);
                    foreach (var provinceParser in toDo)
                    {
                        provinceParser.Culture = newC;
                        provinces.Remove(provinceParser);
                    }
                }
            }
            // Create big religion groups covering multiple culture groups

            foreach (var religionGroupParser in ReligionManager.instance.AllReligionGroups)
            {
                var cgenum = AllCultureGroups.Where(cg => cg.ReligionGroup == religionGroupParser);

                var cultureGroupList = new List <CultureGroupParser>(cgenum);

                int n = Rand.Next(5) + 4;

                for (int x = 0; x < n; x++)
                {
                    var adjacentProv = new List <ProvinceParser>();
                    var adjacent     = new HashSet <CultureGroupParser>();
                    cultureGroupList.ForEach(g => g.Provinces.ForEach(p => adjacentProv.AddRange(p.Adjacent.Where(pa => pa.land && pa.title != null && pa.Culture != null && pa.Culture.Group != g))));
                    adjacentProv.ForEach(p => adjacent.Add(p.Culture.Group));

                    if (adjacent.Count > 0)
                    {
                        List <CultureGroupParser> list = new List <CultureGroupParser>(adjacent);

                        var chosen = list[Rand.Next(list.Count)];
                        chosen.ReligionGroup = religionGroupParser;
                        chosen.Provinces.ForEach(p => p.Religion = religionGroupParser.Religions[0]);
                    }
                }
            }

            // Cut out small ones


            // Now find the biggest two and make them bigger...
            ReligionGroupParser biggest = null;
            ReligionGroupParser second  = null;


            for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++)
            {
                var religionGroupParser = ReligionManager.instance.AllReligionGroups[index];


                if (religionGroupParser.Provinces.Count < 50)
                {
                    while (religionGroupParser.Provinces.Count > 0)
                    {
                        bool possible = true;
                        while (religionGroupParser.Provinces.Count > 0 && possible)
                        {
                            for (int i = 0; i < religionGroupParser.Provinces.Count; i++)
                            {
                                var provinceParser = religionGroupParser.Provinces[i];
                                var difcul         =
                                    provinceParser.Adjacent.Where(
                                        p => p.Religion != provinceParser.Religion && p.Religion != null);
                                if (!difcul.Any())
                                {
                                    if (i == religionGroupParser.Provinces.Count - 1)
                                    {
                                        possible = false;
                                    }
                                    continue;
                                }
                                var list = new List <ProvinceParser>(difcul);
                                provinceParser.Religion = list[Rand.Next(list.Count)].Religion;
                                break;
                            }
                        }

                        if (!possible)
                        {
                            var provinceParser = religionGroupParser.Provinces[0];

                            var list =
                                MapManager.instance.Provinces.Where(
                                    p => p.land && p.title != null && p.Religion.Group != religionGroupParser).ToList();

                            distanceTest = provinceParser;
                            list.Sort(SortByDistance);

                            provinceParser.Religion = list[0].Religion;
                            provinceParser.Culture.Group.ReligionGroup = list[0].Religion.Group;
                        }
                    }
                }

                if (religionGroupParser.Provinces.Count == 0)
                {
                    ReligionManager.instance.AllReligionGroups.Remove(religionGroupParser);
                    System.Console.Out.WriteLine(religionGroupParser.Religions[0].Name + " removed");

                    religionGroupParser.Scope.Remove(religionGroupParser.Religions[0].Scope);
                    ReligionManager.instance.Script.Root.Remove(religionGroupParser.Scope);
                    ReligionManager.instance.ReligionMap.Remove(religionGroupParser.Religions[0].Name);
                    ReligionManager.instance.AllReligions.Remove(religionGroupParser.Religions[0]);

                    foreach (var characterParser in CharacterManager.instance.Characters)
                    {
                        if (characterParser.religion == religionGroupParser.Religions[0].Name)
                        {
                            characterParser.religion = ReligionManager.instance.AllReligions[ReligionManager.instance.AllReligions.Count - 1].Name;
                        }
                    }
                    index--;
                }
            }

            ReligionManager.instance.AllReligionGroups.Sort(ReligionManager.instance.SortByBelievers);

            biggest = ReligionManager.instance.AllReligionGroups[0];
            if (ReligionManager.instance.AllReligionGroups.Count > 1)
            {
                second = ReligionManager.instance.AllReligionGroups[1];
            }

            for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++)
            {
                var religionGroup = ReligionManager.instance.AllReligionGroups[index];

                var provinces = new List <ProvinceParser>(religionGroup.Provinces);
                // Now do the same for cultures...

                var mainReligion = religionGroup.Religions[0];

                int size = religionGroup.Provinces.Count;
                if (size <= 4)
                {
                    size = 1;
                }
                else if (size < 12)
                {
                    size = 1;
                }
                else if (size < 32)
                {
                    size = 2;
                }
                else
                {
                    size = 3;
                }


                if (biggest == religionGroup || second == religionGroup)
                {
                    size = 3;
                }

                for (int c = 0; c < size; c++)
                {
                    if (provinces.Count == 0)
                    {
                        break;
                    }


                    var start = provinces[Rand.Next(provinces.Count)];

                    start.Religion = ReligionManager.instance.BranchReligion(mainReligion.Name, start.Culture.Name);
                    var newC = start.Religion;
                    List <ProvinceParser> target = new List <ProvinceParser>();
                    target.Add(start);
                    target.AddRange(start.Adjacent.Where(p => provinces.Contains(p)));
                    int s = 2;
                    if (size > 16)
                    {
                        s = 3;
                    }
                    if (size > 32)
                    {
                        s = 4;
                    }

                    if (biggest == religionGroup || second == religionGroup)
                    {
                        if (c <= 2)
                        {
                            s += 2;
                        }
                    }

                    for (int x = 0; x < s; x++)
                    {
                        var toAdd = new List <ProvinceParser>();
                        target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null && pp.Religion.Group == start.Religion.Group)));
                        target.AddRange(toAdd);
                    }
                    HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target);
                    foreach (var provinceParser in toDo)
                    {
                        provinceParser.Religion = newC;
                        provinces.Remove(provinceParser);
                    }
                }
            }

            for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++)
            {
                var religionParser = ReligionManager.instance.AllReligionGroups[index];
                if (religionParser.Provinces.Count == 0)
                {
                    ReligionManager.instance.AllReligionGroups.Remove(religionParser);
                    index--;
                    continue;
                }
                religionParser.TryFillHolySites();
            }

            for (int index = 0; index < ReligionManager.instance.AllReligions.Count; index++)
            {
                var religionParser = ReligionManager.instance.AllReligions[index];
                if (religionParser.Provinces.Count == 0)
                {
                    System.Console.Out.WriteLine(religionParser.Name + " removed");
                    if (religionParser.Scope.Name == "enuique")
                    {
                    }

                    ReligionManager.instance.AllReligions.Remove(religionParser);
                    ReligionManager.instance.ReligionMap.Remove(religionParser.Name);
                    religionParser.Group.Scope.Remove(religionParser.Scope);
                    index--;
                    continue;
                }
                religionParser.TryFillHolySites();
            }


            foreach (var characterParser in CharacterManager.instance.Characters)
            {
                if (characterParser.Titles.Count > 0)
                {
                    if (characterParser.PrimaryTitle.Rank == 2)
                    {
                        characterParser.culture  = characterParser.PrimaryTitle.SubTitles.First().Value.Owns[0].Culture.Name;
                        characterParser.religion = characterParser.PrimaryTitle.SubTitles.First().Value.Owns[0].Religion.Name;
                    }
                    else
                    {
                        characterParser.culture  = characterParser.PrimaryTitle.Owns[0].Culture.Name;
                        characterParser.religion = characterParser.PrimaryTitle.Owns[0].Religion.Name;
                    }

                    foreach (var titleParser in characterParser.Titles)
                    {
                        titleParser.culture = characterParser.culture;
                    }
                }
            }

            var l = MapManager.instance.Provinces.Where(p => p.title != null).ToList();

            foreach (var provinceParser in l)
            {
                provinceParser.initialReligion = provinceParser.Religion.Name;
                provinceParser.initialCulture  = provinceParser.Culture.Name;
            }


            foreach (var religionParser in ReligionManager.instance.AllReligions)
            {
                if (religionParser.Provinces.Count > 0)
                {
                    ReligionManager.instance.ReligionMap[religionParser.Name] = religionParser;
                }
                if (religionParser.Provinces.Count > 0 && (religionParser.hasLeader || religionParser.autocephaly))
                {
                    religionParser.DoLeader(religionParser.Provinces[Rand.Next(religionParser.Provinces.Count)]);
                }
            }
        }
Пример #13
0
        public void DoReligiousEquivelents()
        {
            if (!SaveReligions)
            {
                return;
            }

            if (AllReligionGroups.Count == 1)
            {
                return;
            }
            ReligionGroupParser biggestGroup = null;
            ReligionGroupParser secondGroup  = null;
            ReligionGroupParser thirdGroup   = null;
            ReligionGroupParser fourthGroup  = null;
            ReligionGroupParser fifthGroup   = null;
            ReligionGroupParser sixthGroup   = null;

            AllReligionGroups.Sort(SortByBelievers);

            if (AllReligionGroups.Count >= 6)
            {
                this.ChristianGroupSub      = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2];
                this.ChristianGroupSub.Name = this.ChristianGroupSub.Scope.Name;
                AllReligionGroups.Remove(ChristianGroupSub);
                this.MuslimGroupSub      = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2];
                this.MuslimGroupSub.Name = this.MuslimGroupSub.Scope.Name;
                AllReligionGroups.Remove(MuslimGroupSub);
                this.IndianGroupSub      = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2];
                this.IndianGroupSub.Name = this.IndianGroupSub.Scope.Name;
                AllReligionGroups.Remove(IndianGroupSub);
                this.ZoroGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2];
                ZoroGroupSub.Name = this.ZoroGroupSub.Scope.Name;
                AllReligionGroups.Remove(ZoroGroupSub);
                this.PaganGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2];
                PaganGroupSub.Name = this.PaganGroupSub.Scope.Name;
                AllReligionGroups.Remove(PaganGroupSub);
                this.JewGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2];
                JewGroupSub.Name = this.JewGroupSub.Scope.Name;
                AllReligionGroups.Remove(JewGroupSub);

                while (ZoroGroupSub == MuslimGroupSub)
                {
                    ZoroGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                }

                while (ChristianGroupSub == MuslimGroupSub)
                {
                    ChristianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                }
                while (JewGroupSub == MuslimGroupSub)
                {
                    JewGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                }
            }
            else
            {
                if (AllReligionGroups.Count > 3)
                {
                    this.ChristianGroupSub      = AllReligionGroups[Rand.Next(AllReligionGroups.Count / 2)];
                    this.ChristianGroupSub.Name = this.ChristianGroupSub.Scope.Name;
                    AllReligionGroups.Remove(ChristianGroupSub);
                    this.MuslimGroupSub      = AllReligionGroups[Rand.Next(AllReligionGroups.Count / 2)];
                    this.MuslimGroupSub.Name = this.MuslimGroupSub.Scope.Name;
                    AllReligionGroups.Remove(MuslimGroupSub);
                }
                else
                {
                    this.ChristianGroupSub      = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                    this.ChristianGroupSub.Name = this.ChristianGroupSub.Scope.Name;
                    this.MuslimGroupSub         = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                    this.MuslimGroupSub.Name    = this.MuslimGroupSub.Scope.Name;
                }
                this.IndianGroupSub      = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                this.IndianGroupSub.Name = this.IndianGroupSub.Scope.Name;
                this.ZoroGroupSub        = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                ZoroGroupSub.Name        = this.ZoroGroupSub.Scope.Name;
                this.PaganGroupSub       = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                PaganGroupSub.Name       = this.PaganGroupSub.Scope.Name;
                this.JewGroupSub         = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                JewGroupSub.Name         = this.JewGroupSub.Scope.Name;

                while (ZoroGroupSub == MuslimGroupSub)
                {
                    ZoroGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                }

                while (ChristianGroupSub == MuslimGroupSub)
                {
                    ChristianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                }
                while (JewGroupSub == MuslimGroupSub)
                {
                    JewGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                }
            }

            this.ChristianGroupSub.Religions.Sort(SortByBelieversReligion);

            this.CatholicSub = this.ChristianGroupSub.Religions[0];
            //    this.CatholicSub.Name = this.CatholicSub.Scope.Name;
            this.OrthodoxSub = this.ChristianGroupSub.Religions[1];
            //   this.OrthodoxSub.Name = this.OrthodoxSub.Scope.Name;
            this.MuslimGroupSub.Religions.Sort(SortByBelieversReligion);

            this.SunniEquiv = this.MuslimGroupSub.Religions[0];
            //    this.SunniEquiv.Name = this.SunniEquiv.Scope.Name;
            this.ShiiteEquiv = this.MuslimGroupSub.Religions[1];
            //   this.ShiiteEquiv.Name = this.ShiiteEquiv.Scope.Name;

            while (IndianGroupSub.Religions.Count < 3)
            {
                this.IndianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)];
                //    this.IndianGroupSub.Name = this.IndianGroupSub.Scope.Name;
            }
            {
                this.HinduEquiv = this.IndianGroupSub.Religions[0];
                //    this.HinduEquiv.Name = this.HinduEquiv.Scope.Name;
                this.BuddhistEquiv = this.IndianGroupSub.Religions[1];
                //    this.BuddhistEquiv.Name = this.BuddhistEquiv.Scope.Name;
                this.JainEquiv = this.IndianGroupSub.Religions[2];
                //     this.JainEquiv.Name = this.JainEquiv.Scope.Name;
            }

            this.PaganGroupSub.Religions.Sort(SortByBelieversReligion);
            this.NorseSub = this.PaganGroupSub.Religions[0];
            //  this.NorseSub.Name = this.NorseSub.Scope.Name;
            this.NorseReformSub = this.PaganGroupSub.Religions[1];
            //   this.NorseReformSub.Name = this.NorseSub.Scope.Name;

            foreach (var religionParser in PaganGroupSub.Religions)
            {
                religionParser.polytheism = true;
                religionParser.hasLeader  = false;
            }

            foreach (var religionParser in this.ChristianGroupSub.Religions)
            {
                religionParser.hasLeader = true;
            }
            this.NorseSub.allow_viking_invasion = true;
            this.NorseSub.allow_looting         = true;
            this.JainEquiv.pacifist             = false;
            this.JainEquiv.can_call_crusade     = true;
            this.HinduEquiv.pacifist            = true;
            this.HinduEquiv.can_call_crusade    = false;
            this.BuddhistEquiv.pacifist         = true;
            this.BuddhistEquiv.can_call_crusade = false;

            foreach (var religionParser in AllReligions)
            {
                religionParser.RedoReligionScope();
            }
        }
Пример #14
0
        // Following function sets 'allowMultiCultureGroups' to true

        public void CalculateCulturesProper()
        {
            foreach (var cultureGroupParser in AllCultureGroups)
            {
                if (cultureGroupParser.Name == "Urtru")
                {
                    continue;
                }
                if (cultureGroupParser.Provinces.Count == 0)
                {
                    continue;
                }

                var province = cultureGroupParser.Provinces[Rand.Next(cultureGroupParser.Provinces.Count)];

                List <ProvinceParser> target = new List <ProvinceParser>();
                target.Add(province);
                target.AddRange(province.Adjacent.Where(p => p.land == true && p.title != null));

                for (int x = 0; x < 8; x++)
                {
                    var toAdd = new List <ProvinceParser>();
                    target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null && !target.Contains(pp))));
                    target.AddRange(toAdd);
                }

                HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target);

                foreach (var provinceParser in toDo)
                {
                    provinceParser.Culture = cultureGroupParser.Cultures[0];
                    if (provinceParser.Culture.Group.ReligionGroup != null)
                    {
                        provinceParser.Religion = provinceParser.Culture.Group.ReligionGroup.Religions[0];
                    }
                    else
                    {
                        provinceParser.Religion = ReligionManager.instance.AllReligions[0];
                    }
                }
            }

            for (int index = 0; index < AllCultureGroups.Count; index++)
            {
                var cultureGroupParser = AllCultureGroups[index];

                if (cultureGroupParser.Provinces.Count < 20)
                {
                    bool possible = true;
                    while (cultureGroupParser.Provinces.Count > 0 && possible)
                    {
                        for (int i = 0; i < cultureGroupParser.Provinces.Count; i++)
                        {
                            var provinceParser = cultureGroupParser.Provinces[i];
                            var difcul         =
                                provinceParser.Adjacent.Where(
                                    p => p.Culture != provinceParser.Culture && p.Culture != null);
                            if (!difcul.Any())
                            {
                                if (i == cultureGroupParser.Provinces.Count - 1)
                                {
                                    possible = false;
                                }
                                continue;
                            }
                            var list = new List <ProvinceParser>(difcul);
                            provinceParser.Culture  = list[Rand.Next(list.Count)].Culture;
                            provinceParser.Religion = list[Rand.Next(list.Count)].Religion;
                            break;
                        }
                    }
                }

                if (cultureGroupParser.Provinces.Count == 0)
                {
                    AllCultureGroups.Remove(cultureGroupParser);
                    Script.Root.Remove(cultureGroupParser.Scope);
                    CultureMap.Remove(cultureGroupParser.Cultures[0].Name);
                    AllCultures.Remove(cultureGroupParser.Cultures[0]);

                    foreach (var characterParser in CharacterManager.instance.Characters)
                    {
                        if (characterParser.culture == cultureGroupParser.Cultures[0].Name)
                        {
                            characterParser.culture = AllCultures[AllCultures.Count - 1].Name;
                        }
                    }

                    foreach (var value in DynastyManager.instance.DynastyMap.Values)
                    {
                        if ((string)(value.Scope.Children[1] as ScriptCommand).Value == cultureGroupParser.Cultures[0].Name)
                        {
                            (value.Scope.Children[1] as ScriptCommand).Value = AllCultures[AllCultures.Count - 1].Name;
                        }
                    }
                    index--;
                }
            }

            //Enable in-group culture branching

            allowMultiCultureGroups = true;

            for (int index = 0; index < AllCultureGroups.Count; index++)
            {
                var cultureGroupParser = AllCultureGroups[index];

                var provinces = new List <ProvinceParser>(cultureGroupParser.Provinces);

                // Sets a main culture for the culture group

                var mainCulture = cultureGroupParser.Cultures[0];

                int size = cultureGroupParser.Provinces.Count;

                int iterations = 0;

                if (size <= 4)
                {
                    iterations = 2;
                }
                else if (size < 12)
                {
                    iterations = 4;
                }
                else if (size < 24)
                {
                    iterations = 5;
                }
                else if (size < 32)
                {
                    iterations = 6;
                }
                else if (size < 40)
                {
                    iterations = 7;
                }
                else
                {
                    iterations = 8;
                }

                for (int c = 0; c < iterations; c++)
                {
                    if (provinces.Count == 0)
                    {
                        break;
                    }

                    ProvinceParser start = provinces[Rand.Next(provinces.Count)];

                    if (!instance.CultureMap.ContainsKey(mainCulture.Name))
                    {
                        mainCulture = cultureGroupParser.Cultures[cultureGroupParser.Cultures.Count - 1];
                    }

                    if (!CultureMap.ContainsKey(mainCulture.Name))
                    {
                        CultureMap[mainCulture.Name] = mainCulture;
                    }

                    start.Culture = BranchCulture(mainCulture.Name);

                    var newCulture = start.Culture;

                    List <ProvinceParser> target = new List <ProvinceParser>();

                    target.Add(start);
                    target.AddRange(start.Adjacent.Where(p => provinces.Contains(p)));

                    int s = 1;

                    if (iterations > 8)
                    {
                        s = 2;
                    }

                    if (iterations > 15)
                    {
                        s = 3;
                    }

                    for (int x = 0; x < s; x++)
                    {
                        var toAdd = new List <ProvinceParser>();
                        target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null)));
                        target.AddRange(toAdd);
                    }

                    HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target);

                    foreach (var provinceParser in toDo)
                    {
                        provinceParser.Culture = newCulture;
                        provinces.Remove(provinceParser);
                    }
                }
            }

            // Create big religion groups covering multiple culture groups

            foreach (var religionGroupParser in ReligionManager.instance.AllReligionGroups)
            {
                var cgenum = AllCultureGroups.Where(cg => cg.ReligionGroup == religionGroupParser);

                var cultureGroupList = new List <CultureGroupParser>(cgenum);

                int n = Rand.Next(5) + 4;

                for (int x = 0; x < n; x++)
                {
                    var adjacentProv = new List <ProvinceParser>();
                    var adjacent     = new HashSet <CultureGroupParser>();

                    cultureGroupList.ForEach(g => g.Provinces.ForEach(p => adjacentProv.AddRange(p.Adjacent.Where(pa => pa.land && pa.title != null && pa.Culture != null && pa.Culture.Group != g))));

                    adjacentProv.ForEach(p => adjacent.Add(p.Culture.Group));

                    if (adjacent.Count > 0)
                    {
                        List <CultureGroupParser> list = new List <CultureGroupParser>(adjacent);

                        var chosen = list[Rand.Next(list.Count)];

                        chosen.ReligionGroup = religionGroupParser;

                        chosen.Provinces.ForEach(p => p.Religion = religionGroupParser.Religions[0]);
                    }
                }
            }

            // Now find the biggest two and make them bigger...

            ReligionGroupParser biggest = null;
            ReligionGroupParser second  = null;

            for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++)
            {
                var religionGroupParser = ReligionManager.instance.AllReligionGroups[index];

                if (religionGroupParser.Provinces.Count < 50)
                {
                    while (religionGroupParser.Provinces.Count > 0)
                    {
                        bool possible = true;

                        while (religionGroupParser.Provinces.Count > 0 && possible)
                        {
                            for (int i = 0; i < religionGroupParser.Provinces.Count; i++)
                            {
                                var provinceParser = religionGroupParser.Provinces[i];

                                var difcul = provinceParser.Adjacent.Where(p => p.Religion != provinceParser.Religion && p.Religion != null);

                                if (!difcul.Any())
                                {
                                    if (i == religionGroupParser.Provinces.Count - 1)
                                    {
                                        possible = false;
                                    }

                                    continue;
                                }

                                var list = new List <ProvinceParser>(difcul);

                                provinceParser.Religion = list[Rand.Next(list.Count)].Religion;

                                break;
                            }
                        }

                        if (!possible)
                        {
                            var provinceParser = religionGroupParser.Provinces[0];

                            var list = MapManager.instance.Provinces.Where(p => p.land && p.title != null && p.Religion.Group != religionGroupParser).ToList();

                            distanceTest = provinceParser;

                            list.Sort(SortByDistance);

                            provinceParser.Religion = list[0].Religion;

                            provinceParser.Culture.Group.ReligionGroup = list[0].Religion.Group;
                        }
                    }
                }

                if (religionGroupParser.Provinces.Count == 0)
                {
                    ReligionManager.instance.AllReligionGroups.Remove(religionGroupParser);

                    Console.Out.WriteLine(religionGroupParser.Religions[0].Name + " removed");

                    religionGroupParser.Scope.Remove(religionGroupParser.Religions[0].Scope);

                    ReligionManager.instance.Script.Root.Remove(religionGroupParser.Scope);
                    ReligionManager.instance.ReligionMap.Remove(religionGroupParser.Religions[0].Name);
                    ReligionManager.instance.AllReligions.Remove(religionGroupParser.Religions[0]);

                    foreach (var characterParser in CharacterManager.instance.Characters)
                    {
                        if (characterParser.religion == religionGroupParser.Religions[0].Name)
                        {
                            characterParser.religion = ReligionManager.instance.AllReligions[ReligionManager.instance.AllReligions.Count - 1].Name;
                        }
                    }

                    index--;
                }
            }

            ReligionManager.instance.AllReligionGroups.Sort(ReligionManager.instance.SortByBelievers);

            //After sorting grab largest & second-largest religions

            biggest = ReligionManager.instance.AllReligionGroups[0];

            if (ReligionManager.instance.AllReligionGroups.Count > 1)
            {
                second = ReligionManager.instance.AllReligionGroups[1];
            }

            for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++)
            {
                var religionGroup = ReligionManager.instance.AllReligionGroups[index];

                var provinces = new List <ProvinceParser>(religionGroup.Provinces);

                var mainReligion = religionGroup.Religions[0];

                int size = religionGroup.Provinces.Count;

                int iterations = 0;

                if (size <= 4)
                {
                    iterations = 1;
                }
                else if (size < 12)
                {
                    iterations = 1;
                }
                else if (size < 32)
                {
                    iterations = 2;
                }
                else
                {
                    iterations = 3;
                }

                // Do max iterations for first & second groups to make them larger

                if (biggest == religionGroup || second == religionGroup)
                {
                    iterations = 3;
                }

                for (int c = 0; c < iterations; c++)
                {
                    if (provinces.Count == 0)
                    {
                        break;
                    }

                    var start = provinces[Rand.Next(provinces.Count)];

                    start.Religion = ReligionManager.instance.BranchReligion(mainReligion.Name, start.Culture.Name);

                    var newC = start.Religion;

                    List <ProvinceParser> target = new List <ProvinceParser>();

                    target.Add(start);
                    target.AddRange(start.Adjacent.Where(p => provinces.Contains(p)));

                    int s = 2;
                    if (size > 16)
                    {
                        s = 3;
                    }
                    if (size > 32)
                    {
                        s = 4;
                    }

                    //If this is for first/second group, do the next loop two more times than usual the first few iterations

                    if (biggest == religionGroup || second == religionGroup)
                    {
                        if (c <= 2)
                        {
                            s += 2;
                        }
                    }

                    for (int x = 0; x < s; x++)
                    {
                        var toAdd = new List <ProvinceParser>();
                        target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null && pp.Religion.Group == start.Religion.Group)));
                        target.AddRange(toAdd);
                    }

                    HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target);

                    foreach (var provinceParser in toDo)
                    {
                        provinceParser.Religion = newC;
                        provinces.Remove(provinceParser);
                    }
                }
            }

            //Remove any groups with no provinces? then fill some holy sites?

            for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++)
            {
                var religionParser = ReligionManager.instance.AllReligionGroups[index];

                if (religionParser.Provinces.Count == 0)
                {
                    ReligionManager.instance.AllReligionGroups.Remove(religionParser);
                    index--;
                    continue;
                }

                religionParser.TryFillHolySites();
            }

            for (int index = 0; index < ReligionManager.instance.AllReligions.Count; index++)
            {
                var religionParser = ReligionManager.instance.AllReligions[index];

                if (religionParser.Provinces.Count == 0)
                {
                    Console.Out.WriteLine(religionParser.Name + " removed");
                    ReligionManager.instance.AllReligions.Remove(religionParser);
                    ReligionManager.instance.ReligionMap.Remove(religionParser.Name);
                    religionParser.Group.Scope.Remove(religionParser.Scope);

                    index--;

                    continue;
                }

                religionParser.TryFillHolySites();
            }

            //What's going on here? Setting char culture and religion to that of their primary title? Hmmm

            foreach (var characterParser in CharacterManager.instance.Characters)
            {
                if (characterParser.Titles.Count > 0)
                {
                    if (characterParser.PrimaryTitle.Rank == 2)
                    {
                        characterParser.culture  = characterParser.PrimaryTitle.SubTitles.First().Value.Owns[0].Culture.Name;
                        characterParser.religion = characterParser.PrimaryTitle.SubTitles.First().Value.Owns[0].Religion.Name;
                    }
                    else
                    {
                        characterParser.culture  = characterParser.PrimaryTitle.Owns[0].Culture.Name;
                        characterParser.religion = characterParser.PrimaryTitle.Owns[0].Religion.Name;
                    }

                    foreach (var titleParser in characterParser.Titles)
                    {
                        titleParser.culture = characterParser.culture;
                    }
                }
            }

            var l = MapManager.instance.Provinces.Where(p => p.title != null).ToList();

            foreach (var provinceParser in l)
            {
                provinceParser.initialReligion = provinceParser.Religion.Name;
                provinceParser.initialCulture  = provinceParser.Culture.Name;
            }

            //Set up map & leader for any religion with > 0 provinces

            foreach (var religionParser in ReligionManager.instance.AllReligions)
            {
                if (religionParser.Provinces.Count > 0)
                {
                    ReligionManager.instance.ReligionMap[religionParser.Name] = religionParser;
                }

                if (religionParser.Provinces.Count > 0 && (religionParser.hasLeader || religionParser.autocephaly))
                {
                    religionParser.DoLeader(religionParser.Provinces[Rand.Next(religionParser.Provinces.Count)]);
                }
            }
        }