﻿choose_favorite_interaction = {
	category = interaction_category_friendly
	icon = designate_favorite
	interface_priority = 8

	desc = choose_favorite_interaction_desc

	is_available = {
		is_ai = no 
	}

	is_shown = {
		scope:actor = { 
			NOT = { has_relation_favorite_child = scope:recipient }
		}
		scope:recipient.dynasty ?= scope:actor.dynasty
		scope:actor != scope:recipient
		scope:recipient = {
			OR = {
				is_child_of = scope:actor
				is_grandchild_of = scope:actor
				is_great_grandchild_of = scope:actor
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = { is_alive = yes }
		scope:recipient = {
			custom_tooltip = {
				text = cant_be_another_player_tt
				is_ai = yes
			}
			custom_tooltip = {
				text = favorite_child_must_be_in_good_health_tt
				NOR = {
					has_trait = incapable
					health <= 2.5
				}
			}
			custom_tooltip = {
				text = cant_be_hostage_tt
				is_hostage = no
			}
			custom_tooltip = {
				text = cant_already_be_your_heir
				this != scope:actor.player_heir
			}
			custom_tooltip = {
				text = no_republic_or_theocracy_tt
				NOR = {
					government_has_flag = government_is_republic
					government_has_flag = government_is_theocracy
				}
			}
		}
	}

	on_auto_accept = {
		scope:recipient = {
			send_interface_message = {
				title = choose_favorite_interaction_notification
				left_icon = scope:actor
				show_as_tooltip = {
					scope:actor = {
						set_relation_favorite_child = { reason = favorite_child_chosen target = scope:recipient }
					}
				}
			}
		}
	}

	on_accept = {
		assign_favourite_child_effect = {
			ACTOR = scope:actor
			RECIPIENT = scope:recipient
		}
	}

	auto_accept = yes
}