﻿adding_building_slot_interaction = {
	category = interaction_category_uncategorized
	hidden = yes
	special_interaction = adding_building_slot

	desc = adding_building_slot_interaction_desc

	
	target_type = title
	target_filter = recipient_domain_titles_including_leases
	
	auto_accept = yes

	is_shown = {
		scope:actor = {
			this = scope:actor
		}
	}

	
	can_be_picked_title = {
		# custom_tooltip = adding_building_slot_interaction_tt_a
		# custom_description = adding_building_slot_interaction_desc_a
		scope:target = {
			
			holder = {
				OR = {
					this = scope:actor
					is_vassal_or_below_of = scope:actor
				}
			}
			
			trigger_if = {
				limit = { tier <= tier_county }
				NOT = {
					title_province = {
						OR = {
							#cannot expand tribes
							has_holding_type = tribal_holding
							
							#for unforseen reason building slots counts 1 more then its visible, maybe its holding itself?
							AND = {
								building_slots = 7
								county = { development_level <= 30 }
							}
							AND = {
								building_slots = 8
								county = { development_level <= 60 }
							}
							AND = {
								building_slots = 99
								county = { development_level <= 80 }
							}
						}
					}
				}
			}
		}
	}

	cost = {
		gold = {
			value = 300
			if = {
				limit = {
					scope:target = {
						title_province = {
							building_slots > 4
						}
					}
				}
				add = 300
			}
			if = {
				limit = {
					scope:target = {
						title_province = {
							building_slots > 5
						}
					}
				}
				add = 600
			}
			if = {
				limit = {
					scope:target = {
						title_province = {
							building_slots > 6
						}
					}
				}
				add = 1200
			}
			if = {
				limit = {
					scope:target = {
						title_province = {
							building_slots > 7
						}
					}
				}
				add = 1800
			}
			if = {
				limit = {
					scope:target = {
						title_province = {
							building_slots > 10
						}
					}
				}
				add = 2400
			}
			if = {
				limit = {
					scope:target = {
						title_province = {
							building_slots > 15
						}
					}
				}
				add = 5000
			}
			if = {
				limit = {
					scope:target = {
						title_province = {
							county = { development_level >= 50 }
						}
					}
				}
				add = -250
			}
			if = {
				limit = {
					scope:target = {
						title_province = {
							county = { development_level >= 80 }
						}
					}
				}
				add = -750
			}
		}
	}
	
		

	on_accept = {
		custom_tooltip = adding_building_slot_interaction_tt_a
		scope:actor = {
			
			send_interface_toast = {
				title = adding_building_slot_interaction_notification
				right_icon = scope:actor				
				if = {
					limit = { exists = scope:target.title_province }
					scope:target.title_province = {
						add_province_modifier = extra_building_slot
					}
				}
			}
		}
	}

	# ai_potential = {
	# 	is_adult = yes
	# 	is_landed = yes
	# }

	# ai_frequency = 1

	# ai_will_do = {
	# 	base = 100
	# }
	

	# ai_frequency = 1
	# ai_will_do = {
	# 	# TODO: add ai doing and stuff
	# 	base = 110

	# 	modifier = { #if not have much cash
	# 		factor = 0
	# 		gold < 1000
	# 	}
	# 	modifier = { #if have shitloads of cash
	# 		factor = 100
	# 		gold > 5000
	# 	}
	# 	modifier = { #if holding is full
	# 		factor = 50
	# 		scope:target.title_province = {
	# 			free_building_slots = 0
	# 		}
	# 	}
	# }
}
