public void ImportImperatorCharacters(Imperator.World impWorld, ReligionMapper religionMapper, CultureMapper cultureMapper, TraitMapper traitMapper, NicknameMapper nicknameMapper, LocDB locDB, ProvinceMapper provinceMapper, DeathReasonMapper deathReasonMapper, Date endDate, Date ck3BookmarkDate ) { Logger.Info("Importing Imperator Characters..."); foreach (var character in impWorld.Characters) { ImportImperatorCharacter( character, religionMapper, cultureMapper, traitMapper, nicknameMapper, locDB, provinceMapper, deathReasonMapper, endDate, ck3BookmarkDate ); } Logger.Info($"{Count} total characters recognized."); LinkMothersAndFathers(); LinkSpouses(); LinkPrisoners(); }
private void ImportImperatorCharacter( Imperator.Characters.Character character, ReligionMapper religionMapper, CultureMapper cultureMapper, TraitMapper traitMapper, NicknameMapper nicknameMapper, LocDB locDB, ProvinceMapper provinceMapper, DeathReasonMapper deathReasonMapper, Date endDate, Date ck3BookmarkDate ) { // Create a new CK3 character var newCharacter = new Character( character, religionMapper, cultureMapper, traitMapper, nicknameMapper, locDB, provinceMapper, deathReasonMapper, endDate, ck3BookmarkDate ); character.CK3Character = newCharacter; Add(newCharacter); }
private void ImportImperatorCountry( Country country, CountryCollection imperatorCountries, TagTitleMapper tagTitleMapper, LocDB locDB, ProvinceMapper provinceMapper, CoaMapper coaMapper, GovernmentMapper governmentMapper, SuccessionLawMapper successionLawMapper, DefiniteFormMapper definiteFormMapper, ReligionMapper religionMapper, CultureMapper cultureMapper, NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate ) { // Create a new title or update existing title var name = DetermineName(country, imperatorCountries, tagTitleMapper, locDB); if (TryGetValue(name, out var existingTitle)) { existingTitle.InitializeFromTag( country, imperatorCountries, locDB, provinceMapper, coaMapper, governmentMapper, successionLawMapper, definiteFormMapper, religionMapper, cultureMapper, nicknameMapper, characters, conversionDate ); } else { Add( country, imperatorCountries, locDB, provinceMapper, coaMapper, tagTitleMapper, governmentMapper, successionLawMapper, definiteFormMapper, religionMapper, cultureMapper, nicknameMapper, characters, conversionDate ); } }
public void NonMatchGivesEmptyOptional() { var reader = new BufferedReader("link = { ck3 = ck3Nickname imp = impNickname }"); var mapper = new NicknameMapper(reader); var ck3Nickname = mapper.GetCK3NicknameForImperatorNickname("nonMatchingNickname"); Assert.Null(ck3Nickname); }
public void Ck3NicknameCanBeFound() { var reader = new BufferedReader("link = { ck3 = ck3Nickname imp = impNickname }"); var mapper = new NicknameMapper(reader); var ck3Nickname = mapper.GetCK3NicknameForImperatorNickname("impNickname"); Assert.Equal("ck3Nickname", ck3Nickname); }
[Fact] public void MappingsAreReadFromFile() { var mapper = new NicknameMapper("TestFiles/configurables/nickname_map.txt"); Assert.Equal("dull", mapper.GetCK3NicknameForImperatorNickname("dull")); Assert.Equal("dull", mapper.GetCK3NicknameForImperatorNickname("stupid")); Assert.Equal("kind", mapper.GetCK3NicknameForImperatorNickname("friendly")); Assert.Equal("brave", mapper.GetCK3NicknameForImperatorNickname("brave")); }
public void MultipleImpNicknamesCanBeInARule() { var reader = new BufferedReader("link = { ck3 = ck3Nickname imp = impNickname imp = impNickname2 }"); var mapper = new NicknameMapper(reader); var ck3Nickname = mapper.GetCK3NicknameForImperatorNickname("impNickname2"); Assert.Equal("ck3Nickname", ck3Nickname); }
public void NullInNullOut() { var reader = new BufferedReader("link = { ck3 = ck3Nickname imp = impNickname }"); var mapper = new NicknameMapper(reader); var match = mapper.GetCK3NicknameForImperatorNickname(null); Assert.Null(match); }
public void MappingsWithNoCK3NicknameAreIgnored() { var reader = new BufferedReader( "link = { imp = impNickname }" ); var mapper = new NicknameMapper(reader); var ck3Nickname = mapper.GetCK3NicknameForImperatorNickname("impNickname"); Assert.Null(ck3Nickname); }
public void CorrectRuleMatches() { var reader = new BufferedReader( "link = { ck3 = ck3Nickname imp = impNickname }" + "link = { ck3 = ck3Nickname2 imp = impNickname2 }" ); var mapper = new NicknameMapper(reader); var ck3Nickname = mapper.GetCK3NicknameForImperatorNickname("impNickname2"); Assert.Equal("ck3Nickname2", ck3Nickname); }
public void ImportImperatorCountries( CountryCollection imperatorCountries, TagTitleMapper tagTitleMapper, LocDB locDB, ProvinceMapper provinceMapper, CoaMapper coaMapper, GovernmentMapper governmentMapper, SuccessionLawMapper successionLawMapper, DefiniteFormMapper definiteFormMapper, ReligionMapper religionMapper, CultureMapper cultureMapper, NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate ) { Logger.Info("Importing Imperator Countries..."); // landedTitles holds all titles imported from CK3. We'll now overwrite some and // add new ones from Imperator tags. var counter = 0; // We don't need pirates, barbarians etc. foreach (var country in imperatorCountries.Where(c => c.CountryType == CountryType.real)) { ImportImperatorCountry( country, imperatorCountries, tagTitleMapper, locDB, provinceMapper, coaMapper, governmentMapper, successionLawMapper, definiteFormMapper, religionMapper, cultureMapper, nicknameMapper, characters, conversionDate ); ++counter; } Logger.Info($"Imported {counter} countries from I:R."); }
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 Title Add( Country country, CountryCollection imperatorCountries, LocDB locDB, ProvinceMapper provinceMapper, CoaMapper coaMapper, TagTitleMapper tagTitleMapper, GovernmentMapper governmentMapper, SuccessionLawMapper successionLawMapper, DefiniteFormMapper definiteFormMapper, ReligionMapper religionMapper, CultureMapper cultureMapper, NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate ) { var newTitle = new Title(this, country, imperatorCountries, locDB, provinceMapper, coaMapper, tagTitleMapper, governmentMapper, successionLawMapper, definiteFormMapper, religionMapper, cultureMapper, nicknameMapper, characters, conversionDate ); dict[newTitle.Id] = newTitle; return(newTitle); }
private Title(LandedTitles parentCollection, Country country, CountryCollection imperatorCountries, LocDB locDB, ProvinceMapper provinceMapper, CoaMapper coaMapper, TagTitleMapper tagTitleMapper, GovernmentMapper governmentMapper, SuccessionLawMapper successionLawMapper, DefiniteFormMapper definiteFormMapper, ReligionMapper religionMapper, CultureMapper cultureMapper, NicknameMapper nicknameMapper, CharacterCollection characters, Date conversionDate ) { this.parentCollection = parentCollection; Id = DetermineName(country, imperatorCountries, tagTitleMapper, locDB); SetRank(); InitializeFromTag( country, imperatorCountries, locDB, provinceMapper, coaMapper, governmentMapper, successionLawMapper, definiteFormMapper, religionMapper, cultureMapper, nicknameMapper, characters, conversionDate ); }
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"); } } } }