示例#1
0
 public void AddTitle(TitleParser title)
 {
     //   Titles.Add(title);
     TieredTitles[title.Name] = title;
     LandedTitlesScript.Root.Add(title.Scope);
     title.Scope.Parent = LandedTitlesScript.Root;
 }
示例#2
0
        public TitleParser CreateBaronyScriptScope(ProvinceParser capital, CultureParser culture)
        {
            var place = culture.dna.GetPlaceName();
            var text  = place;

            place = StarNames.SafeName(text);
            if (TitleManager.instance.TieredTitles.ContainsKey("b_" + place))
            {
                return(CreateBaronyScriptScope(capital, culture));
            }
            var         rand  = Rand.Get();
            Color       col   = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();

            scope.Parent = capital.Title.Scope;


            scope.Name = "b_" + place;
            LanguageManager.instance.Add("b_" + place, text);
            //  scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });

            TitleParser title = new TitleParser(scope);

            TieredTitles[title.Name] = title;
            capital.Title.Scope.Add(title.Scope);

            //          if (culture.dna.horde)
//                title.Scope.Do("historical_nomad = yes");
            //   AddTitle(title);

            return(title);
        }
示例#3
0
 public void RegisterBarony(string name, TitleParser subTitle)
 {
     if (this.Temples.ContainsKey(name))
     {
         Temples[name].titleParser = subTitle;
     }
 }
示例#4
0
        public void AddSub(TitleParser sub)
        {
            if (sub.Rank >= this.Rank)
            {
                return;
            }
            //  if (SubTitles.ContainsKey(sub.Name))
            //     return;
            if (this == sub)
            {
                return;
            }

            var liege = sub;

            while (liege.Liege != null && liege.Liege.Rank > liege.Rank)
            {
                if (liege == this)
                {
                    return;
                }
                liege = liege.Liege;
            }
            if (liege != null)
            {
                liege.SubTitles.Remove(sub.Name);
            }
            SubTitles[sub.Name] = sub;
            Scope.SetChild(sub.Scope);
            sub.Liege = this;
        }
示例#5
0
 public void AddBarony(string name, TitleParser title)
 {
     baronies.Add(new Barony()
     {
         province = this, title = name, titleParser = title, enabled = false
     });
 }
示例#6
0
        public void RemoveVassal(TitleParser titleParser)
        {
            this.SubTitles.Remove(titleParser.Name);
            if (titleParser.Liege == this)
            {
                titleParser.Liege = null;
            }

            Scope.Remove(titleParser.Scope);
        }
示例#7
0
        private void AddNotAdj(TitleParser other)
        {
            if (AdjacentToTitleSet.Contains(other))
            {
                return;
            }

            AdjacentToTitleSet.Add(other);
            other.AdjacentToTitleSet.Add(this);
        }
示例#8
0
        public CharacterParser PromoteNewRuler(TitleParser title)
        {
            {
                var chara = CharacterManager.instance.GetNewCharacter();

                chara.GiveTitle(title);
                SimulationManager.instance.characters.Add(chara);
                return(chara);
            }
        }
示例#9
0
        public void AddBarony(string type, CultureParser culture, bool enabled = true)
        {
            TitleParser title = TitleManager.instance.CreateBaronyScriptScope(this, culture);

            baronies.Add(new Barony()
            {
                province = this, title = title.Name, titleParser = title, type = type, enabled = enabled
            });
            this.Title.AddSub(title);
        }
示例#10
0
        public bool Adjacent(TitleParser other)
        {
            if (AdjacentToTitleSet.Contains(other))
            {
                return(other.AdjacentToTitle.Contains(this));
            }

            if (Rank == 1)
            {
                if (this.Owns.Count == 0)
                {
                    return(false);
                }
                if (other.Rank == 1)
                {
                    return(this.Owns[0].Adjacent.Contains(other.Owns[0]));
                }
                if (other.Rank == 2)
                {
                    foreach (var titleParser in other.SubTitles)
                    {
                        if (this.Adjacent(titleParser.Value))
                        {
                            AddAdj(other);
                            return(true);
                        }
                    }
                }
            }
            if (Rank == 2)
            {
                if (other.Rank == 2)
                {
                    foreach (var titleParser in other.SubTitles)
                    {
                        if (Adjacent(titleParser.Value))
                        {
                            AddAdj(other);

                            return(true);
                        }
                    }
                }
                else
                {
                    if (other.Adjacent(this))
                    {
                        AddAdj(other);
                        return(true);
                    }
                }
            }
            AddNotAdj(other);
            return(false);
        }
