﻿## Bride Show for most rulers ##
# Command Family to attend Exams
# worship_ancestors_decision = {
# 	title = {
# 		first_valid = {
# 			triggered_desc = {
# 				trigger = {
# 					culture = { has_cultural_parameter = dishu_system }
# 				}
# 				desc = worship_ancestors_decision_china_title
# 			}
# 			desc = worship_ancestors_decision
# 		}
# 	}
# 	desc = worship_ancestors_decision_desc
# 	selection_tooltip = worship_ancestors_decision_tooltip
# 	picture = {
# 		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
# 	}
# 	sort_order = 163
# 	cooldown = { years = 3 }
# 	confirm_text = worship_ancestors_decision_confirm

# 	is_shown = {
# 		is_landed_or_landless_administrative = yes
# 		OR = {
# 			culture = {
# 				OR = {
# 					has_cultural_parameter = dishu_system
# 					has_cultural_tradition = tradition_mystical_ancestors
# 				}
# 			}
# 			faith = {
# 				OR = {
# 					has_doctrine_parameter = parents_get_hooks_on_children
# 					has_doctrine = tenet_ancestor_worship
# 				}
# 			}
# 		}
# 		OR = { # House Heads or sovereigns
# 			house.house_head ?= this
# 			can_have_imperial_consorts_trigger = yes
# 		}
# 	}
	
# 	is_valid = {
# 		# The ancestors don't like illegititimate descendants
# 		is_bastard_child_trigger = no
# 		custom_description = {
# 			text = is_faith_dominant_gender_tooltip
# 			is_faith_dominant_gender = yes
# 		}
# 	}

# 	is_valid_showing_failures_only = {
# 		is_available_adult = yes
# 		custom_tooltip = {
# 			text = mourning_bride_show
# 			NOT = { has_character_modifier = mourner_modifier }
# 		}

# 		custom_tooltip = {
# 			text = contagious_disease_bride_show
# 			has_epidemic_disease_trigger = no
# 		}
# 		custom_tooltip = {
# 			text = epidemic_bride_show
# 			NOR = {
# 				realm_has_any_epidemic = {
# 					SIZE = 1
# 					INTENSITY = minor
# 				}
# 				capital_county ?= { has_county_modifier = isolate_capital_decision_modifier }
# 			}
# 		}
# 		custom_tooltip = {
# 			text = seclusion_bride_show
# 			NOR = {
# 				has_character_modifier = isolating_modifier
# 			}
# 		}
# 	}
	
# 	widget = {
# 		gui = "decision_view_widget_option_list_generic"
# 		controller = decision_option_list_controller
# 		decision_to_second_step_button = "SELECT_ACTION"
# 		show_from_start = no

# 		item = { # Big offering
# 			value = big_offering_decision
# 			is_shown = {
# 				always = yes
# 			}
# 			is_valid = {
# 				gold >= medium_gold_value
# 			}
# 			current_description = big_offering_decision_tooltip
# 			localization = big_offering_decision
# 			icon = "gfx/interface/icons/message_feed/money.dds"
# 			ai_chance = { value = 60 }
# 		}
# 		item = { # Small offering
# 			value = small_offering_decision
# 			is_shown = {
# 				always = yes
# 			}
# 			is_valid = {
# 				gold >= minor_gold_value
# 			}
# 			current_description = small_offering_decision_tooltip
# 			localization = small_offering_decision
# 			icon = "gfx/interface/icons/message_feed/money.dds"
# 			ai_chance = { value = 100 }
# 		}
# 	}

# 	effect = {
# 		save_scope_as = ruler_scope
# 		hidden_effect = {
# 			if = {
# 				limit = {
# 					scope:big_offering_decision = yes
# 				}
# 				remove_short_term_gold = medium_gold_value
# 			}
# 			else = {
# 				remove_short_term_gold = minor_gold_value
# 			}
# 		}
# 		trigger_event = {
# 			id = harem_events.1000
# 			days = { 7 10 }
# 		}
# 	}
	
# 	ai_potential = { always = yes }

