Esempio n. 1
0
        public FamilyTrees(ImportantPaths paths, CharInfoCreator charInfoCreator, DateConverter dtConverter)
        {
            allCharacters = new List <CK2Character>();
            findESFFamilyTreeStructure(charInfoCreator, paths, dtConverter);
            trees = new Dictionary <string, FamilyTree>();
            Dictionary <String, List <CK2Character> > charInfo = reformatCharInfo(charInfoCreator.getCharInfo());

            createTrees(charInfoCreator, charInfo);
            updateSpouses();
        }
Esempio n. 2
0
        private void createTrees(CharInfoCreator charInfoCreator, Dictionary <String, List <CK2Character> > charInfo)
        {
            Dictionary <int, CK2Character> fam2Char = new Dictionary <int, CK2Character>();

            foreach (CK2Character character in allCharacters)
            {
                fam2Char.Add(character.getFamilyTreeID(), character);
            }
            foreach (var pair in charInfo)
            {
                FamilyTree tree = new FamilyTree(charInfoCreator, pair.Value, fam2Char, esfFamilyTreeStructure);
                trees.Add(pair.Key, tree);
            }
        }
Esempio n. 3
0
 private void deriveJobs(CharInfoCreator charInfoCreator)
 {
     foreach (CK2Character character in localCharacters)
     {
         string office = charInfoCreator.getJob(character.getESFID());
         if (office != null)
         {
             character.setOffice(office);
             if (office == "faction_leader")
             {
                 root = character;
             }
         }
     }
 }
Esempio n. 4
0
 public FamilyTree(CharInfoCreator charInfoCreator, List <CK2Character> factionCharacters, Dictionary <int, CK2Character> familyID2Characters, List <List <string> > esfFamilyTreeStructure)
 {
     this.associatedDynasties = new HashSet <CK2Dynasty>();
     this.localCharacters     = factionCharacters;
     this.fam2Char            = familyID2Characters;
     deriveJobs(charInfoCreator);
     if (this.root.getCulture() == "")
     {
         this.root.setCulture("english");
     }
     religion = this.root.getReligion();
     culture  = this.root.getCulture();
     discoverTree(this.root, familyID2Characters, esfFamilyTreeStructure);
     //dynasty = new CK2Dynasty("HolderTree");
     dynasty = this.deriveDynasty(root);
     updateDynasty(dynasty, root, true);
     updateReligion(root, true);
     updateCulture(root, true);
 }
Esempio n. 5
0
        private void findESFFamilyTreeStructure(CharInfoCreator charInfoCreator, ImportantPaths paths, DateConverter dtConverter)
        {
            string      worldPath = paths.getSavegameXMLPath() + "\\campaign_env\\world-0000.xml";
            XmlDocument doc       = new XmlDocument();

            try {
                doc.Load(worldPath);
            }
            catch (Exception) { return; }
            XmlNode root = doc.DocumentElement;

            for (XmlNode node = root.FirstChild; node != null; node = node.NextSibling)
            {
                if (node.Attributes.Count == 0)
                {
                    continue;
                }
                XmlAttribute attr = node.Attributes[0];
                if (attr.Name == "type" && attr.InnerText == "FAMILY_TREE")
                {
                    extractESFFamilyTreeStructure(node, charInfoCreator, dtConverter);
                }
            }
        }
Esempio n. 6
0
        public Form1()
        {
            cultureMaps    = new CultureMaps();
            regionMap      = new RegionMapper();
            ck2RegionsInfo = new CK2CountyRegionsInfo(regionMap);
            religionsInfo  = new ReligionsInfo();
            factionsInfo   = new FactionsInfo();

            InitializeComponent();

            psr = new ProjectSettingsReader();
            string savegameXMLPath = psr.getSavegameXMLLocation();

            importantPaths = new ImportantPaths(savegameXMLPath);


            //Init dating system
            DateConverter dtConverter = new DateConverter(importantPaths);

            //Generate characters located in faction array (these characters are alive)
            CharInfoCreator charInfoCreator = new CharInfoCreator(importantPaths, dtConverter, religionsInfo);

            //Build family tree and generate dead characters
            FamilyTrees famTrees = new FamilyTrees(importantPaths, charInfoCreator, dtConverter);

            //Update faction-specific information with save game data
            factionsInfo.updateImportantPaths(importantPaths);
            factionsInfo.readFactionXMLs();

            //Init region information
            attilaRegionsInfo = new AttilaRegionsInfo(importantPaths, regionMap, factionsInfo);

            //Generate de jure titles
            deJureTitles = new DeJureTitles(attilaRegionsInfo);

            //Update other information regarding factions and regions
            factionsInfo.updateFactionsInfo(attilaRegionsInfo);

            //Process family trees with regards to faction settings. (Dynasty update occurs here)
            factionsInfo.readFamilyTrees(famTrees);


            DirectoryHierarchyCreator.createOutputDirectories();

            MoveFlags.move(factionsInfo);
            MoveCultures.move();

            OutputCommonLandedTitles.output(factionsInfo);
            OutputCommonLandedTitles.outputDeJure(deJureTitles);
            OutputCommonDynasties.output(famTrees);
            //OutputCommonCultures.outputProvinceSpecific(attilaRegionsInfo);

            OutputCharacterHistories.output(factionsInfo);
            OutputProvinceHistories.output(attilaRegionsInfo, ck2RegionsInfo, religionsInfo);
            OutputTitleHistories.outputCountyHistory(factionsInfo);
            OutputTitleHistories.outputFactionTitleHistory(factionsInfo);

            OutputTitleLocalisation.output(factionsInfo);
            OutputTitleLocalisation.outputDeJure(deJureTitles);
            OutputCultureLocalisation.outputCultureGroups(cultureMaps);
            OutputCultureLocalisation.outputCultures(cultureMaps);
        }