示例#11
0
        private void AddBarony(string type, CultureParser culture)
        {
            TitleParser title = TitleManager.instance.CreateBaronyScriptScope(this, culture);

            baronies.Add(new Barony()
            {
                province = this, title = title.Name, titleParser = title, type = type
            });
            this.Title.AddSub(title);
            SimulationManager.instance.AddCharacterForTitle(title);
        }
示例#12
0
        public TitleParser CreateKingScriptScope(ProvinceParser capital, CharacterParser chr)
        {
            var         rand  = Rand.Get();
            Color       col   = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();

            scope.Parent = LandedTitlesScript.Root;



            {
                String place = chr.Culture.dna.GetPlaceName();
                String text  = place;
                place = StarNames.SafeName(place);

                if (TitleManager.instance.TitleMap.ContainsKey("k_" + place))
                {
                    return(CreateKingScriptScope(capital, chr.culture));
                }

                LanguageManager.instance.Add(place, text);
                scope.Name = "k_" + place;
                LanguageManager.instance.Add(scope.Name, text);
            }


            //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });
            scope.Add(new ScriptCommand()
            {
                Name = "color", Value = col
            });
            scope.Add(new ScriptCommand()
            {
                Name = "color2", Value = col
            });

            scope.Add(new ScriptCommand()
            {
                Name = "capital", Value = capital.id
            });

            TitleParser title = new TitleParser(scope);

            AddTitle(title);

            // now place the counties into it...
            if (title.capital != 0)
            {
                title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital];
            }

            return(title);
        }
示例#13
0
        private int SortDuchyByTotalTech(TitleParser x, TitleParser y)
        {
            if (x.AverageTech > y.AverageTech)
            {
                return(-1);
            }
            if (x.AverageTech < y.AverageTech)
            {
                return(1);
            }

            return(0);
        }
示例#14
0
        public TitleParser CreateDukeScriptScope(ProvinceParser capital, String name = null)
        {
            var         rand  = Rand.Get();
            Color       col   = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();

            scope.Parent = LandedTitlesScript.Root;

            if (name == null)
            {
                String place = capital.Title.Holder.Culture.dna.GetPlaceName();
                String text  = place;
                place = StarNames.SafeName(place);
                LanguageManager.instance.Add(place, text);
                scope.Name = "d_" + place;
                LanguageManager.instance.Add(scope.Name, text);
            }
            else
            {
                scope.Name = "d_" + name;
            }

            //  scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });
            scope.Add(new ScriptCommand()
            {
                Name = "color", Value = col
            });
            scope.Add(new ScriptCommand()
            {
                Name = "color2", Value = col
            });

            scope.Add(new ScriptCommand()
            {
                Name = "capital", Value = capital.id
            });

            TitleParser title = new TitleParser(scope);

            //          if (capital.Title.Culture.dna.horde)
//                title.Scope.Do("historical_nomad = yes");

            AddTitle(title);
            if (title.capital != 0)
            {
                title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital];
            }
            // now place the counties into it...

            return(title);
        }
示例#15
0
        private void Add(TitleParser title, float mil, float cul, float eco)
        {
            String name = title.Name;
            int    y    = useYear;

            if (y > SimulationManager.instance.MaxYear)
            {
                y = SimulationManager.instance.MaxYear;
            }
            var group = title.TechGroup;

            if (title.TechGroup != null)
            {
                if (title.TechGroup.HasNamed(y.ToString()))
                {
                    return;
                }

                var date = new ScriptScope((y).ToString());
                date.Add(new ScriptCommand("military", mil, date));
                date.Add(new ScriptCommand("economy", eco, date));
                date.Add(new ScriptCommand("culture", cul, date));
                title.TechGroup.Add(date);
                return;
            }
            if (!Groups.ContainsKey(mil))
            {
                Groups[mil]         = new TechnologyGroup();
                Groups[mil].Date    = new Dictionary <int, ScriptScope>();
                Groups[mil].Date[y] = new ScriptScope((y).ToString());
                Groups[mil].Date[y].Add(new ScriptCommand("military", mil, Groups[mil].Date[y]));
                Groups[mil].Date[y].Add(new ScriptCommand("economy", eco, Groups[mil].Date[y]));
                Groups[mil].Date[y].Add(new ScriptCommand("culture", cul, Groups[mil].Date[y]));
                Groups[mil].Titles = new ScriptScope("titles");
                Groups[mil].Titles.Add("\t\t" + name);
                Script.Root.AllowDuplicates = true;
                var tech = new ScriptScope("technology");
                Script.Root.Add(tech);
                tech.Add(Groups[mil].Titles);
                tech.Add(Groups[mil].Date[y]);
                title.TechGroup = Groups[mil].Titles.Parent;
            }
            else
            {
                if (!Groups[mil].Titles.Children.Contains("\t\t" + name))
                {
                    Groups[mil].Titles.Add("\t\t" + name);
                    title.TechGroup = Groups[mil].Titles.Parent;
                }
            }
        }
