# Attend Children's Examination
### Attend Children's Examination ###
tgp_china_attend_child_exam_decision = {
	title = tgp_china_attend_child_exam_decision
	desc = tgp_china_attend_child_exam_decision_desc
	selection_tooltip = tgp_china_attend_child_exam_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/event_scenes/tgp_examination_room.dds"
	}

	cooldown = { years = 3 }
	sort_order = 80
	decision_group_type = major

	cost = {
		influence = {
			value = minor_influence_value
		}
	}

	is_shown = {
		age >= child_exam_min_age
		age <= 16
		has_tgp_dlc_trigger = yes
		government_allows = merit
		is_playable_character = yes
		NOT = { has_character_flag = passed_child_exam }
		has_domicile = yes
		is_landed = no
		trigger_if = {
			limit = {
				faith = { has_doctrine = doctrine_gender_female_dominated }
			}
			is_female = yes
		}
		trigger_else_if = {
			limit = {
				faith = { has_doctrine = doctrine_gender_male_dominated }
			}
			is_female = no
		}
		trigger_else = { always = yes }
	}

	is_valid = {
		top_liege.highest_held_title_tier >= tier_hegemony
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = tgp_china_attend_child_exam_age_limit
			age >= child_exam_min_age
		}
		is_imprisoned = no
		is_incapable = no
		has_contagious_deadly_disease_trigger = no
	}

	effect = {
		custom_tooltip = tgp_china_decision_effect_tt
		if = {
			limit = {
				employs_court_position = court_tutor_court_position
			}
			custom_description_no_bullet = {
				text = tutor_improved_exam_chances_tt
				object = root
			}
		}
		else = {
			custom_description_no_bullet = {
				text = tutor_needed_for_exam_chances_tt
				object = root
			}						
		}
		#Set variable for nr of safe bets player has made, so we do not need to check for it in every event.
		set_variable = {
			name = safe_bets
			value = 0
		}
		set_variable = {
			name = child_examination_success_chance
			value = child_examination_success_chance_value
		}
		trigger_event = tgp_china_decision.1000
	}

	ai_check_interval = 0

	ai_potential = {
	}

	ai_will_do = {
		base = 100
		modifier = {
			any_close_or_extended_family_member = { is_governor = yes }
			add = 25
		}
		modifier = {
			has_trait = ambitious
			add = 25
		}
		modifier = {
			has_trait = content
			add = -25
		}
		modifier = {
			has_religion = religion:confucianism_religion
			add = 25
		}
		modifier = {
			learning > high_skill_rating
			add = 25
		}
	}
}

# Command Family to attend Exams
tgp_command_family_to_take_exams_decision = {
	decision_group_type = admin
	title = tgp_command_family_to_take_exams_decision
	desc = tgp_command_family_to_take_exams_decision_desc
	selection_tooltip = tgp_command_family_to_take_exams_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/event_scenes/tgp_examination_room.dds"
	}
	sort_order = 90

	is_shown = {
		is_ai = no
		government_allows = merit
		has_tgp_dlc_trigger = yes
		this != top_liege
		exists = house.house_head
	}
	
	is_valid = {
		is_house_head = yes
	}

	is_valid_showing_failures_only = {
	}
	
	widget = {
		gui = "decision_view_widget_generic_multichoice_with_effects"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = yes

		item = { # Command to attend
			value = command_to_attend
			is_valid = {
				custom_tooltip = {
					text = command_to_attend_requirements_desc
					NOT = {
						has_character_flag = command_to_attend_flag
					}
				}
			}
			current_description = command_to_attend_desc
			localization = command_to_attend_name
			icon = "gfx/interface/icons/activities/activity_imperial_examination.dds"
			ai_chance = {
				value = 0
			}
		}
		item = { # Command to stop attending
			value = command_to_stop_attending
			is_valid = {
				custom_tooltip = {
					text = command_to_stop_attending_requirements_desc
					has_character_flag = command_to_attend_flag
				}
			}
			current_description = command_to_stop_attending_desc
			localization = command_to_stop_attending_name
			icon = "gfx/interface/icons/map_icons/map_icon_chinese_manor.dds"
			ai_chance = {
				value = 0
			}
		}
	}

	effect = {
		if = {
			limit = {
				scope:command_to_attend = yes
			}
			custom_tooltip = {
				text = command_to_attend_effect_desc
				add_character_flag = command_to_attend_flag
			}
		}
		else = {
			custom_tooltip = {
				text = command_to_stop_attending_effect_desc
				remove_character_flag = command_to_attend_flag
			}
		}
	}
	
	ai_check_interval = 0
}

