﻿# Sets variable of court position suitable to a character's skills
# Actual job is set with court_position_generator_assignment_effect after using this effect
# VAR - can be used to allow multiple event options: 'target', 'second', 'backup'
# EMPLOYER - should be the char hiring the position
# ROOT - should be the char taking the position
# Saves scope:old_holder as existing holder if they exist
# NOTE: candidates must be courtiers of the employer for this to work
court_position_generator_effect = {
	save_scope_as = candidate
	$EMPLOYER$ = { save_scope_as = liege }
	# Randomly select a fitting role and save it to a variable
	random_list = {
		2 = { # ARCHITECT
			trigger = {
				court_position_generator_pickable_trigger = { POS = royal_architect EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = royal_architect
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = royal_architect
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # SENESCHAL
			trigger = {
				court_position_generator_pickable_trigger = { POS = seneschal EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = seneschal
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = seneschal
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # TUTOR
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_tutor EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_tutor
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_tutor
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # HIGH ALMONER
			trigger = {
				court_position_generator_pickable_trigger = { POS = high_almoner EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = high_almoner
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = high_almoner
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # COURT PHYSICIAN
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_physician EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_physician
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_physician
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # ANTIQUARIAN
			trigger = {
				court_position_generator_pickable_trigger = { POS = antiquarian EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = antiquarian
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = antiquarian
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # HORSE MASTER
			trigger = {
				court_position_generator_pickable_trigger = { POS = master_of_horse EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = master_of_horse
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = master_of_horse
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # BODYGUARD
			trigger = {
				court_position_generator_pickable_trigger = { POS = bodyguard EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = bodyguard
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = bodyguard
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # HUNT MASTER
			trigger = {
				court_position_generator_pickable_trigger = { POS = master_of_hunt EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = master_of_hunt
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = master_of_hunt
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # CHAMPION
			trigger = {
				court_position_generator_pickable_trigger = { POS = champion EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = champion
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = champion
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # POET
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_poet EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_poet
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_poet
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # MUSICIAN
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_musician EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_musician
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_musician
				EMPLOYER = $EMPLOYER$
			}
		}
		1 = { # COURT JESTER
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_jester EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_jester
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_jester
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # EXECUTIONER
			trigger = {
				court_position_generator_pickable_trigger = { POS = executioner EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = executioner
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = executioner
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # FOOD TASTER
			trigger = {
				court_position_generator_pickable_trigger = { POS = food_taster EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = food_taster
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = food_taster
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # CUPBEARER
			trigger = {
				court_position_generator_pickable_trigger = { POS = cupbearer EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = cupbearer
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = cupbearer
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # LADY-IN-WAITING
			trigger = {
				court_position_generator_pickable_trigger = { POS = lady_in_waiting EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = lady_in_waiting
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = lady_in_waiting
				EMPLOYER = $EMPLOYER$
			}
		}
		4 = { # EUNUCH
			trigger = {
				court_position_generator_pickable_trigger = { POS = chief_eunuch EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = chief_eunuch
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = chief_eunuch
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # GARDENER
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_gardener EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_gardener
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_gardener
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # ARTIFICER
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_artificer EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_artificer
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_artificer
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # CULTURAL EMISSARY
			trigger = {
				court_position_generator_pickable_trigger = { POS = cultural_emissary EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = cultural_emissary
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = cultural_emissary
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # CHIEF QADI
			trigger = {
				court_position_generator_pickable_trigger = { POS = chief_qadi EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = chief_qadi
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = chief_qadi
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # GARUDA
			trigger = {
				court_position_generator_pickable_trigger = { POS = garuda EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = garuda
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = garuda
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # KEEPER OF SWANS
			trigger = {
				court_position_generator_pickable_trigger = { POS = keeper_of_swans EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = keeper_of_swans
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = keeper_of_swans
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # CARAVAN MASTER
			trigger = {
				court_position_generator_pickable_trigger = { POS = travel_leader EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = travel_leader
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = travel_leader
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # WET NURSE
			trigger = {
				court_position_generator_pickable_trigger = { POS = wet_nurse EMPLOYER = $EMPLOYER$ }
			}
			modifier = {
				add = 5
				has_trait = loyal
			}
			modifier = {
				add = 10
				has_relation_friend = $EMPLOYER$
			}
			modifier = {
				add = 20
				has_relation_best_friend = $EMPLOYER$
			}
			modifier = {
				add = 30
				has_relation_lover = $EMPLOYER$
			}
			modifier = {
				add = 40
				has_relation_soulmate = $EMPLOYER$
			}
			court_position_generator_shared_modifier = {
				POS = wet_nurse
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = wet_nurse
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # CAVE HERMIT
			trigger = {
				court_position_generator_pickable_trigger = { POS = cave_hermit EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = cave_hermit
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = cave_hermit
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # MASTER ASSASSIN
			trigger = {
				court_position_generator_pickable_trigger = { POS = master_assassin EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = master_assassin
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = master_assassin
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # COURT SCHOLAR
			trigger = {
				court_position_generator_pickable_trigger = { POS = court_scholar EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = court_scholar
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = court_scholar
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # CHRONICLER
			trigger = {
				court_position_generator_pickable_trigger = { POS = chronicler EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = chronicler
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = chronicler
				EMPLOYER = $EMPLOYER$
			}
		}
		2 = { # AKOLOUTHOS
			trigger = {
				court_position_generator_pickable_trigger = { POS = akolouthos EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = akolouthos
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = akolouthos
				EMPLOYER = $EMPLOYER$
			}
		}
#####################
### KETAROS BLOCK ###
#####################
		2 = { # STONEMASON MASTER
			trigger = {
				court_position_generator_pickable_trigger = { POS = stonemason_master EMPLOYER = $EMPLOYER$ }
			}
			court_position_generator_shared_modifier = {
				POS = stonemason_master
				EMPLOYER = $EMPLOYER$
			}
			court_position_generator_variable_effect = {
				VAR = $VAR$
				POS = stonemason_master
				EMPLOYER = $EMPLOYER$
			}
		}
#####################

	}
}

# Gives job of court position suitable to a character's skills
# Job is picked in court_position_generator_effect
# VAR - valid parameters: 'target', 'second', 'backup'
# EMPLOYER - should be the char hiring the position
# CANDIDATE - should be the char taking the position
court_position_generator_assignment_effect = {
	switch = {
		trigger = $CANDIDATE$.var:$VAR$_court_position
		# Architect
		flag:royal_architect = {
			court_position_grant_effect = { POS = royal_architect CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Seneschal
		flag:seneschal = {
			court_position_grant_effect = { POS = seneschal CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Court Tutor
		flag:court_tutor = {
			court_position_grant_effect = { POS = court_tutor CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# High Almoner
		flag:high_almoner = {
			court_position_grant_effect = { POS = high_almoner CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Physician
		flag:court_physician = {
			court_position_grant_effect = { POS = court_physician CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Antiquarian
		flag:antiquarian = {
			court_position_grant_effect = { POS = antiquarian CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Master of the Horse
		flag:master_of_horse = {
			court_position_grant_effect = { POS = master_of_horse CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		} 
		# Bodyguard
		flag:bodyguard = {
			court_position_grant_effect = { POS = bodyguard CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Champion
		flag:champion = {
			court_position_grant_effect = { POS = champion CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Master of the Hunt
		flag:master_of_hunt = {
			court_position_grant_effect = { POS = master_of_hunt CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Poet
		flag:court_poet = {
			court_position_grant_effect = { POS = court_poet CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Musician
		flag:court_musician = {
			court_position_grant_effect = { POS = court_musician CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Court Jester
		flag:court_jester = {
			court_position_grant_effect = { POS = court_jester CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Executioner
		flag:executioner = {
			court_position_grant_effect = { POS = executioner CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Food Taster
		flag:food_taster = {
			court_position_grant_effect = { POS = food_taster CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Cupbearer
		flag:cupbearer = {
			court_position_grant_effect = { POS = cupbearer CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Lady-in-waiting
		flag:lady_in_waiting = {
			court_position_grant_effect = { POS = lady_in_waiting CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		} 
		# Eunuch
		flag:chief_eunuch = {
			court_position_grant_effect = { POS = chief_eunuch CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Gardener
		flag:court_gardener = {
			court_position_grant_effect = { POS = court_gardener CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Court Artificer
		flag:court_artificer = {
			court_position_grant_effect = { POS = court_artificer CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Cultural Emissary
		flag:cultural_emissary = {
			court_position_grant_effect = { POS = cultural_emissary CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Chief Qadi
		flag:chief_qadi = {
			court_position_grant_effect = { POS = chief_qadi CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Garuda
		flag:garuda = {
			court_position_grant_effect = { POS = garuda CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Keeper of the Swans
		flag:keeper_of_swans = {
			court_position_grant_effect = { POS = keeper_of_swans CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Caravan Master
		flag:travel_leader = {
			court_position_grant_effect = { POS = travel_leader CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Wet Nurse
		flag:wet_nurse = {
			court_position_grant_effect = { POS = wet_nurse CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Cave Hermit
		flag:cave_hermit = {
			court_position_grant_effect = { POS = cave_hermit CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Master Assassin
		flag:master_assassin = {
			court_position_grant_effect = { POS = master_assassin CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Court Scholar
		flag:court_scholar = {
			court_position_grant_effect = { POS = court_scholar CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Chronciler
		flag:chronicler = {
			court_position_grant_effect = { POS = chronicler CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
		# Akolouthos
		flag:akolouthos = {
			court_position_grant_effect = { POS = akolouthos CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
#####################
### KETAROS BLOCK ###
#####################
		flag:stonemason_master = {
			court_position_grant_effect = { POS = stonemason_master CANDIDATE = $CANDIDATE$ EMPLOYER = $EMPLOYER$ }
		}
#####################
	}
}

# Giving out generic court positions
decide_court_position_to_give_effect = {
	$EMPLOYER$ = {
		if = {
			limit = { exists = $CANDIDATE$ }
			if = {
				limit = {
					$CANDIDATE$ = { has_trait = education_learning }
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_physician_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = physician_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = high_almoner_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = almoner_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = antiquarian_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = antiquarian_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = chief_qadi_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = qadi_flag }
					}
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = { has_trait = education_intrigue }
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = food_taster_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = taster_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = executioner_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = executioner_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$ 
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = { has_trait = education_diplomacy }
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = cupbearer_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = cupbearer_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = lady_in_waiting_court_position
							}
							$CANDIDATE$ = { is_female = yes }
						}
						$CANDIDATE$ = { add_character_flag = lady_in_waiting_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					20 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_jester_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = jester_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_poet_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = poet_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_musician_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = musician_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = travel_leader_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = travel_leader_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = wet_nurse_court_position
							}
							$CANDIDATE$ = { is_female = yes }
						}
						$CANDIDATE$ = { add_character_flag = wet_nurse_flag }
					}
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = { has_trait = education_stewardship }
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_gardener_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = gardener_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = royal_architect_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = architect_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = keeper_of_swans_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = swan_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = seneschal_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = seneschal_flag }
					}
#####################
### KETAROS BLOCK ###
#####################
					10 = {	trigger = {
							can_appoint_char_to_court_position = {	CHAR = $CANDIDATE$
								COURT_POS = stonemason_master_court_position	}	}
						$CANDIDATE$ = { add_character_flag = stonemason_flag }
					}
#####################
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = { has_trait = education_martial }
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = master_of_horse_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = horse_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = garuda_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = garuda_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = master_of_hunt_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = hunt_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = bodyguard_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = bodyguard_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = champion_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = champion_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = akolouthos_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = akolouthos_flag }
					}
				}
			}
		}
	}
}
distribute_determined_court_position_effect = {
	$EMPLOYER$ = {
		if = {
			limit = { $CANDIDATE$ = { has_character_flag = physician_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = court_physician_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = tutor_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = court_tutor_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = almoner_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = high_almoner_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = antiquarian_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = antiquarian_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = qadi_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = chief_qadi_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = taster_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = food_taster_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = executioner_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = executioner_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = cupbearer_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = cupbearer_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = lady_in_waiting_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = lady_in_waiting_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = jester_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = court_jester_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = poet_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = court_poet_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = musician_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = court_musician_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = gardener_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = court_gardener_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = architect_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = royal_architect_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = swan_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = keeper_of_swans_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = seneschal_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = seneschal_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = horse_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = master_of_horse_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = garuda_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = garuda_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = hunt_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = master_of_hunt_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = bodyguard_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = bodyguard_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = champion_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = champion_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = travel_leader_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = travel_leader_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = wet_nurse_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = wet_nurse_court_position
			}
		}
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = akolouthos_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = akolouthos_court_position
			}
		}
#####################
### KETAROS BLOCK ###
#####################
		else_if = {
			limit = { $CANDIDATE$ = { has_character_flag = stonemason_flag } }
			appoint_court_position = {
				recipient = $CANDIDATE$
				court_position = stonemason_master_court_position
			}
		}
#####################
		
	}
}