示例#16
0
        public void AddTitle(TitleParser title)
        {
            if (!Titles.Contains(title))
            {
                Titles.Add(title);
            }
            TieredTitles[title.Name] = title;
            LandedTitlesScript.Root.Add(title.Scope);
            title.Scope.Parent = LandedTitlesScript.Root;

            title.color = Color.FromArgb(255, Rand.Next(255), Rand.Next(255), Rand.Next(255));
            title.SetProperty("color", title.color);
            title.SetProperty("color2", title.color);
        }
示例#17
0
        public void Create(String name, String casusBelli, List <CharacterParser> attackers, List <CharacterParser> defenders,
                           TitleParser title, int yearStart)
        {
            warScript = new Script();

            warScript.Root = new ScriptScope();
            warScript.Root.Do("name = \"" + name + "\"");
            Attackers.AddRange(attackers);
            Defenders.AddRange(defenders);

            startDate = yearStart;

            CreateCasusBelli(casusBelli, attackers[0], defenders[0], title, yearStart);
            CreateStart(attackers, defenders, yearStart);
        }
示例#18
0
        public TitleParser CreateTitle()
        {
            this.title = this.Name;
            //    string n = culture.dna.GetPlaceName();
            //   String sn = StarNames.SafeName(n);
            //  this.Name = "c_" + sn;
            var scope = new ScriptScope();

            scope.Name = this.title;
            var c = new TitleParser(scope);

            c.capital         = this.id;
            c.CapitalProvince = this;
            TitleManager.instance.AddTitle(c);
            return(c);
        }
示例#19
0
        public TitleParser CreateTitle()
        {
            this.title = "c_" + this.Name;


            var scope = new ScriptScope();

            scope.Name = this.title;
            var c = new TitleParser(scope);

            c.capital         = this.id;
            c.CapitalProvince = this;
            c.Owns.Add(this);
            TitleManager.instance.AddTitle(c);
            return(c);
        }
示例#20
0
 public void AddVassalsToTitle(TitleParser title, List <TitleParser> vassals)
 {
     foreach (var titleParser in vassals)
     {
         title.Scope.SetChild(titleParser.Scope);
         if (titleParser.Liege != null)
         {
             titleParser.Liege.RemoveVassal(titleParser);
         }
         title.SubTitles[titleParser.Name] = titleParser;
         if (title.Liege == titleParser || title.Liege == title)
         {
             title.Liege = null;
         }
         titleParser.Liege = title;
     }
 }
示例#21
0
        public bool SameRealm(TitleParser title)
        {
            var liege = this;

            while (liege.Liege != null && liege.Rank < liege.Liege.Rank)
            {
                liege = liege.Liege;
            }
            var liege2 = title;

            while (liege2.Liege != null && liege2.Rank < liege2.Liege.Rank)
            {
                liege2 = liege2.Liege;
            }

            return(liege == liege2);
        }
示例#22
0
        public TitleParser CreateKingScriptScope(ProvinceParser capital, String name = null)
        {
            var         rand  = Rand.Get();
            Color       col   = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();

            scope.Parent = LandedTitlesScript.Root;


            if (name == null)
            {
                scope.Name = "k_" + capital.Title.Name.Substring(2);
            }
            else
            {
                scope.Name = "k_" + name;
            }


            //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });
            scope.Add(new ScriptCommand()
            {
                Name = "color", Value = col
            });
            scope.Add(new ScriptCommand()
            {
                Name = "color2", Value = col
            });

            scope.Add(new ScriptCommand()
            {
                Name = "capital", Value = capital.id
            });

            TitleParser title = new TitleParser(scope);

            AddTitle(title);

            // now place the counties into it...
            if (title.capital != 0)
            {
                title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital];
            }

            return(title);
        }
