示例#1
0
    public void ImportImperatorProvinces(Imperator.World impWorld, Title.LandedTitles titles, CultureMapper cultureMapper, ReligionMapper religionMapper, ProvinceMapper provinceMapper)
    {
        Logger.Info("Importing Imperator Provinces...");
        var counter = 0;

        // Imperator provinces map to a subset of CK3 provinces. We'll only rewrite those we are responsible for.
        foreach (var province in this)
        {
            var impProvinces = provinceMapper.GetImperatorProvinceNumbers(province.Id);
            // Provinces we're not affecting will not be in this list.
            if (impProvinces.Count == 0)
            {
                continue;
            }
            // Next, we find what province to use as its initializing source.
            var sourceProvince = DetermineProvinceSource(impProvinces, impWorld);
            if (sourceProvince is null)
            {
                Logger.Warn($"Could not determine source province for CK3 province {province.Id}!");
                continue;                 // MISMAP, or simply have mod provinces loaded we're not using.
            }
            province.InitializeFromImperator(sourceProvince.Value.Value, titles, cultureMapper, religionMapper);
            // And finally, initialize it.
            ++counter;
        }
        Logger.Info($"{impWorld.Provinces.Count} Imperator provinces imported into {counter} CK3 provinces.");
    }
        public void EmptyMappingsDefaultToEmpty()
        {
            var reader = new BufferedReader(
                "0.0.0.0 = {\n" +
                "}"
                );
            var mapper = new ProvinceMapper(reader);

            Assert.Empty(mapper.GetImperatorProvinceNumbers(1));
        }
        public void CanLookupImpProvinces()
        {
            var reader = new BufferedReader(
                "0.0.0.0 = {\n" +
                "	link = { ck3 = 2 ck3 = 1 imp = 2 imp = 1 }\n"+
                "}"
                );
            var mapper = new ProvinceMapper(reader);

            Assert.Equal(2, mapper.GetImperatorProvinceNumbers(1).Count);
            Assert.Equal((ulong)2, mapper.GetImperatorProvinceNumbers(1)[0]);
            Assert.Equal((ulong)1, mapper.GetImperatorProvinceNumbers(1)[1]);
            Assert.Equal(2, mapper.GetImperatorProvinceNumbers(2).Count);
            Assert.Equal((ulong)2, mapper.GetImperatorProvinceNumbers(2)[0]);
            Assert.Equal((ulong)1, mapper.GetImperatorProvinceNumbers(2)[1]);
        }