Exemplo n.º 1
0
 private static LocBlock?GetValidatedName(Country imperatorCountry, CountryCollection imperatorCountries, LocDB locDB)
 {
     return(imperatorCountry.Name switch {
         // hard code for Antigonid Kingdom, Seleucid Empire and Maurya
         // these countries use customizable localization for name and adjective
         "PRY_DYN" => locDB.GetLocBlockForKey("get_pry_name_fallback"),
         "SEL_DYN" => locDB.GetLocBlockForKey("get_sel_name_fallback"),
         "MRY_DYN" => locDB.GetLocBlockForKey("get_mry_name_fallback"),
         _ => imperatorCountry.CountryName.GetNameLocBlock(locDB, imperatorCountries)
     });
Exemplo n.º 2
0
        public LocBlock?GetNameLocBlock(LocDB locDB, CountryCollection imperatorCountries)
        {
            var directNameLocMatch = locDB.GetLocBlockForKey(Name);

            if (directNameLocMatch is null || Name != "CIVILWAR_FACTION_NAME")
            {
                return(directNameLocMatch);
            }

            // special case for revolts
            if (BaseName is null)
            {
                return(directNameLocMatch);
            }
            var baseAdjLoc = BaseName.GetAdjectiveLocBlock(locDB, imperatorCountries);

            if (baseAdjLoc is null)
            {
                return(directNameLocMatch);
            }
            directNameLocMatch.ModifyForEveryLanguage(baseAdjLoc,
                                                      (orig, modifying) => orig.Replace("$ADJ$", modifying)
                                                      );
            return(directNameLocMatch);
        }
Exemplo n.º 3
0
    public Dynasty(Family imperatorFamily, LocDB locDB)
    {
        Id   = $"dynn_IMPTOCK3_{imperatorFamily.Id}";
        Name = Id;

        var imperatorMembers = imperatorFamily.Members;

        if (imperatorMembers.Count > 0)
        {
            Imperator.Characters.Character?firstMember = imperatorMembers[0] as Imperator.Characters.Character;
            if (firstMember?.CK3Character is not null)
            {
                Culture = firstMember.CK3Character.Culture;                 // make head's culture the dynasty culture
            }
        }
        else
        {
            Logger.Warn($"Couldn't determine culture for dynasty {Id}, needs manual setting!");
        }

        foreach (var member in imperatorMembers.Values)
        {
            var ck3Member = (member as Imperator.Characters.Character)?.CK3Character;
            if (ck3Member is not null)
            {
                ck3Member.DynastyId = Id;
            }
        }

        var impFamilyLocKey = imperatorFamily.Key;
        var impFamilyLoc    = locDB.GetLocBlockForKey(impFamilyLocKey);

        if (impFamilyLoc is not null)
        {
            Localization = new(Name, impFamilyLoc);
        }
        else             // fallback: use unlocalized Imperator family key
        {
            var locBlock = new LocBlock("english", "french", "german", "russian", "simp_chinese", "spanish")
            {
                ["english"] = impFamilyLocKey
            };
            locBlock.FillMissingLocWithBaseLanguageLoc();
            Localization = new(Name, locBlock);
        }
    }
Exemplo n.º 4
0
        public LocBlock?GetAdjectiveLocBlock(LocDB locDB, CountryCollection imperatorCountries)
        {
            var adj = GetAdjective();
            var directAdjLocMatch = locDB.GetLocBlockForKey(adj);

            if (directAdjLocMatch is not null && adj == "CIVILWAR_FACTION_ADJECTIVE")
            {
                // special case for revolts
                var baseAdjLoc = BaseName?.GetAdjectiveLocBlock(locDB, imperatorCountries);
                if (baseAdjLoc is not null)
                {
                    directAdjLocMatch.ModifyForEveryLanguage(baseAdjLoc, (orig, modifying) =>
                                                             orig.Replace("$ADJ$", modifying)
                                                             );
                    return(directAdjLocMatch);
                }
            }
Exemplo n.º 5
0
    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");
                }
            }
        }
    }