﻿# overriding the vanilla trigger in order to allow a specific case where a female heir with the Prepared Heir trait can be granted a title
can_be_granted_titles_by = { #This is set up with trigger-ifs to allow for nice tooltip printouts in grant title interaction
	save_temporary_scope_as = title_grantee
	trigger_if = {
		limit = {
			is_ruler = no #Rulers can always get additional titles
			is_theocratic_lessee = no #Theocratic lessees use other gender checks
			NOT = { $RULER$ = { government_allows = administrative } }
			NOT = {
				$RULER$.faith = {
					has_dominant_ruling_gender = scope:title_grantee
				}
			}
		}
		trigger_if = {
			limit = {
				$RULER$ = { government_allows = state_faith }
			}
			$RULER$.primary_title.state_faith = {
				has_dominant_ruling_gender = scope:title_grantee
			}
		}
		trigger_else = {
			OR = {
				$RULER$.faith = { has_dominant_ruling_gender = scope:title_grantee }
				custom_description = {
					text = primary_heir_trained_trigger
					subject = $RULER$
					object = scope:title_grantee
					has_trait = education_heir_training
					is_primary_heir_of = $RULER$
				}
			}
		}
	}
	trigger_if = {
		limit = {
			is_ruler = no #Rulers can always get additional titles
			is_theocratic_lessee = no #Theocratic lessees use other gender checks
			$RULER$ = {
				government_allows = administrative
				NOT = { has_realm_law = equal_law }
			}
		}
		trigger_if = {
			limit = {
				$RULER$ = { has_realm_law = male_only_law }
			}
			scope:title_grantee = { is_female = no }
		}
		trigger_if = {
			limit = {
				$RULER$ = { has_realm_law = female_only_law }
			}
			scope:title_grantee = { is_female = yes }
		}
		#trigger_else = { always = yes }
	}
	trigger_else_if = {
		limit = {
			is_theocratic_lessee = yes
		}
		liege = $RULER$
		#If this is ever visible anywhere, we need to write a custom desc "Theocratic lessees cannot only be given titles by their ruler"
	}
	trigger_else = {
		always = yes
	}
}

