Ejemplo n.º 1
0
        private static void writeProvinceHistory(AttilaRegionInfo attilaRegion, CK2CountyRegionInfo ck2County, ReligionsInfo religions)
        {
            //Remove ifs if going province specific
            if (attilaRegion.getIsBurned())
            {
                return;
            }
            FactionInfo faction = attilaRegion.getOwningFaction();

            if (faction.getID().Contains("fact_separatist") || faction.getID().Contains("fact_rebel"))
            {
                return;
            }
            string           filename   = ck2County.getFilename();
            string           outputPath = ImportantPaths.getOutputPath() + "\\history\\provinces\\" + filename;
            HashSet <String> baronies   = ck2County.getBaronies();

            using (StreamWriter writer = File.CreateText(outputPath)) {
                writer.WriteLine("# " + filename.Substring(0, filename.Length - 4));
                writer.WriteLine("");
                writer.WriteLine("# County Title");
                writer.WriteLine("title = " + ck2County.getID());
                writer.WriteLine("");
                writer.WriteLine("# Settlements");
                writer.WriteLine("max_settlements = " + ck2County.getMaxSettlements());
                bool wroteBarony = false;
                foreach (String barony in baronies)
                {
                    if (wroteBarony == false)
                    {
                        writer.WriteLine(barony + " = castle");
                        wroteBarony = true;
                    }
                    else
                    {
                        writer.WriteLine("#" + barony + " = castle");
                    }
                }
                writer.WriteLine("");
                writer.WriteLine("# Misc");
                string culture = faction.getOwner().getCulture();
                writer.WriteLine("culture = " + culture);
                //writer.WriteLine("culture = " + attilaRegion.getIDStr());
                writer.WriteLine("religion = " + religions.getCK2Religion(attilaRegion.getMostPowerfulReligion()));
                writer.WriteLine("");
                writer.WriteLine("# History");
            }
        }
Ejemplo n.º 2
0
        private List <Tuple <String, String> > getCharXMLLocs(ImportantPaths importantPaths, ReligionsInfo religions)
        {
            string factionsPath = importantPaths.getSavegameXMLPath() + "\\factions";

            string[] factionXMLs = Directory.GetFiles(factionsPath);
            List <Tuple <String, String> > charXMLs = new List <Tuple <String, String> >();

            foreach (string xmlPath in factionXMLs)
            {
                string[] dirItems     = xmlPath.Split('\\');
                string   absoluteName = dirItems[dirItems.Length - 1];
                if (!absoluteName.StartsWith("att_fact_"))
                {
                    continue;
                }
                string      faction = absoluteName.Substring(0, absoluteName.Length - 4);
                XmlDocument doc     = new XmlDocument();
                try {
                    doc.Load(xmlPath);
                }
                catch (Exception) {
                    continue;
                }
                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 == "FACTION_RELIGION_MANAGER")
                    {
                        string attilaReligion = node.FirstChild.InnerText;
                        string ck2Religion    = religions.getCK2Religion(attilaReligion);
                        faction2ReligionMap.Add(faction, ck2Religion);
                    }
                    if (attr.Name == "type" && attr.InnerText == "CHARACTER_ARRAY")
                    {
                        for (XmlNode charNode = node.FirstChild; charNode != null; charNode = charNode.NextSibling)
                        {
                            string path = charNode.Attributes[0].InnerText;
                            //Garrison leader
                            if (path.StartsWith("character/colonel"))
                            {
                                continue;
                            }
                            Tuple <String, String> tuple = Tuple.Create <String, String>(faction, path);
                            charXMLs.Add(tuple);
                        }
                    }
                    if (attr.Name == "path" && attr.InnerText.StartsWith("government"))
                    {
                        string governmentLoc = attr.InnerText;
                        governmentLoc = governmentLoc.Replace("/", "\\");
                        readGovernmentInfo(importantPaths, governmentLoc);
                    }
                }
            }
            return(charXMLs);
        }