コード例 #1
0
ファイル: CK2Artifact.cs プロジェクト: Dinglydell/CK2Helper
        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);
        }
コード例 #2
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);
            }
        }
コード例 #3
0
ファイル: CK2Character.cs プロジェクト: Dinglydell/CK2Helper
        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!");
            }
        }