# Choose Career Path Decision
### Choose Career Path ###
tgp_choose_career_path_decision = {
	decision_group_type = admin
	title = tgp_choose_career_path_decision
	desc = tgp_choose_career_path_decision_desc
	selection_tooltip = tgp_choose_career_path_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/tgp_career.dds"
	}
	sort_order = 90

	is_shown = {
		is_ai = no
		government_allows = merit
		has_tgp_dlc_trigger = yes
		this != top_liege
	}
	
	is_valid = {
		is_landed = no
		custom_tooltip = {
			text = you_are_not_a_minister_desc
			tgp_has_minister_title = no
		}
		custom_tooltip = {
			text = you_are_not_refusing_appointments_desc
			trigger_if = {
				limit = {
					has_variable = appointment_trait_override
				}
				var:appointment_trait_override != trait:intellect_good_3
			}
			trigger_else = {
				always = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		is_adult = yes
	}
	
	widget = {
		gui = "decision_view_widget_generic_multichoice_with_effects"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = no

		item = { # Choose a civilian career
			value = civilian_career
			is_valid = {
				custom_tooltip = {
					text = you_have_a_civilian_career_desc
					trigger_if = {
						limit = {
							has_variable = appointment_trait_override
						}
						var:appointment_trait_override != trait:education_stewardship_1
					}
					trigger_else = {
						NOT = { has_trait_with_flag = civilian_province }
					}
				}
			}
			current_description = tgp_choose_career_path_civilian_desc
			localization = tgp_choose_career_path_civilian_name
			icon = "gfx/interface/icons/celestial_administration_types/icon_game_concept_celestial_standard_administration.dds"
			ai_chance = {
				value = 0
			}
		}
		item = { # Choose a military career
			value = military_career
			is_valid = {
				custom_tooltip = {
					text = you_have_a_military_career_desc
					trigger_if = {
						limit = {
							has_variable = appointment_trait_override
						}
						var:appointment_trait_override != trait:education_martial_1
					}
					trigger_else = {
						NOT = { has_trait_with_flag = military_province }
					}
				}
			}
			current_description = tgp_choose_career_path_military_desc
			localization = tgp_choose_career_path_military_name
			icon = "gfx/interface/icons/celestial_administration_types/icon_game_concept_celestial_military_administration.dds"
			ai_chance = {
				value = 0
			}
		}
	}

	cost = {
		influence = {
			value = 50
		}
	}

	effect = {
		if = {
			limit = {
				scope:military_career = yes
			}
			custom_tooltip = {
				text = change_to_military_career_desc
				set_variable = {
					name = appointment_trait_override
					value = trait:education_martial_1
				}
			}
		}
		else = {
			custom_tooltip = {
				text = change_to_civilian_career_desc
				set_variable = {
					name = appointment_trait_override
					value = trait:education_stewardship_1
				}
			}
		}
	}
	
	ai_check_interval = 0
}

# Refuse Appointments
### Refuse Further Appointments ###
tgp_refuse_appointments_decision = {
	decision_group_type = admin
	title = tgp_refuse_appointments_decision
	desc = tgp_refuse_appointments_decision_desc
	selection_tooltip = tgp_refuse_appointments_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/tgp_retire.dds"
	}
	confirm_text = tgp_refuse_appointments_decision_confirm
	sort_order = 75

	is_shown = {
		government_has_flag = government_has_merit
		has_tgp_dlc_trigger = yes
		this != top_liege
		custom_tooltip = {
			text = you_are_not_refusing_appointments_desc
			appointment_timeout_days < 36500
		}
	}

	is_valid_showing_failures_only = {
		is_adult = yes
		is_available = yes
	}

	cost = {
		influence = {
			value = 50
		}
	}

	effect = {
		custom_tooltip = {
			text = tgp_refuse_appointments_decision_refuse_desc
			set_appointment_timeout = {
				years = 150 # I.e. we make it pseudo-permanent
				desc = appointment_timeout_desc_refusing
			}
		}
	}
	
	ai_check_interval = 0
	
	ai_potential = { always = no }
}

# Resume Appointments
### Resume New Appointments ###
tgp_resume_appointments_decision = {
	decision_group_type = admin
	title = tgp_resume_appointments_decision
	desc = tgp_resume_appointments_decision_desc
	selection_tooltip = tgp_resume_appointments_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/tgp_career.dds"
	}
	confirm_text = tgp_resume_appointments_decision_confirm
	sort_order = 75

	is_shown = {
		government_has_flag = government_has_merit
		has_tgp_dlc_trigger = yes
		this != top_liege
		appointment_timeout_days > 0
	}

	is_valid_showing_failures_only = {
		is_adult = yes
		is_available = yes
	}

	cost = {
	}

	effect = {
		custom_tooltip = {
			text = tgp_refuse_appointments_decision_accept_desc
			clear_appointment_timeout = yes
		}
	}
	
	ai_check_interval = 0
	
	ai_potential = { always = no }
}

