# -*- ck2.decisions -*-
targetted_decisions = {
	emf_customize_ruler_dynasty = {
		only_playable = yes
		filter = all
		ai_target_filter = self

		from_potential = {
			ai = no
			trait = emf_customize_ruler
			NOR = {
				has_character_flag = customizing_ruler
				had_global_flag = { flag = EMF days = 15 }
			}
		}
		potential = {
			NOR = {
				dynasty = FROM
				dynasty = none
			}
		}
		allow = {
			culture_group = FROM
		}
		effect = {
			FROM = {
				set_character_flag = customizing_ruler
				if = {
					limit = { trait = bastard }
					character_event = { id = emf_startup.1000 tooltip = CUSTOMIZE_RULER_BASTARD }
					break = yes
				}
				character_event = { id = emf_startup.1000 tooltip = CUSTOMIZE_RULER_CHECK }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	emf_clear_child_focus = {
		only_playable = yes
		filter = home_court
		ai_target_filter = home_court

		from_potential = {
			ai = no
			num_of_children = 1
			NOT = { ruled_years = 1 }
		}
		potential = {
			is_adult = no
			age = 6
			is_child_of = FROM
			host = { character = FROM }
		}
		allow = {
			FROM = {
				NOT = { ruled_years = 1 }
			}
			ROOT = {
				is_child_of = FROM
				custom_tooltip = {
					text = HAS_CHILDHOOD_FOCUS
					hidden_tooltip = {
						OR = {
							has_focus = focus_ch_pride
							has_focus = focus_ch_humility
							has_focus = focus_ch_duty
							has_focus = focus_ch_etiquette
							has_focus = focus_ch_thrift
							has_focus = focus_ch_faith
							has_focus = focus_ch_struggle
							has_focus = focus_ch_heritage
							has_focus = focus_ed_diplomacy
							has_focus = focus_ed_martial
							has_focus = focus_ed_stewardship
							has_focus = focus_ed_intrigue
							has_focus = focus_ed_learning
						}
					}
				}
				custom_tooltip = {
					text = HAS_NOT_CHANGED_CHILDHOOD_FOCUS
					hidden_tooltip = {
						NOT = { has_character_flag = emf_childhood_focus_changed }
					}
				}
			}
		}
		effect = {
			ROOT = {
				set_character_flag = emf_childhood_focus_changed
				custom_tooltip = {
					text = CHILDHOOD_FOCUS_CLEARED
					hidden_tooltip = {
						clear_focus = yes
					}
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
}

decisions = {
	emf_toggle_customization = {
		ai = no
		potential = {
			emf_hiprio_decision_basic_potential = no
		}
		effect = {
			if = {
				limit = { has_character_flag = emf_toggle_customization_off }
				clr_character_flag = emf_toggle_customization_off
			}
			else = {
				set_character_flag = emf_toggle_customization_off
			}
		}
	}

	# New World Order
	emf_customize_nwo = {
		ai = no
		potential = {
			NOT = { has_character_flag = emf_toggle_customization_off }
			emf_hiprio_decision_basic_potential = no
		}
		allow = {
		}
		effect = {
			custom_tooltip = {
				text = emf_ctt_nwo_customize
			}
			hidden_tooltip = {
				e_hip = { owner = { character_event = { id = emf_nwo.0 } } }
			}
		}
	}

	# Convert to Merchant Republic
	emf_customize_mr = {
		ai = no
		potential = {
			NOT = { has_character_flag = emf_toggle_customization_off }
			emf_hiprio_decision_basic_potential = no
			is_merchant_republic = no
		}
		allow = {
			is_adult = yes
			OR = {
				is_feudal = yes
				is_republic = yes
			}
			NOT = { religion_group = muslim }
			capital_scope = {
				port = yes
				OR = {
					has_empty_holding = yes
					any_province_holding = {
						holding_type = city
					}
				}
			}
		}
		effect = {
			custom_tooltip = {
				text = emf_ctt_mr_customize
			}
			hidden_tooltip = {
				narrative_event = { id = emf_mr.1 }
			}
		}
	}

	# Feudalize Tribes
	emf_customize_feudalizer = {
		ai = no
		potential = {
			NOT = { has_character_flag = emf_toggle_customization_off }
			emf_hiprio_decision_basic_potential = no
			NOT = { has_global_flag = emf_feudalizer }
		}
		allow = {
		}
		effect = {
			custom_tooltip = {
				text = emf_ctt_feudalizer_customize
			}
			hidden_tooltip = {
				e_hip = { owner = { character_event = { id = emf_feudalizer.0 } } }
			}
		}
	}

	emf_random_rulers = {
		ai = no
		potential = {
			NOT = { has_character_flag = emf_toggle_customization_off }
			emf_hiprio_decision_basic_potential = no
			NOT = { has_global_flag = random_rulers }
		}
		effect = {
			custom_tooltip = {
				text = emf_ctt_random_rulers
			}
			hidden_tooltip = {
				narrative_event = { id = emf_rr.0 }
			}
		}
	}

	emf_lucky_rulers = {
		ai = no
		potential = {
			NOT = { has_character_flag = emf_toggle_customization_off }
			emf_hiprio_decision_basic_potential = no
		}
		effect = {
			hidden_tooltip = {
				character_event = { id = emf_lucky.0 }
			}
		}
	}
}

