コード例 #1
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);
        }
コード例 #2
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);
                }
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        private List <Tuple <String, CK2Character> > generateCharInfo(ImportantPaths importantPaths, List <Tuple <String, String> > charXMLLocs, DateConverter dtConverter)
        {
            List <Tuple <String, CK2Character> > charInfo = new List <Tuple <String, CK2Character> >();
            string savegamePath = importantPaths.getSavegameXMLPath();

            foreach (Tuple <String, String> charXMLLoc in charXMLLocs)
            {
                string      name = "";
                XmlDocument doc  = new XmlDocument();
                try {
                    doc.Load(savegamePath + "\\" + charXMLLoc.Item2);
                }
                catch (Exception) {
                    continue;
                }
                XmlNode root      = doc.DocumentElement.FirstChild;
                int     esfID     = 0;
                int     treeID    = 0;
                int     nodeCount = 0;
                bool    male      = false;
                string  birthStr  = "";
                for (XmlNode node = root.FirstChild; node != null; node = node.NextSibling)
                {
                    if (nodeCount == 0 && node.Name != "rec")
                    {
                        esfID = Int32.Parse(node.InnerText);
                    }
                    if (node.Name != "rec")
                    {
                        nodeCount++;
                    }
                    if (node.Attributes.Count == 0)
                    {
                        continue;
                    }
                    XmlAttribute attr = node.Attributes[0];
                    if (attr.Name == "type" && attr.InnerText == "CHARACTER_DETAILS")
                    {
                        int  detailCount      = 0;
                        bool i1AryFound       = false;
                        int  countedUAfterPol = 0;
                        bool foundGender      = false;
                        int  ascCount         = 0;
                        for (XmlNode detailNode = node.FirstChild; detailNode != null; detailNode = detailNode.NextSibling)
                        {
                            if (detailNode.Name == "asc")
                            {
                                ascCount++;
                            }
                            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 == 11) {
                              * 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 = extractName(detailNode);
                            }
                        }
                    }
                }
                DateTime birth    = dtConverter.convertDate(birthStr);
                DateTime death    = dtConverter.convertDate("1 0 0 0");
                string   religion = faction2ReligionMap[charXMLLoc.Item1];
                string   culture  = "";
                try {
                    culture = faction2CultureMap[charXMLLoc.Item1];
                }
                catch (Exception) { }
                CK2Character character             = new CK2Character(name, esfID, treeID, male, birth, death, religion, culture);
                Tuple <String, CK2Character> tuple = Tuple.Create <String, CK2Character>(charXMLLoc.Item1, character);
                charInfo.Add(tuple);
            }
            return(charInfo);
        }