public void TitleCanBeGeneratedFromTag() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); var match = mapper.GetTitleForTag("ROM", CountryRank.localPower, "Rome"); var match2 = mapper.GetTitleForTag("DRE", CountryRank.localPower, "Dre Empire"); Assert.Equal("k_IMPTOCK3_ROM", match); Assert.Equal("e_IMPTOCK3_DRE", match2); }
public void GetTitleForTagReturnsNullOnEmptyParameter() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); var match = mapper.GetTitleForTag("", CountryRank.migrantHorde, ""); Assert.Null(match); }
public void TitleCanBeMatchedFromTag() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); // reads title_map.txt from TestFiles var match = mapper.GetTitleForTag("CRT", CountryRank.majorPower); Assert.Equal("k_krete", match); }
public void TitleCanBeMatchedByRanklessLink() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); // reads title_map.txt from TestFiles var match = mapper.GetTitleForTag("RAN", CountryRank.majorPower); Assert.Equal("d_rankless", match); }
public void TagCanBeRegistered() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); mapper.RegisterTag("BOR", "e_boredom"); var match = mapper.GetTitleForTag("BOR", CountryRank.localPower); Assert.Equal("e_boredom", match); }
public void GetTitleForTagReturnsNullOnEmptyTag() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); var country = Country.Parse(new BufferedReader(string.Empty), 1); Assert.Empty(country.Tag); var match = mapper.GetTitleForTag(country, ""); Assert.Null(match); }
public void TitleCanBeGeneratedFromTag() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); var rom = Country.Parse(new BufferedReader("tag=ROM"), 1); for (ulong i = 0; i < 20; ++i) // makes the country a local power { rom.RegisterProvince(new ImperatorToCK3.Imperator.Provinces.Province(i)); } var match = mapper.GetTitleForTag(rom, "Rome"); var dre = Country.Parse(new BufferedReader("tag=DRE"), 1); for (ulong i = 0; i < 20; ++i) // makes the country a local power { dre.RegisterProvince(new ImperatorToCK3.Imperator.Provinces.Province(i)); } var match2 = mapper.GetTitleForTag(dre, "Dre Empire"); Assert.Equal("k_IMPTOCK3_ROM", match); Assert.Equal("e_IMPTOCK3_DRE", match2); }
public void TitleCanBeMatchedByRanklessLink() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); // reads title_map.txt from TestFiles var country = Country.Parse(new BufferedReader("tag=RAN"), 1); for (ulong i = 1; i < 200; ++i) // makes the country a major power { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); country.RegisterProvince(province); } var match = mapper.GetTitleForTag(country); Assert.Equal("d_rankless", match); }
public void TagCanBeRegistered() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); mapper.RegisterTag("BOR", "e_boredom"); var country = Country.Parse(new BufferedReader("tag=BOR"), 1); for (ulong i = 1; i < 20; ++i) // makes the country a local power { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); country.RegisterProvince(province); } var match = mapper.GetTitleForTag(country); Assert.Equal("e_boredom", match); }
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); }
public void GetCK3TitleRankReturnsCorrectRank() { var mapper = new TagTitleMapper(tagTitleMappingsPath, governorshipTitleMappingsPath); var tag1 = Country.Parse(new BufferedReader("tag=TEST_TAG1"), 1); for (ulong i = 1; i < 20; ++i) // makes the country a local power { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); tag1.RegisterProvince(province); } Assert.Equal('e', mapper.GetTitleForTag(tag1, "Test Empire")[0]); var tag2 = Country.Parse(new BufferedReader("tag=TEST_TAG2"), 2); for (ulong i = 1; i < 2; ++i) // makes the country a city state { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); tag2.RegisterProvince(province); } Assert.Equal('k', mapper.GetTitleForTag(tag2, "Test Kingdom")[0]); var tag3 = Country.Parse(new BufferedReader("tag=TEST_TAG3"), 3); // migrant horde Assert.Equal('d', mapper.GetTitleForTag(tag3)[0]); var tag4 = Country.Parse(new BufferedReader("tag=TEST_TAG4"), 4); for (ulong i = 1; i < 2; ++i) // makes the country a city state { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); tag4.RegisterProvince(province); } Assert.Equal('d', mapper.GetTitleForTag(tag4)[0]); var tag5 = Country.Parse(new BufferedReader("tag=TEST_TAG5"), 5); for (ulong i = 1; i < 20; ++i) // makes the country a local power { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); tag5.RegisterProvince(province); } Assert.Equal('k', mapper.GetTitleForTag(tag5)[0]); var tag6 = Country.Parse(new BufferedReader("tag=TEST_TAG6"), 6); for (ulong i = 1; i < 40; ++i) // makes the country a regional power { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); tag6.RegisterProvince(province); } Assert.Equal('k', mapper.GetTitleForTag(tag6)[0]); var tag7 = Country.Parse(new BufferedReader("tag=TEST_TAG7"), 7); for (ulong i = 1; i < 200; ++i) // makes the country a major power { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); tag7.RegisterProvince(province); } Assert.Equal('k', mapper.GetTitleForTag(tag7)[0]); var tag8 = Country.Parse(new BufferedReader("tag=TEST_TAG8"), 8); for (ulong i = 1; i < 501; ++i) // makes the country a great power { var province = new ImperatorToCK3.Imperator.Provinces.Province(i); tag8.RegisterProvince(province); } Assert.Equal('e', mapper.GetTitleForTag(tag8)[0]); }