public void updateDynasty(CK2Dynasty newDynasty, CK2Character character, bool canOverwrite) { associatedDynasties.Add(newDynasty); HashSet <int> processed = new HashSet <int>(); updateDynastyForCharacter(character, newDynasty, canOverwrite, processed); }
private void updateDynastyForCharacter(CK2Character character, CK2Dynasty newDynasty, bool canOverwrite, HashSet <int> processed) { bool hasChar = !(processed.Add(character.getFamilyTreeID())); if (hasChar) { return; } if (character.getDynasty() == null || canOverwrite) { character.setDynasty(newDynasty); } CK2Character father = character.getFather(); if (father != null) { //CK2Dynasty fatherDynasty = father.getDynasty(); //if (fatherDynasty == null || fatherDynasty.getID() != newDynasty.getID()) updateDynastyForCharacter(father, newDynasty, canOverwrite, processed); } List <CK2Character> children = character.getChildren(); if (children != null) { foreach (CK2Character child in children) { //CK2Dynasty childDynasty = child.getDynasty(); //if (childDynasty == null || childDynasty.getID() != newDynasty.getID()) updateDynastyForCharacter(child, newDynasty, canOverwrite, processed); } } }
public void readFamilyTrees(FamilyTrees trees) { foreach (FactionInfo faction in factionPreProcessMappings) { CK2Character character = new CK2Character(); FamilyTree tree = trees.getTree(faction.getID()); if (tree != null) { character = tree.getOwner(); } CK2Dynasty dynasty = new CK2Dynasty(); if (faction.getDynasty() != null) { dynasty = faction.getDynasty(); if (tree != null) { tree.updateDynasty(dynasty, character, true); } } else { if (tree != null) { dynasty = tree.getDynasty(); } faction.setDynasty(dynasty); } //character.setDynasty(dynasty); faction.setOwner(character); } }
private CK2Dynasty deriveDynasty(CK2Character character) { CK2Character curChar = character; while (curChar.getFather() != null) { curChar = curChar.getFather(); } CK2Dynasty dynasty = new CK2Dynasty(curChar.getName()); return(dynasty); }
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); }
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 void updateSpouses(CK2Character character, HashSet <int> processed, List <List <string> > esfFamilyTreeStructure) { bool hasChar = !(processed.Add(character.getID())); if (hasChar) { return; } CK2Character spouse = character.getSpouse(); if (character.getSpouse() != null) { CK2Dynasty spouseDynasty = character.getSpouse().getDynasty(); if (spouseDynasty == null) { discoverTree(spouse, fam2Char, esfFamilyTreeStructure); spouseDynasty = this.deriveDynasty(spouse); associatedDynasties.Add(spouseDynasty); updateDynasty(spouseDynasty, spouse, false); updateReligion(spouse, false); updateCulture(spouse, false); } } CK2Character father = character.getFather(); if (father != null) { updateSpouses(father, processed, esfFamilyTreeStructure); } List <CK2Character> children = character.getChildren(); if (children != null) { foreach (CK2Character child in children) { updateSpouses(child, processed, esfFamilyTreeStructure); } } }
private static void writeCharacter(StreamWriter writer, CK2Character character) { CK2Dynasty dynasty = character.getDynasty(); int dynastyID = 0; if (dynasty != null) { dynastyID = dynasty.getID(); } string name = character.getName(); int charID = character.getID(); int dob = character.getBirthDay(); int mob = character.getBirthMonth(); int yob = character.getBirthYear(); writer.WriteLine(charID + " = {"); writer.WriteLine("\tname=\"" + name + "\""); if (dynastyID != 0) { writer.WriteLine("\tdynasty=" + dynastyID); } else { writer.WriteLine("\tdynasty=" + "NONE"); } writer.WriteLine("\treligion=\"" + character.getReligion() + "\""); writer.WriteLine("\tculture=\"" + character.getCulture() + "\""); if (character.getIsMale() == false) { writer.WriteLine("\tfemale=yes"); } if (character.getIsBastard()) { writer.WriteLine("\tadd_trait=\"bastard\""); } if (character.getFather() != null) { writer.WriteLine("\tfather=" + character.getFather().getID()); } writer.WriteLine("\t" + yob + "." + mob + "." + dob + "={"); writer.WriteLine("\t\tbirth=yes"); writer.WriteLine("\t}"); if (character.getSpouse() != null) { DateTime maxBirthDT = maxBirth(character.getBirth(), character.getSpouse().getBirth()); int yom = maxBirthDT.Year; int mom = maxBirthDT.Month + 1; int dom = maxBirthDT.Day + 1; writer.WriteLine("\t" + yom + "." + mom + "." + dom + "={"); writer.WriteLine("\t\tadd_spouse=" + character.getSpouse().getID()); writer.WriteLine("\t}"); } if (character.getAlive() == false) { int dod = character.getDeathDay(); int mod = character.getDeathMonth(); int yod = character.getDeathYear(); writer.WriteLine("\t" + yod + "." + mod + "." + dod + "={"); writer.WriteLine("\t\tdeath=yes"); writer.WriteLine("\t}"); } writer.WriteLine("}"); }
public void setDynasty(CK2Dynasty dynasty) { this.dynasty = dynasty; }