namespace = cow_decisions

################
# Refound Metropolis
# by Linnéa Thimrén
################
cow_decisions.2001 = {
	type = character_event
	title = cow_decisions.2001.t
	desc = {
		desc = cow_decisions.2001.desc_first
		first_valid = {
			triggered_desc = {
				trigger = {
					calc_true_if = {
						amount >= 2
						any_sub_realm_barony = { this = title:b_alexandria }
						any_sub_realm_barony = { this = title:b_antiocheia }
						any_sub_realm_barony = { this = title:b_baghdad }
						any_sub_realm_barony = { this = title:b_constantinople }
						any_sub_realm_barony = { this = title:b_cordoba }
						any_sub_realm_barony = { this = title:b_roma }
						any_sub_realm_barony = { this = title:b_jerusalem }
					}
				}
				desc = cow_decisions.2001.desc_more
			}
			desc = cow_decisions.2001.desc
		}
	}
	theme = learning
	left_portrait = {
		character = scope:refounder
		animation = personality_rational
	}
	
	option = {
		trigger = {
			any_sub_realm_barony = { 
				this = title:b_alexandria
				title_province = {
					NOT = { exists = var:cow_metropolis }
					NOT = { has_holding_type = cow_metropolis_holding }
					has_ongoing_construction = no
				}
			}
			title:b_alexandria = {
				county = { development_level >= bad_development_level }
			}
		}
		cow_refound_alexandria_effect = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_alexandria
		ai_chance = {
			base = 10
		}
	}
	
	option = {
		trigger = {
			any_sub_realm_barony = { 
				this = title:b_antiocheia
				title_province = {
					NOT = { exists = var:cow_metropolis }
					NOT = { has_holding_type = cow_metropolis_holding }
					has_ongoing_construction = no
				}
			}
			title:b_antiocheia = {
				county = { development_level >= bad_development_level }
			}
		}
		cow_refound_antiocheia_effect = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_antiocheia
		ai_chance = {
			base = 10
		}
	}
	
	option = {
		trigger = {
			any_sub_realm_barony = { 
				this = title:b_baghdad
				title_province = {
					NOT = { exists = var:cow_metropolis }
					NOT = { has_holding_type = cow_metropolis_holding }
					has_ongoing_construction = no
				}
			}
			title:b_baghdad = {
				county = { development_level >= bad_development_level }
			}
		}
		cow_refound_baghdad_effect = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_baghdad
		ai_chance = {
			base = 30
		}
	}
	
	option = {
		trigger = {
			any_sub_realm_barony = { 
				this = title:b_constantinople
				title_province = {
					NOT = { exists = var:cow_metropolis }
					NOT = { has_holding_type = cow_metropolis_holding }
					has_ongoing_construction = no
				}
			}
			title:b_constantinople = {
				county = { development_level >= bad_development_level }
			}
		}
		cow_refound_constantinople_effect = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_constantinople
		ai_chance = {
			base = 30
		}
	}
	
	option = {
		trigger = {
			any_sub_realm_barony = { 
				this = title:b_cordoba
				title_province = {
					NOT = { exists = var:cow_metropolis }
					NOT = { has_holding_type = cow_metropolis_holding }
					has_ongoing_construction = no
				}
			}
			title:b_cordoba = {
				county = { development_level >= bad_development_level }
			}
		}
		cow_refound_cordoba_effect = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_cordoba
		ai_chance = {
			base = 30
		}
	}
	
	option = {
		trigger = {
			any_sub_realm_barony = { 
				this = title:b_roma
				title_province = {
					NOT = { exists = var:cow_metropolis }
					NOT = { has_holding_type = cow_metropolis_holding }
					has_ongoing_construction = no
				}
			}
			title:b_roma = {
				county = { development_level >= bad_development_level }
			}
		}
		cow_refound_roma_effect = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_roma
		ai_chance = {
			base = 20
		}
	}
	
	option = {
		trigger = {
			any_sub_realm_barony = { 
				this = title:b_jerusalem
				title_province = {
					NOT = { exists = var:cow_metropolis }
					NOT = { has_holding_type = cow_metropolis_holding }
					has_ongoing_construction = no
				}
			}
			title:b_jerusalem = {
				county = { development_level >= bad_development_level }
			}
		}
		cow_refound_jerusalem_effect = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_jerusalem
		ai_chance = {
			base = 10
		}
	}
	
	option = {
		trigger = {
			all_hist_cow_metropolis_trigger = yes
		}
		if = {
			limit = { 
				any_sub_realm_barony = { this = title:b_alexandria }
				title:b_alexandria.title_province = { has_ongoing_construction = no }
			}
			cow_refound_alexandria_effect = yes
		}
		if = {
			limit = { 
				any_sub_realm_barony = { this = title:b_antiocheia }
				title:b_antiocheia.title_province = { has_ongoing_construction = no }
			}
			cow_refound_antiocheia_effect = yes
		}
		if = {
			limit = { 
				any_sub_realm_barony = { this = title:b_baghdad }
				title:b_baghdad.title_province = { has_ongoing_construction = no }
			}
			cow_refound_baghdad_effect = yes
		}
		if = {
			limit = { 
				any_sub_realm_barony = { this = title:b_constantinople }
				title:b_constantinople.title_province = { has_ongoing_construction = no }
			}
			cow_refound_constantinople_effect = yes
		}
		if = {
			limit = { 
				any_sub_realm_barony = { this = title:b_cordoba }
				title:b_cordoba.title_province = { has_ongoing_construction = no }
			}
			cow_refound_cordoba_effect = yes
		}
		if = {
			limit = { 
				any_sub_realm_barony = { this = title:b_roma }
				title:b_roma.title_province = { has_ongoing_construction = no }
			}
			cow_refound_roma_effect = yes
		}
		if = {
			limit = { 
				any_sub_realm_barony = { this = title:b_jerusalem }
				title:b_jerusalem.title_province = { has_ongoing_construction = no }
			}
			cow_refound_jerusalem_effect = yes
		}
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.b_all
		ai_chance = {
			base = 100
		}
	}
	
	option = { # fallback in case development somehow tumbles
		trigger = { always = no }
		fallback = yes
		hidden_effect = {
			remove_list_global_variable = {
				name = unavailable_unique_decisions
				target = flag:flag_repeatable_hist_cow_metropolis
			}
		}
		name = cow_decisions.2001.fallback
		custom_tooltip = cow_decisions.2001.fallback.tt
		ai_chance = {
			base = 1
		}
	}
}

