Ejemplo n.º 1
0
 public PopPool(Vic2World world, Vic2Province province)
 {
     World         = world;
     pops          = new Dictionary <string, Pop>();
     this.province = province;
     //culture = new Dictionary<Eu4Province, ValueSet<string>>();
     //religion = new Dictionary<Eu4Province, ValueSet<string>>();
     //foreach (var prov in eu4Provinces)
     //{
     //	culture[prov] = HistoryEffect(prov.CulturalHistory);
     //	religion[prov] = HistoryEffect(prov.ReligiousHistory);
     //}
 }
Ejemplo n.º 2
0
        public string GetV2Culture(string eu4Culture, Eu4ProvinceBase prov, Vic2Province vProv)
        {
            var culture = Map(Culture, eu4Culture);

            if (prov != null)
            {
                Vic2CultureGroup group = null;
                if (World.Cultures.ContainsKey(culture))
                {
                    group = World.Cultures[culture].Group;
                }
                else if (World.CultureGroups.ContainsKey(culture))
                {
                    group = World.CultureGroups[culture];
                }
                else
                {
                    group = new Vic2CultureGroup(World.Eu4Save.Cultures[eu4Culture].Group, World);
                }
                var dist = group.GetDistance(vProv);
                if (dist > 20)                 //diff cul, same group

                // different cultures for off colonies
                {
                    var neoEu4Culture = $"{eu4Culture}:{prov.Continent.Name}";
                    var neoCulture    = Map(Culture, neoEu4Culture);
                    if (neoCulture == null)
                    {
                        // todo: fix what this will do to nations on borders between continents such as the ottomans
                        neoCulture = World.GenerateCulture(eu4Culture, culture + '_' + prov.Continent.Name + 'n', World.Eu4Save.Localisation[prov.Continent.Name], true);

                        NeoCultures[neoCulture] = culture;
                        Culture.Add(neoEu4Culture, neoCulture);
                    }
                    return(neoCulture);
                }
            }

            if (culture == null || !World.Cultures.ContainsKey(culture))
            {
                culture = World.GenerateCulture(eu4Culture, culture);
                if (!Culture.ContainsKey(eu4Culture))
                {
                    Culture.Add(eu4Culture, culture);
                }
            }
            return(culture);
        }
Ejemplo n.º 3
0
        internal PdxSublist GetData(Vic2Province province)
        {
            var data = new PdxSublist(null, province.ProvID.ToString());

            foreach (var pop in Pops)
            {
                var job = pop.Job;
                if (province.Factories.Count == 0 && (job == "craftsmen" || job == "clerks"))
                {
                    job = "artisans";
                }
                var popData = new PdxSublist(data, job);
                popData.AddValue("culture", pop.Culture);
                popData.AddValue("religion", pop.Religion);
                popData.AddValue("size", pop.Size.ToString());
                data.AddSublist(pop.Job, popData);
            }
            return(data);
        }
Ejemplo n.º 4
0
        internal double GetDistance(Vic2Province prov, Eu4Religion religion)
        {
            //var religion = myReligion ?? prov.MajorityReligion;
            var dx   = prov.MapPosition.X - Centre.MapPosition.X;
            var dy   = prov.MapPosition.Y - Centre.MapPosition.Y;
            var dist = Math.Sqrt(dx * dx + dy * dy) / 100;

            if (religion != Centre.MajorityReligion)
            {
                dist += 5;
            }
            if (religion.Group != Centre.MajorityReligion.Group)
            {
                dist += 10;
            }
            if (prov.Owner != Centre.Owner)
            {
                dist += 5;
            }

            return(dist);
        }
Ejemplo n.º 5
0
 internal double GetDistance(Vic2Province prov)
 {
     return(GetDistance(prov, prov.MajorityReligion));
 }
Ejemplo n.º 6
0
        internal void FindCentre()
        {
            var    mainReligions = World.Vic2Provinces.SelectMany(p => p.Eu4Provinces).Where(p => DoesMap(p.Culture)).GroupBy(p => p.Religion).OrderByDescending(g => g.Sum(p => p.Development));
            string mainReligion  = null;

            // if a religion is more than 50% of the dev it's the main one
            if (mainReligions.Count() != 0 && mainReligions.First().Sum(p => p.Development) * 2 > mainReligions.Sum(g => g.Sum(p => p.Development)))
            {
                mainReligion = mainReligions.First().First().Religion;
            }

            var x   = 0f;
            var y   = 0f;
            var sum = 0f;

            foreach (var prov in World.Vic2Provinces)
            {
                if (prov.Eu4Provinces.Count == 0)
                {
                    continue;
                }

                var weight = prov.Eu4Provinces.Sum(p =>
                {
                    var pWeight = 0f;
                    if (DoesMap(p.Culture))
                    {
                        pWeight += 5;
                    }
                    if (DoesMap(p.OriginalCulture))
                    {
                        pWeight += 2.5f;
                    }
                    if (mainReligion != null && p.Religion == mainReligion)
                    {
                        pWeight += 1;
                    }


                    return(pWeight);
                }) / prov.Eu4Provinces.Count;

                x   += weight * prov.MapPosition.X;
                y   += weight * prov.MapPosition.Y;
                sum += weight;
            }
            x /= sum;
            y /= sum;

            Vic2Province closest   = null;
            var          closeDist = int.MaxValue;

            foreach (var prov in World.Vic2Provinces)
            {
                var dx   = prov.MapPosition.X - (int)x;
                var dy   = prov.MapPosition.Y - (int)y;
                var dist = dx * dx + dy * dy;
                if (closest == null || closeDist > dist)
                {
                    closest   = prov;
                    closeDist = dist;
                }
            }

            Console.WriteLine($"The centre of {Name} culture is {closest.FileName}");
            Centre = closest;
        }