﻿court_tutor_court_position = {
	max_available_positions = 1
	category = court_position_category_common

	opinion = {
		value = regular_court_position_opinion
	}
	
	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }

	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 10
		add = {
			value = learning
			multiply = 1.5
			max = 45
			desc = court_position_skill_learning
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = { 
				value = 10
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = intellect_good_3
			}
			add = { 
				value = 30
				desc = court_position_intellect_good_3_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_2
			}
			add = { 
				value = 20
				desc = court_position_intellect_good_2_trait
			}
		}
		else_if = {
			limit = {
				has_trait = intellect_good_1
			}
			add = {
				value = 10
				desc = court_position_intellect_good_1_trait
			}
		}
		if = {
			limit = {
				has_trait = shrewd
			}
			add = {
				value = 10
				desc = court_position_shrewd_trait
			}
		}
		if = {
			limit = {
				has_trait = scholar
			}
			add = {
				value = 10
				desc = court_position_scholar_trait
			}
		}
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_low_penalty_value
	}

	is_shown = {
		has_ep1_court_positions_dlc_trigger = yes
	}

	# Is this an available position for this court? (root is court owner)
	valid_position = { }

	is_shown_character = {
		scope:employee = {
			is_courtier_of = scope:liege
			is_imprisoned = no
		}
	}

	valid_character = {
		scope:employee = {
			custom_tooltip = {
				text = IS_NOT_THE_SPOUSE_OF_CHARACTER_COURT_POSITION
				NOT = { is_spouse_of = scope:liege }
			}
			trigger_if = {
				limit = { NOT = { has_court_position = court_tutor_court_position } }
				court_position_does_not_already_have_a_job_trigger = yes # This positions is considered a job, and cannot be held at the same tims as another similar position
			}
		}
	}

	revoke_cost = {
		prestige =  {
			value = major_court_position_prestige_revoke_cost

			# Set to 0 with Dynasty Perk Inner Circle
			if = {
				limit = {
					exists = dynasty
					dynasty = { has_dynasty_perk = fp2_coterie_legacy_1 }

					employs_court_position = court_tutor_court_position
					any_court_position_holder = {
				        type = court_tutor_court_position
						exists = dynasty
						house = prev.house
					}
				}
				multiply = 0
			}
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
		}
	}

	salary = {
		round = no
		gold = {
			value = medium_court_position_salary
			# Set to 0 with Dynasty Perk Inner Circle
			if = {
				limit = {
					scope:liege = {
						exists = dynasty
						dynasty = { has_dynasty_perk = fp2_coterie_legacy_1 }

						employs_court_position = court_tutor_court_position
						any_court_position_holder = {
					        type = court_tutor_court_position
							exists = dynasty
							house = prev.house
						}
					}
				}
				multiply = {
					value = 0.0
					desc = inner_circle_salary_mod
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			if = {
				limit = {
					scope:liege = {
						employs_court_position = court_tutor_court_position
						any_court_position_holder = {
					        type = court_tutor_court_position
					        scope:liege = {
								has_hook_of_type = {
									type = obligation_hook
									target = prev
								}
							}
						}
					}
				}
				multiply = {
					value = 0.5
					desc = obligation_hook_salary
				}
			}
		}
	}
	
	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints) 
	scaling_employer_modifiers = {
		terrible = {
			learn_language_scheme_phase_duration_add = -4
		}
		poor = {
			learn_language_scheme_phase_duration_add = -8
		}
		average = {
			learn_language_scheme_phase_duration_add = -12
		}
		good = {
			learn_language_scheme_phase_duration_add = -16
            monthly_lifestyle_xp_gain_mult = 0.05
		}
		excellent = {
			learn_language_scheme_phase_duration_add = -20
            monthly_lifestyle_xp_gain_mult = 0.10
		}
	}

	custom_employer_modifier_description = court_tutor_employer_custom_effect_description

	base_employer_modifier = {
	}

	modifier = {
		monthly_prestige = minor_court_position_prestige_salary
	}

	on_court_position_received = {
		court_tutor_title_accepted_effect = yes
	}
	on_court_position_revoked = { 
		court_tutor_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_tutor_title_invalidated_effect = yes
	}
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value

        scope:employee = {
			value = scope:employee_aptitude
			multiply = 25
		}

        scope:employee = {
			value = scope:employee_aptitude
			subtract = scope:highest_available_aptitude
			multiply = 100
		}

		scope:liege = {
			if = {
				limit = {
					OR = {
						AND = {
							exists = primary_heir
							primary_heir = {
								is_adult = no
								is_courtier_of = scope:liege
							}
						}
						any_child = {
							count >= 3
							is_adult = no
							is_courtier_of = scope:liege
						}
					}
				}
				add = 20
			}
			if = {
				limit = {
					has_perk = pedagogy_perk
				}
				add = 50
			}
		}
		add = court_position_debt_considerations_value
	}
}