public static void outputFactionTitleHistory(FactionsInfo factions) { string outputDir = ImportantPaths.getOutputPath() + "\\history\\titles"; string titleAcquireDate = "767.1.1"; foreach (FactionInfo faction in factions.getFactions()) { if (!faction.getExists() || faction.getCK2Title() == null) { continue; } string ck2Title = faction.getCK2Title(); int ownerCharID = faction.getOwner().getID(); using (StreamWriter writer = File.CreateText(outputDir + "\\" + ck2Title + ".txt")) { writer.WriteLine(titleAcquireDate + "={"); writer.WriteLine("\tholder=" + ownerCharID); if (faction.getCK2Title().StartsWith("e_")) { writer.WriteLine("\tlaw=imperial_administration"); writer.WriteLine("\tlaw=succ_primogeniture"); } if (!faction.getIsNewTitle()) { string idName = ("correction_" + faction.getCK2Title()).ToUpper(); string idAdj = ("correction_" + faction.getCK2Title() + "_adj").ToUpper(); writer.WriteLine("name=" + idName); writer.WriteLine("adjective=" + idAdj); } writer.WriteLine("}"); } } }
public static void output(FactionsInfo factionsObj) { List <CK2Character> owners = factionsObj.getOwners(); List <FactionInfo> factions = factionsObj.getFactions(); Dictionary <string, HashSet <CK2Character> > charactersToOutput = new Dictionary <string, HashSet <CK2Character> >(); foreach (FactionInfo faction in factions) { if (!faction.getExists()) { continue; } CK2Character owner = faction.getOwner(); HashSet <int> writtenCharacters = new HashSet <int>(); selectCharacter(writtenCharacters, owner, charactersToOutput); } foreach (var pair in charactersToOutput) { string filename = ImportantPaths.getOutputPath() + "\\history\\characters\\" + pair.Key + ".txt"; HashSet <CK2Character> characters = pair.Value; using (StreamWriter writer = File.CreateText(filename)) { foreach (CK2Character character in characters) { writeCharacter(writer, character); } } } }
public static void outputCountyHistory(FactionsInfo factions) { string outputDir = ImportantPaths.getOutputPath() + "\\history\\titles"; string countyAcquireDate = "767.1.1"; foreach (FactionInfo faction in factions.getFactions()) { if (!faction.getExists() || faction.getCK2Title() == null) { continue; } HashSet <String> counties = faction.getOwnedCounties(); foreach (String countyStr in counties) { using (StreamWriter writer = File.CreateText(outputDir + "\\" + countyStr + ".txt")) { writer.WriteLine(countyAcquireDate + "={"); writer.WriteLine("\tholder=" + faction.getOwner().getID()); //if (faction.getOwner().getName() == "Giesmus") { // int h = 0; //} writer.WriteLine("}"); } } } }
public void readFactionColor(ImportantPaths importantPaths) { string savegameFactionPath = importantPaths.getSavegameXMLPath() + "\\factions\\" + this.id + ".xml"; XmlDocument doc = new XmlDocument(); try { doc.Load(savegameFactionPath); } 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 == "FACTION_FLAG_AND_COLOURS") { XmlNode redNode = node.FirstChild.NextSibling; XmlNode greenNode = redNode.NextSibling; XmlNode blueNode = greenNode.NextSibling; int red = Int32.Parse(redNode.InnerText); int green = Int32.Parse(greenNode.InnerText); int blue = Int32.Parse(blueNode.InnerText); this.color = Color.FromArgb(red, green, blue); return; } } }
public static void outputProvinceSpecific(AttilaRegionsInfo attilaRegions) { string outputPath = ImportantPaths.getOutputPath() + "\\common\\cultures\\specialProvCultures.txt"; List <AttilaRegionInfo> regions = attilaRegions.getList(); using (StreamWriter writer = File.CreateText(outputPath)) { writer.WriteLine("iberian = {"); writer.WriteLine("\tgraphical_cultures = { occitangfx }"); writer.WriteLine("\t"); Random rand = new Random(); foreach (AttilaRegionInfo region in regions) { writer.WriteLine("\t" + region.getIDStr() + " = {"); writer.WriteLine("\t\tgraphical_cultures = { southerngfx }"); writer.WriteLine("\t\tsecondary_event_pictures = bedouin_arabic"); writer.WriteLine("\t\t"); double r = (rand.Next(0, 100)) / 100.0; double g = (rand.Next(0, 100)) / 100.0; double b = (rand.Next(0, 100)) / 100.0; writer.WriteLine("\t\tcolor = { " + r + " " + g + " " + b + " }"); writer.WriteLine("\t\t"); writer.WriteLine("\t\tmale_names = { Placeholder }"); writer.WriteLine("\t\tfemale_names = { Placeholder }"); writer.WriteLine("\t\t"); writer.WriteLine("\t\tmodifier = default_culture_modifier"); writer.WriteLine("\t}"); } writer.WriteLine("}"); } }
public RegionMapper() { regionsMap = new Dictionary <string, string[]>(); alteredRegions = new List <string>(); string converterInfo = ImportantPaths.conversionInfoPath(); string regionMapFile = converterInfo + "\\region\\regionsMap.csv"; using (var regionsMapReader = new StreamReader(regionMapFile)) { while (!regionsMapReader.EndOfStream) { string[] kvPair = regionsMapReader.ReadLine().Split(','); string key = kvPair[0]; string[] values = kvPair[1].Split(';'); regionsMap.Add(key, values); alteredRegions.AddRange(values); } } alteredRegions.Sort(); /*for (int i = 0; i < alteredRegions.Count - 1; i++) { * if (alteredRegions[i] == alteredRegions[i + 1]) { * bool trouble = true; * } * }*/ }
public AttilaRegionsInfo(ImportantPaths importantPaths, RegionMapper map, FactionsInfo factions) { this.importantPaths = importantPaths; getRegionXMLInfo(map, factions); AttilaRegionsInfoComparer attilaComp = new AttilaRegionsInfoComparer(); attilaRegionMappings.Sort(attilaComp); }
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(); }
public CharInfoCreator(ImportantPaths importantPaths, DateConverter dtConverter, ReligionsInfo religions) { esfID2Job = new Dictionary <int, string>(); faction2ReligionMap = new Dictionary <string, string>(); faction2CultureMap = buildCultureMap(); List <Tuple <String, String> > charXMLLocs = getCharXMLLocs(importantPaths, religions); nameIDMap = generateNameIDMap(); charInfo = generateCharInfo(importantPaths, charXMLLocs, dtConverter); }
private void readGovernmentInfo(ImportantPaths paths, string loc) { string govPath = paths.getSavegameXMLPath() + "\\" + loc; XmlDocument doc = new XmlDocument(); try { doc.Load(govPath); } 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 == "CHARACTER_POSTS") { for (XmlNode charPostContainer = node.FirstChild; charPostContainer != null; charPostContainer = charPostContainer.NextSibling) { for (XmlNode charPost = charPostContainer.FirstChild; charPost != null; charPost = charPost.NextSibling) { if (charPost.Name != "rec") { continue; } int pos = 0; string office = ""; int esfID = 0; for (XmlNode charPostPos = charPost.FirstChild; charPostPos != null; charPostPos = charPostPos.NextSibling) { if (pos == 1) { office = charPostPos.InnerText; } else if (pos == 2) { esfID = Int32.Parse(charPostPos.InnerText); } pos++; } if (esfID != 0) { esfID2Job.Add(esfID, office); } } } } } }
public static void move() { string searchDir = ImportantPaths.conversionInfoPath() + "\\cultures\\cultureFiles"; string destDir = ImportantPaths.getOutputPath() + "\\common\\cultures"; string[] searchFiles = Directory.GetFiles(searchDir, "*.txt"); foreach (string searchFile in searchFiles) { string absoluteFilename = Path.GetFileName(searchFile); string destFile = destDir + "\\" + absoluteFilename; File.Copy(searchFile, destFile, true); } }
public static void output(FamilyTrees trees) { List <CK2Dynasty> dynasties = trees.getDynasties(); string filename = ImportantPaths.getOutputPath() + "\\common\\dynasties\\attila_dynasties.txt"; using (StreamWriter writer = File.CreateText(filename)) { foreach (CK2Dynasty dynasty in dynasties) { int id = dynasty.getID(); string name = dynasty.getName(); writeDynasty(writer, id, name); } } }
public ReligionsInfo() { religions = new Dictionary <string, ReligionInfo>(); string converterInfo = ImportantPaths.conversionInfoPath(); string religionFile = converterInfo + "\\religion\\religions.csv"; using (var religionsReader = new StreamReader(@religionFile)) { while (!religionsReader.EndOfStream) { ReligionInfo religion = new ReligionInfo(religionsReader.ReadLine()); religions.Add(religion.getAttilaName(), religion); } } }
public void readFactionNumID(ImportantPaths importantPaths) { string savegameFactionPath = importantPaths.getSavegameXMLPath() + "\\factions\\" + this.id + ".xml"; XmlDocument doc = new XmlDocument(); try { doc.Load(savegameFactionPath); } catch (Exception) { return; } XmlNode root = doc.DocumentElement; this.numID = Int32.Parse(root.FirstChild.FirstChild.InnerText); }
public CK2CountyRegionsInfo(RegionMapper map) { counties = new Dictionary <string, CK2CountyRegionInfo>(); string provinceHistoryPath = ImportantPaths.conversionInfoPath() + "\\region\\provinceHistory"; string[] histories = Directory.GetFiles(provinceHistoryPath); foreach (string historyPath in histories) { CK2CountyRegionInfo county = new CK2CountyRegionInfo(map, historyPath); if (county.countyShallBeAltered()) { counties.Add(county.getID(), county); } } }
private Dictionary <String, String> generateNameIDMap() { string nameMapFile = ImportantPaths.conversionInfoPath() + "\\characters\\namesMap.csv"; Dictionary <String, String> nameIDMap = new Dictionary <String, String>(); using (var nameMapReader = new StreamReader(nameMapFile)) { while (!nameMapReader.EndOfStream) { var line = nameMapReader.ReadLine(); var lineValues = line.Split(','); nameIDMap.Add(lineValues[0], lineValues[1]); } } return(nameIDMap); }
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"); } }
private Dictionary <string, string> buildCultureMap() { Dictionary <string, string> map = new Dictionary <string, string>(); string cultureMapFilename = ImportantPaths.conversionInfoPath() + "\\cultures\\factionCultureMap.csv"; using (var cultureMapReader = new StreamReader(cultureMapFilename)) { while (!cultureMapReader.EndOfStream) { string[] pair = cultureMapReader.ReadLine().Split(','); string faction = pair[0]; string culture = pair[1]; map.Add(faction, culture); } } return(map); }
public static void outputv1History(CK2CountyRegionsInfo ck2Regions) { Dictionary <string, CK2CountyRegionInfo> counties = ck2Regions.getCountiesMap(); string outputDir = ImportantPaths.getOutputPath() + "\\history\\titles"; foreach (var countyPair in counties) { string countyStr = countyPair.Key; int luckyGuy = 157600001; using (StreamWriter writer = File.CreateText(outputDir + "\\" + countyStr + ".txt")) { writer.WriteLine("767.1.1={"); writer.WriteLine("\tholder=" + luckyGuy); writer.WriteLine("}"); } } }
public static void outputDeJure(DeJureTitles titles) { string outputPath = ImportantPaths.getOutputPath() + "\\common\\landed_titles\\newDeJureTitles.txt"; List <DeJureKingdom> kingdoms = titles.getTitles(); using (StreamWriter writer = File.CreateText(outputPath)) { foreach (DeJureKingdom kingdom in kingdoms) { writeDeJureKingdomInfo(writer, kingdom); List <DeJureDuchy> duchies = kingdom.getDuchies(); foreach (DeJureDuchy duchy in duchies) { writeDeJureDuchyInfo(writer, duchy); } } } }
public static void output(FactionsInfo factionsInfo) { string outputFile = ImportantPaths.getOutputPath() + "\\localisation\\newTitles.csv"; using (StreamWriter writer = File.CreateText(outputFile)) { writer.WriteLine(LocalisationFormatter.header()); foreach (FactionInfo faction in factionsInfo.getFactions()) { if (faction.getCK2Title() == null) { continue; } outputNames(writer, faction); outputAdjectives(writer, faction); } } }
public static void outputDeJure(DeJureTitles titles) { string outputFile = ImportantPaths.getOutputPath() + "\\localisation\\newDeJureTitles.csv"; List <DeJureKingdom> kingdoms = titles.getTitles(); using (StreamWriter writer = File.CreateText(outputFile)) { foreach (DeJureKingdom kingdom in kingdoms) { outputDeJureInfo(writer, true, kingdom.getName(), kingdom.getScreenName(), kingdom.getScreenName()); List <DeJureDuchy> duchies = kingdom.getDuchies(); foreach (DeJureDuchy duchy in duchies) { outputDeJureInfo(writer, false, duchy.getName(), duchy.getScreenName(), duchy.getScreenName()); } } } }
public AttilaRegionInfo(ImportantPaths importantPaths, string regionXML, RegionMapper map, FactionsInfo factions) { this.importantPaths = importantPaths; idNum = 0; idStr = ""; burned = true; religionBreakdown = new List <Tuple <string, double> >(); ck2Regions = new List <String>(); readRegionXML(regionXML, factions); readPopulation(); strongestReligion = this.deriveMostPowerfulReligion(); string[] foundCK2regions = map.getCK2Regions(idStr); if (foundCK2regions != null) { foreach (string region in foundCK2regions) { ck2Regions.Add(region); } } }
public static void outputCultureGroups(CultureMaps maps) { string outputFile = ImportantPaths.getOutputPath() + "\\localisation\\newGroupCultures.csv"; using (StreamWriter writer = File.CreateText(outputFile)) { writer.WriteLine(LocalisationFormatter.header()); foreach (var pair in maps.getCultureGroupMaps()) { string id = pair.Key; string english = ""; if (pair.Value.Count > 0) { english = pair.Value[0]; } string line = LocalisationFormatter.format(id, english); writer.WriteLine(line); } } }
public void readCultureMaps() { cultureMaps = new Dictionary <string, List <string> >(); string converterInfo = ImportantPaths.conversionInfoPath(); string CMFile = converterInfo + "\\cultures\\cultureNameMap.csv"; using (var CGReader = new StreamReader(CMFile)) { while (!CGReader.EndOfStream) { string[] items = CGReader.ReadLine().Split(','); string cultureTag = items[0]; List <String> localisation = new List <string>(); for (int i = 1; i < items.Length; i++) { localisation.Add(items[i]); } cultureGroupMaps.Add(cultureTag, localisation); } } }
private List <Tuple <string, string, bool> > readFactionCK2Equivalent() { string conversionInfoPath = ImportantPaths.conversionInfoPath(); string factionEquivalentsPath = conversionInfoPath + "\\factions\\ck2Titles\\titlesFactionMap.csv"; List <Tuple <string, string, bool> > factionEquivalents = new List <Tuple <string, string, bool> >(); using (var factionEquivalentsReader = new StreamReader(@factionEquivalentsPath)) { while (!factionEquivalentsReader.EndOfStream) { var line = factionEquivalentsReader.ReadLine(); var lineValues = line.Split(','); string faction = lineValues[0]; string ck2Title = lineValues[1]; bool isNewTitle = (Int32.Parse(lineValues[2]) == 1); Tuple <string, string, bool> mapping = Tuple.Create <string, string, bool>(faction, ck2Title, isNewTitle); factionEquivalents.Add(mapping); } } return(factionEquivalents); }
private void searchForFactionDynasty() { string conversionInfoPath = ImportantPaths.conversionInfoPath(); string factionDynastiesPath = conversionInfoPath + "\\factions\\ck2Titles\\titlesDynastiesMap.csv"; using (var factionDynastiesReader = new StreamReader(@factionDynastiesPath)) { while (!factionDynastiesReader.EndOfStream) { var line = factionDynastiesReader.ReadLine(); var lineValues = line.Split(','); string faction = lineValues[0]; string dynastyStr = lineValues[1]; if (faction == id) { CK2Dynasty dynasty = new CK2Dynasty(dynastyStr); this.dynasty = dynasty; } } } }
public ProjectSettingsReader() { string settingsLoc = ImportantPaths.conversionInfoPath() + "\\settings.xml"; XmlDocument doc = new XmlDocument(); try { doc.Load(settingsLoc); } catch (Exception) { return; } XmlNode root = doc.DocumentElement; for (XmlNode node = root.FirstChild; node != null; node = node.NextSibling) { if (node.Name == "savegameXMLLocation") { this.savegameXMLLocation = node.InnerText; } } }
private static int deriveFirstDynastyID() { string settingsLoc = ImportantPaths.conversionInfoPath() + "\\settings.xml"; XmlDocument doc = new XmlDocument(); try { doc.Load(settingsLoc); } catch (Exception) { return(1000001); } XmlNode root = doc.DocumentElement; for (XmlNode node = root.FirstChild; node != null; node = node.NextSibling) { if (node.Name == "firstDynastyID") { return(Int32.Parse(node.InnerText)); } } return(1000001); }
private List <Tuple <string, string> > readFactionAdjectives() { string conversionInfoPath = ImportantPaths.conversionInfoPath(); string factionAdjectivesPath = conversionInfoPath + "\\factions\\faction_adjectives.csv"; List <Tuple <string, string> > factionAdjectives = new List <Tuple <string, string> >(); using (var factionAdjectivesReader = new StreamReader(@factionAdjectivesPath)) { while (!factionAdjectivesReader.EndOfStream) { var line = factionAdjectivesReader.ReadLine(); var lineValues = line.Split(','); string a = lineValues[0]; //att_fact_* if (a.Substring(0, 3) != "att") { continue; } string b = lineValues[1]; //Adjective Tuple <string, string> mapping = Tuple.Create <string, string>(a, b); factionAdjectives.Add(mapping); } } return(factionAdjectives); }