示例#23
0
        private bool PromoteToTop(TitleParser title)
        {
            var array = title.SubTitles.ToArray();

            if (title.Rank == 0)
            {
                return(false);
            }
            foreach (var titleParser in array)
            {
                if (PromoteToTop(titleParser.Value))
                {
                    titleParser.Value.SubTitles.Clear();
                }
            }
            title.Scope.Parent.Remove(title.Scope);
            title.SubTitles.Clear();
            toTop.Add(title);
            return(true);
        }
示例#24
0
        private void DoVanillaTitle(ScriptScope scope, TitleParser liege)
        {
            if (scope.Name == "gain_effect")
            {
                return;
            }

            var empire = new TitleParser(scope as ScriptScope, true);

            if (empire.Name == "e_rebels")
            {
                Titles.Remove(empire);
                return;
            }
            if (empire.Name == "e_pirates")
            {
                Titles.Remove(empire);
                return;
            }
        }
示例#25
0
 public void AddTitle(TitleParser title)
 {
  //   Titles.Add(title);
     TieredTitles[title.Name] = title;
     LandedTitlesScript.Root.Add(title.Scope);
     title.Scope.Parent = LandedTitlesScript.Root;
 }
示例#26
0
        private static void FixupDuchies()
        {
            List <TitleParser> orphans = new List <TitleParser>();

            foreach (var titleParser in TitleManager.instance.Titles)
            {
                if (titleParser.Rank == 1 && titleParser.Liege == null)
                {
                    orphans.Add(titleParser);
                }
            }

            for (int index = 0; index < orphans.Count; index++)
            {
                var         titleParser = orphans[index];
                int         smallest    = 10000000;
                TitleParser title       = null;
                foreach (var provinceParser in titleParser.Owns[0].Adjacent)
                {
                    if (provinceParser.title == null)
                    {
                        continue;
                    }

                    if (provinceParser.Title.Liege != null)
                    {
                        var liege = provinceParser.Title.Liege;

                        int c = liege.SubTitles.Count;
                        if (smallest > c)
                        {
                            smallest = c;
                            title    = liege;
                        }
                    }
                }

                if (title != null)
                {
                    title.AddSub(titleParser);
                    orphans.Remove(titleParser);
                    index--;
                }
            }
            orphans.Clear();
            foreach (var titleParser in TitleManager.instance.Titles)
            {
                if (titleParser.Rank == 2)
                {
                    List <TitleParser> titles = new List <TitleParser>(titleParser.SubTitles.Values);
                    for (int index = 0; index < titles.Count; index++)
                    {
                        var value = titles[index];
                        for (int i = index + 1; i < titles.Count; i++)
                        {
                            var value2 = titles[i];
                            if (value.Owns.Count == 0)
                            {
                                continue;
                            }

                            if (!value.Adjacent(value2))
                            {
                                if (!orphans.Contains(value2))
                                {
                                    orphans.Add(value2);
                                }
                                continue;
                            }
                        }
                    }
                }
            }
            for (int index = 0; index < orphans.Count; index++)
            {
                var         titleParser = orphans[index];
                int         smallest    = 10000000;
                TitleParser title       = null;
                foreach (var provinceParser in titleParser.Owns[0].Adjacent)
                {
                    if (provinceParser.title == null)
                    {
                        continue;
                    }

                    if (provinceParser.Title.Liege != null)
                    {
                        var liege = provinceParser.Title.Liege;

                        int c = liege.SubTitles.Count;
                        if (smallest > c)
                        {
                            smallest = c;
                            title    = liege;
                        }
                    }
                }

                if (title != null)
                {
                    title.AddSub(titleParser);
                    orphans.Remove(titleParser);
                    index--;
                }
            }
            orphans.Clear();

            foreach (var titleParser in TitleManager.instance.Titles)
            {
                if (titleParser.Rank == 2)
                {
                    if (titleParser.SubTitles.Count > 0)
                    {
                        orphans.Add(titleParser);
                    }
                }
            }

            // now wo do the regions...
            List <TitleParser> forRegion = new List <TitleParser>();

            for (int index = 0; index < orphans.Count; index++)
            {
                var titleParser = orphans[index];
                int kingSize    = Rand.Next(10 * 10);
                var results     = titleParser.Holder.GetProvinceGroup(kingSize, null);

                foreach (var provinceParser in results)
                {
                    if (provinceParser.Title != null && provinceParser.Title.Liege != null &&
                        provinceParser.Title.Liege.Rank == 2)
                    {
                        if (!forRegion.Contains(provinceParser.Title.Liege))
                        {
                            forRegion.Add(provinceParser.Title.Liege);
                        }
                    }
                }

                foreach (var parser in forRegion)
                {
                    if (orphans.Contains(parser))
                    {
                        int index2 = orphans.IndexOf(parser);

                        if (index2 <= index)
                        {
                            index--;
                        }
                        orphans.Remove(parser);
                    }
                }

                String name = forRegion[0].Culture.dna.GetPlaceName();
                RegionManager.instance.AddRegion(name, forRegion);
                forRegion.Clear();
            }
        }
