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); }
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); }
public void IgnoredTokensAreStored() { var reader1 = new BufferedReader( "character = 69 " + "start_date = 500.2.3 " + "government = dictatorship " + "corruption = unused" ); _ = RulerTerm.Parse(reader1); var reader2 = new BufferedReader( "character = 69 " + "start_date = 500.2.3 " + "government = dictatorship " + "list = { unused }" ); _ = RulerTerm.Parse(reader2); Assert.True(RulerTerm.IgnoredTokens.SetEquals(new HashSet <string> { "corruption", "list" })); }
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); }
public void InitializeFromTag( Country country, CountryCollection imperatorCountries, LocDB locDB, ProvinceMapper provinceMapper, CoaMapper coaMapper, GovernmentMapper governmentMapper, SuccessionLawMapper successionLawMapper, DefiniteFormMapper definiteFormMapper, ReligionMapper religionMapper, CultureMapper cultureMapper, NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate ) { IsImportedOrUpdatedFromImperator = true; ImperatorCountry = country; ImperatorCountry.CK3Title = this; LocBlock?validatedName = GetValidatedName(country, imperatorCountries, locDB); HasDefiniteForm.Value = definiteFormMapper.IsDefiniteForm(ImperatorCountry.Name); RulerUsesTitleName.Value = false; PlayerCountry = ImperatorCountry.PlayerCountry; ClearHolderSpecificHistory(); FillHolderAndGovernmentHistory(); // ------------------ 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 history.InternalHistory.AddFieldValue("succession_laws", successionLawMapper.GetCK3LawsForImperatorLaws(ImperatorCountry.GetLaws()), conversionDate, "succession_laws" ); // 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 = parentCollection.GetCountyForProvince(provMappingsForImperatorCapital[0]); if (foundCounty is not null) { CapitalCounty = foundCounty; } } } // determine country name localization var nameSet = false; if (validatedName is not null) { var nameLocBlock = Localizations.AddLocBlock(Id); nameLocBlock.CopyFrom(validatedName); nameSet = true; } if (!nameSet) { var impTagLoc = locDB.GetLocBlockForKey(ImperatorCountry.Tag); if (impTagLoc is not null) { var nameLocBlock = Localizations.AddLocBlock(Id); nameLocBlock.CopyFrom(impTagLoc); nameSet = true; } } if (!nameSet) { // use unlocalized name if not empty var name = ImperatorCountry.Name; if (!string.IsNullOrEmpty(name)) { Logger.Warn($"Using unlocalized Imperator name {name} as name for {Id}!"); var nameLocBlock = Localizations.AddLocBlock(Id); nameLocBlock["english"] = name; nameLocBlock.FillMissingLocWithBaseLanguageLoc(); nameSet = true; } } // giving up if (!nameSet) { Logger.Warn($"{Id} needs help with localization! {ImperatorCountry.Name}?"); } // determine adjective localization TrySetAdjectiveLoc(locDB, imperatorCountries); void FillHolderAndGovernmentHistory() { // ------------------ determine previous and current holders // 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, characters, governmentMapper, locDB, religionMapper, cultureMapper, nicknameMapper, provinceMapper ); 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.AddFieldValue("holder", characterId, startDate, "holder"); if (gov is not null) { history.InternalHistory.AddFieldValue("government", gov, startDate, "government"); } } if (ImperatorCountry.Government is not null) { var lastCK3TermGov = history.GetGovernment(conversionDate); var ck3CountryGov = governmentMapper.GetCK3GovernmentForImperatorGovernment(ImperatorCountry.Government); if (lastCK3TermGov != ck3CountryGov && ck3CountryGov is not null) { history.InternalHistory.AddFieldValue("government", ck3CountryGov, conversionDate, "government"); } } } }