﻿###DECISIONS LIST###

#form_portugal_decision
#unite_the_spanish_thrones_decision
#unite_africa_decision
#avenge_the_battle_of_tours_decision
#build_grand_church_decision

form_portugal_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	major = yes
	ai_check_interval = 60
	desc = form_portugal_decision_desc

	is_shown = {
		has_culture_group = culture_group:iberian_group
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_portugal_decision
			}
		}
	}

	is_valid = {
		is_independent_ruler = yes 
		
		has_culture_group = culture_group:iberian_group

		trigger_if = {
			limit = { title:d_porto = { any_in_de_jure_hierarchy = { tier = tier_county } } } #Has de jure land
			completely_controls = title:d_porto
		}
		trigger_if = {
			limit = { title:d_coimbra = { any_in_de_jure_hierarchy = { tier = tier_county } } } #Has de jure land
			completely_controls = title:d_coimbra
		}
		trigger_if = {
			limit = { title:d_beja = { any_in_de_jure_hierarchy = { tier = tier_county } } } #Has de jure land
			completely_controls = title:d_beja
		}
		trigger_if = {
			limit = { title:d_algarve = { any_in_de_jure_hierarchy = { tier = tier_county } } } #Has de jure land
			completely_controls = title:d_algarve
		}
	}

	effect = {
		save_scope_as = portugal_former

		show_as_tooltip = { form_portugal_decision_effects = yes } #Actually applied in iberia_north_africa.0001 - title changes, prestige, culture swap etc.

		#Events
		trigger_event = iberia_north_africa.0001
		every_player = {
			limit = {
				NOT = { this = scope:portugal_former }
				is_within_diplo_range = { CHARACTER = scope:portugal_former }
			}
			trigger_event = iberia_north_africa.0002
		}
		every_vassal_or_below = {
			limit = {
				is_ai = yes
				exists = capital_province
				capital_province = {
					county = {
						any_this_title_or_de_jure_above = {
							this = title:k_portugal
						}
					}
				}	
			}
			trigger_event = iberia_north_africa.0002 #So they can convert
		}

		#Can only happen once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:form_portugal_decision
		}
	}

	cost = { gold = { value = 300 } }

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}



