union_war = {
	groups = {
		general
	}

	texture = "gfx/interface/icons/war_goals/annex_country.dds"

	requires_approval = no
	should_notify_third_parties = yes
	show_effect_in_tooltip = yes
	show_confirmation_box = yes
	can_use_obligations = no
	is_hostile = yes

	selectable = {
		NOT = { is_country_type = decentralized }
		is_subject = no
		is_revolutionary = no
		is_secessionist = no
		aggressive_diplomatic_plays_permitted = yes
	}

	potential = {
		uw_union_war_valid_target = yes
	}

	possible = {
		# Player may open a union war even while already at war / in a play.
		# Only block if we are already fighting *this* target, or have a truce with them.
		NOT = { has_war_with = scope:target_country }
		NOT = { is_diplomatic_play_enemy_of = scope:target_country }
		NOT = { has_truce_with = scope:target_country }
		uw_union_war_valid_target = yes
	}

	accept_effect = {
		uw_start_union_war = yes
	}

	ai = {
		# Prefer evaluating while free; being busy crushes tendency to near-zero.
		evaluation_chance = {
			value = 0
			if = {
				limit = {
					is_subject = no
					NOT = { is_country_type = decentralized }
				}
				add = 1
			}
			if = {
				limit = {
					OR = {
						is_at_war = yes
						is_diplomatic_play_committed_participant = yes
					}
				}
				multiply = 0
			}
		}

		# Army ratio met → almost always; busy status zeroes the score.
		propose_score = {
			value = 0

			if = {
				limit = {
					uw_ai_army_power_sufficient = yes
				}
				add = 10000
			}

			if = {
				limit = {
					OR = {
						is_at_war = yes
						is_diplomatic_play_committed_participant = yes
					}
				}
				multiply = 0
			}
		}

		# AI only launches while free, under army-ratio rule, and without breaking 100 infamy.
		will_propose = {
			is_at_war = no
			is_diplomatic_play_committed_participant = no
			uw_ai_should_union_war = yes
			uw_ai_infamy_safe = yes
		}
	}
}
