public CK2Province(int id, CK2World world, PdxSublist historyData) { World = world; ID = id; county = historyData.KeyValuePairs["title"]; _cultureHistory = new List <Dated <CK2Culture> >(); _religionHistory = new List <Dated <CK2Religion> >(); if (historyData.KeyValuePairs.ContainsKey("culture")) { _cultureHistory.Add(new Dated <CK2Culture>(new DateTime(769, 1, 1), world.CK2Cultures[historyData.KeyValuePairs["culture"]])); } if (historyData.KeyValuePairs.ContainsKey("religion")) { _religionHistory.Add(new Dated <CK2Religion>(new DateTime(769, 1, 1), world.CK2Religions[historyData.KeyValuePairs["religion"]])); } historyData.ForEachSublist((sub) => { var date = PdxSublist.ParseDate(sub.Key); if (sub.Value.KeyValuePairs.ContainsKey("religion")) { _religionHistory.Add(new Dated <CK2Religion>(date, world.CK2Religions[sub.Value.KeyValuePairs["religion"]])); } if (sub.Value.KeyValuePairs.ContainsKey("culture")) { _cultureHistory.Add(new Dated <CK2Culture>(date, world.CK2Cultures[sub.Value.KeyValuePairs["culture"]])); } }); }
public CK2Title(string name, CK2World world) { Name = name; switch (name.First()) { case 'b': Rank = TitleRank.barony; break; case 'c': Rank = TitleRank.county; break; case 'd': Rank = TitleRank.duchy; break; case 'k': Rank = TitleRank.kingdom; break; case 'e': Rank = TitleRank.empire; break; } World = world; }
public CK2Culture(PdxSublist data, CK2World world, CK2CultureGroup group) : this(data.Key, world) { Group = group; if (data.BoolValues.ContainsKey("dynasty_title_names")) { DynastyTitleNames = data.BoolValues["dynasty_title_names"].Single(); } }
public CK2Religion initFromSave(PdxSublist data, CK2World world) { HolySites = data.Sublists["holy_sites"].Values.Select(v => world.CK2Titles[v]).ToList(); if (data.Sublists.ContainsKey("features")) { Features = data.Sublists["features"].Values; } return(this); }
public CK2Culture(string name, CK2World world) { Name = name; if (world.Localisation.ContainsKey(name)) { DisplayName = world.Localisation[name]; } SubCultures = new List <CK2Culture>(); }
public CK2Artifact(CK2World world, PdxSublist data) { Owner = world.CK2Characters[(int)data.GetFloat("owner")]; Equipped = data.GetBool("equipped"); Type = data.GetString("type"); Obtained = data.GetDate("obtained"); Created = data.GetDate("obtained"); Owner.AddArtifact(this); }
public CK2Dynasty(CK2World world, PdxSublist data) { if (data.KeyValuePairs.ContainsKey("name")) { Name = data.KeyValuePairs["name"]; } if (data.KeyValuePairs.ContainsKey("culture")) { Culture = world.CK2Cultures[data.KeyValuePairs["culture"]]; } if (data.KeyValuePairs.ContainsKey("religion")) { Religion = world.CK2Religions[data.KeyValuePairs["religion"]]; } }
public CK2CharacterBase(CK2World world, PdxSublist data) { Children = new List <CK2CharacterBase>(); World = world; ID = int.Parse(data.Key); Name = data.KeyValuePairs["bn"]; FatherID = (int)GetFloat(data, "fat"); MotherID = (int)GetFloat(data, "mot"); Titles = new List <CK2Title>(); Gender = (data.BoolValues.ContainsKey("fem") && data.BoolValues["fem"].Single()) ? Gender.female : Gender.male; Artifacts = new List <CK2Artifact>(); if (data.FloatValues.ContainsKey("spouse")) { SpouseIDs = data.FloatValues["spouse"].ConvertAll(f => (int)f); } if (data.Sublists.ContainsKey("dmn")) { var dmn = data.Sublists["dmn"]; if (dmn.KeyValuePairs.ContainsKey("primary")) { PrimaryTitleID = dmn.KeyValuePairs["primary"]; } if (dmn.KeyValuePairs.ContainsKey("capital")) { CapitalID = dmn.KeyValuePairs["capital"]; } } Attribites = new AttributeSet(this, data.Sublists["att"].FloatValues[string.Empty].Select(f => (int)f).ToList()); Traits = new List <CK2Traits>(); if (data.Sublists.ContainsKey("tr")) { data.Sublists["tr"].FloatValues[string.Empty].ForEach(id => { Traits.Add(world.CK2Traits[(int)id]); }); } Modifiers = new List <string>(); data.Sublists.ForEach("md", (sub) => { Modifiers.Add(sub.KeyValuePairs["modifier"]); }); Prestige = GetFloat(data, "prs"); Piety = GetFloat(data, "piety"); if (data.KeyValuePairs.ContainsKey("gov")) { GovernmentType = data.KeyValuePairs["gov"]; } IsPlayer = false; if (data.BoolValues.ContainsKey("player") && data.BoolValues["player"].Single()) { IsPlayer = true; } if (data.FloatValues.ContainsKey("dnt")) { DynastyID = (int)data.FloatValues["dnt"].Single(); if (!world.CK2Dynasties.ContainsKey(DynastyID)) { Console.WriteLine($"Warning: No dynasty {DynastyID}"); DynastyID = 0; } } if (data.KeyValuePairs.ContainsKey("rel")) { var rel = data.KeyValuePairs["rel"]; if (rel != "noreligion") { Religion = world.CK2Religions[rel]; } } //Culture if (data.KeyValuePairs.ContainsKey("cul")) { var cul = data.KeyValuePairs["cul"]; //if (rel != "noreligion") //{ Culture = world.CK2Cultures[cul]; //} } BirthDate = data.GetDate("b_d"); if (ID == 1425122) { Console.WriteLine("Usunbike!"); } }
public CK2Title(string name, CK2World world, PdxSublist data) : this(name, world) { Laws = new HashSet <string>(); data.KeyValuePairs.ForEach("law", (law) => { Laws.Add(law); }); if (data.FloatValues.ContainsKey("capital")) { Capital = (int)(data.FloatValues["capital"].Single()); } if (data.Sublists.ContainsKey("color")) { var colour = data.GetSublist("color"); Colour = new Colour(colour.FloatValues[string.Empty]); } if (data.KeyValuePairs.ContainsKey("name")) { DisplayName = data.KeyValuePairs["name"]; } else if (world.Localisation.ContainsKey(Name)) { DisplayName = world.Localisation[Name]; } if (data.KeyValuePairs.ContainsKey("adjective")) { var adj = data.KeyValuePairs["adjective"]; DisplayAdj = world.Localisation.ContainsKey(adj) ? world.Localisation[adj] : adj; } else if (world.Localisation.ContainsKey(Name + "_adj")) { DisplayAdj = world.Localisation[Name + "_adj"]; } Succession = data.KeyValuePairs["succession"]; GenderSuccession = data.KeyValuePairs["gender"]; if (data.FloatValues.ContainsKey("holder")) { Holder = world.CK2Characters[(int)data.FloatValues["holder"].Single()]; Holder.Titles.Add(this); } if (data.KeyValuePairs.ContainsKey("liege")) { LiegeTitleID = data.KeyValuePairs["liege"]; } else if (data.Sublists.ContainsKey("liege")) { LiegeTitleID = data.Sublists["liege"].KeyValuePairs["title"]; } else { world.AddIndependentTitle(this); } if (data.KeyValuePairs.ContainsKey("de_jure_liege")) { DejureLiegeTitleID = data.KeyValuePairs["de_jure_liege"]; } if (data.BoolValues.ContainsKey("major_revolt")) { IsRevolt = data.BoolValues["major_revolt"].Single(); } }
public void FindCentre(CK2World world) { var culturedProvinces = world.CK2Provinces.Values.Where(c => c.Culture == this); if (culturedProvinces.Count() == 0) { return; } var x = 0; var y = 0; foreach (var prov in culturedProvinces) { x += prov.MapPosition.X; y += prov.MapPosition.Y; } x /= culturedProvinces.Count(); y /= culturedProvinces.Count(); CK2Province closest = null; var closeDist = int.MaxValue; foreach (var prov in culturedProvinces) { var dx = prov.MapPosition.X - x; var dy = prov.MapPosition.Y - y; var dist = dx * dx + dy * dy; if (closest == null || closeDist > dist) { closest = prov; closeDist = dist; } } RankedCentres = new Dictionary <TitleRank, CK2Title>(); SetCentreAndLieges(closest.CountyTitle); Centre = closest; //var culturedTitles = new Dictionary<CK2Title, int>(); //foreach (var prov in culturedProvinces) //{ // AddTitleCultures(culturedTitles, prov.CountyTitle); //} //Centre = culturedTitles.OrderByDescending(c => c.Value).First().Key; // //var rank = (TitleRank)((int)Centre.Rank - 1); //var liege = Centre; //if (Centre.Holder.Culture == this && Centre.Capital != 0) //{ // //something to do with things goes here //} //RankedCentres[Centre.Rank] = Centre; //while ((int)rank > (int)TitleRank.county) //{ // var centred = culturedTitles.Where(c => (c.Key.LiegeTitle == liege || c.Key.DejureLiegeTitle == liege) && c.Key.Rank == rank).OrderByDescending(c => c.Value); // if (centred.Count() != 0) // { // liege = centred.First().Key; // RankedCentres.Add(rank, liege); // } // rank = (TitleRank)((int)rank - 1); //} //if (Centre.Rank != TitleRank.county) //{ // RankedCentres[TitleRank.county] = culturedTitles.Where(c => c.Key.Rank == TitleRank.county && c.Key.LiegeTitle == RankedCentres[TitleRank.duchy]).First().Key; //} Console.WriteLine($"Centre of {Name} culture is {Centre.Name} ({string.Join(", ", RankedCentres.Values.Select(t => t.Name))})"); }