Ejemplo n.º 1
0
        public Vic2Religion AddReligion(string name, Eu4Save save)
        {
            var religion = new Vic2Religion(name, save);

            Religions.Add(religion);
            return(religion);
        }
Ejemplo n.º 2
0
        public Vic2World(Eu4Save eu4Save, bool keepStartDate)
        {
            KeepStartDate   = keepStartDate;
            Eu4Save         = eu4Save;
            ReligiousGroups = new Dictionary <string, Vic2ReligionGroup>();
            V2Mapper        = new Mapper(this);
            ProvMapper      = new ProvinceMapper("province_mappings.txt");
            LoadProvinceMap();
            LoadVanillaLocalisation();
            LoadLocalisationHelper();
            LoadEffects();
            LoadFactories();
            LoadPoliticalParties();
            LoadVicTech();
            LoadVicReligion();
            LoadVicCulture();
            LoadVicPopData();
            LoadExistingCountries();

            Console.WriteLine("Constructing Vic2 world...");
            GenerateCountries();
            GeneratePrimaryNations();
            GenerateProvinces();
            FindCultureCentres();
            PostInitProvinces();
            GenerateRelations();


            CreateModFiles();

            Console.WriteLine("Done!");
        }
Ejemplo n.º 3
0
        public Vic2Religion(string name, Eu4Save eu4)
        {
            Name = name;
            var eu4Religion = eu4.Religions[name];

            DisplayName = eu4Religion.DisplayName;
            Colour      = eu4Religion.Colour;
        }
Ejemplo n.º 4
0
        public Eu4DiploRelation(PdxSublist data, Eu4Save save)
        {
            Type   = (Relation)Enum.Parse(typeof(Relation), data.Key);
            First  = save.Countries[data.GetString("first")];
            Second = save.Countries[data.GetString("second")];

            if (Type == Relation.dependency)
            {
                SubjectType = data.GetString("subject_type");
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var keepStartDate = !args.Contains("1836");
            //TGAWriter.WriteTricolourTGA("test.tga", new Colour(0, 85, 164), new Colour(255, 255, 255), new Colour(239, 65, 53));

            var save = new Eu4Save("Grindia.eu4", @"C:\Users\Blake\Documents\Paradox Interactive\Europa Universalis IV\mod\converter_test");

            //Console.WriteLine(save.RootList);
            var V2World = new Vic2World(save, keepStartDate);


            Console.Read();
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
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!");
            }
        }
Ejemplo n.º 8
0
        private void CreateCountryFiles()
        {
            //common
            Console.WriteLine("Creating country files...");
            var vanillaCtry = PdxSublist.ReadFile(Path.Combine(VIC2_DIR, @"common\countries.txt"));
            var txt         = Path.Combine(OUTPUT, @"common\countries.txt");

            using (var txtFile = File.CreateText(txt))
            {
                foreach (var country in Vic2Countries)
                {
                    txtFile.WriteLine($"{country.CountryTag} = \"countries/{country.CountryTag}.txt\"");
                }
                txtFile.WriteLine("# From vanilla");
                foreach (var ctry in vanillaCtry.KeyValuePairs)
                {
                    var genCtry = Vic2Countries.Find(c => c.CountryTag == ctry.Key);
                    if (genCtry == null)
                    {
                        txtFile.WriteLine($"{ctry.Key} = \"{ctry.Value}\"");
                    }
                }
            }


            var dir       = Directory.CreateDirectory(Path.Combine(OUTPUT, @"common\countries"));
            var histDir   = Directory.CreateDirectory(Path.Combine(OUTPUT, @"history\countries"));
            var flagDir   = Directory.CreateDirectory(Path.Combine(OUTPUT, @"gfx\flags"));
            var eu4Flags  = Eu4Save.GetFilesFor(@"gfx\flags");
            var vic2Flags = Directory.GetFiles(Path.Combine(VIC2_DIR, @"gfx\flags"));
            var suffixes  = new string[] { "", "communist", "fascist", "monarchy", "republic" };

            foreach (var country in Vic2Countries)
            {
                //common\countries
                using (var file = File.CreateText(Path.Combine(dir.FullName, $"{country.CountryTag}.txt")))
                {
                    country.GetCommonCountryFile().WriteToFile(file);
                }
                //history\countries
                using (var file = File.CreateText(Path.Combine(histDir.FullName, $"{country.CountryTag}.txt")))
                {
                    country.GetHistoryCountryFile(this).WriteToFile(file);
                }
                if (country.CountryTag == "GRA")
                {
                    Console.WriteLine();
                }
                if (vic2Flags.FirstOrDefault(f => Path.GetFileName(f).StartsWith(country.CountryTag)) == null)
                {
                    var eu4Flag = eu4Flags.Find(f => Path.GetFileName(f).StartsWith(country.Eu4Country?.CountryTag ?? "!"));
                    foreach (var suff in suffixes)
                    {
                        var name = country.CountryTag + (suff == string.Empty ? string.Empty : $"_{suff}");
                        if (eu4Flag == null)
                        {
                            country.CreateFlag(Path.Combine(flagDir.FullName, $"{name}.tga"), suff);
                        }
                        else
                        {
                            File.Copy(eu4Flag, Path.Combine(flagDir.FullName, $"{name}.tga"));
                        }
                    }
                }
            }
        }