#Other players informed
cow_decisions.2002 = {
	type = character_event
	title = cow_decisions.2001.t
	desc = cow_decisions.2002.desc
	left_portrait = {
		character = scope:founder
		animation = personality_rational
	}
	theme = learning

	option = {
		name = cow_decisions.2002.a
	}
}

################
# Found Metropolis
# by Linnéa Thimrén
################
cow_decisions.3001 = {
	type = character_event
	title = cow_decisions.3001.t
	desc = {
		desc = cow_decisions.3001.desc_first
		first_valid = {
			desc = cow_decisions.3001.desc
		}
	}
	theme = learning
	left_portrait = {
		character = scope:founder
		animation = personality_rational
	}
	
	option = {
		trigger = {
			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 >= 30 }
				has_ongoing_construction = no
			}
		}
		capital_province = {
			cow_refound_set_holding_lvl_flag_effect = yes
			cow_set_building_lvl_flag_effect = yes
			set_holding_type = cow_metropolis_holding
			if = {
				limit = { barony_variable_holding_level_trigger = yes }
				cow_refound_add_holding_level_effect = yes
			}
			if = {
				limit = { barony_variable_building_level_trigger = yes }
				cow_add_building_lvl_effect = yes
			}
		}
		name = cow_decisions.3001.b_generic_metropolis
		ai_chance = {
			base = 100
		}
	}
	
	option = { # fallback in case development somehow tumbles
		trigger = { always = no }
		fallback = yes
		remove_list_global_variable = {
			name = unavailable_unique_decisions
			target = flag:flag_constructed_generic_cow_metropolis
		}
		name = cow_decisions.3001.fallback
		custom_tooltip = cow_decisions.3001.fallback.tt
		ai_chance = {
			base = 1
		}
	}
}

#Other players informed
cow_decisions.3002 = {
	type = character_event
	title = cow_decisions.3001.t
	desc = cow_decisions.3002.desc
	left_portrait = {
		character = scope:founder
		animation = personality_rational
	}
	theme = learning

	option = {
		name = cow_decisions.3002.a
	}
}

cow_decisions.3003 = {
	type = character_event
	title = cow_decisions.3003.t
	desc = {
		desc = cow_decisions.3003.desc_first
		first_valid = {
			desc = cow_decisions.3003.desc
		}
	}
	theme = learning
	left_portrait = {
		character = scope:founder
		animation = personality_rational
	}
	
	option = {
		trigger = {
			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 }
				}
				has_ongoing_construction = no
			}
		}
		capital_province = {
			cow_refound_set_holding_lvl_flag_effect = yes
			cow_set_building_lvl_flag_effect = yes
			set_holding_type = cow_metropolis_holding
			if = {
				limit = { barony_variable_holding_level_trigger = yes }
				cow_refound_add_holding_level_effect = yes
			}
			if = {
				limit = { barony_variable_building_level_trigger = yes }
				cow_add_building_lvl_effect = yes
			}
		}
		name = cow_decisions.3003.b_generic_metropolis
		ai_chance = {
			base = 100
		}
	}
	
	option = { # fallback in case development somehow tumbles
		trigger = { always = no }
		fallback = yes
		remove_character_flag = flag_ai_cow_found_metropolis
		name = cow_decisions.3003.fallback
		custom_tooltip = cow_decisions.3003.fallback.tt
		ai_chance = {
			base = 1
		}
	}
}