예제 #1
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()]);
            }
        }
예제 #2
0
        public Vic2DiploRelation(Eu4DiploRelation eu4, Vic2World world)
        {
            World = world;
            Type  = V2Relation.invalid;
            switch (eu4.Type)
            {
            case Relation.alliance:
                Type = V2Relation.alliance;
                break;

            case Relation.dependency:
                if (eu4.SubjectType == "vassal")
                {
                    Type = V2Relation.vassal;
                }
                break;
            }
            First  = world.GetCountry(eu4.First);
            Second = world.GetCountry(eu4.Second);
        }
예제 #3
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;
                }
            }
        }