Beispiel #1
0
 public RulerTerm(Imperator.Countries.RulerTerm imperatorRulerTerm, GovernmentMapper governmentMapper)
 {
     if (imperatorRulerTerm.CharacterId is not null)
     {
         CharacterId = "imperator" + imperatorRulerTerm.CharacterId.ToString();
     }
     StartDate = imperatorRulerTerm.StartDate;
     if (imperatorRulerTerm.Government is not null)
     {
         Government = governmentMapper.GetCK3GovernmentForImperatorGovernment(imperatorRulerTerm.Government);
     }
 }
        public void PreImperatorTermIsCorrectlyConverted()
        {
            var countries     = new ImperatorToCK3.Imperator.Countries.CountryCollection();
            var countryReader = new BufferedReader("= { tag = SPA capital=420 }");
            var sparta        = ImperatorToCK3.Imperator.Countries.Country.Parse(countryReader, 69);

            countries.Add(sparta);

            var preImpTermReader = new BufferedReader("= { name=\"Alexander\"" +
                                                      " birth_date=200.1.1 death_date=300.1.1 throne_date=250.1.1" +
                                                      " nickname=stupid religion=hellenic culture=spartan" +
                                                      " country=SPA }"
                                                      );
            var impRulerTerm = new ImperatorToCK3.Imperator.Countries.RulerTerm(preImpTermReader, countries);

            var govReader      = new BufferedReader("link = {imp=dictatorship ck3=feudal_government }");
            var govMapper      = new GovernmentMapper(govReader);
            var religionMapper = new ReligionMapper(new BufferedReader("link={imp=hellenic ck3=hellenic}"));

            religionMapper.LoadRegionMappers(
                new ImperatorRegionMapper(),
                new CK3RegionMapper()
                );
            var ck3Characters = new ImperatorToCK3.CK3.Characters.CharacterCollection();
            var ck3RulerTerm  = new RulerTerm(impRulerTerm,
                                              ck3Characters,
                                              govMapper,
                                              new LocDB("english"),
                                              religionMapper,
                                              new CultureMapper(new BufferedReader("link = { imp=spartan ck3=greek }")),
                                              new NicknameMapper("TestFiles/configurables/nickname_map.txt"),
                                              new ProvinceMapper()
                                              );

            Assert.Equal("imperatorRegnalSPAAlexander504.1.1BC", ck3RulerTerm.CharacterId);
            Assert.Equal(new Date(250, 1, 1, AUC: true), ck3RulerTerm.StartDate);
            var ruler = ck3RulerTerm.PreImperatorRuler;

            Assert.NotNull(ruler);
            Assert.Equal("Alexander", ruler.Name);

            var ck3Character = ck3Characters["imperatorRegnalSPAAlexander504.1.1BC"];

            Assert.Equal(new Date(0, 1, 1), ck3Character.BirthDate);             // BC dates are not supported by CK3
            Assert.Equal(new Date(0, 1, 30), ck3Character.DeathDate);            // BC dates are not supported by CK3
            Assert.Equal("Alexander", ck3Character.Name);
            Assert.Equal("dull", ck3Character.Nickname);
            Assert.Equal("greek", ck3Character.Culture);
            Assert.Equal("hellenic", ck3Character.Religion);
        }
Beispiel #3
0
        public void ImperatorRulerTermIsCorrectlyConverted()
        {
            var reader = new BufferedReader(
                "character = 69 " +
                "start_date = 500.2.3 " +
                "government = dictatorship"
                );
            var impRulerTerm = ImperatorToCK3.Imperator.Countries.RulerTerm.Parse(reader);
            var govReader    = new BufferedReader("link = {imp=dictatorship ck3=feudal_government }");
            var govMapper    = new GovernmentMapper(govReader);
            var ck3RulerTerm = new RulerTerm(impRulerTerm, govMapper);

            Assert.Equal("imperator69", ck3RulerTerm.CharacterId);
            Assert.Equal(new Date(500, 2, 3, AUC: true), ck3RulerTerm.StartDate);
            Assert.Equal("feudal_government", ck3RulerTerm.Government);
        }
