﻿admin_governor = {
	default_candidates = { holder_councilor landed_vassal  unlanded_noble_house_head }
	invested_candidates = { holder_house_member direct_subject holder_court_position holder_close_extended_family unlanded_noble_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
			}
			# Traits
			if = {
				limit = {
					OR = {
						has_trait = blind
						has_trait = incapable
						has_trait = infirm
					}
				}
				subtract = {
					value = 50
					desc = negative_trait_succession
				}
			}
			if = {
				limit = { has_trait = disinherited }
				subtract = {
					value = 200
					desc = trait_disinherited
				}
			}
			if = {
				limit = { has_trait = gallivanter }
				subtract = {
					value = 200
					desc = trait_gallivanter
				}
			}
			# CRIMINAL
			# COUNCIL POSITIONS
			# COURT POSITIONS
			# FAITH HOSTILITY
			if = {
				limit = {
					top_liege.primary_title.state_faith ?= {
						NOT = { this = root.faith }
					}
				}
				subtract = {
					value = 50
					desc = HOF_INTERACTION_STATE_FAITH
				}
			}
			# CLAIMS
			# POPULAR OPINION
			# PERKS
			if = {
				limit = { has_perk = ducal_conquest_perk }
				add = {
					value = 30
					desc = ducal_conquest_perk_name
				}
			}
			# LOWBORN? EW no
			# INFLUENCE LEVEL
			if = {
				limit = {
					influence_level = 0
				}
				subtract = {
					value = 10
					desc = "[influence_level|E]"
				}
			}
			else_if = {
				limit = {
					influence_level >= 2
				}
				add = {
					value = 10
					multiply = {
						value = influence_level
						subtract = 1 # Base value should start at 2
					}
					desc = "[influence_level|E]"
				}
			}
			#SAME CULTURE AS REGION
			#DIFFERENT CULTURE FROM IMPERIAL CAPITAL
			if = {
				limit = {
					root.top_liege.capital_county.culture ?= {
						NOT = { this = root.culture }
					}
				}
				subtract = {
					value = 25
					desc = no_cultural_acceptance
				}
			}
			# Personal reasons
			#ELDEST ELIGIBLE CHILD
			if = {
				limit = {
					is_player_heir_of = scope:title.holder
				}
				add = {
					value = 10
					multiply = scope:title.holder.influence_level
					desc = PLAYER_HEIR_RELATION
				}
			}
			#FRIENDS OF THE HOLDER
			#REGENT OF EMPEROR
			# Schemes
			if = {
				limit = { has_character_modifier = scheme_slandered_modifier }
				add = {
					value = slander_appointment_score_value
					desc = scheme_slandered_modifier
				}
			}
			if = {
				limit = { has_character_modifier = scheme_promoted_modifier }
				add = {
					value = promote_appointment_score_value	# Keep this balanced if more values are added!
					desc = scheme_promoted_modifier
				}
			}
			# Decisions
			if = {
				limit = {
					has_character_modifier = ep3_integration_promoter_modifier
					has_variable = integration_promoted_in
					var:integration_promoted_in.duchy ?= scope:title
				}
				add = {
					value = 30
					desc = ep3_integration_promoter_modifier
				}
			}
			# PETITION
			if = {
				limit = { scope:title.var:petition_house_rights ?= house }
				add = {
					value = 250
					desc = petition_liege_house_province_rights_value_desc
				}
			}

			# EXISTING GOVERNORSHIPS
			if = {
				limit = { is_governor = yes }
				add = {
					value = -1000
					desc = already_a_governor_tt
				}
			}
			# We remove all score from the emperor, to make sure you don't inherit governorships needlessly
			else_if = {
				limit = {
					is_independent_ruler = yes
				}
				add = {
					value = -1000
					desc = appointment_is_top_liege
				}
			}
			# age
			if = {
				limit = {
					bureaucrat_level_value <  scope:title.holder.bureaucrat_title_rank_value
					age < 70
				}
				add = {
					value = age
					subtract = 30
					multiply = 2
					desc = "CHARACTER_SORT_AGE"
				}
			}
			# realm priest
			if = {
				limit = { is_theocratic_lessee = yes }
				add = {
					value = -1000
					desc = game_concept_realm_priest
				}
			}
			# IS Child
			if = {
				limit = { is_adult = no }
				add = { value = -1000 desc = game_concept_child }
			}

			if = {
				limit = {
					scope:title.holder.top_liege ?= { faith = { has_doctrine = doctrine_gender_male_dominated } }
					is_female = yes
				}
				add = {
					value = -1000
					desc = male_only_law
				}
			}
			#ADJUST BASED ON GENDER LAW - MUST GO AT THE END
			if = {
				limit = {
					scope:title.holder ?= { has_realm_law = male_preference_law }
					is_female = yes
				}
				multiply = {
					value = 0.33
					desc = male_preference_law
				}
			}
			else_if = {
				limit = {
					scope:title.holder ?= { has_realm_law = male_only_law }
					is_female = yes
				}
				multiply = {
					value = 0
					desc = male_only_law
				}
			}
			else_if = {
				limit = {
					scope:title.holder ?= { has_realm_law = female_preference_law }
					is_female = no
				}
				multiply = {
					value = 0.33
					desc = female_preference_law
				}
			}
			else_if = {
				limit = {
					scope:title.holder ?= { has_realm_law = female_only_law }
					is_female = no
				}
				multiply = {
					value = 0
					desc = female_only_law
				}
			}
		}
	}
}
