Ejemplo n.º 1
0
 public void SetupUnionNation(Vic2World world)
 {
     if (world.CultureNations.GetSublist("union").KeyValuePairs.ContainsKey(Name))
     {
         var tag = world.CultureNations.GetSublist("union").GetString(Name);
         Union = world.Vic2Countries.Find(c => c.CountryTag == tag) ?? new Vic2Country(world, tag, this);
     }
     else if (unionKey != null)
     {
         Union = new Vic2Country(world, unionKey, this);
     }
 }
Ejemplo n.º 2
0
        private void IterateEffects(Vic2World vic2World, PdxSublist provEffects, int siblingProvinces, List <Eu4ProvinceBase> eu4Provinces, Action <Dictionary <string, float>, Eu4ProvinceBase> callback)
        {
            foreach (var prov in eu4Provinces)
            {
                Action <Dictionary <string, float> > newCallback = (Dictionary <string, float> effects) =>
                {
                    callback(effects, prov);
                };
                // development
                vic2World.ValueEffect(provEffects, newCallback, "base_tax", prov.BaseTax / (float)siblingProvinces);
                vic2World.ValueEffect(provEffects, newCallback, "base_production", prov.BaseProduction / (float)siblingProvinces);
                vic2World.ValueEffect(provEffects, newCallback, "base_manpower", prov.BaseManpower / (float)siblingProvinces);
                // total dev
                vic2World.ValueEffect(provEffects, newCallback, "development", (prov.BaseTax + prov.BaseProduction + prov.BaseManpower) / (float)siblingProvinces);

                // estates
                if (prov.Estate != null && provEffects.Sublists["estate"].Sublists.ContainsKey(prov.Estate))
                {
                    newCallback(provEffects.Sublists["estate"].Sublists[prov.Estate].FloatValues.ToDictionary(effect => effect.Key, effect => effect.Value.Sum() / eu4Provinces.Count));
                }


                // province flags
                if (provEffects.Sublists.ContainsKey("province_flags") && prov.Flags != null)
                {
                    foreach (var flag in prov.Flags)
                    {
                        if (provEffects.Sublists["province_flags"].Sublists.ContainsKey(flag))
                        {
                            newCallback(provEffects.Sublists["province_flags"].Sublists[flag].FloatValues.ToDictionary(effect => effect.Key, effect => effect.Value.Sum() / eu4Provinces.Count));
                        }
                    }
                }

                // buildings
                if (provEffects.Sublists.ContainsKey("buildings"))
                {
                    foreach (var build in prov.Buildings)
                    {
                        if (provEffects.Sublists["buildings"].Sublists.ContainsKey(build))
                        {
                            newCallback(provEffects.Sublists["buildings"].Sublists[build].FloatValues.ToDictionary(effect => effect.Key, effect => effect.Value.Sum() / eu4Provinces.Count));
                        }
                    }
                }
                // from owner country
                if (prov.Owner != null && provEffects.Sublists.ContainsKey("owner"))
                {
                    Vic2Country.IterateCountryEffects(vic2World, prov.Owner, provEffects.Sublists["owner"], (effects) => { callback(effects, null); });
                }
            }
        }
Ejemplo n.º 3
0
        private void GenerateCountries()
        {
            Console.WriteLine("Creating Vic2 countries...");
            Vic2Countries = new List <Vic2Country>();
            foreach (var eu4Country in Eu4Save.Countries.Values)
            {
                //if more than 2 instutions missing, skip
                if (eu4Country.Institutions.Count(i => !i.Value) < 3)
                {
                    var v2Country = new Vic2Country(this, eu4Country);
                    Vic2Countries.Add(v2Country);
                }
                else
                {
                    Console.WriteLine($"{eu4Country.CountryTag} has not embraced enough institutions and so will not exist in Vic2.");
                }
            }

            Console.WriteLine($"Created {Vic2Countries.Count} Vic2 countries...");
        }
Ejemplo n.º 4
0
        public void SetupPrimaryNation(Vic2World world)
        {
            if (Name == "british_north_america")
            {
                Console.WriteLine();
            }
            //if(isNeoCulture)
            //{
            //	return;
            //}
            if (world.CultureNations.GetSublist("except").Values.Contains(Name))
            {
                // this culture is blacklisted
                return;
            }
            if (world.CultureNations.GetSublist("primary").KeyValuePairs.ContainsKey(Name))
            {
                var tag = world.CultureNations.GetSublist("primary").GetString(Name);
                PrimaryNation = world.Vic2Countries.Find(c => c.CountryTag == tag) ?? new Vic2Country(world, tag, this);
            }
            else if (primaryKey != null)
            {
                PrimaryNation = world.Vic2Countries.Find(c => c.CountryTag == primaryKey) ?? new Vic2Country(world, primaryKey, this);
            }
            else if (eu4Cultures.Count == 1 && (eu4Cultures[0].PrimaryNation != null || isNeoCulture))
            {
                if (isNeoCulture)
                {
                    //find colonial nation matching the culture-region
                    PrimaryNation = world.Vic2Countries.Where(c => (c.Eu4Country?.Overlord ?? string.Empty) == PrimaryNation?.Eu4Country?.CountryTag && c.Eu4Country.IsColonialNation && world.Eu4Save.Continents.Where(cul => cul.Value == eu4Cultures[0].Continent && cul.Value.Provinces.Contains(c.Capital)).Count() != 0).FirstOrDefault();
                }
                else if (eu4Cultures[0].PrimaryNation != null)
                {
                    PrimaryNation = world.GetCountry(eu4Cultures[0].PrimaryNation) ?? new Vic2Country(world, world.V2Mapper.GetV2Country(eu4Cultures[0].PrimaryNation), this);
                }
            }
            else if (Group.Union == null && !isNeoCulture)
            {
                var tag = 'P' + world.NumCultureNations.ToString("D2");
                world.NumCultureNations++;
                PrimaryNation = new Vic2Country(world, tag, this);
            }


            if (PrimaryNation?.FemaleLeaders ?? false)
            {
                foreach (var eu4Culture in eu4Cultures)
                {
                    FirstNames.AddRange(eu4Culture.FemaleNames);
                }
            }
            if (Colour == null)
            {
                Colour = PrimaryNation?.MapColour;
                if (Colour == null)
                {
                    byte r          = 0;
                    byte g          = 0;
                    byte b          = 240;
                    byte threshhold = 8;
                    while (!isUnique(r, g, b, (byte)(threshhold * 4)))
                    {
                        r += (byte)(threshhold * 2);
                        if (r < threshhold * 2)
                        {
                            g += (byte)(threshhold * 4);


                            if (g < threshhold * 4)
                            {
                                b += (byte)(threshhold * 3);
                            }
                        }
                    }
                    Colour = new Colour(r, g, b);
                }

                if (PrimaryNation != null && PrimaryNation.MapColour == null)
                {
                    PrimaryNation.MapColour = Colour;
                }
            }
        }