unite_the_spanish_thrones_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"
	major = yes
	ai_check_interval = 60
	desc = unite_the_spanish_thrones_decision_desc

	is_shown = {
		has_culture_group = culture_group:iberian_group
		game_start_date >= 1000.1.1
		OR = {
			calc_true_if = { #At least 2 of the titles has de jure land
				amount >= 2
				title:k_castille = { any_in_de_jure_hierarchy = { tier = tier_county } }
				title:k_leon = { any_in_de_jure_hierarchy = { tier = tier_county } }
				title:k_spanish_galicia = { any_in_de_jure_hierarchy = { tier = tier_county } }
			}
		}
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:unite_the_spanish_thrones_decision
			}
		}
		highest_held_title_tier < tier_empire
	}

	is_valid = {
		has_culture_group = culture_group:iberian_group
		trigger_if = {
			limit = { title:k_castille = { any_in_de_jure_hierarchy = { tier = tier_county } } } #Has de jure land
			completely_controls = title:k_castille
			has_title = title:k_castille
		}
		trigger_if = {
			limit = { title:k_leon = { any_in_de_jure_hierarchy = { tier = tier_county } } } #Has de jure land
			completely_controls = title:k_leon
			has_title = title:k_leon
		}
		trigger_if = {
			limit = { title:k_spanish_galicia = { any_in_de_jure_hierarchy = { tier = tier_county } } } #Has de jure land
			completely_controls = title:k_spanish_galicia
			has_title = title:k_spanish_galicia
		}
		OR = {
			has_primary_title = title:k_castille
			has_primary_title = title:k_leon
			has_primary_title = title:k_spanish_galicia
			has_primary_title = title:k_portugal
			has_primary_title = title:k_aragon
			has_primary_title = title:k_navarra
			has_primary_title = title:k_andalusia
			has_primary_title = title:k_badajoz
			has_primary_title = title:k_valencia
		}
	}

	is_valid_showing_failures_only = {
		OR = {
			has_primary_title = title:k_castille
			has_primary_title = title:k_leon
			has_primary_title = title:k_spanish_galicia
			has_primary_title = title:k_portugal
			has_primary_title = title:k_aragon
			has_primary_title = title:k_navarra
			has_primary_title = title:k_andalusia
			has_primary_title = title:k_badajoz
			has_primary_title = title:k_valencia
		}
	}

	effect = {
		save_scope_as = spain_uniter

		show_as_tooltip = { unite_the_spanish_thrones_decision_effects = yes } #Actually applied in iberia_north_africa.0005 - prestige, laws, title changes

		#Events
		trigger_event = iberia_north_africa.0005
		every_player = {
			limit = {
				NOT = { this = scope:spain_uniter }
				is_within_diplo_range = { CHARACTER = scope:spain_uniter }
			}
			trigger_event = iberia_north_africa.0006
		}

		#Can only be done once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:unite_the_spanish_thrones_decision
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

unite_africa_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"
	major = yes
	ai_check_interval = 120
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = {
						OR = {
							religion_tag = west_african_roog_religion
							religion_tag = west_african_religion
						}
					}
				}
				desc = unite_africa_decision_ancestors_desc
			}
			triggered_desc = {
				trigger = { faith = { religion_tag = west_african_bori_religion } }
				desc = unite_africa_decision_spirits_desc
			}
			desc = unite_africa_decision_generic_desc
		}
	}	

	is_shown = {
		OR = {
			has_culture_group = culture_group:west_african_group
			has_culture_group = culture_group:sahelian_group
			has_culture_group = culture_group:senegambian_group
			has_culture_group = culture_group:akan_group
			has_culture_group = culture_group:central_african_group
			has_culture_group = culture_group:yoruba_group
			has_culture_group = culture_group:east_african_group
			has_culture_group = culture_group:somalian_group
			has_culture = culture:butr
			has_culture = culture:baranis
			has_culture = culture:maghrebi
			has_culture = culture:egyptian
			has_culture = culture:bedouin
		}
		exists = capital_province
		capital_province = { geographical_region = world_africa }
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:unite_africa_decision
			}
		}
	}

	is_valid = {
		completely_controls_region = world_africa
		capital_province = { geographical_region = world_africa }
	}

	effect = {
		save_scope_as = africa_uniter

		show_as_tooltip = { unite_africa_decision_effects = yes } #Actually applied in iberia_north_africa.0010 - prestige & religion bonuses

		#Events
		trigger_event = iberia_north_africa.0010
		every_player = {
			limit = {
				NOT = { this = scope:africa_uniter }
				is_within_diplo_range = { CHARACTER = scope:africa_uniter }
			}
			trigger_event = iberia_north_africa.0011
		}

		#Can only be done once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:unite_africa_decision
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

avenge_the_battle_of_tours_decision = {
	picture = "gfx/interface/illustrations/decisions/avenge_the_battle_of_tours.dds"
	major = yes
	ai_check_interval = 60
	desc = avenge_the_battle_of_tours_decision_desc

	is_shown = {
		faith = { religion_tag = islam_religion }
		exists = capital_province
		capital_province = {
			OR = {
				geographical_region = world_europe_west_francia
				geographical_region = world_europe_west_iberia
				geographical_region = world_europe_west_francia
				geographical_region = world_africa_north_west
			}
		}
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:avenge_the_battle_of_tours_decision
			}
		}
	}

	is_valid = {
		completely_controls_region = world_europe_west_iberia
		completely_controls_region = custom_south_francia
	}


	effect = {
		save_scope_as = avenger

		#Christian penalty scope save
		title:e_france = {
			random_de_jure_county_holder = { #If there's a big christian presence in France
				limit = {
					faith = { religion_tag = christianity_religion }
					OR = {
						has_culture = culture:french
						has_culture = culture:occitan
					}
					highest_held_title_tier = tier_empire
				}
				alternative_limit = {
					faith = { religion_tag = christianity_religion }
					OR = {
						has_culture = culture:french
						has_culture = culture:occitan
					}
					highest_held_title_tier = tier_kingdom
				}
				alternative_limit = {
					faith = { religion_tag = christianity_religion }
					OR = {
						has_culture = culture:french
						has_culture = culture:occitan
					}
					highest_held_title_tier = tier_duchy
				}
				faith = {
					save_scope_as = frankish_christian_faith
				}
			}
		}

		show_as_tooltip = { avenge_the_battle_of_tours_decision_effects = yes } #Actually applied in iberia_north_africa.0015 - Prestige, religion bonuses

		#Events
		trigger_event = iberia_north_africa.0015
		every_player = {
			limit = {
				NOT = { this = scope:avenger }
				is_within_diplo_range = { CHARACTER = scope:avenger }
			}
			trigger_event = iberia_north_africa.0016
		}

		#Can only be done once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:avenge_the_battle_of_tours_decision
		}
	}

	ai_will_do = {
		base = 100
	}
}