示例#27
0
        public void DoLeader(ProvinceParser capital)
        {
            String popeName = StarNames.SafeName(StarNames.Generate(10000000));

            LanguageManager.instance.Add(popeName, StarNames.Generate(10000000));

            PopeName = popeName;
            TitleParser title = null;
            bool        bNew  = false;

            ReligiousHeadTitle = null;

            if (ReligiousHeadTitle == null)
            {
                bNew = true;

                switch (Rand.Next(8))
                {
                case 0:
                case 1:
                case 2:
                case 3:
                    title = TitleManager.instance.CreateKingScriptScope(capital, Name);
                    break;

                case 4:
                    title = TitleManager.instance.CreateEmpireScriptScope(capital, Name);
                    break;

                case 5:
                case 6:
                case 7:
                    title = TitleManager.instance.CreateDukeScriptScope(capital, Name);
                    break;
                }

                ReligiousHeadTitle = title;
            }

            ReligiousHeadTitle.Religious = true;
            ReligiousHeadTitle.Active    = true;
            ReligiousHeadTitle.religion  = Name;

            TitleManager.instance.ReligiousTitles.Add(ReligiousHeadTitle);

            if (bNew)
            {
                var ch = SimulationManager.instance.AddCharacterForTitle(ReligiousHeadTitle, true);
                ch.religion = Name;
                ch.UpdateCultural();
            }

            String religious_names = "";

            for (int n = 0; n < 40; n++)
            {
                religious_names = CultureManager.instance.CultureMap[ReligiousHeadTitle.Holder.culture].dna.GetMaleName() + " ";
            }

            ReligiousHeadTitle.Scope.Do(@"

	        title = """     + popeName + @"""
	        foa = ""POPE_FOA""
	        short_name = "     + (Rand.Next(2) == 0 ? "yes" : "no") + @"
	        location_ruler_title = "     + (Rand.Next(2) == 0 ? "yes" : "no") + @"
	        landless = "     + (bNew ? "yes" : "no") + @"
	        controls_religion = """     + Name + @"""
	        religion = """     + Name + @"""
	        primary = yes
	        dynasty_title_names = no
	    

");

            LanguageManager.instance.Add(ReligiousHeadTitle.Name, this.LanguageName);
        }
示例#28
0
        public void DoLeader(ProvinceParser capital)
        {
            String popeName = StarNames.SafeName(StarNames.Generate(10000000));

            LanguageManager.instance.Add(popeName, StarNames.Generate(10000000));

            TitleParser title = null;

            switch (Rand.Next(3))
            {
            case 0:
                title = TitleManager.instance.CreateKingScriptScope(capital, Name);
                break;

            case 1:
                title = TitleManager.instance.CreateEmpireScriptScope(capital, Name);
                break;

            case 2:
                title = TitleManager.instance.CreateDukeScriptScope(capital, Name);
                break;
            }

            ReligiousHeadTitle           = title;
            ReligiousHeadTitle.Religious = true;
            ReligiousHeadTitle.Active    = true;
            //  ch.UpdateCultural();
            var ch = SimulationManager.instance.AddCharacterForTitle(ReligiousHeadTitle, true);

            ch.religion = Name;
            ch.UpdateCultural();
            var liege = ReligiousHeadTitle.CapitalProvince.Title;

            if (Rand.Next(3) == 0)
            {
                ch.GiveTitle(ReligiousHeadTitle.CapitalProvince.Title);
            }
            String religious_names = "";

            for (int n = 0; n < 40; n++)
            {
                religious_names = CultureManager.instance.CultureMap[ch.culture].dna.GetMaleName() + " ";
            }
            title.Scope.Do(@"

	        title = """     + popeName + @"""
	        foa = ""POPE_FOA""
	        short_name = yes
	        location_ruler_title = yes
	        landless = yes
	        controls_religion = """     + Name + @"""
	        religion = """     + Name + @"""
	        primary = yes
	        dynasty_title_names = no
	        male_names = {
			        "             + religious_names + @"
        }

");



            LanguageManager.instance.Add(title.Name, this.LanguageName);
        }
示例#29
0
 private bool PromoteToTop(TitleParser title)
 {
     var array = title.SubTitles.ToArray();
     if (title.Rank == 0)
         return false;
     foreach (var titleParser in array)
     {
         if(PromoteToTop(titleParser.Value))
             titleParser.Value.SubTitles.Clear();
     }
     title.Scope.Parent.Remove(title.Scope);            
     title.SubTitles.Clear();
     toTop.Add(title);
     return true;
 }
示例#30
0
        public TitleParser CreateDukeScriptScope(ProvinceParser capital, String name = null)
        {
            var rand = Rand.Get();
            Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();
            scope.Parent = LandedTitlesScript.Root;

            if (name == null)
            {
                String place = capital.Title.Holder.Culture.dna.GetPlaceName();
                String text = place;
                place = StarNames.SafeName(place);
                LanguageManager.instance.Add(place, text);
                scope.Name = "d_" + place;
                LanguageManager.instance.Add(scope.Name, text);
            }
            else
                scope.Name = "d_" + name;

            //  scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });
            scope.Add(new ScriptCommand() { Name = "color", Value = col });
            scope.Add(new ScriptCommand() { Name = "color2", Value = col });
            
            scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id });
          
            TitleParser title = new TitleParser(scope);
            
  //          if (capital.Title.Culture.dna.horde)
//                title.Scope.Do("historical_nomad = yes");
            
            AddTitle(title);
            if (title.capital != 0)
                title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital];
            // now place the counties into it...

            return title;
        }