# 	ai_check_interval_by_tier = {
# 		barony = 0
# 		county = 96
# 		duchy = 48
# 		kingdom = 36
# 		empire = 36
# 		hegemony = 36
# 	}
# 	ai_will_do = {
# 		base = 30
# 		ai_value_modifier = {
# 			ai_zeal = 0.25
# 		}
# 		ai_value_modifier = {
# 			ai_greed = -0.2
# 		}
# 		modifier = {
# 			any_consort = {
# 				is_visibly_fertile = yes
# 				count > 0
# 			}
# 			NOT = {
# 				any_child = {
# 					is_bastard_child_trigger = no
# 					NOT = {
# 						has_trait = child_of_concubine
# 					}
# 					sex_same_as = root
# 				}
# 			}
# 			add = 20
# 		}
# 		modifier = {
# 			health <= poor_health
# 			add = 30
# 		}
# 		modifier = {
# 			has_tgp_dlc_trigger = yes
# 			government_allows = merit
# 			NOR = {
# 				top_liege = root 
# 				has_character_modifier = tgp_local_exam_initial_success
# 			}
# 			add = 20
# 		}
# 		modifier = {
# 			is_valid_for_legitimacy_change = yes
# 			add = 20
# 		}
# 		modifier = {
# 			is_at_war = yes
# 			add = 30
# 		}
# 	}
# }