#### Request Bestowal of Honors ###
#tgp_minister_request_bestowal_of_honors_decision = {
#	decision_group_type = major
#	title = tgp_minister_request_bestowal_of_honors_decision
#	desc = tgp_minister_request_bestowal_of_honors_decision_desc
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/tgp_kowtow.dds"
#	}
#	sort_order = 1000
#
#	is_shown = {
#		exists = house
#		government_has_flag = government_is_celestial
#		liege = { tgp_has_access_to_ministry_trigger = yes }
#		# keep them in hard enum, since we can not avoid touch this decision by encapsulation
#		OR = {
#			has_title = title:e_minister_chancellor
#			has_title = title:e_minister_censor
#			has_title = title:e_minister_grand_marshal
#			has_title = title:e_minister_of_personnel
#			has_title = title:e_minister_of_revenue
#			has_title = title:e_minister_of_rites
#			has_title = title:e_minister_of_war
#			has_title = title:e_minister_of_justice
#			has_title = title:e_minister_of_works
#		}
#	}
#	
#	is_valid = {
#		influence_level >= 5
#		OR = {
#			has_title = title:e_minister_chancellor
#			has_title = title:e_minister_censor
#			has_title = title:e_minister_grand_marshal
#			has_title = title:e_minister_of_personnel
#			has_title = title:e_minister_of_revenue
#			has_title = title:e_minister_of_rites
#			has_title = title:e_minister_of_war
#			has_title = title:e_minister_of_justice
#			has_title = title:e_minister_of_works
#		}
#	}
#
#	is_valid_showing_failures_only = {
#		is_at_war = no
#		is_adult = yes
#		root.top_liege = {
#			is_physically_able = yes
#		}
#		trigger_if = {
#			limit = {
#				has_title = title:e_minister_chancellor
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_chancellor_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_censor
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_censor_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_grand_marshal
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_grand_marshal_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_of_personnel
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_of_personnel_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_of_revenue
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_of_revenue_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_of_rites
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_of_rites_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_of_war
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_of_war_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_of_justice
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_of_justice_modifier
#				}
#			}
#		}
#		trigger_else_if = {
#			limit = {
#				has_title = title:e_minister_of_works
#			}
#			NOT = {
#				house = {
#					has_house_modifier = tgp_e_minister_of_works_modifier
#				}
#			}
#		}
#		trigger_else = {
#			always = yes
#		}
#	}
#	
#	cost = {
#		influence = {
#			value = 5000
#		}
#	}
#
#	effect = {
#		close_view = {
#			view = decisions
#			player = root
#		}
#		trigger_event = tgp_china_ministry.1000
#		show_as_tooltip = {
#			reverse_add_opinion = {
#				target = root.top_liege
#				modifier = honorable_opinion
#				opinion = 50
#			}
#			add_character_modifier = tgp_personal_honors_modifier
#			if = {
#				limit = {
#					has_title = title:e_minister_chancellor
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_chancellor_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_censor
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_censor_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_grand_marshal
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_grand_marshal_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_of_personnel
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_of_personnel_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_of_revenue
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_of_revenue_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_of_rites
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_of_rites_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_of_war
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_of_war_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_of_justice
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_of_justice_modifier
#				}
#			}
#			else_if = {
#				limit = {
#					has_title = title:e_minister_of_works
#				}
#				house = {
#					add_house_modifier = tgp_e_minister_of_works_modifier
#				}
#			}
#			dynasty = { add_dynasty_prestige = 2000 }
#		}
#	}
#	
#	ai_check_interval_by_tier = {
#		barony = 0
#		county = 0
#		duchy = 0
#		kingdom = 0
#		empire = 12
#		hegemony = 0
#	}
#	
#	ai_potential = {
#		government_has_flag = government_is_celestial
#	}
#	
#	ai_will_do = { base = 100 }
#}
#
## Recruit Courtiers from Celestial Capital
#### Summon Courtiers for the Celestial Bureau ###
#tgp_minister_recruit_courtiers_decision = {
#	decision_group_type = courtier
#	title = tgp_minister_recruit_courtiers_decision
#	desc = tgp_minister_recruit_courtiers_decision_desc
#	selection_tooltip = tgp_minister_recruit_courtiers_decision_tooltip
#	picture = {
#		reference = "gfx/interface/illustrations/event_scenes/tgp_courtyard_asia.dds"
#	}
#	sort_order = 110
#
#	is_shown = {
#		government_has_flag = government_is_celestial
#		liege = { tgp_has_access_to_ministry_trigger = yes }
#		OR = {
#			has_title = title:e_minister_chancellor
#			has_title = title:e_minister_censor
#			has_title = title:e_minister_grand_marshal
#			has_title = title:e_minister_of_personnel
#			has_title = title:e_minister_of_revenue
#			has_title = title:e_minister_of_rites
#			has_title = title:e_minister_of_war
#			has_title = title:e_minister_of_justice
#			has_title = title:e_minister_of_works
#		}
#	}
#	
#	is_valid = {
#	}
#
#	is_valid_showing_failures_only = {
#		is_at_war = no
#		is_adult = yes
#	}
#	
#	cooldown = { years = 2 }
#	
#	widget = {
#		gui = "decision_view_widget_option_list_generic"
#		controller = decision_option_list_controller
#		decision_to_second_step_button = "CHOOSE_NOMAD_COURTIER_DECISION_NEXT_STEP_BUTTON"
#		show_from_start = yes
#
#		item = {
#			value = minister_recruit_administrator
#			is_valid = {
#				NOR = {
#					has_title = title:e_minister_grand_marshal
#					has_title = title:e_minister_of_rites
#					has_title = title:e_minister_of_war
#				}
#			}
#			current_description = minister_recruit_administrator_desc
#			localization = minister_recruit_administrator_desc
#			icon = "gfx/interface/icons/modifiers/icon_merit_07.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = minister_recruit_diplomat
#			is_valid = {
#				NOR = {
#					has_title = title:e_minister_grand_marshal
#					has_title = title:e_minister_of_rites
#					has_title = title:e_minister_of_war
#					has_title = title:e_minister_of_works
#				}
#			}
#			current_description = minister_recruit_diplomat_desc
#			localization = minister_recruit_diplomat_desc
#			icon = "gfx/interface/icons/court_position_types/grand_historian_court_position.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = minister_recruit_commander
#			is_valid = {
#				NOR = {
#					has_title = title:e_minister_censor
#					has_title = title:e_minister_of_revenue
#					has_title = title:e_minister_of_rites
#					has_title = title:e_minister_of_justice
#					has_title = title:e_minister_of_works
#				}
#			}
#			current_description = minister_recruit_commander_desc
#			localization = minister_recruit_commander_desc
#			icon = "gfx/interface/icons/character_interactions/icon_coax_to_war.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = minister_recruit_warrior
#			is_valid = {
#				NOR = {
#					has_title = title:e_minister_censor
#					has_title = title:e_minister_of_revenue
#					has_title = title:e_minister_of_rites
#					has_title = title:e_minister_of_justice
#					has_title = title:e_minister_of_works
#				}
#			}
#			current_description = minister_recruit_warrior_desc
#			localization = minister_recruit_warrior_desc
#			icon = "gfx/interface/icons/character_interactions/icon_combat.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = minister_recruit_scholar
#			is_valid = {
#				NOR = {
#					has_title = title:e_minister_censor
#					has_title = title:e_minister_grand_marshal
#					has_title = title:e_minister_of_revenue
#					has_title = title:e_minister_of_war
#				}
#			}
#			current_description = minister_recruit_scholar_desc
#			localization = minister_recruit_scholar_desc
#			icon = "gfx/interface/icons/character_interactions/imperial_examination.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = minister_recruit_confucian_scholar
#			is_valid = {
#				NOR = {
#					has_title = title:e_minister_censor
#					has_title = title:e_minister_grand_marshal
#					has_title = title:e_minister_of_revenue
#					has_title = title:e_minister_of_war
#					has_title = title:e_minister_of_works
#				}
#			}
#			current_description = minister_recruit_confucian_scholar_desc
#			localization = minister_recruit_confucian_scholar_desc
#			icon = "gfx/interface/icons/modifiers/icon_piety_confucianism_02.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = minister_recruit_eunuch
#			is_valid = {
#				NOR = {
#					has_title = title:e_minister_grand_marshal
#					has_title = title:e_minister_of_revenue
#					has_title = title:e_minister_of_rites
#					has_title = title:e_minister_of_war
#					has_title = title:e_minister_of_justice
#					has_title = title:e_minister_of_works
#				}
#			}
#			current_description = minister_recruit_eunuch_desc
#			localization = minister_recruit_eunuch_desc
#			icon = "gfx/interface/icons/character_interactions/provincial_examination.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#	}
#
#	cost = {
#		treasury = {
#			value = 100
#		}
#	}
#
#	effect = {
#		save_scope_as = minister_scope
#		custom_tooltip = tgp_minister_recruit_courtiers_decision_effect_desc
#		hidden_effect = {
#			if = {
#				limit = { scope:minister_recruit_administrator = yes }
#				minister_courtier_recruitment_effect = { COURTIER_TEMPLATE = tgp_minister_administrator_template }
#			}
#			else_if = {
#				limit = { scope:minister_recruit_diplomat = yes }
#				minister_courtier_recruitment_effect = { COURTIER_TEMPLATE = tgp_minister_diplomat_template }
#			}
#			else_if = {
#				limit = { scope:minister_recruit_commander = yes }
#				minister_courtier_recruitment_effect = { COURTIER_TEMPLATE = tgp_minister_commander_template }
#			}
#			else_if = {
#				limit = { scope:minister_recruit_warrior = yes }
#				minister_courtier_recruitment_effect = { COURTIER_TEMPLATE = tgp_minister_warrior_template }
#			}
#			else_if = {
#				limit = { scope:minister_recruit_scholar = yes }
#				minister_courtier_recruitment_effect = { COURTIER_TEMPLATE = tgp_minister_scholar_template }
#			}
#			else_if = {
#				limit = { scope:minister_recruit_confucian_scholar = yes }
#				minister_courtier_recruitment_effect = { COURTIER_TEMPLATE = tgp_minister_confucian_scholar_template }
#			}
#			else_if = {
#				limit = { scope:minister_recruit_eunuch = yes }
#				minister_courtier_recruitment_effect = { COURTIER_TEMPLATE = tgp_minister_eunuch_template }
#			}
#		}
#	}
#	
#	ai_check_interval_by_tier = {
#		barony = 0
#		county = 0
#		duchy = 0
#		kingdom = 0
#		empire = 12
#		hegemony = 0
#	}
#	
#	ai_potential = {
#		liege = { tgp_has_access_to_ministry_trigger = yes }
#		is_councillor = yes
#		any_courtier = { count <= 10 }
#	}
#	
#	ai_will_do = { base = 100 }
#}