Beispiel #4
0
    public RulerTerm(
        Imperator.Countries.RulerTerm imperatorRulerTerm,
        Characters.CharacterCollection characters,
        GovernmentMapper governmentMapper,
        LocDB locDB,
        ReligionMapper religionMapper,
        CultureMapper cultureMapper,
        NicknameMapper nicknameMapper,
        ProvinceMapper provinceMapper
        )
    {
        if (imperatorRulerTerm.CharacterId is not null)
        {
            CharacterId = $"imperator{imperatorRulerTerm.CharacterId}";
        }
        StartDate = imperatorRulerTerm.StartDate;
        if (imperatorRulerTerm.Government is not null)
        {
            Government = governmentMapper.GetCK3GovernmentForImperatorGovernment(imperatorRulerTerm.Government);
        }

        PreImperatorRuler = imperatorRulerTerm.PreImperatorRuler;
        if (PreImperatorRuler?.Country is not null)
        {
            // create a new ruler character
            var character = new Character(
                PreImperatorRuler,
                StartDate,
                PreImperatorRuler.Country,
                locDB,
                religionMapper,
                cultureMapper,
                nicknameMapper,
                provinceMapper
                );
            characters.Add(character);
            CharacterId = character.Id;
        }
    }
        public void ImperatorRulerTermIsCorrectlyConverted()
        {
            var reader = new BufferedReader(
                "character = 69 " +
                "start_date = 500.2.3 " +
                "government = dictatorship"
                );
            var impRulerTerm = ImperatorToCK3.Imperator.Countries.RulerTerm.Parse(reader);
            var govReader    = new BufferedReader("link = {imp=dictatorship ck3=feudal_government }");
            var govMapper    = new GovernmentMapper(govReader);
            var ck3RulerTerm = new RulerTerm(impRulerTerm,
                                             new ImperatorToCK3.CK3.Characters.CharacterCollection(),
                                             govMapper,
                                             new LocDB("english"),
                                             new ReligionMapper(),
                                             new CultureMapper(),
                                             new NicknameMapper("TestFiles/configurables/nickname_map.txt"),
                                             new ProvinceMapper()
                                             );

            Assert.Equal("imperator69", ck3RulerTerm.CharacterId);
            Assert.Equal(new Date(500, 2, 3, AUC: true), ck3RulerTerm.StartDate);
            Assert.Equal("feudal_government", ck3RulerTerm.Government);
        }
