﻿fatimid_grant_mecca_to_hashimids_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}
	desc = fatimid_grant_mecca_to_hashimids_decision_desc
	ai_check_interval = 60 # 5 years
	decision_group_type = major

	is_shown = {
		game_start_date < 1061.1.1
		is_ruler = yes
		is_landed = yes
		exists = dynasty
		capital_province = { geographical_region = special_fatimid_conquest_region_total_arabia }
		faith = { has_doctrine = muhammad_succession_shia_doctrine }
		NOT = { # only once
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:fatimid_grant_mecca_to_hashimids_decision
			}
		}
	}

	is_valid = {
		faith = { has_doctrine = muhammad_succession_shia_doctrine }
		highest_held_title_tier >= tier_kingdom
		completely_controls = title:d_mecca
		completely_controls = title:d_medina
		custom_tooltip = {
			text = fatimid_grant_mecca_to_hashimids_decision_region_tt
			any_county_in_region = {
				region = special_fatimid_hejaz_region
				count = all
				OR = {
					holder = { is_ai = yes }
					holder = root
				}
				NOT = { this = root.capital_county }
			}
		}
		realm_size >= 30
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
		is_available = yes
		is_at_war = no
	}

	cost = { # only players pay a cost
		gold = {
			value = 0
			if = {
				limit = { is_ai = no }
				add = 75
			}
		}
		prestige = {
			value = 0
			if = {
				limit = { is_ai = no }
				add = 500
			}
		}
	}

	effect = {
		add_piety = 250

		trigger_event = fatimid_invasion.1010

		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:fatimid_grant_mecca_to_hashimids_decision
		}
	}

	ai_potential = {
		highest_held_title_tier >= tier_kingdom
	}

	ai_will_do = {
		base = 100
	}
}