# Court Position re-assignment events
namespace = court_position_management_event

# Generic / landed character court position vacated event, offer the up to two best candidates by aptitude
court_position_management_event.0001 = {
	type = character_event
	title = court_position_management_event.0001.t
	theme = court

	desc = {
		desc = court_position_management_event.0001.desc
		triggered_desc = {
			trigger = {
				scope:employee = {
					is_alive = no
				}
			}
			desc = court_position_management_event.0001.desc.dead
		}
		triggered_desc = {
			trigger = {
				exists = scope:candidate_1
				NOT = { exists = scope:candidate_2 }
			}
			desc = court_position_management_event.0001.desc.one_candidate
		}
		triggered_desc = {
			trigger = {
				exists = scope:candidate_1
				exists = scope:candidate_2
			}
			desc = court_position_management_event.0001.desc.two_candidates
		}
		triggered_desc = {
			trigger = {
				NOT = { exists = scope:candidate_1 }
				NOT = { exists = scope:candidate_2 }
			}
			desc = court_position_management_event.0001.desc.no_candidates
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:candidate_1 }
				NOT = { exists = scope:candidate_2 }
			}
			save_scope_as = left_portrait_character
		}
		else = {
			scope:candidate_1 = {
				save_scope_as = left_portrait_character
			}
		}
	}

	left_portrait = {
		character = scope:left_portrait_character

		# If we have no candidates, we're just stand there, thinking
		triggered_animation = {
			trigger = { scope:left_portrait_character = root }
			animation = thinking
		}
	}

	right_portrait = scope:candidate_2
	lower_center_portrait = scope:employee

	# Pick candidate #1
	option = {
		name = court_position_management_event.0001.a
		custom_tooltip = court_position_management_event.0001.a.aptitude
		trigger = {
			exists = scope:candidate_1
			exists = scope:court_position_type
		}
		appoint_court_position = {
			recipient = scope:candidate_1
			court_position = scope:court_position_type
		}
	}

	# Pick candidate #2
	option = {
		name = court_position_management_event.0001.b
		custom_tooltip = court_position_management_event.0001.b.aptitude
		trigger = {
			exists = scope:candidate_2
		}
		appoint_court_position = {
			recipient = scope:candidate_2
			court_position = scope:court_position_type
		}
	}

	# Go to a recruitment decision
	option = {
		name = court_position_management_event.0001.c
		custom_tooltip = court_position_management_event.0001.c.tt

		# Court positions that are valid in 'recruit_court_position_decision'
		trigger = {
			NOT = { exists = scope:candidate_1 }
			NOT = { exists = scope:candidate_2 }
			OR = {
				scope:court_position_type = court_position_type:travel_leader_court_position
				scope:court_position_type = court_position_type:court_physician_court_position
				scope:court_position_type = court_position_type:wet_nurse_court_position
				scope:court_position_type = court_position_type:charioteer_court_position
				scope:court_position_type = court_position_type:chief_eunuch_court_position
				scope:court_position_type = court_position_type:court_gardener_court_position
			}
		}

		open_view_data = {
			view = decision_detail
			data = decision:recruit_court_position_decision
			player = root
		}
	}

	# I will figure this out myself
	option = {
		name = court_position_management_event.0001.d
		custom_tooltip = court_position_management_event.0001.d.tt

		trigger = {
        	exists = scope:candidate_1
		}

		open_view_data = {
			view = appoint_position
			data = scope:court_position_type
			player = root
		}
	}

	# Leave it open
	option = {
		name = court_position_management_event.0001.e
	}
}


# Landless adventurer court position vacated event, offer the up to two best candidates by aptitude
court_position_management_event.0002 = {
	type = character_event
	title = court_position_management_event.0002.t
	theme = landless_adventurer

	desc = {
		desc = court_position_management_event.0002.desc
		triggered_desc = {
			trigger = {
				scope:employee = {
					is_alive = no
				}
			}
			desc = court_position_management_event.0002.desc.dead
		}
		triggered_desc = {
			trigger = {
				exists = scope:candidate_1
				NOT = { exists = scope:candidate_2 }
			}
			desc = court_position_management_event.0002.desc.one_candidate
		}
		triggered_desc = {
			trigger = {
				exists = scope:candidate_1
				exists = scope:candidate_2
			}
			desc = court_position_management_event.0002.desc.two_candidates
		}
		triggered_desc = {
			trigger = {
				NOT = { exists = scope:candidate_1 }
				NOT = { exists = scope:candidate_2 }
			}
			desc = court_position_management_event.0002.desc.no_candidates
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:candidate_1 }
				NOT = { exists = scope:candidate_2 }
			}
			save_scope_as = left_portrait_character
		}
		else = {
			scope:candidate_1 = {
				save_scope_as = left_portrait_character
			}
		}
	}

	left_portrait = {
		character = scope:left_portrait_character

		# If we have no candidates, we're just stand there, thinking
		triggered_animation = {
			trigger = { scope:left_portrait_character = root }
			animation = thinking
		}
	}

	right_portrait = scope:candidate_2
	lower_center_portrait = scope:employee

	# Pick candidate #1
	option = {
		name = court_position_management_event.0002.a
		custom_tooltip = court_position_management_event.0002.a.aptitude
		trigger = {
			exists = scope:candidate_1
			exists = scope:court_position_type
		}
		appoint_court_position = {
			recipient = scope:candidate_1
			court_position = scope:court_position_type
		}
	}

	# Pick candidate #2
	option = {
		name = court_position_management_event.0002.b
		custom_tooltip = court_position_management_event.0002.b.aptitude
		trigger = {
			exists = scope:candidate_2
		}
		appoint_court_position = {
			recipient = scope:candidate_2
			court_position = scope:court_position_type
		}
	}

	# I will figure this out myself
	option = {
		name = court_position_management_event.0002.d
		custom_tooltip = court_position_management_event.0002.d.tt

		trigger = {
        	exists = scope:candidate_1
		}

		open_view_data = {
			view = appoint_position
			data = scope:court_position_type
			player = root
		}
	}

	# Leave it open
	option = {
		name = court_position_management_event.0002.e
	}
}