# Study Confucian Classics
### Study the Confucian Classics ###
tgp_china_study_confucian_classics_decision = {
	decision_group_type = admin
	title = tgp_china_study_confucian_classics_decision
	desc = tgp_china_study_confucian_classics_decision_desc
	selection_tooltip = tgp_china_study_confucian_classics_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/tgp_debate.dds"
	}
	sort_order = 120
	
	cooldown = { years = 5 }

	cost = {
	}

	is_shown = {
		has_tgp_dlc_trigger = yes
		government_allows = merit
		is_playable_character = yes
		NOT = { top_liege = root }
	}

	is_valid = {
		knows_language = language_chinese
		custom_tooltip = {
			text = tgp_china_study_confucian_classics_decision_req_tt
			NOT = {
				any_scheme = {
					type = study_confucian_classics
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		NOT = {
			has_character_modifier = tgp_gave_up_modifier
		}
		is_available = yes
		can_start_scheme = {
			type = study_confucian_classics
			target_character = root
		}
	}

	effect = {
		custom_tooltip = {
			text = tgp_china_study_confucian_classics_decision_tt
			start_scheme = {
				type = study_confucian_classics
				target_character = root
			}
			close_view = {
				view = decisions
				player = root
			}
			random_scheme = {
				type = study_confucian_classics
				save_scope_as = scheme
			}
			save_scope_as = owner
			trigger_event = study_confucian_classics_outcome.10
		}
		if = {
			limit = {
				any_scheme = { is_scheme_category = personal }
			}
			custom_tooltip = tgp_china_study_confucian_classics_decision_end_scheme_tt
		}
		if = {
			limit = { is_landed = yes }
			custom_tooltip = tgp_china_study_confucian_classics_decision_recommendations_tt
		}
	}

	ai_check_interval = 0

	ai_potential = {
	}

	ai_will_do = {
		base = 100
	}
}

### Claim the Mantle of Maitreya ###
tgp_claim_the_mantle_of_maitreya_decision = {
	ai_check_interval = 0
	picture = {
		reference = "gfx/interface/illustrations/event_scenes/tgp_holysite_asia.dds"
	}
	desc = claim_the_mantle_of_maitreya_decision_desc
	decision_group_type = major

	selection_tooltip = claim_the_mantle_of_maitreya_decision_tooltip

	cooldown = { years = 30 }

	is_shown = {
		faith = {
			has_doctrine = tenet_extinction_of_dharma
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = the_maitreya_already_exists
			NOT = {
				has_global_variable = the_maitreya_has_descended
			}
		}
		is_available_adult = yes
	}

	is_valid = {
		is_independent_ruler = yes
		capital_county.faith = root.faith
		piety_level >= 5
		OR = {
			has_trait = zealous
			has_trait = peasant_leader
			has_trait = possessed
			has_trait = lunatic
		}
		highest_held_title_tier >= tier_kingdom
		custom_tooltip = {
			text = maitreya_hof_requirement
			OR = {
				NOT = {
					exists = faith.religious_head
				}
				faith.religious_head ?= this
			}
		}
	}

	cost = {
		prestige = {
			value = monumental_prestige_value
		}
		piety = {
			value = monumental_piety_value
		}
	}

	effect = {
		faith = {
			change_fervor = {
				value = 100
				desc = maitreya_has_descended_fervor_desc
			}
		}
		add_character_modifier = claimed_mantle_of_maitreya_modifier
		hidden_effect = {
			set_global_variable = {
				name = the_maitreya_has_descended
				value = yes
			}
		}
		spawn_army = {
			levies = maitreya_devotee_army_value
			location = root.capital_province
			origin = root.capital_province
			inheritable = no
			name = maitreya_devotees
		}
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

# Drink Tea/Perform Tea Ceremony - Unlocked from the Asian Estate
### Drink Tea ###
tgp_tea_ceremony_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_scenes/tgp_relaxing_room_asia.dds"
	}
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					culture = { has_cultural_pillar = heritage_chinese }
				}
				desc = tgp_tea_ceremony_decision
			}
			desc = tgp_tea_ceremony_decision_ceremony_name
		}
	}
	desc = tgp_tea_ceremony_decision_desc
	sort_order = 200

	selection_tooltip = tgp_tea_ceremony_decision_tooltip

	cooldown = { years = 5 }

	is_shown = {
		domicile ?= { has_domicile_parameter = estate_unlock_tea_ceremony }
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
	}

	is_valid = {
	}

	cost = {
		piety = {
			value = minor_piety_value
		}
	}

	effect = {
		custom_tooltip = {
			text = tgp_tea_ceremony_decision_effect_desc
			
			random_courtier = {
				limit = {
					is_available_adult = yes
				}
				weight = {
					base = 5
					
					modifier = {
						add = 5
						is_close_family_of = root
					}
					modifier = {
						add = 3
						exists = house
						house = root.house
					}
					modifier = {
						add = {
							value = learning
							divide = 4
						}
						learning >= 10
					}
				}
				save_scope_as = inspired_courtier
			}
			
			send_interface_toast = {
				type = event_toast_effect_good
				title = tgp_tea_ceremony_decision_toast
				left_icon = root
				
				# Lose stress
				if = {
					limit = { stress > 0 }
					stress_impact = {
						base = -25
						content = medium_stress_impact_loss
						humble = minor_stress_impact_loss
						patient = minor_stress_impact_loss
						calm = minor_stress_impact_loss
						gregarious = minor_stress_impact_loss
					}
				}
				# Gain a random effect
				random_list = {
					20 = { # Gain opinion
						trigger = {
							exists = scope:inspired_courtier
						}
						
						progress_towards_friend_effect = {
							REASON = friend_drinking_tea
							CHARACTER = scope:inspired_courtier
							OPINION = default_friend_opinion
						}
					}
					10 = { # Courtier becomes inspired
						trigger = {
							exists = scope:inspired_courtier
						}
						
						# Add inspiration
						if = {
							limit = {
								has_royal_court = yes
							}
							grant_inspiration_to_character_effect = { CHARACTER = scope:inspired_courtier }
						}
						else = {
							grant_inspiration_to_character_no_court_artifacts_effect = { CHARACTER = scope:inspired_courtier }
						}
						# Custom tooltip to explain that a courtier was inspired
						custom_tooltip = courtier_inspired_effect
					}
					10 = { # Health negation
						add_character_modifier = {
							modifier = tea_ceremony_health_benefit
							years = 5
						}
					}
					10 = { # Diplomacy
						add_character_modifier = {
							modifier = tea_ceremony_perfect_tea
							years = 5
						}
					}
					10 = { # Stress
						add_character_modifier = {
							modifier = tea_ceremony_peace_of_mind
							years = 5
						}
					}
					10 = { # Spirit/piety
						add_character_modifier = {
							modifier = tea_ceremony_spirit
							years = 5
						}
					}
					10 = { # Family
						add_character_modifier = {
							modifier = tea_ceremony_family
							years = 5
						}
					}
				}
			}
		}
	}
	
	ai_check_interval = 0
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}
#
## Suggest Treasury Audit
#### Suggest Treasury Audit ###
#tgp_suggest_budget_change_decision = {
#	decision_group_type = admin
#	title = tgp_suggest_budget_change_decision
#	desc = tgp_suggest_budget_change_decision_desc
#	selection_tooltip = tgp_suggest_budget_change_decision_tooltip
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/tgp_scholars.dds"
#	}
#	sort_order = 110
#
#	is_shown = {
#		government_has_flag = government_is_celestial
#		liege = { tgp_has_access_to_ministry_trigger = yes }
#		has_title = title:e_minister_of_revenue
#	}
#	
#	is_valid = {
#	}
#
#	is_valid_showing_failures_only = {
#		is_at_war = no
#		is_adult = yes
#	}
#	
#	cooldown = { years = 3 }
#	
#	widget = {
#		gui = "decision_view_widget_option_list_generic"
#		controller = decision_option_list_controller
#		decision_to_second_step_button = "SELECT_ACTION"
#		show_from_start = yes
#
#		item = {
#			value = suggest_salary_budget
#			is_valid = {
#				custom_tooltip = {
#					text = liege_already_has_budget_desc
#					can_suggest_budget_salary_template_trigger = yes
#				}
#			}
#			current_description = suggest_salary_budget_desc
#			localization = suggest_salary_budget_desc
#			icon = "gfx/interface/icons/character_interactions/icon_gold.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = suggest_ministry_budget
#			is_valid = {
#				custom_tooltip = {
#					text = liege_already_has_budget_desc
#					can_suggest_budget_ministry_template_trigger = yes
#				}
#			}
#			current_description = suggest_ministry_budget_desc
#			localization = suggest_ministry_budget_desc
#			icon = "gfx/interface/icons/government_types/celestial_government.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = suggest_military_budget
#			is_valid = {
#				custom_tooltip = {
#					text = liege_already_has_budget_desc
#					can_suggest_budget_military_template_trigger = yes
#				}
#			}
#			current_description = suggest_military_budget_desc
#			localization = suggest_military_budget_desc
#			icon = "gfx/interface/icons/celestial_administration_types/icon_game_concept_celestial_military_administration.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = suggest_hegemon_budget
#			is_valid = {
#				custom_tooltip = {
#					text = liege_already_has_budget_desc
#					can_suggest_budget_hegemon_template_trigger = yes
#				}
#			}
#			current_description = suggest_hegemon_budget_desc
#			localization = suggest_hegemon_budget_desc
#			icon = "gfx/interface/icons/legitimacy_types/mandate_legitimacy.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = suggest_balanced_budget
#			is_valid = {
#				custom_tooltip = {
#					text = liege_already_has_budget_desc
#					can_suggest_budget_balanced_template_trigger = yes
#				}
#			}
#			current_description = suggest_balanced_budget_desc
#			localization = suggest_balanced_budget_desc
#			icon = "gfx/interface/icons/character_interactions/scroll_scales.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = suggest_salary_increase
#			is_valid = {
#				liege = {
#					NOT = { realm_law_group_at_maximum_level = budget_allocation_salary_law }
#				}
#			}
#			current_description = increase_budget_salary_desc
#			localization = increase_budget_salary_name
#			icon = "gfx/interface/icons/character_interactions/icon_gold.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = suggest_ministry_increase
#			is_valid = {
#				liege = {
#					NOT = { realm_law_group_at_maximum_level = budget_allocation_ministry_law }
#				}
#			}
#			current_description = increase_budget_ministry_desc
#			localization = increase_budget_ministry_name
#			icon = "gfx/interface/icons/court_position_types/favored_minister_court_position.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#		item = {
#			value = suggest_military_increase
#			is_valid = {
#				liege = {
#					NOT = { realm_law_group_at_maximum_level = budget_allocation_military_law }
#				}
#			}
#			current_description = increase_budget_military_desc
#			localization = increase_budget_military_name
#			icon = "gfx/interface/icons/message_feed/soldier.dds"
#			ai_chance = {
#				value = 100
#			}
#		}
#	}
#
#	cost = {
#		influence = {
#			value = medium_influence_value
#		}
#	}
#
#	effect = {
#		save_scope_as = minister_of_revenue
#		liege = { save_scope_as = treasury_ruler }
#		custom_tooltip = tgp_suggest_budget_change_decision_liege_desc
#		if = {
#			limit = { scope:suggest_salary_budget = yes }
#			custom_tooltip = tgp_treasury_enact_salary_budget_desc
#			save_scope_as = budget_suggestion_salary_template
#		}
#		else_if = {
#			limit = { scope:suggest_ministry_budget= yes }
#			custom_tooltip = tgp_treasury_enact_ministry_budget_desc
#			save_scope_as = budget_suggestion_ministry_template
#		}
#		else_if = {
#			limit = { scope:suggest_military_budget = yes }
#			custom_tooltip = tgp_treasury_enact_military_budget_desc
#			save_scope_as = budget_suggestion_military_template
#		}
#		else_if = {
#			limit = { scope:suggest_hegemon_budget = yes }
#			custom_tooltip = tgp_treasury_enact_hegemon_budget_desc
#			save_scope_as = budget_suggestion_hegemon_template
#		}
#		else_if = {
#			limit = { scope:suggest_balanced_budget = yes }
#			custom_tooltip = tgp_treasury_enact_balanced_budget_desc
#			save_scope_as = budget_suggestion_balanced_template
#		}
#		else_if = {
#			limit = { scope:suggest_salary_increase = yes }
#			custom_tooltip = increase_budget_salary_tooltip
#			save_scope_as = budget_suggestion_salary_increase
#		}
#		else_if = {
#			limit = { scope:suggest_ministry_increase = yes }
#			custom_tooltip = increase_budget_ministry_tooltip
#			save_scope_as = budget_suggestion_ministry_increase
#		}
#		else_if = {
#			limit = { scope:suggest_military_increase = yes }
#			custom_tooltip = increase_budget_military_tooltip
#			save_scope_as = budget_suggestion_military_increase
#		}
#		liege = {
#			trigger_event = { id = tgp_china_ministry.0200 days = 1 }
#		}
#	}
#	
#	ai_check_interval_by_tier = {
#		barony = 0
#		county = 0
#		duchy = 0
#		kingdom = 0
#		empire = 0
#		hegemony = 0
#	}
#	
#	ai_potential = {
#		always = no
#	}
#	
#	ai_will_do = { base = 0 }
#}
#