Esempio n. 7
0
        private void extractESFFamilyTreeStructure(XmlNode root, CharInfoCreator charInfoCreator, DateConverter dtConverter)
        {
            int treeSize = Int32.Parse(root.FirstChild.InnerText);

            esfFamilyTreeStructure = new List <List <string> >(treeSize);
            for (XmlNode node = root.FirstChild.NextSibling; node != null; node = node.NextSibling)
            {
                if (node.Name != "rec")
                {
                    continue;
                }
                List <string> treeContents = new List <string>();
                for (XmlNode treeContentItem = node.FirstChild; treeContentItem != null; treeContentItem = treeContentItem.NextSibling)
                {
                    if (treeContentItem.Name == "u")
                    {
                        treeContents.Add(treeContentItem.InnerText);
                    }
                    else if (treeContentItem.Name == "no" || treeContentItem.Name == "yes")
                    {
                        treeContents.Add(treeContentItem.Name);
                    }
                    else if (treeContentItem.Attributes.Count > 0 && treeContentItem.Attributes[0].InnerText == "CHARACTER_DETAILS")
                    {
                        int    detailCount      = 0;
                        bool   i1AryFound       = false;
                        int    countedUAfterPol = 0;
                        bool   foundGender      = false;
                        int    ascCount         = 0;
                        bool   male             = false;
                        int    treeID           = Int32.Parse(treeContents[0]);
                        string name             = "";
                        string birthStr         = "";
                        string deathStr         = "";
                        for (XmlNode detailNode = treeContentItem.FirstChild; detailNode != null; detailNode = detailNode.NextSibling)
                        {
                            if (detailNode.Name == "asc")
                            {
                                ascCount++;
                            }
                            if (birthStr != "" && deathStr == "" && detailNode.Name == "date2")
                            {
                                deathStr = detailNode.InnerText;
                            }
                            if (birthStr == "" && detailNode.Name == "date2")
                            {
                                birthStr = detailNode.InnerText;
                            }
                            if (foundGender == false && ascCount == 2 && (detailNode.Name == "yes" || detailNode.Name == "no"))
                            {
                                male        = (detailNode.Name == "yes");
                                foundGender = true;
                            }/*
                              * if (detailCount == 12) {
                              * male = (detailNode.Name == "yes");
                              * }*/
                            if (detailNode.Name == "i1_ary")
                            {
                                i1AryFound = true;
                            }
                            if (detailNode.Name == "u" && i1AryFound)
                            {
                                countedUAfterPol++;
                                if (countedUAfterPol == 5)
                                {
                                    treeID = Int32.Parse(detailNode.InnerText);
                                }
                            }
                            if (detailNode.Name != "rec")
                            {
                                detailCount++;
                            }
                            if (detailNode.Attributes.Count == 0)
                            {
                                continue;
                            }
                            XmlAttribute detailAttr = detailNode.Attributes[0];
                            if (detailAttr.Name == "type" && detailAttr.InnerText == "CHARACTER_NAME")
                            {
                                name = charInfoCreator.extractName(detailNode);
                            }
                        }
                        DateTime     birth     = dtConverter.convertDate(birthStr);
                        DateTime     death     = dtConverter.convertDate(deathStr);
                        CK2Character character = new CK2Character(name, 0, treeID, male, birth, death, "", "");
                        allCharacters.Add(character);
                    }
                }
                esfFamilyTreeStructure.Add(treeContents);
            }
        }