Beispiel #6
0
        public void InitializeFromTag(
            Imperator.Countries.Country country,
            Dictionary <ulong, Imperator.Countries.Country> imperatorCountries,
            LocalizationMapper localizationMapper,
            LandedTitles landedTitles,
            ProvinceMapper provinceMapper,
            CoaMapper coaMapper,
            TagTitleMapper tagTitleMapper,
            GovernmentMapper governmentMapper,
            SuccessionLawMapper successionLawMapper,
            DefiniteFormMapper definiteFormMapper
            )
        {
            IsImportedOrUpdatedFromImperator = true;
            ImperatorCountry = country;

            // ------------------ determine CK3 title

            LocBlock?validatedName;

            // hard code for Antigonid Kingdom, Seleucid Empire and Maurya (which use customizable localization for name and adjective)
            if (ImperatorCountry.Name == "PRY_DYN")
            {
                validatedName = localizationMapper.GetLocBlockForKey("get_pry_name_fallback");
            }
            else if (ImperatorCountry.Name == "SEL_DYN")
            {
                validatedName = localizationMapper.GetLocBlockForKey("get_sel_name_fallback");
            }
            else if (ImperatorCountry.Name == "MRY_DYN")
            {
                validatedName = localizationMapper.GetLocBlockForKey("get_mry_name_fallback");
            }
            // normal case
            else
            {
                validatedName = ImperatorCountry.CountryName.GetNameLocBlock(localizationMapper, imperatorCountries);
            }

            HasDefiniteForm = definiteFormMapper.IsDefiniteForm(ImperatorCountry.Name);

            string?title;

            if (validatedName is not null)
            {
                title = tagTitleMapper.GetTitleForTag(ImperatorCountry.Tag, ImperatorCountry.GetCountryRank(), validatedName.english);
            }
            else
            {
                title = tagTitleMapper.GetTitleForTag(ImperatorCountry.Tag, ImperatorCountry.GetCountryRank());
            }

            if (title is null)
            {
                throw new ArgumentException("Country " + ImperatorCountry.Tag + " could not be mapped!");
            }

            Name = title;

            SetRank();

            PlayerCountry = ImperatorCountry.PlayerCountry;

            // ------------------ determine previous and current holders
            history.InternalHistory.SimpleFields.Remove("holder");
            history.InternalHistory.SimpleFields.Remove("government");
            // there was no 0 AD, but year 0 works in game and serves well for adding BC characters to holder history
            var firstPossibleDate = new Date(0, 1, 1);

            foreach (var impRulerTerm in ImperatorCountry.RulerTerms)
            {
                var rulerTerm   = new RulerTerm(impRulerTerm, governmentMapper);
                var characterId = rulerTerm.CharacterId;
                var gov         = rulerTerm.Government;

                var startDate = new Date(rulerTerm.StartDate);
                if (startDate < firstPossibleDate)
                {
                    startDate = new Date(firstPossibleDate);                     // TODO: remove this workaround if CK3 supports negative dates
                    firstPossibleDate.ChangeByDays(1);
                }

                history.InternalHistory.AddSimpleFieldValue("holder", characterId, startDate);
                if (gov is not null)
                {
                    history.InternalHistory.AddSimpleFieldValue("government", gov, startDate);
                }
            }

            // ------------------ determine color
            var color1Opt = ImperatorCountry.Color1;

            if (color1Opt is not null)
            {
                Color1 = color1Opt;
            }
            var color2Opt = ImperatorCountry.Color2;

            if (color2Opt is not null)
            {
                Color2 = color2Opt;
            }

            // determine successions laws
            SuccessionLaws = successionLawMapper.GetCK3LawsForImperatorLaws(ImperatorCountry.GetLaws());

            // ------------------ determine CoA
            CoA = coaMapper.GetCoaForFlagName(ImperatorCountry.Flag);

            // ------------------ determine other attributes

            var srcCapital = ImperatorCountry.Capital;

            if (srcCapital is not null)
            {
                var provMappingsForImperatorCapital = provinceMapper.GetCK3ProvinceNumbers((ulong)srcCapital);
                if (provMappingsForImperatorCapital.Count > 0)
                {
                    var foundCounty = landedTitles.GetCountyForProvince(provMappingsForImperatorCapital[0]);
                    if (foundCounty is not null)
                    {
                        CapitalCounty = new(foundCounty.Name, foundCounty);
                    }
                }
            }

            // ------------------ Country Name Locs

            var nameSet = false;

            if (validatedName is not null)
            {
                Localizations.Add(Name, validatedName);
                nameSet = true;
            }
            if (!nameSet)
            {
                var impTagLoc = localizationMapper.GetLocBlockForKey(ImperatorCountry.Tag);
                if (impTagLoc is not null)
                {
                    Localizations.Add(Name, impTagLoc);
                    nameSet = true;
                }
            }
            // giving up
            if (!nameSet)
            {
                Logger.Warn($"{Name} needs help with localization! {ImperatorCountry.Name}?");
            }

            // --------------- Adjective Locs
            TrySetAdjectiveLoc(localizationMapper, imperatorCountries);
        }