﻿#refound_hist_cow_metropolis_decision
#found_generic_cow_metropolis_decision

refound_hist_cow_metropolis_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_misc.dds"
	major = yes
	ai_check_interval = 0

	desc = refound_hist_cow_metropolis_decision_desc
	selection_tooltip = refound_hist_cow_metropolis_decision_tooltip

	is_shown = {
		any_sub_realm_barony = {
			OR = { #A place where Metropolises or great capitals historically existed early
				this = title:b_alexandria
				this = title:b_antiocheia
				this = title:b_baghdad
				this = title:b_constantinople
				this = title:b_cordoba
				this = title:b_roma
				this = title:b_jerusalem
			}
			title_province = {
				NOT = { exists = var:cow_metropolis }
				NOT = { has_holding_type = cow_metropolis_holding }
			}
		}
		NOT = {  #Can't spam button - is cleared through event options
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
	}

	is_valid = {
		prestige_level >= 3
		highest_held_title_tier >= tier_kingdom
		is_at_war = no

		OR = {
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_alexandria }
					title:b_alexandria.title_province = { NOT = { exists = var:cow_metropolis } }
				}
				AND = {
					title:b_alexandria.county = { development_level >= bad_development_level }
					custom_description = {
						text = no_cow_metropolis_holding
						title:b_alexandria.title_province = { NOT = { has_holding_type = cow_metropolis_holding } }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_antiocheia }
					title:b_antiocheia.title_province = { NOT = { exists = var:cow_metropolis } }
				}
				AND = {
					title:b_antiocheia.county = { development_level >= bad_development_level }
					custom_description = {
						text = no_cow_metropolis_holding
						title:b_antiocheia.title_province = { NOT = { has_holding_type = cow_metropolis_holding } }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_baghdad }
					title:b_baghdad.title_province = { NOT = { exists = var:cow_metropolis } }
				}
				AND = {
					title:b_baghdad.county = { development_level >= bad_development_level }
					custom_description = {
						text = no_cow_metropolis_holding
						title:b_baghdad.title_province = { NOT = { has_holding_type = cow_metropolis_holding } }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_constantinople }
					title:b_constantinople.title_province = { NOT = { exists = var:cow_metropolis } }
				}
				AND = {
					title:b_constantinople.county = { development_level >= bad_development_level }
					custom_description = {
						text = no_cow_metropolis_holding
						title:b_constantinople.title_province = { NOT = { has_holding_type = cow_metropolis_holding } }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_cordoba }
					title:b_cordoba.title_province = { NOT = { exists = var:cow_metropolis } }
				}
				AND = {
					title:b_cordoba.county = { development_level >= bad_development_level }
					custom_description = {
						text = no_cow_metropolis_holding
						title:b_cordoba.title_province = { NOT = { has_holding_type = cow_metropolis_holding } }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_roma }
					title:b_roma.title_province = { NOT = { exists = var:cow_metropolis } }
				}
				AND = {
					title:b_roma.county = { development_level >= bad_development_level }
					custom_description = {
						text = no_cow_metropolis_holding
						title:b_roma.title_province = { NOT = { has_holding_type = cow_metropolis_holding } }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_jerusalem }
					title:b_jerusalem.title_province = { NOT = { exists = var:cow_metropolis } }
				}
				AND = {
					title:b_jerusalem.county = { development_level >= bad_development_level }
					custom_description = {
						text = no_cow_metropolis_holding
						title:b_jerusalem.title_province = { NOT = { has_holding_type = cow_metropolis_holding } }
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_ruler = yes
		is_available_adult = yes
	}

	effect = {
		save_scope_as = refounder

		custom_tooltip = decision_reestablish_cow_metropolis_custom_tooltip
		
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:flag_repeatable_hist_cow_metropolis
		}

		trigger_event = cow_decisions.2001
	}

	cost = {
		prestige = medium_prestige_value
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

found_generic_cow_metropolis_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_misc.dds"
	major = yes
	ai_check_interval = 0

	desc = found_generic_cow_metropolis_decision_desc
	selection_tooltip = found_generic_cow_metropolis_decision_tooltip

	is_shown = {
		capital_province = {
			NOT = { has_holding_type = cow_metropolis_holding }
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_constructed_generic_cow_metropolis
			}
		}
	}
	

	is_valid = {
		prestige_level >= 4
		highest_held_title_tier = tier_empire
		is_at_war = no
		
		capital_province = {
			OR = {
				has_holding_type = castle_holding
				has_holding_type = city_holding
				has_holding_type = church_holding
				NOT = { has_holding_type = cow_metropolis_holding }
			}
			county = { development_level >= bad_development_level }
		}
	}

	is_valid_showing_failures_only = {
		is_ruler = yes
		is_available_adult = yes
	}

	effect = {
		save_scope_as = founder

		custom_tooltip = decision_found_generic_cow_metropolis_custom_tooltip
		
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:flag_constructed_generic_cow_metropolis
		}
		
		trigger_event = cow_decisions.3001
	}

	cost = {
		gold = 600
		prestige = monumental_prestige_value
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}