示例#31
0
        public CharacterParser PromoteNewRuler(TitleParser title)
        {
    
            {
                var chara = CharacterManager.instance.GetNewCharacter();

                chara.GiveTitle(title);
                SimulationManager.instance.characters.Add(chara);
                return chara;
            }


        }
示例#32
0
        private void AddNotAdj(TitleParser other)
        {
            if (AdjacentToTitleSet.Contains(other))
                return;

            AdjacentToTitleSet.Add(other);
            other.AdjacentToTitleSet.Add(this);
          
        }
示例#33
0
        public bool SameRealm(TitleParser title)
        {          
            var liege = this;

            while (liege.Liege != null && liege.Rank < liege.Liege.Rank)
            {
                
                liege = liege.Liege;
            }
            var liege2 = title;

            while (liege2.Liege != null && liege2.Rank < liege2.Liege.Rank)
            {
                liege2 = liege2.Liege;
            }

            return liege == liege2;

        }
示例#34
0
        public TitleParser CreateEmperor(ProvinceParser capital)
        {
            TitleParser s = CreateEmpireScriptScope(capital);

            return(s);
        }
示例#35
0
 public void AddVassalsToTitle(TitleParser title, List<TitleParser> vassals)
 {
     foreach (var titleParser in vassals)
     {
         title.Scope.SetChild(titleParser.Scope);
         if (titleParser.Liege != null)
         {
             titleParser.Liege.RemoveVassal(titleParser);
         }
         title.SubTitles[titleParser.Name] = titleParser;
         if (title.Liege == titleParser || title.Liege == title)
             title.Liege = null;
         titleParser.Liege = title;                
     }
     
 }