# The Silkworm Goddess Ceremony
silkworm_goddess_ceremony_decision = {
	title = silkworm_goddess_ceremony_decision
	desc = silkworm_goddess_ceremony_decision_desc
	selection_tooltip = silkworm_goddess_ceremony_decision_selection_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	sort_order = 162
	cooldown = { years = 3 }
	confirm_text = silkworm_goddess_ceremony_decision_confirm

	is_shown = {
		is_male = yes
		can_have_four_consorts_trigger = yes
		OR = {
			primary_spouse ?= {
				is_female = yes
				is_available_healthy_adult = yes
				is_courtier_of = root
			}
			mother ?= {
				is_available_healthy_adult = yes
				is_courtier_of = root
			}
		}
	}
	
	is_valid = {
		OR = {
			custom_description = {
				text = primary_spouse_silkworm_worship_tooltip
				primary_spouse ?= {
					is_available_healthy_adult = yes
					is_female = yes
				}
			}
			custom_description = {
				text = mother_silkworm_worship_tooltip
				mother ?= {
					is_available_healthy_adult = yes
					is_female = yes
				}
			}
		}
		custom_description = {
			text = silkworm_goddess_ceremony_month_tooltip
			current_month >= 1
			current_month <= 2
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = mourning_bride_show
			NOT = { has_character_modifier = mourner_modifier }
		}

		custom_tooltip = {
			text = contagious_disease_bride_show
			has_epidemic_disease_trigger = no
		}
		custom_tooltip = {
			text = epidemic_bride_show
			NOR = {
				realm_has_any_epidemic = {
					SIZE = 1
					INTENSITY = minor
				}
				capital_county ?= { has_county_modifier = isolate_capital_decision_modifier }
			}
		}
		custom_tooltip = {
			text = seclusion_bride_show
			NOR = {
				has_character_modifier = isolating_modifier
			}
		}
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = { has_treasury = no }
				add = medium_gold_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = { has_treasury = yes }
				add = medium_treasury_value
			}
		}
	}

	effect = {
		save_scope_as = ruler_scope
		hidden_effect = {
			if = {
				limit = {
					any_courtier = {
						is_head_of_the_harem_trigger = { LIEGE = root }
						is_available_healthy_adult = yes
						is_courtier_of = root
						is_female = yes
						OR = {
							is_parent_of = scope:ruler_scope
							scope:ruler_scope.primary_spouse ?= this
						}
					}
				}
				random_courtier = {
					limit = {
						is_head_of_the_harem_trigger = { LIEGE = root }
					}
					save_scope_as = ritual_leader
				}
			}
			else_if = {
				limit = {
					mother ?= {
						is_available_healthy_adult = yes
						is_courtier_of = root
					}
				}
				mother = { save_scope_as = ritual_leader }
			}
			else_if = {
				limit = {
					primary_spouse ?= {
						is_female = yes
						is_available_healthy_adult = yes
						is_courtier_of = root
					}
				}
				primary_spouse = {
					save_scope_as = ritual_leader
				}
			}
		}
		trigger_event = {
			id = harem_events.2000
			days = { 20 35 }
		}
	}
	
	ai_potential = { always = yes }

	ai_check_interval = 36
	ai_will_do = {
		base = 30
		ai_value_modifier = {
			ai_zeal = 0.25
		}
		modifier = {
			is_valid_for_legitimacy_change = yes
			legitimacy_level < 6
			add = 5
		}
		modifier = {
			is_valid_for_legitimacy_change = yes
			highest_held_title_tier = tier_empire
			legitimacy_level < 6
			add = 5
		}
		modifier = {
			is_valid_for_legitimacy_change = yes
			legitimacy_level < 5
			add = 5
		}
		modifier = {
			is_valid_for_legitimacy_change = yes
			legitimacy_level < 4
			add = 5
		}
		modifier = {
			any_courtier = {
				is_head_of_the_harem_trigger = { LIEGE = root }
				is_available_healthy_adult = yes
				is_courtier_of = root
				is_female = yes
				OR = {
					is_parent_of = root
					root.primary_spouse ?= this
				}
				learning >= decent_skill_rating
			}
			add = 15
		}
	}
}
# Visit matriarch
visit_matriarch_decision = {
	title = visit_matriarch_decision
	desc = visit_matriarch_decision_desc
	selection_tooltip = visit_matriarch_decision_selection_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	sort_order = 162
	cooldown = { years = 3 }
	confirm_text = visit_matriarch_decision_confirm

	is_shown = {
		OR = {
			hp_has_seniority_based_harem_relatives_trigger = yes
			religion = religion:islam_religion
		}
		any_courtier = {
			is_eligible_harem_member_trigger = {
				LIEGE = root
			}
			trigger_if = {
				limit = {
					root = {
						religion = religion:islam_religion
						any_parent = {
							is_eligible_harem_member_trigger = {
								LIEGE = root
							}
						}
					}
				}
				is_parent_of = root
			}
			trigger_else_if = {
				limit = {
					root = {
						any_ancestor = {
							is_eligible_harem_member_trigger = {
								LIEGE = root
							}
							is_grandparent_of = root
						}
					}
				}
				is_grandparent_of = root
			}
			trigger_else = {
				root = {
					any_parent = {
						is_eligible_harem_member_trigger = {
							LIEGE = root
						}
					}
				}
				is_parent_of = root
			}
		}
	}
	
	is_valid = {
		OR = {
			custom_description = {
				text = visit_matriarch_parent_tooltip
				any_parent = {
					is_eligible_harem_member_trigger = {
						LIEGE = root
					}
				}
			}
			custom_description = {
				text = visit_matriarch_grandparent_tooltip
				any_ancestor = {
					is_eligible_harem_member_trigger = {
						LIEGE = root
					}
					is_grandparent_of = root
				}
			}
		}
	}

	is_valid_showing_failures_only = {

		custom_tooltip = {
			text = contagious_disease_bride_show
			has_epidemic_disease_trigger = no
		}

		custom_tooltip = {
			text = seclusion_bride_show
			NOR = {
				has_character_modifier = isolating_modifier
			}
		}
	}

	# cost = {
	# 	gold = {
	# 		value = 0
	# 		if = {
	# 			limit = { has_treasury = no }
	# 			add = medium_gold_value
	# 		}
	# 	}
	# 	treasury = {
	# 		value = 0
	# 		if = {
	# 			limit = { has_treasury = yes }
	# 			add = medium_treasury_value
	# 		}
	# 	}
	# }

	effect = {
		save_scope_as = ruler_scope
		trigger_event = {
			id = harem_events.2100
			days = { 7 14 }
		}
	}
	
	ai_potential = { always = yes }

	ai_check_interval_by_tier = {
		barony = 0
		county = 96
		duchy = 48
		kingdom = 36
		empire = 36
		hegemony = 36
	}
	
	ai_will_do = {
		base = 30
		ai_value_modifier = {
			ai_zeal = 0.25
		}
	}
}