@@ -119,35 +119,7 @@ Date conversionDate
119119
120120 ClearHolderSpecificHistory ( ) ;
121121
122- // ------------------ determine previous and current holders
123- // there was no 0 AD, but year 0 works in game and serves well for adding BC characters to holder history
124- var firstPossibleDate = new Date ( 0 , 1 , 1 ) ;
125- foreach ( var impRulerTerm in ImperatorCountry . RulerTerms ) {
126- var rulerTerm = new RulerTerm (
127- impRulerTerm ,
128- characters ,
129- governmentMapper ,
130- localizationMapper ,
131- religionMapper ,
132- cultureMapper ,
133- nicknameMapper ,
134- provinceMapper
135- ) ;
136-
137- var characterId = rulerTerm . CharacterId ;
138- var gov = rulerTerm . Government ;
139-
140- var startDate = new Date ( rulerTerm . StartDate ) ;
141- if ( startDate < firstPossibleDate ) {
142- startDate = new Date ( firstPossibleDate ) ; // TODO: remove this workaround if CK3 supports negative dates
143- firstPossibleDate . ChangeByDays ( 1 ) ;
144- }
145-
146- history . InternalHistory . AddFieldValue ( "holder" , characterId , startDate , "holder" ) ;
147- if ( gov is not null ) {
148- history . InternalHistory . AddFieldValue ( "government" , gov , startDate , "government" ) ;
149- }
150- }
122+ FillHolderAndGovernmentHistory ( ) ;
151123
152124 // ------------------ determine color
153125 var color1Opt = ImperatorCountry . Color1 ;
@@ -212,6 +184,46 @@ Date conversionDate
212184
213185 // --------------- Adjective Locs
214186 TrySetAdjectiveLoc ( localizationMapper , imperatorCountries ) ;
187+
188+ void FillHolderAndGovernmentHistory ( ) {
189+ // ------------------ determine previous and current holders
190+ // there was no 0 AD, but year 0 works in game and serves well for adding BC characters to holder history
191+ var firstPossibleDate = new Date ( 0 , 1 , 1 ) ;
192+ foreach ( var impRulerTerm in ImperatorCountry . RulerTerms ) {
193+ var rulerTerm = new RulerTerm (
194+ impRulerTerm ,
195+ characters ,
196+ governmentMapper ,
197+ localizationMapper ,
198+ religionMapper ,
199+ cultureMapper ,
200+ nicknameMapper ,
201+ provinceMapper
202+ ) ;
203+
204+ var characterId = rulerTerm . CharacterId ;
205+ var gov = rulerTerm . Government ;
206+
207+ var startDate = new Date ( rulerTerm . StartDate ) ;
208+ if ( startDate < firstPossibleDate ) {
209+ startDate = new Date ( firstPossibleDate ) ; // TODO: remove this workaround if CK3 supports negative dates
210+ firstPossibleDate . ChangeByDays ( 1 ) ;
211+ }
212+
213+ history . InternalHistory . AddFieldValue ( "holder" , characterId , startDate , "holder" ) ;
214+ if ( gov is not null ) {
215+ history . InternalHistory . AddFieldValue ( "government" , gov , startDate , "government" ) ;
216+ }
217+ }
218+
219+ if ( ImperatorCountry . Government is not null ) {
220+ var lastCK3TermGov = history . GetGovernment ( conversionDate ) ;
221+ var ck3CountryGov = governmentMapper . GetCK3GovernmentForImperatorGovernment ( ImperatorCountry . Government ) ;
222+ if ( lastCK3TermGov != ck3CountryGov && ck3CountryGov is not null ) {
223+ history . InternalHistory . AddFieldValue ( "government" , ck3CountryGov , conversionDate , "government" ) ;
224+ }
225+ }
226+ }
215227 }
216228
217229 internal void RemoveDeFactoLiegeReferences ( string name ) {
0 commit comments