示例#36
0
        public TitleParser CreateBaronyScriptScope(ProvinceParser capital, CultureParser culture)
        {
            var place = culture.dna.GetPlaceName();
            var text = place;
            place = StarNames.SafeName(text);
            if (TitleManager.instance.TieredTitles.ContainsKey("b_" + place))
            {
                return CreateBaronyScriptScope(capital, culture);
            }
            var rand = Rand.Get();
            Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();
            scope.Parent = capital.Title.Scope;

            
                scope.Name = "b_" + place;
                LanguageManager.instance.Add("b_" + place, text);
            //  scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });
         
            TitleParser title = new TitleParser(scope);
            TieredTitles[title.Name] = title;
            capital.Title.Scope.Add(title.Scope);

  //          if (culture.dna.horde)
//                title.Scope.Do("historical_nomad = yes");
         //   AddTitle(title);
         
            return title;
        }
示例#37
0
        public void AddSub(TitleParser sub)
        {
            if (sub.Rank >= this.Rank)
                return;
          //  if (SubTitles.ContainsKey(sub.Name))
           //     return;
            if (this == sub)
                return;

            var liege = sub;

            while (liege.Liege != null && liege.Liege.Rank > liege.Rank)
            {
                if (liege == this)
                {

                    return;
                }
                liege = liege.Liege;
                
            }
            if (liege != null)
            {
                liege.SubTitles.Remove(sub.Name);
            }
            SubTitles[sub.Name] = sub;
            Scope.SetChild(sub.Scope);
            sub.Liege = this;

        }
示例#38
0
 public void RemoveTitle(TitleParser titleParser)
 {
     Titles.Remove(titleParser);
     TitleMap.Remove(titleParser.Name);
     LandedTitlesScript.Root.Remove(titleParser.Scope);
 }
示例#39
0
        public bool Adjacent(TitleParser other)
        {
        
            if (AdjacentToTitleSet.Contains(other))
                return other.AdjacentToTitle.Contains(this);
          
            if (Rank==1)
            {
                if (this.Owns.Count == 0)
                    return false;
                if (other.Rank == 1)
                    return (this.Owns[0].Adjacent.Contains(other.Owns[0]));
                if (other.Rank == 2)
                {
                    foreach (var titleParser in other.SubTitles)
                    {
                        if (this.Adjacent(titleParser.Value))
                        {
                            AddAdj(other);
                            return true;
                        }
                     
                    }
                }

            }
            if (Rank==2)
            {
                if (other.Rank==2)
                {
                    foreach (var titleParser in other.SubTitles)
                    {
                        if (Adjacent(titleParser.Value))
                        {
                            AddAdj(other);

                            return true;
                        }
                       
                    }
                    
                }
                else
                {
                    if (other.Adjacent(this))
                    {
                        AddAdj(other);
                        return true;
                    }
                  
                }
            }
            AddNotAdj(other);
            return false;
        }
