﻿########################################
# Inherit realm history (civil war years and puppet regency years)
# Called on heir/new title holder when they inherit from a strictly higher-ranked
# predecessor but they already had a stability score (we don't want to overwrite their
# existing stability_score). This effect copies supplementary history to the heir.
riseandfall_inherit_realm_history_se = {
    if = { limit = { has_game_rule = riseandfall_realm_stability_enabled }
        # Copy civil war years
        if = { limit = { scope:predecessor = { has_variable = riseandfall_rs_civil_war_years } } set_variable = { name = riseandfall_rs_civil_war_years value = scope:predecessor.var:riseandfall_rs_civil_war_years } }
        
        else = { set_variable = { name = riseandfall_rs_civil_war_years value = 0 } }

        # Copy puppet regency years
        if = { limit = { scope:predecessor = { has_variable = riseandfall_puppet_regency_years } } set_variable = { name = riseandfall_puppet_regency_years value = scope:predecessor.var:riseandfall_puppet_regency_years } }
        
        else = { set_variable = { name = riseandfall_puppet_regency_years value = 0 } }

    }
}
