﻿#Edited to also include estates
feudalize_tribal_holding_interaction = {
	category = interaction_category_uncategorized
	hidden = yes
	special_interaction = feudalize_tribal_holding

	desc = feudalize_tribal_holding_interaction_desc

	target_type = title
	target_filter = actor_domain_titles
	
	auto_accept = yes

	is_shown = {
		scope:actor = {
			this = scope:recipient
			NOT = { government_has_flag = government_is_tribal }
		}
	}
	
	can_be_picked_title = {
		scope:target = {
			holder = scope:actor
			is_capital_barony = no # we'll use the county in that case
			trigger_if = {
				limit = { tier <= tier_county }
				OR = {
					title_province = {
						has_holding_type = tribal_holding
					}
					title_province = {
						has_holding_type = estate_holding
					}
				}
			}
			trigger_else = {
				custom_description = {
					text = "feudalize_tribal_holding_interaction_title_not_county_or_below"
					always = no
				}
			}
		}
		NOT = {
			AND = {
				scope:target = {
					title_province = {
						has_holding_type = estate_holding
					}
				}
				scope:actor = {
					OR = {
						government_has_flag = government_is_imperial_cult
						government_has_flag = government_is_imperial
						government_has_flag = government_is_autocratic
						AND = {
							government_has_flag = government_is_roman 
							OR = {
								is_independent_ruler = no
								AND = {
									exists = culture
									culture = {
										has_cultural_pillar = heritage_latin 
									}
								}
							}
						}
					}
				}
			}
		}
	}

	has_valid_target_showing_failures_only = {
		scope:target = {
			trigger_if = {
				limit = { tier <= tier_county }
				title_province = {
					barony_controller = scope:actor
					has_ongoing_construction = no
				}
			}
		}
	}

	cost = {
		gold = scope:actor.feudalize_tribal_holding_interaction_cost
		
	}

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				title = feudalize_tribal_holding_interaction_notification

				right_icon = scope:actor					

				if = {
					limit = { exists = scope:target.title_province }
					scope:target.title_province = {
						set_holding_type = castle_holding
					}
				}
			}
		}
	}

	ai_will_do = {
		base = 1500
	}
}
