﻿admin_governor = {
	default_candidates = { holder_close_family }

	candidate_score = {
		value = {
			# Base - Based on skills
			add = {
				value = martial
				add = diplomacy
				add = stewardship
				add = intrigue
				add = learning
				multiply = 1
				desc = sum_of_skills_desc
			}

			add = appointment_score_base
			add = appointment_score_non_military
			add = appointment_score_non_merit
			add = appointment_score_governor

			# PIETY LEVEL (from admin family attribute)
			if = {
				limit = {
					piety_level >= 1
					house ?= {
						OR = {
							has_house_aspiration_parameter = candidate_score_per_piety_level_1
							has_house_aspiration_parameter = candidate_score_per_piety_level_2
							has_house_aspiration_parameter = candidate_score_per_piety_level_3
						}
					}
				}
				add = {
					value = 0
					add = {
						if = {
							limit = {
								house ?= { has_house_aspiration_parameter = candidate_score_per_piety_level_3 }
							}
							add = candidate_score_per_piety_level_3_value
						}
						else_if = {
							limit = {
								house ?= { has_house_aspiration_parameter = candidate_score_per_piety_level_2 }
							}
							add = candidate_score_per_piety_level_2_value
						}
						else = {
							add = candidate_score_per_piety_level_1_value
						}
					}
					multiply = piety_level
					desc = "family_attribute_desc"
				}
			}
			add = appointment_score_final_factors
			# Rise and Fall: preserve Warlord, Puppet Regency and assigned score adjustments.


			if = {
				limit = {
					is_child_of = scope:title.holder
					scope:title.holder = {
						has_trait = warlord
						OR = {
							government_has_flag = government_is_administrative
							government_has_flag = government_is_celestial
							government_has_flag = government_is_meritocratic
							government_has_flag = government_is_japan_administrative
						}
					}
				}
				add = {
					value = riseandfall_warlord_child_succession_value
					desc = riseandfall_warlord_child_succession_desc
				}
			}
			if = {
				limit = {
					scope:title.holder ?= {
						is_close_family_of = root
						has_trait = warlord
					}
				}
				add = {
					value = 690
					desc = riseandfall_warlord_relative_succession_desc
				}
			}

			# RANDOM ADMIN NERF SCORE (if assigned by scripted effect)
			if = {
				limit = { has_variable = riseandfall_admin_nerf }
				add = {
					value = var:riseandfall_admin_nerf
					desc = riseandfall_admin_nerf_desc
				}
			}
		}
	}
}
