예제 #1
0
 public Estate(PdxSublist estate)
 {
     Type      = estate.GetString("type");
     Loyalty   = estate.GetFloat("loyalty");
     Influence = estate.GetFloat("influence");
     Territory = estate.FloatValues.ContainsKey("territory") ? estate.GetFloat("territory") : 0;
 }
예제 #2
0
 public Eu4Province(Eu4World world, int ID, PdxSublist history)
 {
     this.World       = world;
     this.ProvinceID  = ID;
     Cores            = new List <Eu4CountryBase>();
     Modifiers        = new List <string>();
     LatentTradeGoods = new List <string>();
     if (history.KeyValuePairs.ContainsKey("trade_goods"))
     {
         TradeGood = history.KeyValuePairs["trade_goods"];
     }
     history.Sublists.ForEach("latent_trade_goods", (sub =>
     {
         LatentTradeGoods.AddRange(sub.Values);
     }));
     if (history.FloatValues.ContainsKey("center_of_trade"))
     {
         CentreOfTradeWeight += 0.25f * history.GetFloat("center_of_trade");
     }
     history.Sublists.ForEach("add_permanent_province_modifier", (sub) =>
     {
         var mod = sub.KeyValuePairs["name"];
         if (mod.Contains("estuary_modifier"))
         {
             CentreOfTradeWeight += 0.25f;
         }
         Modifiers.Add(mod);
     });
 }
예제 #3
0
 private float LoadFloat(PdxSublist country, string key, float deflt = 0)
 {
     if (!country.FloatValues.ContainsKey(key))
     {
         return(deflt);
     }
     return(country.GetFloat(key));
 }
예제 #4
0
        public Monarchy(PdxSublist monarchy)
        {
            ID = monarchy.Key;
            if (monarchy.KeyValuePairs.ContainsKey("min_absolutism"))
            {
                MinAbsolutism = monarchy.GetFloat("min_absolutism");
            }
            else
            {
                MinAbsolutism = 0;
            }

            if (monarchy.KeyValuePairs.ContainsKey("max_absolutism"))
            {
                MaxAbsolutism = monarchy.GetFloat("max_absolutism");
            }
            else
            {
                MaxAbsolutism = int.MaxValue;
            }
        }