### Withdraw Fund from Treasury ###
extract_gold_from_treasury = {
	picture = {
		trigger = {
			culture = {
				has_graphical_east_asia_culture_group_trigger = yes
			}
		}
		reference = "gfx/interface/illustrations/decisions/tgp_scholars.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3_decision_tax_collector.dds"
	}

	desc = extract_gold_from_treasury_desc
	decision_group_type = admin
	selection_tooltip = extract_gold_from_treasury_tooltip
	sort_order = 110

	cooldown = { years = 2 }

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		is_playable_character = yes
		has_treasury = yes
		OR = {
			is_independent_ruler = yes
			tgp_is_any_minister = yes
		}
	}

	is_valid_showing_failures_only = {
		treasury >= medium_treasury_value
		trigger_if = {
			limit = {
				is_valid_for_legitimacy_change = yes
			}
			legitimacy_level > 0
		}
	}

	effect = {
		remove_short_term_treasury = medium_treasury_value
		add_short_term_gold = medium_treasury_value

		if = {
			limit = {
				is_valid_for_legitimacy_change = yes
			}

			add_legitimacy = {
				value = major_legitimacy_loss
				min = {
					value = medium_treasury_value
					multiply = -0.5
				}
			}
			add_character_modifier = {
				modifier = tgp_dipped_into_treasury_modifier
				years = 3
			}
		}
		else_if = {
			limit = {
				tgp_is_any_minister = yes
			}
			add_character_modifier = {
				modifier = tgp_minister_dipped_into_treasury_modifier
				years = 3
			}
		}

		if = {
			limit = {
				top_liege.primary_title = title:h_china
			}
			tgp_activate_catalyst_against_hegemon_effect = {
				HEGEMON = root.top_liege
				CATALYST = catalyst_dipped_into_treasury
			}
		}
	}

	cost = {
		influence = {
			value = 0
			if = {
				limit = { is_valid_for_legitimacy_change = no }
				add = massive_influence_value
			}
		}
	}

	ai_potential = {
		OR = {
			gold < 0
			AND = {
				top_liege = this
				gold < massive_gold_value
				ai_greed > high_positive_ai_value
			}
		}
		# Don't do it if this when at low legitimacy, as the top ruler
		OR = {
			top_liege != this
			legitimacy_level > 1
		}
	}

	ai_will_do = {
		base = 100
	}
}