示例#40
0
        public void Draw(Graphics graphics, float w, float h)
        {
            float xrat = w / 1456.0f;
            float yrat = h / 1027.0f;

            try
            {
                foreach (var provinceParser in Provinces)
                {
                    if (provinceParser.title == null)
                    {
                        continue;
                    }
                    if (!provinceParser.land)
                    {
                        continue;
                    }

                    if (!TitleManager.instance.TitleMap[provinceParser.title].Active)
                    {
                        continue;
                    }
                    if (TitleManager.instance.TitleMap[provinceParser.title].Holder == null && TitleManager.instance.TitleMap[provinceParser.title].CurrentHolder == null)
                    {
                        continue;
                    }

                    if (this.ProvinceBitmaps.ContainsKey(provinceParser.id))
                    {
                        // Get a picture box's Graphics object
                        Graphics gra = graphics;
                        if (provinceParser == null)
                        {
                            continue;
                        }

                        if (provinceParser.ProvinceOwner == null)
                        {
                            continue;
                        }
                        var hh = provinceParser.ProvinceOwner.Holder;
                        if (TitleManager.instance.TitleMap[provinceParser.title].CurrentHolder != null)
                        {
                            hh = TitleManager.instance.TitleMap[provinceParser.title].CurrentHolder;
                        }
                        Color col = hh.Color;

                        //    col = Color.FromArgb(255, rand.Next(255), rand.Next(255), rand.Next(255));
                        // Create a new color matrix and set the alpha value to 0.5
                        cm.Matrix00 = col.R / 255.0f;
                        cm.Matrix11 = col.G / 255.0f;
                        cm.Matrix22 = col.B / 255.0f;
                        cm.Matrix33 = 1.0f;
                        cm.Matrix44 = 1.0f;

                        TitleParser tit = TitleManager.instance.TitleMap[provinceParser.title];
                        if (tit.Liege == null)
                        {
                            cm.Matrix33 = 0.3f;
                        }
                        while (tit.Liege != null && tit.Liege.Rank > tit.Rank)
                        {
                            tit = tit.Liege;
                        }

                        // Create a new image attribute object and set the color matrix to
                        // the one just created
                        ia.SetColorMatrix(cm);

                        if (!ProvinceBitmaps.ContainsKey(provinceParser.id))
                        {
                        }
                        Bitmap bmp = this.ProvinceBitmaps[provinceParser.id].Bitmap;
                        var    p   = this.ProvinceBitmaps[provinceParser.id].MapPoint;
                        graphics.DrawImage(bmp, new Rectangle((int)(p.X * RenderMod * xrat), (int)(p.Y * RenderMod * yrat), (int)(bmp.Width * RenderMod * xrat), (int)(bmp.Height * RenderMod * yrat)), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, ia);
                    }
                }
            }
            catch (Exception ex)
            {
            }


            //     graphics.DrawImage(this.ProvinceBitmap, new Rectangle(0, 0, ProvinceBitmap.Width, ProvinceBitmap.Height));
        }
示例#41
0
        public void RemoveVassal(TitleParser titleParser)
        {
            this.SubTitles.Remove(titleParser.Name);
            if (titleParser.Liege == this)
                titleParser.Liege = null;

            Scope.Remove(titleParser.Scope);
        }
示例#42
0
 public void RegisterBarony(string name, TitleParser subTitle)
 {
     if (this.Temples.ContainsKey(name))
     {
         Temples[name].titleParser = subTitle;
     }
 }
示例#43
0
        public TitleParser CreateEmpireScriptScope(ProvinceParser capital, CharacterParser chr)
        {
            var rand = Rand.Get();
            Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();
            scope.Parent = LandedTitlesScript.Root;



            {
                String place = chr.Culture.dna.GetPlaceName();
                String text = place;
                place = StarNames.SafeName(place);
                LanguageManager.instance.Add(place, text);
                scope.Name = "e_" + place;
                LanguageManager.instance.Add(scope.Name, text);
            }


            //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });
            scope.Add(new ScriptCommand() { Name = "color", Value = col });
            scope.Add(new ScriptCommand() { Name = "color2", Value = col });

            scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id });

            TitleParser title = new TitleParser(scope);
            AddTitle(title);

            // now place the counties into it...
            if (title.capital != 0)
                title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital];

            return title;
        }
示例#44
0
 public void RemoveTitle(TitleParser titleParser)
 {
     Titles.Remove(titleParser);
     TitleMap.Remove(titleParser.Name);
     LandedTitlesScript.Root.Remove(titleParser.Scope);
 }
示例#45
0
 public TitleParser CreateTitle()
 {
     this.title = this.Name;
 //    string n = culture.dna.GetPlaceName();
  //   String sn = StarNames.SafeName(n);
   //  this.Name = "c_" + sn;
     var scope = new ScriptScope();
     scope.Name = this.title;
     var c = new TitleParser(scope);
     c.capital = this.id;
     c.CapitalProvince = this;
     TitleManager.instance.AddTitle(c);
     return c;
 }
示例#46
0
        public TitleParser CreateKingScriptScope(ProvinceParser capital, String name = null)
        {
            var rand = Rand.Get();
            Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55);
            ScriptScope scope = new ScriptScope();
            scope.Parent = LandedTitlesScript.Root;


            if (name == null)
                scope.Name = "k_" + capital.Title.Name.Substring(2);
            else
                scope.Name = "k_" + name;


            //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false });
            scope.Add(new ScriptCommand() { Name = "color", Value = col });
            scope.Add(new ScriptCommand() { Name = "color2", Value = col });
        
            scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id });

            TitleParser title = new TitleParser(scope);
            AddTitle(title);

            // now place the counties into it...
            if (title.capital != 0)
                title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital];

            return title;
        }