예제 #5
0
        private void DoSetup(int provID, PdxSublist defaultProvince, Vic2World vic2World, int siblingProvinces, List <Eu4ProvinceBase> eu4Provinces)
        {
            World            = vic2World;
            Subfolder        = Path.GetFileName(Path.GetDirectoryName(defaultProvince.Key));
            FileName         = Path.GetFileName(defaultProvince.Key);
            Eu4Provinces     = eu4Provinces;
            ProvID           = provID;
            TradeGoods       = defaultProvince.GetString("trade_goods");
            LifeRating       = (int)defaultProvince.GetFloat("life_rating");
            Pops             = new PopPool(vic2World, this);
            Factories        = new HashSet <string>();
            SiblingProvinces = siblingProvinces;
            if (ProvID == 222)
            {
                Console.WriteLine();
            }
            var mapPos = vic2World.Vic2ProvPositions[ProvID.ToString()];
            var mapX   = mapPos.Sum(p => p.X) / mapPos.Count;
            var mapY   = mapPos.Sum(p => p.Y) / mapPos.Count;

            MapPosition = new Point(mapX, mapY);
            if (eu4Provinces.Count > 0)
            {
                // most common owner
                Owner = vic2World.GetCountry(eu4Provinces.GroupBy(p => p.Owner).OrderByDescending(grp => grp.Count())
                                             .Select(grp => grp.Key).First());
                if (Owner?.Eu4Country?.IsColonialNation ?? false)
                {
                    Owner = vic2World.GetCountry(Owner.Eu4Country.Overlord);
                }
                if (Owner != null)
                {
                    Owner.NumProvinces++;
                }
                // all countries that have full cores in any of the eu4 counterparts gets cores here
                Cores = eu4Provinces.Where(p => p.IsState).SelectMany(p => p.Cores).Select(c => vic2World.GetCountry(c)).Distinct().ToList();
                //Cores = new List<Vic2Country>();
                var r = eu4Provinces.GroupBy(p => p.Religion).OrderByDescending(g => g.Sum(p => p.Development)).First().First().Religion;
                if (r != "no_religion")
                {
                    MajorityReligion = World.Eu4Save.Religions[r];
                }

                FortLevel = eu4Provinces.Any(p => p.FortLevel > 6) ? 1 : 0;
            }
            else
            {
                Pops.ReadData(vic2World.PopData.Sublists[provID.ToString()]);
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        public Eu4Country(PdxSublist country, Eu4Save save)
        {
            World      = save;
            CountryTag = country.Key;
            Opinions   = country.GetSublist("opinion_cache").Values.Select(int.Parse).ToList();
            //Console.WriteLine($"Loading {CountryTag}...");
            if (country.KeyValuePairs.ContainsKey("name"))
            {
                DisplayNoun = country.GetString("name").Replace("\"", string.Empty);
            }
            else
            {
                DisplayNoun = save.Localisation[CountryTag];
            }
            if (country.KeyValuePairs.ContainsKey("adjective"))
            {
                DisplayAdj = country.GetString("adjective").Replace("\"", string.Empty);
            }
            else
            {
                DisplayAdj = save.Localisation[$"{CountryTag}_ADJ"];
            }

            Exists = country.Sublists.ContainsKey("owned_provinces");

            if (country.KeyValuePairs.ContainsKey("overlord"))
            {
                Overlord = country.GetString("overlord").Replace("\"", string.Empty);
            }
            Subjects = new List <string>();
            if (country.Sublists.ContainsKey("subjects"))
            {
                country.Sublists["subjects"].Values.ForEach(s =>
                {
                    Subjects.Add(s);
                });
            }
            if (country.KeyValuePairs.ContainsKey("liberty_desire"))
            {
                LibertyDesire = float.Parse(country.GetString("liberty_desire"));
            }
            if (country.KeyValuePairs.ContainsKey("colonial_parent"))
            {
                IsColonialNation = true;
            }
            States = new HashSet <Eu4Area>();
            if (country.Sublists.ContainsKey("state"))
            {
                country.Sublists.ForEach("state", stData =>
                {
                    var area = save.Areas[stData.KeyValuePairs["area"]];
                    States.Add(area);
                    area.Prosperity = stData.GetFloat("prosperity");
                    //area.Owner = this;
                });
            }

            var institutions     = country.GetSublist("institutions");
            var listInstitutions = institutions.FloatValues[string.Empty].Select(ins => ins == 1).ToList();

            Institutions = new Dictionary <string, bool>();
            for (var i = 0; i < listInstitutions.Count; i++)
            {
                Institutions.Add(INSTITUTION_NAMES[i], listInstitutions[i]);
            }
            Capital = (int)country.GetFloat("capital");
            var colours   = country.GetSublist("colors");
            var mapColour = colours.GetSublist("map_color");

            MapColour = new Colour(mapColour.FloatValues[string.Empty]);

            PrimaryCulture = country.GetString("primary_culture");

            AcceptedCultures = new List <string>();

            country.KeyValuePairs.ForEach("accepted_culture", (value) =>
            {
                AcceptedCultures.Add(value);
            });
            if (country.KeyValuePairs.ContainsKey("religion"))
            {
                Religion = country.GetString("religion");
            }
            else
            {
                Religion = (country.Sublists["history"].Sublists.Where(s => s.Value.KeyValuePairs.ContainsKey("religion")).OrderByDescending(s => PdxSublist.ParseDate(s.Key).Ticks).FirstOrDefault().Value ?? country.Sublists["history"]).GetString("religion");
            }


            GovernmentRank = (byte)country.GetFloat("government_rank");

            var tech = country.GetSublist("technology");

            AdmTech = (byte)tech.GetFloat("adm_tech");
            DipTech = (byte)tech.GetFloat("dip_tech");
            MilTech = (byte)tech.GetFloat("adm_tech");

            Estates = new List <Estate>();
            country.Sublists.ForEach("estate", (est) =>
            {
                Estates.Add(new Estate(est));
            });


            PowerProjection = LoadFloat(country, "current_power_projection");

            LastElection = country.GetDate("last_election");

            Prestige = LoadFloat(country, "prestige");

            Stability = (sbyte)country.GetFloat("stability");
            Inflation = LoadFloat(country, "inflation");


            country.GetAllMatchingSublists("loan", (loan) =>
            {
                Debt += (int)loan.GetFloat("amount");
            });

            Absolutism          = LoadFloat(country, "absolutism");
            Legitimacy          = LoadFloat(country, "legitimacy", 50);
            RepublicanTradition = LoadFloat(country, "republican_tradition", 50);
            Corruption          = LoadFloat(country, "corruption");
            Mercantilism        = LoadFloat(country, "mercantilism");

            Ideas = new Dictionary <string, byte>();
            var ideas = country.GetSublist("active_idea_groups");

            foreach (var idp in ideas.FloatValues)
            {
                Ideas.Add(idp.Key, (byte)idp.Value.Single());
            }

            Flags    = country.Sublists.ContainsKey("flags") ? country.GetSublist("flags").KeyValuePairs.Keys.ToList() : new List <string>();
            Policies = new List <string>();
            country.Sublists.ForEach("active_policy", (pol) =>
            {
                Policies.Add(pol.GetString("policy"));
            });

            Government = country.GetSublist("government").GetString("government");
            if (country.Key == "GBR")
            {
                //	Console.WriteLine(Institutions);
            }
        }
예제 #8
0
        public Eu4Province(PdxSublist province, Eu4Save save)
        {
            ProvinceID = -int.Parse(province.Key);
            if (province.KeyValuePairs.ContainsKey("owner"))
            {
                Owner = save.Countries[province.GetString("owner")];
            }
            var institutions = province.GetSublist("institutions");

            Institutions = institutions.Values.Select(ins => float.Parse(ins)).ToList();
            try
            {
                Area = save.Areas.Values.Single(a => a.Provinces.Contains(ProvinceID));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"WARNING: {ProvinceID} exists in multiple areas!");
                var areas = save.Areas.Values.Where(a => a.Provinces.Contains(ProvinceID));
                foreach (var area in areas)
                {
                    Console.WriteLine($"{ProvinceID} exists in {area.Name}");
                }
                Area = areas.Last();
            }
            IsState = Owner?.States.Contains(Area) ?? false;

            Continent = save.Continents.Values.Single(c => c.Provinces.Contains(ProvinceID));

            Cores = new List <Eu4CountryBase>();

            province.KeyValuePairs.ForEach("core", (value) =>
            {
                Cores.Add(save.Countries[value]);
            });

            Culture = province.GetString("culture");
            if (province.KeyValuePairs.ContainsKey("religion"))
            {
                Religion = province.GetString("religion");
            }
            else
            {
                // this probably happened because you messed up the conversion from ck2
                Religion = "no_religion";
            }

            var history = province.GetSublist("history");

            CulturalHistory = AddHistory(history, "culture");
            if (CulturalHistory.Count == 0)
            {
                OriginalCulture = Culture;
            }
            else
            {
                OriginalCulture = CulturalHistory.OrderBy(entry => entry.Key.Ticks).First().Value;
            }
            ReligiousHistory = AddHistory(history, "religion");

            //Culture = CulturalHistory.Last().Value;
            //Religion = ReligiousHistory.Last().Value;

            if (province.KeyValuePairs.ContainsKey("fort_level"))
            {
                FortLevel = (int)province.GetFloat("fort_level");
            }

            BaseTax        = (int)province.GetFloat("base_tax");
            BaseProduction = (int)province.GetFloat("base_production");
            BaseManpower   = (int)province.GetFloat("base_manpower");

            if (province.KeyValuePairs.ContainsKey("estate"))
            {
                Estate = Eu4Helper.Estate.EstateTypes[(int)province.GetFloat("estate")];
            }

            if (province.Sublists.ContainsKey("flags"))
            {
                Flags = province.GetSublist("flags").KeyValuePairs.Keys.ToList();
            }

            Buildings = new List <string>();
            if (province.Sublists.ContainsKey("buildings"))
            {
                foreach (var build in save.Buildings)
                {
                    if (province.Sublists["buildings"].BoolValues.ContainsKey(build) && province.Sublists["buildings"].GetBool(build))
                    {
                        Buildings.Add(build);
                    }
                }
            }

            if (ProvinceID == 233)
            {
                //Console.WriteLine("Cornwall!");
            }
        }
예제 #9
0
 public Vic2Religion(PdxSublist data)
 {
     Name   = data.Key;
     Icon   = (int)data.GetFloat("icon");
     Colour = new Colour(data.Sublists["color"].FloatValues[string.Empty], 255);
 }
예제 #10
0
 public Eu4Religion(PdxSublist data, Eu4ReligionGroup group, Eu4WorldBase world) : this(data.Key, group, world)
 {
     Colour      = new Colour(data.GetSublist("color").FloatValues[string.Empty]);
     Icon        = (int)data.GetFloat("icon");
     DisplayName = world.Localisation[data.Key];
 }